Update copyright, format record, add 'AUTH' packet type for MQTT 5.0
This commit is contained in:
parent
a52754df56
commit
4df2a71c27
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
|
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
%% Banner
|
%% Banner
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(COPYRIGHT, "Copyright (C) 2012-2017, Feng Lee <feng@emqtt.io>").
|
-define(COPYRIGHT, "Copyright (c) 2013-2017 EMQ Enterprise, Inc.").
|
||||||
|
|
||||||
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
-define(LICENSE_MESSAGE, "Licensed under the Apache License, Version 2.0").
|
||||||
|
|
||||||
|
@ -48,21 +48,21 @@
|
||||||
%% MQTT Topic
|
%% MQTT Topic
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-record(mqtt_topic, {
|
-record(mqtt_topic,
|
||||||
topic :: binary(),
|
{ topic :: binary(),
|
||||||
flags = [] :: [retained | static]
|
flags = [] :: [retained | static]
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_topic() :: #mqtt_topic{}).
|
-type(mqtt_topic() :: #mqtt_topic{}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Subscription
|
%% MQTT Subscription
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_subscription, {
|
-record(mqtt_subscription,
|
||||||
subid :: binary() | atom(),
|
{ subid :: binary() | atom(),
|
||||||
topic :: binary(),
|
topic :: binary(),
|
||||||
qos :: 0 | 1 | 2
|
qos :: 0 | 1 | 2
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_subscription() :: #mqtt_subscription{}).
|
-type(mqtt_subscription() :: #mqtt_subscription{}).
|
||||||
|
|
||||||
|
@ -73,18 +73,18 @@
|
||||||
-type(ws_header_key() :: atom() | binary() | string()).
|
-type(ws_header_key() :: atom() | binary() | string()).
|
||||||
-type(ws_header_val() :: atom() | binary() | string() | integer()).
|
-type(ws_header_val() :: atom() | binary() | string() | integer()).
|
||||||
|
|
||||||
-record(mqtt_client, {
|
-record(mqtt_client,
|
||||||
client_id :: binary() | undefined,
|
{ client_id :: binary() | undefined,
|
||||||
client_pid :: pid(),
|
client_pid :: pid(),
|
||||||
username :: binary() | undefined,
|
username :: binary() | undefined,
|
||||||
peername :: {inet:ip_address(), integer()},
|
peername :: {inet:ip_address(), inet:port_number()},
|
||||||
clean_sess :: boolean(),
|
clean_sess :: boolean(),
|
||||||
proto_ver :: 3 | 4,
|
proto_ver :: 3 | 4,
|
||||||
keepalive = 0,
|
keepalive = 0,
|
||||||
will_topic :: undefined | binary(),
|
will_topic :: undefined | binary(),
|
||||||
ws_initial_headers :: list({ws_header_key(), ws_header_val()}),
|
ws_initial_headers :: list({ws_header_key(), ws_header_val()}),
|
||||||
connected_at :: erlang:timestamp()
|
connected_at :: erlang:timestamp()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_client() :: #mqtt_client{}).
|
-type(mqtt_client() :: #mqtt_client{}).
|
||||||
|
|
||||||
|
@ -92,33 +92,46 @@
|
||||||
%% MQTT Session
|
%% MQTT Session
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-record(mqtt_session, {
|
-record(mqtt_session,
|
||||||
client_id :: binary(),
|
{ client_id :: binary(),
|
||||||
sess_pid :: pid(),
|
sess_pid :: pid(),
|
||||||
persistent :: boolean()
|
clean_sess :: boolean()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_session() :: #mqtt_session{}).
|
-type(mqtt_session() :: #mqtt_session{}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Message
|
%% MQTT Message
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-type(mqtt_msgid() :: binary() | undefined).
|
-type(mqtt_msgid() :: binary() | undefined).
|
||||||
|
|
||||||
-type(mqtt_pktid() :: 1..16#ffff | undefined).
|
-type(mqtt_pktid() :: 1..16#ffff | undefined).
|
||||||
|
|
||||||
-record(mqtt_message, {
|
-record(mqtt_message,
|
||||||
id :: mqtt_msgid(), %% Global unique message ID
|
{ %% Global unique message ID
|
||||||
pktid :: mqtt_pktid(), %% PacketId
|
id :: mqtt_msgid(),
|
||||||
from :: {binary(), undefined | binary()}, %% ClientId and Username
|
%% PacketId
|
||||||
topic :: binary(), %% Topic that the message is published to
|
pktid :: mqtt_pktid(),
|
||||||
qos = 0 :: 0 | 1 | 2, %% Message QoS
|
%% ClientId and Username
|
||||||
flags = [] :: [retain | dup | sys], %% Message Flags
|
from :: {binary(), undefined | binary()},
|
||||||
retain = false :: boolean(), %% Retain flag
|
%% Topic that the message is published to
|
||||||
dup = false :: boolean(), %% Dup flag
|
topic :: binary(),
|
||||||
sys = false :: boolean(), %% $SYS flag
|
%% Message QoS
|
||||||
|
qos = 0 :: 0 | 1 | 2,
|
||||||
|
%% Message Flags
|
||||||
|
flags = [] :: [retain | dup | sys],
|
||||||
|
%% Retain flag
|
||||||
|
retain = false :: boolean(),
|
||||||
|
%% Dup flag
|
||||||
|
dup = false :: boolean(),
|
||||||
|
%% $SYS flag
|
||||||
|
sys = false :: boolean(),
|
||||||
headers = [] :: list(),
|
headers = [] :: list(),
|
||||||
payload :: binary(), %% Payload
|
%% Payload
|
||||||
timestamp :: pos_integer() %% os:timestamp to seconds
|
payload :: binary(),
|
||||||
|
%% Timestamp
|
||||||
|
timestamp :: erlang:timestamp()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_message() :: #mqtt_message{}).
|
-type(mqtt_message() :: #mqtt_message{}).
|
||||||
|
@ -126,46 +139,45 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Delivery
|
%% MQTT Delivery
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_delivery, {
|
|
||||||
sender :: pid(), %% Pid of the sender/publisher
|
-record(mqtt_delivery,
|
||||||
|
{ sender :: pid(), %% Pid of the sender/publisher
|
||||||
message :: mqtt_message(), %% Message
|
message :: mqtt_message(), %% Message
|
||||||
flows :: list()
|
flows :: list()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_delivery() :: #mqtt_delivery{}).
|
-type(mqtt_delivery() :: #mqtt_delivery{}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Route
|
%% MQTT Route
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_route, {
|
|
||||||
topic :: binary(),
|
-record(mqtt_route,
|
||||||
|
{ topic :: binary(),
|
||||||
node :: node()
|
node :: node()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_route() :: #mqtt_route{}).
|
-type(mqtt_route() :: #mqtt_route{}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Alarm
|
%% MQTT Alarm
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_alarm, {
|
|
||||||
id :: binary(),
|
-record(mqtt_alarm,
|
||||||
|
{ id :: binary(),
|
||||||
severity :: warning | error | critical,
|
severity :: warning | error | critical,
|
||||||
title :: iolist() | binary(),
|
title :: iolist() | binary(),
|
||||||
summary :: iolist() | binary(),
|
summary :: iolist() | binary(),
|
||||||
timestamp :: erlang:timestamp() %% Timestamp
|
timestamp :: erlang:timestamp() %% Timestamp
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-type(mqtt_alarm() :: #mqtt_alarm{}).
|
-type(mqtt_alarm() :: #mqtt_alarm{}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Plugin
|
%% MQTT Plugin
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_plugin, {
|
|
||||||
name,
|
-record(mqtt_plugin, { name, version, descr, active = false }).
|
||||||
version,
|
|
||||||
descr,
|
|
||||||
active = false
|
|
||||||
}).
|
|
||||||
|
|
||||||
-type(mqtt_plugin() :: #mqtt_plugin{}).
|
-type(mqtt_plugin() :: #mqtt_plugin{}).
|
||||||
|
|
||||||
|
@ -173,14 +185,8 @@
|
||||||
%% MQTT CLI Command
|
%% MQTT CLI Command
|
||||||
%% For example: 'broker metrics'
|
%% For example: 'broker metrics'
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_cli, {
|
|
||||||
name,
|
-record(mqtt_cli, { name, action, args = [], opts = [], usage, descr }).
|
||||||
action,
|
|
||||||
args = [],
|
|
||||||
opts = [],
|
|
||||||
usage,
|
|
||||||
descr
|
|
||||||
}).
|
|
||||||
|
|
||||||
-type(mqtt_cli() :: #mqtt_cli{}).
|
-type(mqtt_cli() :: #mqtt_cli{}).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
|
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
|
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2012-2017 Feng Lee <feng@emqtt.io>.
|
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -14,23 +14,32 @@
|
||||||
%% limitations under the License.
|
%% limitations under the License.
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
%% MQTT Protocol Header
|
%%--------------------------------------------------------------------
|
||||||
|
%% MQTT SockOpts
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-define(MQTT_SOCKOPTS, [binary, {packet, raw}, {reuseaddr, true},
|
||||||
|
{backlog, 512}, {nodelay, true}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Protocol Version and Levels
|
%% MQTT Protocol Version and Levels
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-define(MQTT_PROTO_V31, 3).
|
|
||||||
-define(MQTT_PROTO_V311, 4).
|
-define(MQTT_PROTO_V3, 3).
|
||||||
|
-define(MQTT_PROTO_V4, 4).
|
||||||
|
-define(MQTT_PROTO_V5, 5).
|
||||||
|
|
||||||
-define(PROTOCOL_NAMES, [
|
-define(PROTOCOL_NAMES, [
|
||||||
{?MQTT_PROTO_V31, <<"MQIsdp">>},
|
{?MQTT_PROTO_V3, <<"MQIsdp">>},
|
||||||
{?MQTT_PROTO_V311, <<"MQTT">>}]).
|
{?MQTT_PROTO_V4, <<"MQTT">>},
|
||||||
|
{?MQTT_PROTO_V5, <<"MQTT">>}]).
|
||||||
|
|
||||||
-type(mqtt_vsn() :: ?MQTT_PROTO_V31 | ?MQTT_PROTO_V311).
|
-type(mqtt_vsn() :: ?MQTT_PROTO_V3 | ?MQTT_PROTO_V4 | ?MQTT_PROTO_V5).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT QoS
|
%% MQTT QoS Level
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(QOS_0, 0). %% At most once
|
-define(QOS_0, 0). %% At most once
|
||||||
-define(QOS_1, 1). %% At least once
|
-define(QOS_1, 1). %% At least once
|
||||||
-define(QOS_2, 2). %% Exactly once
|
-define(QOS_2, 2). %% Exactly once
|
||||||
|
@ -63,8 +72,9 @@
|
||||||
end).
|
end).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Max ClientId Length. Why 1024? NiDongDe...
|
%% Max ClientId Length. Why 1024?
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(MAX_CLIENTID_LEN, 1024).
|
-define(MAX_CLIENTID_LEN, 1024).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
@ -85,6 +95,7 @@
|
||||||
-define(PINGREQ, 12). %% PING request
|
-define(PINGREQ, 12). %% PING request
|
||||||
-define(PINGRESP, 13). %% PING response
|
-define(PINGRESP, 13). %% PING response
|
||||||
-define(DISCONNECT, 14). %% Client is disconnecting
|
-define(DISCONNECT, 14). %% Client is disconnecting
|
||||||
|
-define(AUTH, 15). %% Authentication exchange
|
||||||
|
|
||||||
-define(TYPE_NAMES, [
|
-define(TYPE_NAMES, [
|
||||||
'CONNECT',
|
'CONNECT',
|
||||||
|
@ -100,13 +111,15 @@
|
||||||
'UNSUBACK',
|
'UNSUBACK',
|
||||||
'PINGREQ',
|
'PINGREQ',
|
||||||
'PINGRESP',
|
'PINGRESP',
|
||||||
'DISCONNECT']).
|
'DISCONNECT',
|
||||||
|
'AUTH']).
|
||||||
|
|
||||||
-type(mqtt_packet_type() :: ?RESERVED..?DISCONNECT).
|
-type(mqtt_packet_type() :: ?RESERVED..?DISCONNECT).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Connect Return Codes
|
%% MQTT Connect Return Codes
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(CONNACK_ACCEPT, 0). %% Connection accepted
|
-define(CONNACK_ACCEPT, 0). %% Connection accepted
|
||||||
-define(CONNACK_PROTO_VER, 1). %% Unacceptable protocol version
|
-define(CONNACK_PROTO_VER, 1). %% Unacceptable protocol version
|
||||||
-define(CONNACK_INVALID_ID, 2). %% Client Identifier is correct UTF-8 but not allowed by the Server
|
-define(CONNACK_INVALID_ID, 2). %% Client Identifier is correct UTF-8 but not allowed by the Server
|
||||||
|
@ -119,6 +132,7 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Parser and Serializer
|
%% MQTT Parser and Serializer
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(MAX_LEN, 16#fffffff).
|
-define(MAX_LEN, 16#fffffff).
|
||||||
-define(HIGHBIT, 2#10000000).
|
-define(HIGHBIT, 2#10000000).
|
||||||
-define(LOWBITS, 2#01111111).
|
-define(LOWBITS, 2#01111111).
|
||||||
|
@ -126,6 +140,7 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Packet Fixed Header
|
%% MQTT Packet Fixed Header
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-record(mqtt_packet_header, {
|
-record(mqtt_packet_header, {
|
||||||
type = ?RESERVED :: mqtt_packet_type(),
|
type = ?RESERVED :: mqtt_packet_type(),
|
||||||
dup = false :: boolean(),
|
dup = false :: boolean(),
|
||||||
|
@ -135,13 +150,14 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Packets
|
%% MQTT Packets
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-type(mqtt_client_id() :: binary()).
|
-type(mqtt_client_id() :: binary()).
|
||||||
-type(mqtt_username() :: binary() | undefined).
|
-type(mqtt_username() :: binary() | undefined).
|
||||||
-type(mqtt_packet_id() :: 1..16#ffff | undefined).
|
-type(mqtt_packet_id() :: 1..16#ffff | undefined).
|
||||||
|
|
||||||
-record(mqtt_packet_connect, {
|
-record(mqtt_packet_connect,
|
||||||
client_id = <<>> :: mqtt_client_id(),
|
{ client_id = <<>> :: mqtt_client_id(),
|
||||||
proto_ver = ?MQTT_PROTO_V311 :: mqtt_vsn(),
|
proto_ver = ?MQTT_PROTO_V4 :: mqtt_vsn(),
|
||||||
proto_name = <<"MQTT">> :: binary(),
|
proto_name = <<"MQTT">> :: binary(),
|
||||||
will_retain = false :: boolean(),
|
will_retain = false :: boolean(),
|
||||||
will_qos = ?QOS_0 :: mqtt_qos(),
|
will_qos = ?QOS_0 :: mqtt_qos(),
|
||||||
|
@ -151,51 +167,60 @@
|
||||||
will_topic = undefined :: undefined | binary(),
|
will_topic = undefined :: undefined | binary(),
|
||||||
will_msg = undefined :: undefined | binary(),
|
will_msg = undefined :: undefined | binary(),
|
||||||
username = undefined :: undefined | binary(),
|
username = undefined :: undefined | binary(),
|
||||||
password = undefined :: undefined | binary()}).
|
password = undefined :: undefined | binary()
|
||||||
|
}).
|
||||||
|
|
||||||
-record(mqtt_packet_connack, {
|
-record(mqtt_packet_connack,
|
||||||
ack_flags = ?RESERVED :: 0 | 1,
|
{ ack_flags = ?RESERVED :: 0 | 1,
|
||||||
return_code :: mqtt_connack() }).
|
return_code :: mqtt_connack()
|
||||||
|
}).
|
||||||
|
|
||||||
-record(mqtt_packet_publish, {
|
-record(mqtt_packet_publish,
|
||||||
topic_name :: binary(),
|
{ topic_name :: binary(),
|
||||||
packet_id :: mqtt_packet_id() }).
|
packet_id :: mqtt_packet_id()
|
||||||
|
}).
|
||||||
|
|
||||||
-record(mqtt_packet_puback, {
|
-record(mqtt_packet_puback,
|
||||||
packet_id :: mqtt_packet_id() }).
|
{ packet_id :: mqtt_packet_id() }).
|
||||||
|
|
||||||
-record(mqtt_packet_subscribe, {
|
-record(mqtt_packet_subscribe,
|
||||||
packet_id :: mqtt_packet_id(),
|
{ packet_id :: mqtt_packet_id(),
|
||||||
topic_table :: list({binary(), mqtt_qos()}) }).
|
topic_table :: list({binary(), mqtt_qos()})
|
||||||
|
}).
|
||||||
|
|
||||||
-record(mqtt_packet_unsubscribe, {
|
-record(mqtt_packet_unsubscribe,
|
||||||
packet_id :: mqtt_packet_id(),
|
{ packet_id :: mqtt_packet_id(),
|
||||||
topics :: list(binary()) }).
|
topics :: list(binary())
|
||||||
|
}).
|
||||||
|
|
||||||
-record(mqtt_packet_suback, {
|
-record(mqtt_packet_suback,
|
||||||
packet_id :: mqtt_packet_id(),
|
{ packet_id :: mqtt_packet_id(),
|
||||||
qos_table :: list(mqtt_qos() | 128) }).
|
qos_table :: list(mqtt_qos() | 128)
|
||||||
|
}).
|
||||||
|
|
||||||
-record(mqtt_packet_unsuback, {
|
-record(mqtt_packet_unsuback,
|
||||||
packet_id :: mqtt_packet_id() }).
|
{ packet_id :: mqtt_packet_id() }).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Control Packet
|
%% MQTT Control Packet
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-record(mqtt_packet, {
|
|
||||||
header :: #mqtt_packet_header{},
|
-record(mqtt_packet,
|
||||||
|
{ header :: #mqtt_packet_header{},
|
||||||
variable :: #mqtt_packet_connect{} | #mqtt_packet_connack{}
|
variable :: #mqtt_packet_connect{} | #mqtt_packet_connack{}
|
||||||
| #mqtt_packet_publish{} | #mqtt_packet_puback{}
|
| #mqtt_packet_publish{} | #mqtt_packet_puback{}
|
||||||
| #mqtt_packet_subscribe{} | #mqtt_packet_suback{}
|
| #mqtt_packet_subscribe{} | #mqtt_packet_suback{}
|
||||||
| #mqtt_packet_unsubscribe{} | #mqtt_packet_unsuback{}
|
| #mqtt_packet_unsubscribe{} | #mqtt_packet_unsuback{}
|
||||||
| mqtt_packet_id() | undefined,
|
| mqtt_packet_id() | undefined,
|
||||||
payload :: binary() | undefined }).
|
payload :: binary() | undefined
|
||||||
|
}).
|
||||||
|
|
||||||
-type mqtt_packet() :: #mqtt_packet{}.
|
-type(mqtt_packet() :: #mqtt_packet{}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% MQTT Packet Match
|
%% MQTT Packet Match
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-define(CONNECT_PACKET(Var),
|
-define(CONNECT_PACKET(Var),
|
||||||
#mqtt_packet{header = #mqtt_packet_header{type = ?CONNECT}, variable = Var}).
|
#mqtt_packet{header = #mqtt_packet_header{type = ?CONNECT}, variable = Var}).
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Copyright (c) 2016-2017 Feng Lee <feng@emqtt.io>.
|
%% Copyright (c) 2013-2017 EMQ Enterprise, Inc. (http://emqtt.io)
|
||||||
%%
|
%%
|
||||||
%% Licensed under the Apache License, Version 2.0 (the "License");
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
%% you may not use this file except in compliance with the License.
|
%% you may not use this file except in compliance with the License.
|
||||||
|
@ -16,20 +16,20 @@
|
||||||
|
|
||||||
-type(trie_node_id() :: binary() | atom()).
|
-type(trie_node_id() :: binary() | atom()).
|
||||||
|
|
||||||
-record(trie_node, {
|
-record(trie_node,
|
||||||
node_id :: trie_node_id(),
|
{ node_id :: trie_node_id(),
|
||||||
edge_count = 0 :: non_neg_integer(),
|
edge_count = 0 :: non_neg_integer(),
|
||||||
topic :: binary() | undefined,
|
topic :: binary() | undefined,
|
||||||
flags :: [retained | static]
|
flags :: [retained | static]
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(trie_edge, {
|
-record(trie_edge,
|
||||||
node_id :: trie_node_id(),
|
{ node_id :: trie_node_id(),
|
||||||
word :: binary() | atom()
|
word :: binary() | atom()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
-record(trie, {
|
-record(trie,
|
||||||
edge :: #trie_edge{},
|
{ edge :: #trie_edge{},
|
||||||
node_id :: trie_node_id()
|
node_id :: trie_node_id()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue