emqtt_frame.hrl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. %
  2. % NOTICE: copy from rabbitmq mqtt-adaper
  3. %
  4. %% The contents of this file are subject to the Mozilla Public License
  5. %% Version 1.1 (the "License"); you may not use this file except in
  6. %% compliance with the License. You may obtain a copy of the License
  7. %% at http://www.mozilla.org/MPL/
  8. %%
  9. %% Software distributed under the License is distributed on an "AS IS"
  10. %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  11. %% the License for the specific language governing rights and
  12. %% limitations under the License.
  13. %%
  14. %% The Original Code is RabbitMQ.
  15. %%
  16. %% The Initial Developer of the Original Code is VMware, Inc.
  17. %% Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
  18. %%
  19. -define(MQTT_PROTO_MAJOR, 3).
  20. -define(MQTT_PROTO_MINOR, 1).
  21. %% frame types
  22. -define(CONNECT, 1).
  23. -define(CONNACK, 2).
  24. -define(PUBLISH, 3).
  25. -define(PUBACK, 4).
  26. -define(PUBREC, 5).
  27. -define(PUBREL, 6).
  28. -define(PUBCOMP, 7).
  29. -define(SUBSCRIBE, 8).
  30. -define(SUBACK, 9).
  31. -define(UNSUBSCRIBE, 10).
  32. -define(UNSUBACK, 11).
  33. -define(PINGREQ, 12).
  34. -define(PINGRESP, 13).
  35. -define(DISCONNECT, 14).
  36. %% connect return codes
  37. -define(CONNACK_ACCEPT, 0).
  38. -define(CONNACK_PROTO_VER, 1). %% unacceptable protocol version
  39. -define(CONNACK_INVALID_ID, 2). %% identifier rejected
  40. -define(CONNACK_SERVER, 3). %% server unavailable
  41. -define(CONNACK_CREDENTIALS, 4). %% bad user name or password
  42. -define(CONNACK_AUTH, 5). %% not authorized
  43. %% qos levels
  44. -define(QOS_0, 0).
  45. -define(QOS_1, 1).
  46. -define(QOS_2, 2).
  47. -record(mqtt_frame, {fixed,
  48. variable,
  49. payload}).
  50. -record(mqtt_frame_fixed, {type = 0,
  51. dup = 0,
  52. qos = 0,
  53. retain = 0}).
  54. -record(mqtt_frame_connect, {proto_ver,
  55. will_retain,
  56. will_qos,
  57. will_flag,
  58. clean_sess,
  59. keep_alive,
  60. client_id,
  61. will_topic,
  62. will_msg,
  63. username,
  64. password}).
  65. -record(mqtt_frame_connack, {return_code}).
  66. -record(mqtt_frame_publish, {topic_name,
  67. message_id}).
  68. -record(mqtt_frame_subscribe,{message_id,
  69. topic_table}).
  70. -record(mqtt_frame_suback, {message_id,
  71. qos_table = []}).
  72. -record(mqtt_topic, {name,
  73. qos}).
  74. -record(mqtt_frame_other, {other}).
  75. -record(mqtt_msg, {retain,
  76. qos,
  77. topic,
  78. dup,
  79. message_id,
  80. payload}).