mqtt.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. * Copyright (C) 2019, Björn Stenberg, <bjorn@haxx.se>
  10. *
  11. * This software is licensed as described in the file COPYING, which
  12. * you should have received as part of this distribution. The terms
  13. * are also available at https://curl.haxx.se/docs/copyright.html.
  14. *
  15. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. * copies of the Software, and permit persons to whom the Software is
  17. * furnished to do so, under the terms of the COPYING file.
  18. *
  19. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. * KIND, either express or implied.
  21. *
  22. ***************************************************************************/
  23. #include "curl_setup.h"
  24. #ifdef CURL_ENABLE_MQTT
  25. #include "urldata.h"
  26. #include <curl/curl.h>
  27. #include "transfer.h"
  28. #include "sendf.h"
  29. #include "progress.h"
  30. #include "mqtt.h"
  31. #include "select.h"
  32. #include "strdup.h"
  33. #include "url.h"
  34. #include "escape.h"
  35. #include "warnless.h"
  36. #include "curl_printf.h"
  37. #include "curl_memory.h"
  38. #include "multiif.h"
  39. #include "rand.h"
  40. /* The last #include file should be: */
  41. #include "memdebug.h"
  42. #define MQTT_MSG_CONNECT 0x10
  43. #define MQTT_MSG_CONNACK 0x20
  44. #define MQTT_MSG_PUBLISH 0x30
  45. #define MQTT_MSG_SUBSCRIBE 0x82
  46. #define MQTT_MSG_SUBACK 0x90
  47. #define MQTT_MSG_DISCONNECT 0xe0
  48. #define MQTT_CONNACK_LEN 2
  49. #define MQTT_SUBACK_LEN 3
  50. #define MQTT_CLIENTID_LEN 12 /* "curl0123abcd" */
  51. /*
  52. * Forward declarations.
  53. */
  54. static CURLcode mqtt_do(struct connectdata *conn, bool *done);
  55. static CURLcode mqtt_doing(struct connectdata *conn, bool *done);
  56. static int mqtt_getsock(struct connectdata *conn, curl_socket_t *sock);
  57. static CURLcode mqtt_setup_conn(struct connectdata *conn);
  58. /*
  59. * MQTT protocol handler.
  60. */
  61. const struct Curl_handler Curl_handler_mqtt = {
  62. "MQTT", /* scheme */
  63. mqtt_setup_conn, /* setup_connection */
  64. mqtt_do, /* do_it */
  65. ZERO_NULL, /* done */
  66. ZERO_NULL, /* do_more */
  67. ZERO_NULL, /* connect_it */
  68. ZERO_NULL, /* connecting */
  69. mqtt_doing, /* doing */
  70. ZERO_NULL, /* proto_getsock */
  71. mqtt_getsock, /* doing_getsock */
  72. ZERO_NULL, /* domore_getsock */
  73. ZERO_NULL, /* perform_getsock */
  74. ZERO_NULL, /* disconnect */
  75. ZERO_NULL, /* readwrite */
  76. ZERO_NULL, /* connection_check */
  77. PORT_MQTT, /* defport */
  78. CURLPROTO_MQTT, /* protocol */
  79. PROTOPT_NONE /* flags */
  80. };
  81. static CURLcode mqtt_setup_conn(struct connectdata *conn)
  82. {
  83. /* allocate the HTTP-specific struct for the Curl_easy, only to survive
  84. during this request */
  85. struct MQTT *mq;
  86. struct Curl_easy *data = conn->data;
  87. DEBUGASSERT(data->req.protop == NULL);
  88. mq = calloc(1, sizeof(struct MQTT));
  89. if(!mq)
  90. return CURLE_OUT_OF_MEMORY;
  91. data->req.protop = mq;
  92. return CURLE_OK;
  93. }
  94. static CURLcode mqtt_send(struct connectdata *conn,
  95. char *buf, size_t len)
  96. {
  97. CURLcode result = CURLE_OK;
  98. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  99. struct Curl_easy *data = conn->data;
  100. struct MQTT *mq = data->req.protop;
  101. ssize_t n;
  102. result = Curl_write(conn, sockfd, buf, len, &n);
  103. if(!result && data->set.verbose)
  104. Curl_debug(data, CURLINFO_HEADER_OUT, buf, (size_t)n);
  105. if(len != (size_t)n) {
  106. size_t nsend = len - n;
  107. char *sendleftovers = Curl_memdup(&buf[n], nsend);
  108. if(!sendleftovers)
  109. return CURLE_OUT_OF_MEMORY;
  110. mq->sendleftovers = sendleftovers;
  111. mq->nsend = nsend;
  112. }
  113. return result;
  114. }
  115. /* Generic function called by the multi interface to figure out what socket(s)
  116. to wait for and for what actions during the DOING and PROTOCONNECT
  117. states */
  118. static int mqtt_getsock(struct connectdata *conn,
  119. curl_socket_t *sock)
  120. {
  121. sock[0] = conn->sock[FIRSTSOCKET];
  122. return GETSOCK_READSOCK(FIRSTSOCKET);
  123. }
  124. static CURLcode mqtt_connect(struct connectdata *conn)
  125. {
  126. CURLcode result = CURLE_OK;
  127. const size_t client_id_offset = 14;
  128. const size_t packetlen = client_id_offset + MQTT_CLIENTID_LEN;
  129. char client_id[MQTT_CLIENTID_LEN + 1] = "curl";
  130. const size_t curl_len = strlen("curl");
  131. char packet[32] = {
  132. MQTT_MSG_CONNECT, /* packet type */
  133. 0x00, /* remaining length */
  134. 0x00, 0x04, /* protocol length */
  135. 'M','Q','T','T', /* protocol name */
  136. 0x04, /* protocol level */
  137. 0x02, /* CONNECT flag: CleanSession */
  138. 0x00, 0x3c, /* keep-alive 0 = disabled */
  139. 0x00, 0x00 /* payload1 length */
  140. };
  141. packet[1] = (packetlen - 2) & 0x7f;
  142. packet[client_id_offset - 1] = MQTT_CLIENTID_LEN;
  143. result = Curl_rand_hex(conn->data, (unsigned char *)&client_id[curl_len],
  144. MQTT_CLIENTID_LEN - curl_len + 1);
  145. memcpy(&packet[client_id_offset], client_id, MQTT_CLIENTID_LEN);
  146. infof(conn->data, "Using client id '%s'\n", client_id);
  147. if(!result)
  148. result = mqtt_send(conn, packet, packetlen);
  149. return result;
  150. }
  151. static CURLcode mqtt_disconnect(struct connectdata *conn)
  152. {
  153. CURLcode result = CURLE_OK;
  154. result = mqtt_send(conn, (char *)"\xe0\x00", 2);
  155. return result;
  156. }
  157. static CURLcode mqtt_verify_connack(struct connectdata *conn)
  158. {
  159. CURLcode result;
  160. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  161. unsigned char readbuf[MQTT_CONNACK_LEN];
  162. ssize_t nread;
  163. struct Curl_easy *data = conn->data;
  164. result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_CONNACK_LEN, &nread);
  165. if(result)
  166. goto fail;
  167. if(data->set.verbose)
  168. Curl_debug(data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
  169. /* fixme */
  170. if(nread < MQTT_CONNACK_LEN) {
  171. result = CURLE_WEIRD_SERVER_REPLY;
  172. goto fail;
  173. }
  174. /* verify CONNACK */
  175. if(readbuf[0] != 0x00 || readbuf[1] != 0x00) {
  176. failf(data, "Expected %02x%02x but got %02x%02x",
  177. 0x00, 0x00, readbuf[0], readbuf[1]);
  178. result = CURLE_WEIRD_SERVER_REPLY;
  179. }
  180. fail:
  181. return result;
  182. }
  183. static CURLcode mqtt_get_topic(struct connectdata *conn,
  184. char **topic, size_t *topiclen)
  185. {
  186. CURLcode result = CURLE_OK;
  187. char *path = conn->data->state.up.path;
  188. if(strlen(path) > 1) {
  189. result = Curl_urldecode(conn->data, path + 1, 0, topic, topiclen,
  190. REJECT_NADA);
  191. }
  192. else {
  193. failf(conn->data, "Error: No topic specified.");
  194. result = CURLE_URL_MALFORMAT;
  195. }
  196. return result;
  197. }
  198. static int mqtt_encode_len(char *buf, size_t len)
  199. {
  200. unsigned char encoded;
  201. int i;
  202. for(i = 0; (len > 0) && (i<4); i++) {
  203. encoded = len % 0x80;
  204. len /= 0x80;
  205. if(len)
  206. encoded |= 0x80;
  207. buf[i] = encoded;
  208. }
  209. return i;
  210. }
  211. static CURLcode mqtt_subscribe(struct connectdata *conn)
  212. {
  213. CURLcode result = CURLE_OK;
  214. char *topic = NULL;
  215. size_t topiclen;
  216. unsigned char *packet = NULL;
  217. size_t packetlen;
  218. char encodedsize[4];
  219. size_t n;
  220. result = mqtt_get_topic(conn, &topic, &topiclen);
  221. if(result)
  222. goto fail;
  223. conn->proto.mqtt.packetid++;
  224. packetlen = topiclen + 5; /* packetid + topic (has a two byte length field)
  225. + 2 bytes topic length + QoS byte */
  226. n = mqtt_encode_len((char *)encodedsize, packetlen);
  227. packetlen += n + 1; /* add one for the control packet type byte */
  228. packet = malloc(packetlen);
  229. if(!packet) {
  230. result = CURLE_OUT_OF_MEMORY;
  231. goto fail;
  232. }
  233. packet[0] = MQTT_MSG_SUBSCRIBE;
  234. memcpy(&packet[1], encodedsize, n);
  235. packet[1 + n] = (conn->proto.mqtt.packetid >> 8) & 0xff;
  236. packet[2 + n] = conn->proto.mqtt.packetid & 0xff;
  237. packet[3 + n] = (topiclen >> 8) & 0xff;
  238. packet[4 + n ] = topiclen & 0xff;
  239. memcpy(&packet[5 + n], topic, topiclen);
  240. packet[5 + n + topiclen] = 0; /* QoS zero */
  241. result = mqtt_send(conn, (char *)packet, packetlen);
  242. fail:
  243. free(topic);
  244. free(packet);
  245. return result;
  246. }
  247. /*
  248. * Called when the first byte was already read.
  249. */
  250. static CURLcode mqtt_verify_suback(struct connectdata *conn)
  251. {
  252. CURLcode result;
  253. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  254. unsigned char readbuf[MQTT_SUBACK_LEN];
  255. ssize_t nread;
  256. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  257. result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_SUBACK_LEN, &nread);
  258. if(result)
  259. goto fail;
  260. if(conn->data->set.verbose)
  261. Curl_debug(conn->data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
  262. /* fixme */
  263. if(nread < MQTT_SUBACK_LEN) {
  264. result = CURLE_WEIRD_SERVER_REPLY;
  265. goto fail;
  266. }
  267. /* verify SUBACK */
  268. if(readbuf[0] != ((mqtt->packetid >> 8) & 0xff) ||
  269. readbuf[1] != (mqtt->packetid & 0xff) ||
  270. readbuf[2] != 0x00)
  271. result = CURLE_WEIRD_SERVER_REPLY;
  272. fail:
  273. return result;
  274. }
  275. static CURLcode mqtt_publish(struct connectdata *conn)
  276. {
  277. CURLcode result;
  278. char *payload = conn->data->set.postfields;
  279. size_t payloadlen = (size_t)conn->data->set.postfieldsize;
  280. char *topic = NULL;
  281. size_t topiclen;
  282. unsigned char *pkt = NULL;
  283. size_t i = 0;
  284. size_t remaininglength;
  285. size_t encodelen;
  286. char encodedbytes[4];
  287. result = mqtt_get_topic(conn, &topic, &topiclen);
  288. if(result)
  289. goto fail;
  290. remaininglength = payloadlen + 2 + topiclen;
  291. encodelen = mqtt_encode_len(encodedbytes, remaininglength);
  292. /* add the control byte and the encoded remaining length */
  293. pkt = malloc(remaininglength + 1 + encodelen);
  294. if(!pkt) {
  295. result = CURLE_OUT_OF_MEMORY;
  296. goto fail;
  297. }
  298. /* assemble packet */
  299. pkt[i++] = MQTT_MSG_PUBLISH;
  300. memcpy(&pkt[i], encodedbytes, encodelen);
  301. i += encodelen;
  302. pkt[i++] = (topiclen >> 8) & 0xff;
  303. pkt[i++] = (topiclen & 0xff);
  304. memcpy(&pkt[i], topic, topiclen);
  305. i += topiclen;
  306. memcpy(&pkt[i], payload, payloadlen);
  307. i += payloadlen;
  308. result = mqtt_send(conn, (char *)pkt, i);
  309. fail:
  310. free(pkt);
  311. free(topic);
  312. return result;
  313. }
  314. static size_t mqtt_decode_len(unsigned char *buf,
  315. size_t buflen, size_t *lenbytes)
  316. {
  317. size_t len = 0;
  318. size_t mult = 1;
  319. size_t i;
  320. unsigned char encoded = 128;
  321. for(i = 0; (i < buflen) && (encoded & 128); i++) {
  322. encoded = buf[i];
  323. len += (encoded & 127) * mult;
  324. mult *= 128;
  325. }
  326. if(lenbytes)
  327. *lenbytes = i;
  328. return len;
  329. }
  330. #ifdef CURLDEBUG
  331. static const char *statenames[]={
  332. "MQTT_FIRST",
  333. "MQTT_REMAINING_LENGTH",
  334. "MQTT_CONNACK",
  335. "MQTT_SUBACK",
  336. "MQTT_SUBACK_COMING",
  337. "MQTT_PUBWAIT",
  338. "MQTT_PUB_REMAIN",
  339. "NOT A STATE"
  340. };
  341. #endif
  342. /* The only way to change state */
  343. static void mqstate(struct connectdata *conn,
  344. enum mqttstate state,
  345. enum mqttstate nextstate) /* used if state == FIRST */
  346. {
  347. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  348. #ifdef CURLDEBUG
  349. infof(conn->data, "%s (from %s) (next is %s)\n",
  350. statenames[state],
  351. statenames[mqtt->state],
  352. (state == MQTT_FIRST)? statenames[nextstate] : "");
  353. #endif
  354. mqtt->state = state;
  355. if(state == MQTT_FIRST)
  356. mqtt->nextstate = nextstate;
  357. }
  358. /* for the publish packet */
  359. #define MQTT_HEADER_LEN 5 /* max 5 bytes */
  360. static CURLcode mqtt_read_publish(struct connectdata *conn,
  361. bool *done)
  362. {
  363. CURLcode result = CURLE_OK;
  364. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  365. ssize_t nread;
  366. struct Curl_easy *data = conn->data;
  367. unsigned char *pkt = (unsigned char *)data->state.buffer;
  368. size_t remlen;
  369. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  370. struct MQTT *mq = data->req.protop;
  371. unsigned char packet;
  372. switch(mqtt->state) {
  373. MQTT_SUBACK_COMING:
  374. case MQTT_SUBACK_COMING:
  375. result = mqtt_verify_suback(conn);
  376. if(result)
  377. break;
  378. mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
  379. break;
  380. case MQTT_SUBACK:
  381. case MQTT_PUBWAIT:
  382. /* we are expecting PUBLISH or SUBACK */
  383. packet = mq->firstbyte & 0xf0;
  384. if(packet == MQTT_MSG_PUBLISH)
  385. mqstate(conn, MQTT_PUB_REMAIN, MQTT_NOSTATE);
  386. else if(packet == MQTT_MSG_SUBACK) {
  387. mqstate(conn, MQTT_SUBACK_COMING, MQTT_NOSTATE);
  388. goto MQTT_SUBACK_COMING;
  389. }
  390. else if(packet == MQTT_MSG_DISCONNECT) {
  391. infof(data, "Got DISCONNECT\n");
  392. *done = TRUE;
  393. goto end;
  394. }
  395. else {
  396. result = CURLE_WEIRD_SERVER_REPLY;
  397. goto end;
  398. }
  399. /* -- switched state -- */
  400. remlen = mq->remaining_length;
  401. infof(data, "Remaining length: %zd bytes\n", remlen);
  402. Curl_pgrsSetDownloadSize(data, remlen);
  403. data->req.bytecount = 0;
  404. data->req.size = remlen;
  405. mq->npacket = remlen; /* get this many bytes */
  406. /* FALLTHROUGH */
  407. case MQTT_PUB_REMAIN: {
  408. /* read rest of packet, but no more. Cap to buffer size */
  409. struct SingleRequest *k = &data->req;
  410. size_t rest = mq->npacket;
  411. if(rest > (size_t)data->set.buffer_size)
  412. rest = (size_t)data->set.buffer_size;
  413. result = Curl_read(conn, sockfd, (char *)pkt, rest, &nread);
  414. if(result) {
  415. if(CURLE_AGAIN == result) {
  416. infof(data, "EEEE AAAAGAIN\n");
  417. }
  418. goto end;
  419. }
  420. if(!nread) {
  421. infof(data, "server disconnected\n");
  422. result = CURLE_PARTIAL_FILE;
  423. goto end;
  424. }
  425. if(data->set.verbose)
  426. Curl_debug(data, CURLINFO_DATA_IN, (char *)pkt, (size_t)nread);
  427. mq->npacket -= nread;
  428. k->bytecount += nread;
  429. Curl_pgrsSetDownloadCounter(data, k->bytecount);
  430. /* if QoS is set, message contains packet id */
  431. result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)pkt, nread);
  432. if(result)
  433. goto end;
  434. if(!mq->npacket)
  435. /* no more PUBLISH payload, back to subscribe wait state */
  436. mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
  437. break;
  438. }
  439. default:
  440. DEBUGASSERT(NULL); /* illegal state */
  441. result = CURLE_WEIRD_SERVER_REPLY;
  442. goto end;
  443. }
  444. end:
  445. return result;
  446. }
  447. static CURLcode mqtt_do(struct connectdata *conn, bool *done)
  448. {
  449. CURLcode result = CURLE_OK;
  450. struct Curl_easy *data = conn->data;
  451. *done = FALSE; /* unconditionally */
  452. result = mqtt_connect(conn);
  453. if(result) {
  454. failf(data, "Error %d sending MQTT CONN request", result);
  455. return result;
  456. }
  457. mqstate(conn, MQTT_FIRST, MQTT_CONNACK);
  458. return CURLE_OK;
  459. }
  460. static CURLcode mqtt_doing(struct connectdata *conn, bool *done)
  461. {
  462. CURLcode result = CURLE_OK;
  463. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  464. struct Curl_easy *data = conn->data;
  465. struct MQTT *mq = data->req.protop;
  466. ssize_t nread;
  467. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  468. unsigned char *pkt = (unsigned char *)data->state.buffer;
  469. unsigned char byte;
  470. *done = FALSE;
  471. if(mq->nsend) {
  472. /* send the remainder of an outgoing packet */
  473. char *ptr = mq->sendleftovers;
  474. result = mqtt_send(conn, mq->sendleftovers, mq->nsend);
  475. free(ptr);
  476. if(result)
  477. return result;
  478. }
  479. infof(data, "mqtt_doing: state [%d]\n", (int) mqtt->state);
  480. switch(mqtt->state) {
  481. case MQTT_FIRST:
  482. /* Read the initial byte only */
  483. result = Curl_read(conn, sockfd, (char *)&mq->firstbyte, 1, &nread);
  484. if(result)
  485. break;
  486. if(data->set.verbose)
  487. Curl_debug(data, CURLINFO_HEADER_IN, (char *)&mq->firstbyte, 1);
  488. /* remember the first byte */
  489. mq->npacket = 0;
  490. mqstate(conn, MQTT_REMAINING_LENGTH, MQTT_NOSTATE);
  491. /* FALLTHROUGH */
  492. case MQTT_REMAINING_LENGTH:
  493. do {
  494. result = Curl_read(conn, sockfd, (char *)&byte, 1, &nread);
  495. if(result)
  496. break;
  497. if(data->set.verbose)
  498. Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1);
  499. pkt[mq->npacket++] = byte;
  500. } while((byte & 0x80) && (mq->npacket < 4));
  501. if(result)
  502. break;
  503. mq->remaining_length = mqtt_decode_len(&pkt[0], mq->npacket, NULL);
  504. mq->npacket = 0;
  505. if(mq->remaining_length) {
  506. mqstate(conn, mqtt->nextstate, MQTT_NOSTATE);
  507. break;
  508. }
  509. mqstate(conn, MQTT_FIRST, MQTT_FIRST);
  510. if(mq->firstbyte == MQTT_MSG_DISCONNECT) {
  511. infof(data, "Got DISCONNECT\n");
  512. *done = TRUE;
  513. }
  514. break;
  515. case MQTT_CONNACK:
  516. result = mqtt_verify_connack(conn);
  517. if(result)
  518. break;
  519. if(conn->data->state.httpreq == HTTPREQ_POST) {
  520. result = mqtt_publish(conn);
  521. if(!result) {
  522. result = mqtt_disconnect(conn);
  523. *done = TRUE;
  524. }
  525. mqtt->nextstate = MQTT_FIRST;
  526. }
  527. else {
  528. result = mqtt_subscribe(conn);
  529. if(!result) {
  530. mqstate(conn, MQTT_FIRST, MQTT_SUBACK);
  531. }
  532. }
  533. break;
  534. case MQTT_SUBACK:
  535. case MQTT_PUBWAIT:
  536. case MQTT_PUB_REMAIN:
  537. result = mqtt_read_publish(conn, done);
  538. break;
  539. default:
  540. failf(conn->data, "State not handled yet");
  541. *done = TRUE;
  542. break;
  543. }
  544. if(result == CURLE_AGAIN)
  545. result = CURLE_OK;
  546. return result;
  547. }
  548. #endif /* CURL_ENABLE_MQTT */