2020-04-14 17:19:12 +08:00
|
|
|
#ifndef HEADER_CURL_MQTT_H
|
|
|
|
#define HEADER_CURL_MQTT_H
|
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \___|\___/|_| \_\_____|
|
|
|
|
*
|
2023-01-02 20:51:48 +08:00
|
|
|
* Copyright (C) Björn Stenberg, <bjorn@haxx.se>
|
2020-04-14 17:19:12 +08:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
2020-04-14 17:19:12 +08:00
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
2022-05-17 17:16:50 +08:00
|
|
|
* SPDX-License-Identifier: curl
|
|
|
|
*
|
2020-04-14 17:19:12 +08:00
|
|
|
***************************************************************************/
|
|
|
|
|
2020-08-31 15:45:09 +08:00
|
|
|
#ifndef CURL_DISABLE_MQTT
|
2020-04-14 17:19:12 +08:00
|
|
|
extern const struct Curl_handler Curl_handler_mqtt;
|
|
|
|
#endif
|
|
|
|
|
2020-04-16 19:20:52 +08:00
|
|
|
enum mqttstate {
|
|
|
|
MQTT_FIRST, /* 0 */
|
|
|
|
MQTT_REMAINING_LENGTH, /* 1 */
|
|
|
|
MQTT_CONNACK, /* 2 */
|
|
|
|
MQTT_SUBACK, /* 3 */
|
|
|
|
MQTT_SUBACK_COMING, /* 4 - the SUBACK remainder */
|
|
|
|
MQTT_PUBWAIT, /* 5 - wait for publish */
|
|
|
|
MQTT_PUB_REMAIN, /* 6 - wait for the remainder of the publish */
|
|
|
|
|
2020-04-21 05:27:04 +08:00
|
|
|
MQTT_NOSTATE /* 7 - never used an actual state */
|
2020-04-16 19:20:52 +08:00
|
|
|
};
|
|
|
|
|
2020-04-14 17:19:12 +08:00
|
|
|
struct mqtt_conn {
|
2020-04-16 19:20:52 +08:00
|
|
|
enum mqttstate state;
|
|
|
|
enum mqttstate nextstate; /* switch to this after remaining length is
|
|
|
|
done */
|
2020-04-14 17:19:12 +08:00
|
|
|
unsigned int packetid;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* protocol-specific transfer-related data */
|
|
|
|
struct MQTT {
|
|
|
|
char *sendleftovers;
|
|
|
|
size_t nsend; /* size of sendleftovers */
|
|
|
|
|
2020-04-20 16:05:28 +08:00
|
|
|
/* when receiving */
|
2020-04-14 17:19:12 +08:00
|
|
|
size_t npacket; /* byte counter */
|
|
|
|
unsigned char firstbyte;
|
2020-04-16 19:20:52 +08:00
|
|
|
size_t remaining_length;
|
2023-10-09 17:36:37 +08:00
|
|
|
struct dynbuf recvbuf;
|
2024-01-26 16:21:37 +08:00
|
|
|
unsigned char pkt_hd[4]; /* for decoding the arriving packet length */
|
2020-04-14 17:19:12 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* HEADER_CURL_MQTT_H */
|