2
0

mqtt.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef HEADER_CURL_MQTT_H
  2. #define HEADER_CURL_MQTT_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 2019 - 2020, Björn Stenberg, <bjorn@haxx.se>
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at https://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. ***************************************************************************/
  24. #ifdef CURL_ENABLE_MQTT
  25. extern const struct Curl_handler Curl_handler_mqtt;
  26. #endif
  27. enum mqttstate {
  28. MQTT_FIRST, /* 0 */
  29. MQTT_REMAINING_LENGTH, /* 1 */
  30. MQTT_CONNACK, /* 2 */
  31. MQTT_SUBACK, /* 3 */
  32. MQTT_SUBACK_COMING, /* 4 - the SUBACK remainder */
  33. MQTT_PUBWAIT, /* 5 - wait for publish */
  34. MQTT_PUB_REMAIN, /* 6 - wait for the remainder of the publish */
  35. MQTT_NOSTATE /* 7 - never used an actual state */
  36. };
  37. struct mqtt_conn {
  38. enum mqttstate state;
  39. enum mqttstate nextstate; /* switch to this after remaining length is
  40. done */
  41. unsigned int packetid;
  42. };
  43. /* protocol-specific transfer-related data */
  44. struct MQTT {
  45. char *sendleftovers;
  46. size_t nsend; /* size of sendleftovers */
  47. /* when receiving */
  48. size_t npacket; /* byte counter */
  49. unsigned char firstbyte;
  50. size_t remaining_length;
  51. };
  52. #endif /* HEADER_CURL_MQTT_H */