mqtt.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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.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. #ifndef CURL_DISABLE_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. CURLPROTO_MQTT, /* family */
  80. PROTOPT_NONE /* flags */
  81. };
  82. static CURLcode mqtt_setup_conn(struct connectdata *conn)
  83. {
  84. /* allocate the HTTP-specific struct for the Curl_easy, only to survive
  85. during this request */
  86. struct MQTT *mq;
  87. struct Curl_easy *data = conn->data;
  88. DEBUGASSERT(data->req.p.mqtt == NULL);
  89. mq = calloc(1, sizeof(struct MQTT));
  90. if(!mq)
  91. return CURLE_OUT_OF_MEMORY;
  92. data->req.p.mqtt = mq;
  93. return CURLE_OK;
  94. }
  95. static CURLcode mqtt_send(struct connectdata *conn,
  96. char *buf, size_t len)
  97. {
  98. CURLcode result = CURLE_OK;
  99. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  100. struct Curl_easy *data = conn->data;
  101. struct MQTT *mq = data->req.p.mqtt;
  102. ssize_t n;
  103. result = Curl_write(conn, sockfd, buf, len, &n);
  104. if(!result)
  105. Curl_debug(data, CURLINFO_HEADER_OUT, buf, (size_t)n);
  106. if(len != (size_t)n) {
  107. size_t nsend = len - n;
  108. char *sendleftovers = Curl_memdup(&buf[n], nsend);
  109. if(!sendleftovers)
  110. return CURLE_OUT_OF_MEMORY;
  111. mq->sendleftovers = sendleftovers;
  112. mq->nsend = nsend;
  113. }
  114. return result;
  115. }
  116. /* Generic function called by the multi interface to figure out what socket(s)
  117. to wait for and for what actions during the DOING and PROTOCONNECT
  118. states */
  119. static int mqtt_getsock(struct connectdata *conn,
  120. curl_socket_t *sock)
  121. {
  122. sock[0] = conn->sock[FIRSTSOCKET];
  123. return GETSOCK_READSOCK(FIRSTSOCKET);
  124. }
  125. static CURLcode mqtt_connect(struct connectdata *conn)
  126. {
  127. CURLcode result = CURLE_OK;
  128. const size_t client_id_offset = 14;
  129. const size_t packetlen = client_id_offset + MQTT_CLIENTID_LEN;
  130. char client_id[MQTT_CLIENTID_LEN + 1] = "curl";
  131. const size_t clen = strlen("curl");
  132. char packet[32] = {
  133. MQTT_MSG_CONNECT, /* packet type */
  134. 0x00, /* remaining length */
  135. 0x00, 0x04, /* protocol length */
  136. 'M','Q','T','T', /* protocol name */
  137. 0x04, /* protocol level */
  138. 0x02, /* CONNECT flag: CleanSession */
  139. 0x00, 0x3c, /* keep-alive 0 = disabled */
  140. 0x00, 0x00 /* payload1 length */
  141. };
  142. packet[1] = (packetlen - 2) & 0x7f;
  143. packet[client_id_offset - 1] = MQTT_CLIENTID_LEN;
  144. result = Curl_rand_hex(conn->data, (unsigned char *)&client_id[clen],
  145. MQTT_CLIENTID_LEN - clen + 1);
  146. memcpy(&packet[client_id_offset], client_id, MQTT_CLIENTID_LEN);
  147. infof(conn->data, "Using client id '%s'\n", client_id);
  148. if(!result)
  149. result = mqtt_send(conn, packet, packetlen);
  150. return result;
  151. }
  152. static CURLcode mqtt_disconnect(struct connectdata *conn)
  153. {
  154. CURLcode result = CURLE_OK;
  155. result = mqtt_send(conn, (char *)"\xe0\x00", 2);
  156. return result;
  157. }
  158. static CURLcode mqtt_verify_connack(struct connectdata *conn)
  159. {
  160. CURLcode result;
  161. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  162. unsigned char readbuf[MQTT_CONNACK_LEN];
  163. ssize_t nread;
  164. struct Curl_easy *data = conn->data;
  165. result = Curl_read(conn, sockfd, (char *)readbuf, MQTT_CONNACK_LEN, &nread);
  166. if(result)
  167. goto fail;
  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. Curl_debug(conn->data, CURLINFO_HEADER_IN, (char *)readbuf, (size_t)nread);
  261. /* fixme */
  262. if(nread < MQTT_SUBACK_LEN) {
  263. result = CURLE_WEIRD_SERVER_REPLY;
  264. goto fail;
  265. }
  266. /* verify SUBACK */
  267. if(readbuf[0] != ((mqtt->packetid >> 8) & 0xff) ||
  268. readbuf[1] != (mqtt->packetid & 0xff) ||
  269. readbuf[2] != 0x00)
  270. result = CURLE_WEIRD_SERVER_REPLY;
  271. fail:
  272. return result;
  273. }
  274. static CURLcode mqtt_publish(struct connectdata *conn)
  275. {
  276. CURLcode result;
  277. char *payload = conn->data->set.postfields;
  278. size_t payloadlen;
  279. char *topic = NULL;
  280. size_t topiclen;
  281. unsigned char *pkt = NULL;
  282. size_t i = 0;
  283. size_t remaininglength;
  284. size_t encodelen;
  285. char encodedbytes[4];
  286. curl_off_t postfieldsize = conn->data->set.postfieldsize;
  287. if(!payload)
  288. return CURLE_BAD_FUNCTION_ARGUMENT;
  289. if(postfieldsize < 0)
  290. payloadlen = strlen(payload);
  291. else
  292. payloadlen = (size_t)postfieldsize;
  293. result = mqtt_get_topic(conn, &topic, &topiclen);
  294. if(result)
  295. goto fail;
  296. remaininglength = payloadlen + 2 + topiclen;
  297. encodelen = mqtt_encode_len(encodedbytes, remaininglength);
  298. /* add the control byte and the encoded remaining length */
  299. pkt = malloc(remaininglength + 1 + encodelen);
  300. if(!pkt) {
  301. result = CURLE_OUT_OF_MEMORY;
  302. goto fail;
  303. }
  304. /* assemble packet */
  305. pkt[i++] = MQTT_MSG_PUBLISH;
  306. memcpy(&pkt[i], encodedbytes, encodelen);
  307. i += encodelen;
  308. pkt[i++] = (topiclen >> 8) & 0xff;
  309. pkt[i++] = (topiclen & 0xff);
  310. memcpy(&pkt[i], topic, topiclen);
  311. i += topiclen;
  312. memcpy(&pkt[i], payload, payloadlen);
  313. i += payloadlen;
  314. result = mqtt_send(conn, (char *)pkt, i);
  315. fail:
  316. free(pkt);
  317. free(topic);
  318. return result;
  319. }
  320. static size_t mqtt_decode_len(unsigned char *buf,
  321. size_t buflen, size_t *lenbytes)
  322. {
  323. size_t len = 0;
  324. size_t mult = 1;
  325. size_t i;
  326. unsigned char encoded = 128;
  327. for(i = 0; (i < buflen) && (encoded & 128); i++) {
  328. encoded = buf[i];
  329. len += (encoded & 127) * mult;
  330. mult *= 128;
  331. }
  332. if(lenbytes)
  333. *lenbytes = i;
  334. return len;
  335. }
  336. #ifdef CURLDEBUG
  337. static const char *statenames[]={
  338. "MQTT_FIRST",
  339. "MQTT_REMAINING_LENGTH",
  340. "MQTT_CONNACK",
  341. "MQTT_SUBACK",
  342. "MQTT_SUBACK_COMING",
  343. "MQTT_PUBWAIT",
  344. "MQTT_PUB_REMAIN",
  345. "NOT A STATE"
  346. };
  347. #endif
  348. /* The only way to change state */
  349. static void mqstate(struct connectdata *conn,
  350. enum mqttstate state,
  351. enum mqttstate nextstate) /* used if state == FIRST */
  352. {
  353. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  354. #ifdef CURLDEBUG
  355. infof(conn->data, "%s (from %s) (next is %s)\n",
  356. statenames[state],
  357. statenames[mqtt->state],
  358. (state == MQTT_FIRST)? statenames[nextstate] : "");
  359. #endif
  360. mqtt->state = state;
  361. if(state == MQTT_FIRST)
  362. mqtt->nextstate = nextstate;
  363. }
  364. /* for the publish packet */
  365. #define MQTT_HEADER_LEN 5 /* max 5 bytes */
  366. static CURLcode mqtt_read_publish(struct connectdata *conn,
  367. bool *done)
  368. {
  369. CURLcode result = CURLE_OK;
  370. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  371. ssize_t nread;
  372. struct Curl_easy *data = conn->data;
  373. unsigned char *pkt = (unsigned char *)data->state.buffer;
  374. size_t remlen;
  375. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  376. struct MQTT *mq = data->req.p.mqtt;
  377. unsigned char packet;
  378. switch(mqtt->state) {
  379. MQTT_SUBACK_COMING:
  380. case MQTT_SUBACK_COMING:
  381. result = mqtt_verify_suback(conn);
  382. if(result)
  383. break;
  384. mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
  385. break;
  386. case MQTT_SUBACK:
  387. case MQTT_PUBWAIT:
  388. /* we are expecting PUBLISH or SUBACK */
  389. packet = mq->firstbyte & 0xf0;
  390. if(packet == MQTT_MSG_PUBLISH)
  391. mqstate(conn, MQTT_PUB_REMAIN, MQTT_NOSTATE);
  392. else if(packet == MQTT_MSG_SUBACK) {
  393. mqstate(conn, MQTT_SUBACK_COMING, MQTT_NOSTATE);
  394. goto MQTT_SUBACK_COMING;
  395. }
  396. else if(packet == MQTT_MSG_DISCONNECT) {
  397. infof(data, "Got DISCONNECT\n");
  398. *done = TRUE;
  399. goto end;
  400. }
  401. else {
  402. result = CURLE_WEIRD_SERVER_REPLY;
  403. goto end;
  404. }
  405. /* -- switched state -- */
  406. remlen = mq->remaining_length;
  407. infof(data, "Remaining length: %zd bytes\n", remlen);
  408. Curl_pgrsSetDownloadSize(data, remlen);
  409. data->req.bytecount = 0;
  410. data->req.size = remlen;
  411. mq->npacket = remlen; /* get this many bytes */
  412. /* FALLTHROUGH */
  413. case MQTT_PUB_REMAIN: {
  414. /* read rest of packet, but no more. Cap to buffer size */
  415. struct SingleRequest *k = &data->req;
  416. size_t rest = mq->npacket;
  417. if(rest > (size_t)data->set.buffer_size)
  418. rest = (size_t)data->set.buffer_size;
  419. result = Curl_read(conn, sockfd, (char *)pkt, rest, &nread);
  420. if(result) {
  421. if(CURLE_AGAIN == result) {
  422. infof(data, "EEEE AAAAGAIN\n");
  423. }
  424. goto end;
  425. }
  426. if(!nread) {
  427. infof(data, "server disconnected\n");
  428. result = CURLE_PARTIAL_FILE;
  429. goto end;
  430. }
  431. Curl_debug(data, CURLINFO_DATA_IN, (char *)pkt, (size_t)nread);
  432. mq->npacket -= nread;
  433. k->bytecount += nread;
  434. Curl_pgrsSetDownloadCounter(data, k->bytecount);
  435. /* if QoS is set, message contains packet id */
  436. result = Curl_client_write(conn, CLIENTWRITE_BODY, (char *)pkt, nread);
  437. if(result)
  438. goto end;
  439. if(!mq->npacket)
  440. /* no more PUBLISH payload, back to subscribe wait state */
  441. mqstate(conn, MQTT_FIRST, MQTT_PUBWAIT);
  442. break;
  443. }
  444. default:
  445. DEBUGASSERT(NULL); /* illegal state */
  446. result = CURLE_WEIRD_SERVER_REPLY;
  447. goto end;
  448. }
  449. end:
  450. return result;
  451. }
  452. static CURLcode mqtt_do(struct connectdata *conn, bool *done)
  453. {
  454. CURLcode result = CURLE_OK;
  455. struct Curl_easy *data = conn->data;
  456. *done = FALSE; /* unconditionally */
  457. result = mqtt_connect(conn);
  458. if(result) {
  459. failf(data, "Error %d sending MQTT CONN request", result);
  460. return result;
  461. }
  462. mqstate(conn, MQTT_FIRST, MQTT_CONNACK);
  463. return CURLE_OK;
  464. }
  465. static CURLcode mqtt_doing(struct connectdata *conn, bool *done)
  466. {
  467. CURLcode result = CURLE_OK;
  468. struct mqtt_conn *mqtt = &conn->proto.mqtt;
  469. struct Curl_easy *data = conn->data;
  470. struct MQTT *mq = data->req.p.mqtt;
  471. ssize_t nread;
  472. curl_socket_t sockfd = conn->sock[FIRSTSOCKET];
  473. unsigned char *pkt = (unsigned char *)data->state.buffer;
  474. unsigned char byte;
  475. *done = FALSE;
  476. if(mq->nsend) {
  477. /* send the remainder of an outgoing packet */
  478. char *ptr = mq->sendleftovers;
  479. result = mqtt_send(conn, mq->sendleftovers, mq->nsend);
  480. free(ptr);
  481. if(result)
  482. return result;
  483. }
  484. infof(data, "mqtt_doing: state [%d]\n", (int) mqtt->state);
  485. switch(mqtt->state) {
  486. case MQTT_FIRST:
  487. /* Read the initial byte only */
  488. result = Curl_read(conn, sockfd, (char *)&mq->firstbyte, 1, &nread);
  489. if(!nread)
  490. break;
  491. Curl_debug(data, CURLINFO_HEADER_IN, (char *)&mq->firstbyte, 1);
  492. /* remember the first byte */
  493. mq->npacket = 0;
  494. mqstate(conn, MQTT_REMAINING_LENGTH, MQTT_NOSTATE);
  495. /* FALLTHROUGH */
  496. case MQTT_REMAINING_LENGTH:
  497. do {
  498. result = Curl_read(conn, sockfd, (char *)&byte, 1, &nread);
  499. if(!nread)
  500. break;
  501. Curl_debug(data, CURLINFO_HEADER_IN, (char *)&byte, 1);
  502. pkt[mq->npacket++] = byte;
  503. } while((byte & 0x80) && (mq->npacket < 4));
  504. if(result)
  505. break;
  506. mq->remaining_length = mqtt_decode_len(&pkt[0], mq->npacket, NULL);
  507. mq->npacket = 0;
  508. if(mq->remaining_length) {
  509. mqstate(conn, mqtt->nextstate, MQTT_NOSTATE);
  510. break;
  511. }
  512. mqstate(conn, MQTT_FIRST, MQTT_FIRST);
  513. if(mq->firstbyte == MQTT_MSG_DISCONNECT) {
  514. infof(data, "Got DISCONNECT\n");
  515. *done = TRUE;
  516. }
  517. break;
  518. case MQTT_CONNACK:
  519. result = mqtt_verify_connack(conn);
  520. if(result)
  521. break;
  522. if(conn->data->state.httpreq == HTTPREQ_POST) {
  523. result = mqtt_publish(conn);
  524. if(!result) {
  525. result = mqtt_disconnect(conn);
  526. *done = TRUE;
  527. }
  528. mqtt->nextstate = MQTT_FIRST;
  529. }
  530. else {
  531. result = mqtt_subscribe(conn);
  532. if(!result) {
  533. mqstate(conn, MQTT_FIRST, MQTT_SUBACK);
  534. }
  535. }
  536. break;
  537. case MQTT_SUBACK:
  538. case MQTT_PUBWAIT:
  539. case MQTT_PUB_REMAIN:
  540. result = mqtt_read_publish(conn, done);
  541. break;
  542. default:
  543. failf(conn->data, "State not handled yet");
  544. *done = TRUE;
  545. break;
  546. }
  547. if(result == CURLE_AGAIN)
  548. result = CURLE_OK;
  549. return result;
  550. }
  551. #endif /* CURL_DISABLE_MQTT */