diff options
Diffstat (limited to 'deps/rabbitmq_mqtt/include')
-rw-r--r-- | deps/rabbitmq_mqtt/include/mqtt_machine.hrl | 8 | ||||
-rw-r--r-- | deps/rabbitmq_mqtt/include/rabbit_mqtt.hrl | 92 | ||||
-rw-r--r-- | deps/rabbitmq_mqtt/include/rabbit_mqtt_frame.hrl | 90 | ||||
-rw-r--r-- | deps/rabbitmq_mqtt/include/rabbit_mqtt_retained_msg_store.hrl | 6 |
4 files changed, 196 insertions, 0 deletions
diff --git a/deps/rabbitmq_mqtt/include/mqtt_machine.hrl b/deps/rabbitmq_mqtt/include/mqtt_machine.hrl new file mode 100644 index 0000000000..b670c7b32e --- /dev/null +++ b/deps/rabbitmq_mqtt/include/mqtt_machine.hrl @@ -0,0 +1,8 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +%% + +-record(machine_state, {client_ids = #{}}). diff --git a/deps/rabbitmq_mqtt/include/rabbit_mqtt.hrl b/deps/rabbitmq_mqtt/include/rabbit_mqtt.hrl new file mode 100644 index 0000000000..912f5ad46f --- /dev/null +++ b/deps/rabbitmq_mqtt/include/rabbit_mqtt.hrl @@ -0,0 +1,92 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +%% + +-define(CLIENT_ID_MAXLEN, 23). + +%% reader state +-record(state, { socket, + conn_name, + await_recv, + deferred_recv, + received_connect_frame, + connection_state, + keepalive, + keepalive_sup, + conserve, + parse_state, + proc_state, + connection, + stats_timer }). + +%% processor state +-record(proc_state, { socket, + subscriptions, + consumer_tags, + unacked_pubs, + awaiting_ack, + awaiting_seqno, + message_id, + client_id, + clean_sess, + will_msg, + channels, + connection, + exchange, + adapter_info, + ssl_login_name, + %% Retained messages handler. See rabbit_mqtt_retainer_sup + %% and rabbit_mqtt_retainer. + retainer_pid, + auth_state, + send_fun, + peer_addr, + mqtt2amqp_fun, + amqp2mqtt_fun, + register_state }). + +-record(auth_state, {username, + user, + vhost}). + +%% does not include vhost: it is used in +%% the table name +-record(retained_message, {topic, + mqtt_msg}). + +-define(INFO_ITEMS, + [host, + port, + peer_host, + peer_port, + protocol, + channels, + channel_max, + frame_max, + client_properties, + ssl, + ssl_protocol, + ssl_key_exchange, + ssl_cipher, + ssl_hash, + conn_name, + connection_state, + connection, + consumer_tags, + unacked_pubs, + awaiting_ack, + awaiting_seqno, + message_id, + client_id, + clean_sess, + will_msg, + exchange, + ssl_login_name, + retainer_pid, + user, + vhost]). + +-define(MQTT_GUIDE_URL, <<"https://rabbitmq.com/mqtt.html">>). diff --git a/deps/rabbitmq_mqtt/include/rabbit_mqtt_frame.hrl b/deps/rabbitmq_mqtt/include/rabbit_mqtt_frame.hrl new file mode 100644 index 0000000000..2b06da502b --- /dev/null +++ b/deps/rabbitmq_mqtt/include/rabbit_mqtt_frame.hrl @@ -0,0 +1,90 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +%% + +-define(PROTOCOL_NAMES, [{3, "MQIsdp"}, {4, "MQTT"}]). + +%% frame types + +-define(CONNECT, 1). +-define(CONNACK, 2). +-define(PUBLISH, 3). +-define(PUBACK, 4). +-define(PUBREC, 5). +-define(PUBREL, 6). +-define(PUBCOMP, 7). +-define(SUBSCRIBE, 8). +-define(SUBACK, 9). +-define(UNSUBSCRIBE, 10). +-define(UNSUBACK, 11). +-define(PINGREQ, 12). +-define(PINGRESP, 13). +-define(DISCONNECT, 14). + +%% connect return codes + +-define(CONNACK_ACCEPT, 0). +-define(CONNACK_PROTO_VER, 1). %% unacceptable protocol version +-define(CONNACK_INVALID_ID, 2). %% identifier rejected +-define(CONNACK_SERVER, 3). %% server unavailable +-define(CONNACK_CREDENTIALS, 4). %% bad user name or password +-define(CONNACK_AUTH, 5). %% not authorized + +%% qos levels + +-define(QOS_0, 0). +-define(QOS_1, 1). +-define(QOS_2, 2). + +%% TODO +-type message_id() :: any(). + +-record(mqtt_frame, {fixed, + variable, + payload}). + +-record(mqtt_frame_fixed, {type = 0, + dup = 0, + qos = 0, + retain = 0}). + +-record(mqtt_frame_connect, {proto_ver, + will_retain, + will_qos, + will_flag, + clean_sess, + keep_alive, + client_id, + will_topic, + will_msg, + username, + password}). + +-record(mqtt_frame_connack, {session_present, + return_code}). + +-record(mqtt_frame_publish, {topic_name, + message_id}). + +-record(mqtt_frame_subscribe,{message_id, + topic_table}). + +-record(mqtt_frame_suback, {message_id, + qos_table = []}). + +-record(mqtt_topic, {name, + qos}). + +-record(mqtt_frame_other, {other}). + +-record(mqtt_msg, {retain :: boolean(), + qos :: ?QOS_0 | ?QOS_1 | ?QOS_2, + topic :: string(), + dup :: boolean(), + message_id :: message_id(), + payload :: binary()}). + +-type mqtt_msg() :: #mqtt_msg{}. diff --git a/deps/rabbitmq_mqtt/include/rabbit_mqtt_retained_msg_store.hrl b/deps/rabbitmq_mqtt/include/rabbit_mqtt_retained_msg_store.hrl new file mode 100644 index 0000000000..52b61b5924 --- /dev/null +++ b/deps/rabbitmq_mqtt/include/rabbit_mqtt_retained_msg_store.hrl @@ -0,0 +1,6 @@ +%% This Source Code Form is subject to the terms of the Mozilla Public +%% License, v. 2.0. If a copy of the MPL was not distributed with this +%% file, You can obtain one at https://mozilla.org/MPL/2.0/. +%% +%% Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved. +%% |