emqtt_frame.hrl 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. -record(mqtt_frame, {fixed,
  44. variable,
  45. payload}).
  46. -record(mqtt_frame_fixed, {type = 0,
  47. dup = 0,
  48. qos = 0,
  49. retain = 0}).
  50. -record(mqtt_frame_connect, {proto_ver,
  51. will_retain,
  52. will_qos,
  53. will_flag,
  54. clean_sess,
  55. keep_alive,
  56. client_id,
  57. will_topic,
  58. will_msg,
  59. username,
  60. password}).
  61. -record(mqtt_frame_connack, {return_code}).
  62. -record(mqtt_frame_publish, {topic_name,
  63. message_id}).
  64. -record(mqtt_frame_subscribe,{message_id,
  65. topic_table}).
  66. -record(mqtt_frame_suback, {message_id,
  67. qos_table = []}).
  68. -record(mqtt_topic, {name,
  69. qos}).
  70. -record(mqtt_frame_other, {other}).