DurableMessage.asn 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. -- This schema specifies binary encoding of EMQX's internal
  2. -- representation of a message.
  3. --
  4. -- Note: MQTT standard specifies that certain properties like topic
  5. -- should be UTF8 strings. Here we represent them as OCTET STRING to
  6. -- avoid extra checks.
  7. DurableMessage DEFINITIONS AUTOMATIC TAGS ::=
  8. BEGIN
  9. -- Non-standard flag:
  10. MiscFlag ::= SEQUENCE {
  11. key UTF8String,
  12. value BOOLEAN
  13. }
  14. -- Non-standard header or property.
  15. -- Both key and value are interpreted as erlang terms:
  16. MiscProperty ::= SEQUENCE {
  17. key OCTET STRING,
  18. value OCTET STRING
  19. }
  20. ClientAttr ::= SEQUENCE {
  21. key OCTET STRING,
  22. value OCTET STRING
  23. }
  24. -- Wrapper for any data that doesn't comply with the strict schema:
  25. Misc ::= CHOICE {
  26. flag MiscFlag,
  27. header MiscProperty,
  28. property MiscProperty,
  29. -- Currently these are unused:
  30. clientAttr ClientAttr,
  31. extra MiscProperty
  32. }
  33. -- Both key and value are interpreted as binaries:
  34. UserProperty ::= SEQUENCE {
  35. key OCTET STRING,
  36. value OCTET STRING
  37. }
  38. -- Common properties that are present in almost any message:
  39. StdProperties ::= SEQUENCE {
  40. payloadFormatIndicator INTEGER (0..255) OPTIONAL,
  41. messageExpiryInterval INTEGER (0..4294967295) OPTIONAL,
  42. responseTopic OCTET STRING OPTIONAL,
  43. correlationData OCTET STRING OPTIONAL,
  44. contentType OCTET STRING OPTIONAL,
  45. userProperty SEQUENCE OF UserProperty
  46. }
  47. ProtoVer ::= CHOICE {
  48. mqtt INTEGER(0..255),
  49. mqtt-sn INTEGER(0..255),
  50. coap INTEGER(0..255)
  51. }
  52. -- Common headers that are present in almost any message:
  53. StdHeaders ::= SEQUENCE {
  54. protoVer ProtoVer OPTIONAL,
  55. peerhost OCTET STRING (SIZE(4..16)) OPTIONAL, -- IPv4 (4 octets) .. IPv6 (16 octets)
  56. peername OCTET STRING (SIZE(6..18)) OPTIONAL, -- IPv4 (4 octets) .. IPv6 (16 octets) + 2 octets for (TCP/UDP) port
  57. username OCTET STRING OPTIONAL
  58. }
  59. From ::= CHOICE {
  60. atom UTF8String,
  61. binary OCTET STRING
  62. }
  63. DurableMessage ::= SEQUENCE {
  64. id OCTET STRING,
  65. from From,
  66. topic OCTET STRING,
  67. payload OCTET STRING,
  68. timestamp INTEGER,
  69. qos INTEGER (0..2),
  70. -- MQTT PUBLISH flags:
  71. sys BOOLEAN,
  72. dup BOOLEAN,
  73. retain BOOLEAN,
  74. -- Headers:
  75. headers StdHeaders,
  76. properties StdProperties,
  77. -- Miscellaneous, highly EMQX-specific internal data:
  78. misc SEQUENCE OF Misc OPTIONAL
  79. }
  80. END