Annotation of libaitmqtt/inc/aitmqtt.h, revision 1.3.4.3
1.1 misho 1: /*************************************************************************
2: * (C) 2011 AITNET ltd - Sofia/Bulgaria - <misho@aitbg.com>
3: * by Michael Pounov <misho@openbsd-bg.org>
4: *
5: * $Author: misho $
1.3.4.3 ! misho 6: * $Id: aitmqtt.h,v 1.3.4.2 2022/09/12 21:52:57 misho Exp $
1.1 misho 7: *
8: **************************************************************************
9: The ELWIX and AITNET software is distributed under the following
10: terms:
11:
12: All of the documentation and software included in the ELWIX and AITNET
13: Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
14:
1.3.4.2 misho 15: Copyright 2004 - 2022
1.1 misho 16: by Michael Pounov <misho@elwix.org>. All rights reserved.
17:
18: Redistribution and use in source and binary forms, with or without
19: modification, are permitted provided that the following conditions
20: are met:
21: 1. Redistributions of source code must retain the above copyright
22: notice, this list of conditions and the following disclaimer.
23: 2. Redistributions in binary form must reproduce the above copyright
24: notice, this list of conditions and the following disclaimer in the
25: documentation and/or other materials provided with the distribution.
26: 3. All advertising materials mentioning features or use of this software
27: must display the following acknowledgement:
28: This product includes software developed by Michael Pounov <misho@elwix.org>
29: ELWIX - Embedded LightWeight unIX and its contributors.
30: 4. Neither the name of AITNET nor the names of its contributors
31: may be used to endorse or promote products derived from this software
32: without specific prior written permission.
33:
34: THIS SOFTWARE IS PROVIDED BY AITNET AND CONTRIBUTORS ``AS IS'' AND
35: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
36: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
37: ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
38: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
39: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
40: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
41: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
42: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
43: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44: SUCH DAMAGE.
45: */
46: #ifndef __AITMQTT_H
47: #define __AITMQTT_H
48:
49:
1.2 misho 50: #define MAX_CONNID 24
51: #define MAX_CRED 13
1.3.4.2 misho 52: #define MQTTMSG_MAX 65535
1.3.4.3 ! misho 53: #define MQTTMSG_BIN_MAX 65535
1.2 misho 54: #define MQTT_DATA_MAX 268435455
55:
56: #define MQTT_PROTO_VER 3
57: #define MQTT_KEEPALIVE 10
58: #define MQTT_DEFAULT_MSGID 0xDEBA
59:
1.1 misho 60: /* FIXED HEADER */
61:
62: struct mqtthdr {
63: union {
64: struct {
65: unsigned char retain:1,
66: qos:2,
67: dup:1,
68: type:4;
69: };
70: unsigned char val;
71: } mqtt_msg;
72: unsigned char mqtt_len[1]; /* may be grow to 4 bytes */
1.3.4.1 misho 73: } __attribute__((packed));
1.3.4.3 ! misho 74: #define MQTTHDR_MSGINIT(x) (assert((x)), (x)->mqtt_msg.val ^= (x)->mqtt_msg.val, *mqtt_len = 0)
1.2 misho 75: #define MQTTHDR_DATA_SIZEOF(x) (assert((x)), mqtt_decodeLen((x)->mqtt_len, NULL))
1.1 misho 76:
77: #define MQTT_TYPE_UNKNOWN 0 /* reserved */
1.3.4.3 ! misho 78: #define MQTT_TYPE_CONNECT 1 /* client request to connect to server (CLI) */
! 79: #define MQTT_TYPE_CONNACK 2 /* connect acknowledgment (SRV) */
1.1 misho 80: #define MQTT_TYPE_PUBLISH 3 /* publish message */
81: #define MQTT_TYPE_PUBACK 4 /* publish acknowledgment */
82: #define MQTT_TYPE_PUBREC 5 /* publish received (assured delivery part 1) */
83: #define MQTT_TYPE_PUBREL 6 /* publish release (assured delivery part 2) */
84: #define MQTT_TYPE_PUBCOMP 7 /* publish complete (assured delivery part 3) */
1.3.4.3 ! misho 85: #define MQTT_TYPE_SUBSCRIBE 8 /* client subscribe request (CLI) */
! 86: #define MQTT_TYPE_SUBACK 9 /* subscribe acknowledgment (SRV) */
! 87: #define MQTT_TYPE_UNSUBSCRIBE 10 /* client unsubscribe request (CLI) */
! 88: #define MQTT_TYPE_UNSUBACK 11 /* unsubscribe acknowledgment (SRV) */
! 89: #define MQTT_TYPE_PINGREQ 12 /* PING request (CLI) */
! 90: #define MQTT_TYPE_PINGRESP 13 /* PING response (SRV) */
1.1 misho 91: #define MQTT_TYPE_DISCONNECT 14 /* client is disconnecting */
1.3.4.2 misho 92: #define MQTT_TYPE_AUTH 15 /* authentication exchange */
1.3.4.3 ! misho 93:
! 94: #define MQTT_TYPE_MAX 15
1.1 misho 95:
96: #define MQTT_FLAG_DUP 1 /* This flag is set when the client or server attempts to re-deliver
97: a PUBLISH, PUBREL, SUBSCRIBE or UNSUBSCRIBE message.
98: This applies to messages where the value of QoS is greater than
99: zero (0), and an acknowledgment is required.
100: When the DUP bit is set, the variable header includes a Message ID.
101:
102: The recipient should treat this flag as a hint as to whether
103: the message may have been previously received.
104: It should not be relied on to detect duplicates. */
105:
106: #define MQTT_QOS_ONCE 0 /* At most once, Fire and Forget, <=1 */
107: #define MQTT_QOS_ACK 1 /* At least once, Acknowledged delivery, >=1 */
108: #define MQTT_QOS_EXACTLY 2 /* Exactly once, Assured delivery, =1 */
109: #define MQTT_QOS_RESERVED 3 /* reserved */
110:
1.2 misho 111: #define MQTT_QOS_DENY 0 /* Not granted QoS for SUBACK */
112: #define MQTT_QOS_PASS 2 /* Granted QoS for SUBACK */
113:
1.1 misho 114: #define MQTT_FLAG_RETAIN 1 /* This flag is only used on PUBLISH messages.
115:
116: When a client sends a PUBLISH to a server,
117: if the Retain flag is set (1),
118: the server should hold on to the message after it has been
119: delivered to the current subscribers.
120: When a new subscription is established on a topic,
121: the last retained message on that topic should be sent to
122: the subscriber with the Retain flag set.
123: If there is no retained message, nothing is sent
124: This is useful where publishers send messages on a
125: "report by exception" basis, where it might be some time between messages.
126: This allows new subscribers to instantly receive data with the retained,
127: or Last Known Good, value.
128:
129: When a server sends a PUBLISH to a client as a result of
130: a subscription that already existed when the original PUBLISH arrived,
131: the Retain flag should not be set, regardless of the Retain flag
132: of the original PUBLISH. This allows a client to distinguish messages
133: that are being received because they were retained and those
134: that are being received "live".
135:
136: Retained messages should be kept over restarts of the server.
137: A server may delete a retained message if it receives a message
138: with a zero-length payload and the Retain flag set on the same topic. */
139:
140: /* VARIABLE HEADERS */
141:
142: #define MQTT_RETCODE_ACCEPTED 0
143: #define MQTT_RETCODE_REFUSE_VER 1
144: #define MQTT_RETCODE_REFUSE_ID 2
145: #define MQTT_RETCODE_REFUSE_UNAVAIL 3
146: #define MQTT_RETCODE_REFUSE_USERPASS 4
147: #define MQTT_RETCODE_DENIED 5
148:
149:
150: /* MQTT Message buffer */
151:
152: typedef struct {
153: void *msg_base;
154: unsigned short msg_len;
155: } mqtt_msg_t;
156:
157: /* MQTT structures */
158:
159: typedef union {
160: struct {
161: unsigned short m:8,
162: l:8;
163: } sb;
164: unsigned short val;
165: } mqtt_len_t;
166:
167: typedef struct {
168: unsigned char sub_ret;
169: mqtt_msg_t sub_topic;
170: mqtt_msg_t sub_value;
171: } mqtt_subscr_t;
172:
173: typedef struct {
174: mqtt_len_t var_sb;
175: unsigned char var_data[0];
1.3.4.1 misho 176: } __attribute__((packed)) mqtthdr_var_t;
1.1 misho 177: #define MQTTHDR_VAR_SIZEOF(x) (assert((x)), sizeof(mqtt_len_t) + ntohs((x)->var_sb.val))
178:
179: typedef unsigned char mqtthdr_protover_t;
180:
181: typedef union {
182: struct {
183: unsigned char reserved:1,
184: clean_sess:1,
185: will_flg:1,
186: will_qos:2,
187: will_retain:1,
188: password:1,
189: username:1;
190: };
191: unsigned char flags;
1.3.4.1 misho 192: } __attribute__((packed)) mqtthdr_connflgs_t;
1.1 misho 193:
194: typedef struct {
195: unsigned char reserved;
196: unsigned char retcode;
1.3.4.1 misho 197: } __attribute__((packed)) mqtthdr_connack_t;
1.1 misho 198:
199:
200: // -------------------------------------------------------
201: // mqtt_GetErrno() Get error code of last operation
1.3 misho 202: int mqtt_GetErrno();
1.1 misho 203: // mqtt_GetError() Get error text of last operation
1.3 misho 204: const char *mqtt_GetError();
1.1 misho 205: // -------------------------------------------------------
206:
207:
208: /*
209: * mqtt_msgAlloc() Allocate memory for MQTT Message
210: *
211: * @len = >0 Allocate buffer with length
212: * return: NULL error or Message, after use must call mqtt_msgFree() with all!=0
213: */
1.3 misho 214: mqtt_msg_t *mqtt_msgAlloc(unsigned short len);
1.1 misho 215: /*
216: * mqtt_msgFree() Free MQTT message
217: *
218: * @msg = Message buffer
219: * @all = !=0 Destroy entire message, if MQTT Message allocated with mqtt_msgAlloc()
220: * return: none
221: */
1.3 misho 222: void mqtt_msgFree(mqtt_msg_t ** __restrict msg, int all);
1.1 misho 223: /*
224: * mqtt_msgRealloc() Reallocate MQTT message buffer
225: *
226: * @msg = MQTT message
227: * @len = new length
228: * return: -1 error or >-1 old buffer length
229: */
1.3 misho 230: int mqtt_msgRealloc(mqtt_msg_t * __restrict msg, unsigned short len);
1.2 misho 231: /*
232: * mqtt_msgDup() - Duplicate message buffer
233: *
234: * @msg = Message
235: * return: NULL error or !=NULL duplicated message, after use must call mqtt_msgFree() with all!=0
236: */
1.3 misho 237: mqtt_msg_t *mqtt_msgDup(mqtt_msg_t * __restrict msg);
1.2 misho 238:
239: /*
240: * mqtt_expandTopic() - Expanding topic to regular expression
241: *
242: * @csInput = Input topic
243: * @psRegEx = Output to regular expression
244: * @regexLen = Length of psRegEx
245: * @BOL = Begin of Line, if =0 not added
246: * @EOL = End of Line, if =0 not appended
247: * return: -1 error, 0 nothing expanded or >0 expanded bytes
248: */
249: int mqtt_expandTopic(const char *csInput, char * __restrict psRegEx, int regexLen,
250: unsigned char BOL, unsigned char EOL);
251: /*
252: * mqtt_sqlTopic() - Expanding topic to SQL search string
253: *
254: * @csInput = Input topic
255: * @psSQL = Output to SQL search string
256: * @sqlLen = Length of psSQL
257: * return: -1 error, 0 changed bytes
258: */
259: int mqtt_sqlTopic(const char *csInput, char * __restrict psSQL, int sqlLen);
1.1 misho 260:
261: /*
262: * mqtt_encodeLen() Encode number to MQTT length field
263: *
264: * @num = number for encode
265: * return: -1 error or >-1 length
266: */
1.3 misho 267: unsigned int mqtt_encodeLen(unsigned int num);
1.1 misho 268: /*
269: * mqtt_decodeLen() Decode length from MQTT packet
270: *
271: * @len = length from MQTT header
272: * @n = sizeof bytes, if !=NULL
273: * return: -1 error, >-1 length of message
274: */
1.3 misho 275: unsigned int mqtt_decodeLen(void * __restrict len, int * __restrict n);
1.1 misho 276: /*
277: * mqtt_sizeLen Return sizeof len field
278: *
279: * @len = length
280: * return: -1 error, >-1 sizeof len in bytes
281: */
1.3 misho 282: char mqtt_sizeLen(unsigned int len);
1.1 misho 283: /*
1.2 misho 284: * mqtt_pktLen() - Get total packet length
1.1 misho 285: *
1.2 misho 286: * @hdr = MQTT packet header
287: * return: packet length
288: */
1.3 misho 289: unsigned int mqtt_pktLen(struct mqtthdr * __restrict hdr);
1.2 misho 290: /*
291: * mqtt_str2subs Create MQTT subscribe variable from string(s)
292: *
293: * @csStr = null terminated string array
294: * @strnum = copy at most number of strings elements
1.1 misho 295: * @qoses = QoS elements applied to subscribe variable,
296: * count of elements must be equal with csStr elements
297: * return: NULL error or != subscribe variables array, must be free after use with mqtt_freeSub()
298: */
1.3 misho 299: mqtt_subscr_t *mqtt_str2subs(const char **csStr, unsigned short strnum,
1.2 misho 300: unsigned char *qoses);
1.1 misho 301: /*
302: * mqtt_subFree() Free array from subscribe variables
303: *
304: * @subs = Subscribe variables
305: * return: none
306: */
1.3 misho 307: void mqtt_subFree(mqtt_subscr_t ** __restrict subs);
1.1 misho 308: /*
309: * mqtt_subAlloc() Create array from subscribe variables
310: *
311: * @num = Number of elements
312: * return: NULL error or subscribe array, after use must call mqtt_subFree()
313: */
1.3 misho 314: mqtt_subscr_t *mqtt_subAlloc(unsigned short num);
1.1 misho 315: /*
316: * mqtt_subRealloc() Reallocate array from subscribe variables
317: *
318: * @subs = Subscribe array
319: * @num = Number of elements
320: * return: NULL error or subscribe array, after use must call mqtt_subFree()
321: */
1.3 misho 322: mqtt_subscr_t *mqtt_subRealloc(mqtt_subscr_t ** __restrict subs, unsigned short num);
1.2 misho 323: /*
324: * mqtt_subCopy() - Copy subscription structure to another one
325: *
326: * @dst = destination subscription
327: * @src = source subscription
328: * return: =NULL error or !=NULL successful copied a structure
329: */
1.3 misho 330: mqtt_subscr_t *mqtt_subCopy(mqtt_subscr_t * __restrict dst, mqtt_subscr_t * __restrict src);
1.1 misho 331:
332:
333: /*** SENDER FUNCTIONS ***/
334:
335: /*
336: * mqtt_msgCONNECT() Create CONNECT message
337: *
338: * @buf = Message buffer
339: * @csConnID = ConnectID
1.2 misho 340: * @kasec = Keep alive timeout, if =0 default timeout for MQTT
1.1 misho 341: * @csUser = Username if !=NULL
342: * @csPass = Password for Username, only if csUser is set
343: * @csWillTopic = Will Topic if !=NULL Will Flags set into message
344: * @csWillMessage = Will Message, may be NULL
345: * @ClrSess = Clear Session subscriptions after disconnect
346: * @WillQOS = Will QOS if csWillTopic is set
347: * @WillRetain = Will Retain Will Message if csWillTopic is set
348: * return: -1 error or >-1 message size for send
349: */
350: int mqtt_msgCONNECT(mqtt_msg_t * __restrict buf, const char *csConnID,
351: unsigned short kasec, const char *csUser, const char *csPass,
352: const char *csWillTopic, const char *csWillMessage,
353: unsigned char ClrSess, unsigned char WillQOS, unsigned char WillRetain);
354: /*
355: * mqtt_msgCONNACK() Create CONNACK message
356: *
357: * @buf = Message buffer
358: * @retcode = Return code
359: * return: -1 error or >-1 message size for send
360: */
361: int mqtt_msgCONNACK(mqtt_msg_t * __restrict buf, unsigned char retcode);
362: /*
363: * mqtt_msgDISCONNECT() Create DISCONNECT message
364: *
365: * @buf = Message buffer
366: * return: -1 error or >-1 message size for send
367: */
368: int mqtt_msgDISCONNECT(mqtt_msg_t * __restrict buf);
369: /*
370: * mqtt_msgPINGREQ() Create PINGREQ message
371: *
372: * @buf = Message buffer
373: * return: -1 error or >-1 message size for send
374: */
375: int mqtt_msgPINGREQ(mqtt_msg_t * __restrict buf);
376: /*
377: * mqtt_msgPINGRESP() Create PINGRESP message
378: *
379: * @buf = Message buffer
380: * return: -1 error or >-1 message size for send
381: */
382: int mqtt_msgPINGRESP(mqtt_msg_t * __restrict buf);
383:
384: /*
385: * mqtt_msgPUBLISH() Create PUBLISH message
386: *
387: * @buf = Message buffer
388: * @csTopic = Publish topic
389: * @msgID = MessageID >0, if QOS != MQTT_QOS_ONCE
390: * @Dup = Duplicate message
391: * @QOS = QoS
392: * @Retain = Retain message
393: * @pData = Publish data into topic
394: * @datlen = Publish data length
395: * return: -1 error or >-1 message size for send
396: */
397: int mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const char *csTopic,
398: unsigned short msgID, unsigned char Dup, unsigned char QOS,
399: unsigned char Retain, const void *pData, int datlen);
400: /*
401: * mqtt_msgPUBACK() Create PUBACK message
402: *
403: * @buf = Message buffer
404: * @msgID = MessageID
405: * return: -1 error or >-1 message size for send
406: */
1.3 misho 407: int mqtt_msgPUBACK(mqtt_msg_t * __restrict buf, unsigned short msgID);
1.1 misho 408: /*
409: * mqtt_msgPUBREC() Create PUBREC message
410: *
411: * @buf = Message buffer
412: * @msgID = MessageID
413: * return: -1 error or >-1 message size for send
414: */
1.3 misho 415: int mqtt_msgPUBREC(mqtt_msg_t * __restrict buf, unsigned short msgID);
1.1 misho 416: /*
417: * mqtt_msgPUBREL() Create PUBREL message
418: *
419: * @buf = Message buffer
420: * @msgID = MessageID
421: * return: -1 error or >-1 message size for send
422: */
1.3 misho 423: int mqtt_msgPUBREL(mqtt_msg_t * __restrict buf, unsigned short msgID);
1.1 misho 424: /*
425: * mqtt_msgPUBCOMP() Create PUBCOMP message
426: *
427: * @buf = Message buffer
428: * @msgID = MessageID
429: * return: -1 error or >-1 message size for send
430: */
1.3 misho 431: int mqtt_msgPUBCOMP(mqtt_msg_t * __restrict buf, unsigned short msgID);
1.1 misho 432:
433: /*
434: * mqtt_msgSUBSCRIBE() Create SUBSCRIBE message
435: *
436: * @buf = Message buffer
437: * @Topics = MQTT subscription topics
438: * @msgID = MessageID
439: * @Dup = Duplicate message
440: * @QOS = QoS
441: * return: -1 error or >-1 message size for send
442: */
443: int
444: mqtt_msgSUBSCRIBE(mqtt_msg_t * __restrict buf, mqtt_subscr_t * __restrict Topics,
445: unsigned short msgID, unsigned char Dup, unsigned char QOS);
446: /*
447: * mqtt_msgSUBACK() Create SUBACK message
448: *
449: * @buf = Message buffer
450: * @Topics = MQTT subscription topics
451: * @msgID = MessageID
452: * return: -1 error or >-1 message size for send
453: */
454: int mqtt_msgSUBACK(mqtt_msg_t * __restrict buf, mqtt_subscr_t * __restrict Topics,
455: unsigned short msgID);
456: /*
457: * mqtt_msgUNSUBSCRIBE() Create UNSUBSCRIBE message
458: *
459: * @buf = Message buffer
460: * @Topics = MQTT subscription topics
461: * @msgID = MessageID
462: * @Dup = Duplicate message
463: * @QOS = QoS
464: * return: -1 error or >-1 message size for send
465: */
466: int
467: mqtt_msgUNSUBSCRIBE(mqtt_msg_t * __restrict buf, mqtt_subscr_t * __restrict Topics,
468: unsigned short msgID, unsigned char Dup, unsigned char QOS);
469: /*
470: * mqtt_msgUNSUBACK() Create UNSUBACK message
471: *
472: * @buf = Message buffer
473: * @msgID = MessageID
474: * return: -1 error or >-1 message size for send
475: */
476: int mqtt_msgUNSUBACK(mqtt_msg_t * __restrict buf, unsigned short msgID);
477:
478:
479: /*** RECEIVER FUNCTIONS ***/
480:
481: /*
482: * mqtt_readCONNECT() Read elements from CONNECT message
483: *
484: * @buf = Message buffer
485: * @kasec = Keep Alive in seconds for current connection
486: * @psConnID = ConnectID
487: * @connLen = ConnectID length
488: * @psUser = Username if !=NULL
489: * @userLen = Username length
490: * @psPass = Password for Username, only if csUser is set
491: * @passLen = Password length
492: * @psWillTopic = Will Topic if !=NULL Will Flags set into message and must be free()
493: * @psWillMessage = Will Message, may be NULL if !NULL must be free() after use!
494: * return: .reserved == 1 is error or == 0 connection flags & msg ok
495: */
496: mqtthdr_connack_t mqtt_readCONNECT(mqtt_msg_t * __restrict buf, unsigned short *kasec,
497: char * __restrict psConnID, int connLen,
498: char * __restrict psUser, int userLen, char * __restrict psPass, int passLen,
499: char ** __restrict psWillTopic, char ** __restrict psWillMessage);
500: /*
501: * mqtt_readCONNACK() Read CONNACK message
502: *
503: * @buf = Message buffer
504: * return: -1 error or >-1 CONNECT message return code
505: */
506: unsigned char mqtt_readCONNACK(mqtt_msg_t * __restrict buf);
507: /*
508: * mqtt_readDISCONNECT() Read DISCONNECT message
509: *
510: * @buf = Message buffer
511: * return: -1 error, 0 ok, >0 undefined result
512: */
513: int mqtt_readDISCONNECT(mqtt_msg_t * __restrict buf);
514: /*
515: * mqtt_readPINGREQ() Read PINGREQ message
516: *
517: * @buf = Message buffer
518: * return: -1 error, 0 ok, >0 undefined result
519: */
520: int mqtt_readPINGREQ(mqtt_msg_t * __restrict buf);
521: /*
522: * mqtt_readPINGRESP() Read PINGRESP message
523: *
524: * @buf = Message buffer
525: * return: -1 error, 0 ok, >0 undefined result
526: */
527: int mqtt_readPINGRESP(mqtt_msg_t * __restrict buf);
528:
529: /*
530: * mqtt_readPUBLISH() Read PUBLISH message
531: *
532: * @buf = Message buffer
533: * @psTopic = Topic
534: * @topicLen = Topic length
535: * @msgID = MessageID
1.2 misho 536: * @pData = Data buffer, may be NULL
537: * return: -1 error or !=-1 allocated data buffer length
1.1 misho 538: */
1.2 misho 539: int mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * __restrict psTopic,
540: int topicLen, unsigned short *msgID, void ** __restrict pData);
1.1 misho 541: /*
542: * mqtt_readPUBACK() Read PUBACK message
543: *
544: * @buf = Message buffer
545: * return: -1 error or MessageID
546: */
1.2 misho 547: unsigned short mqtt_readPUBACK(mqtt_msg_t * __restrict buf);
1.1 misho 548: /*
549: * mqtt_readPUBREC() Read PUBREC message
550: *
551: * @buf = Message buffer
552: * return: -1 error or MessageID
553: */
1.2 misho 554: unsigned short mqtt_readPUBREC(mqtt_msg_t * __restrict buf);
1.1 misho 555: /*
556: * mqtt_readPUBREL() Read PUBREL message
557: *
558: * @buf = Message buffer
559: * return: -1 error or MessageID
560: */
1.2 misho 561: unsigned short mqtt_readPUBREL(mqtt_msg_t * __restrict buf);
1.1 misho 562: /*
563: * mqtt_readPUBCOMP() Read PUBCOMP message
564: *
565: * @buf = Message buffer
566: * return: -1 error or MessageID
567: */
1.2 misho 568: unsigned short mqtt_readPUBCOMP(mqtt_msg_t * __restrict buf);
1.1 misho 569:
570: /*
571: * mqtt_readSUBSCRIBE() Read SUBSCRIBE message
572: *
573: * @buf = Message buffer
574: * @msgID = MessageID
575: * @subscr = Subscriptions, must be free after use with mqtt_subFree()
1.2 misho 576: * return: -1 error or >-1 elements into subscr
1.1 misho 577: */
1.2 misho 578: int mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, unsigned short *msgID,
1.1 misho 579: mqtt_subscr_t **subscr);
580: /*
581: * mqtt_readSUBACK() Read SUBACK message
582: *
583: * @buf = Message buffer
584: * @msgID = MessageID
585: * @subqos = Subscribes QoS, must be free after use with free()
586: * return: -1 error or >-1 readed subscribes QoS elements
587: */
1.2 misho 588: int mqtt_readSUBACK(mqtt_msg_t * __restrict buf, unsigned short *msgID, unsigned char **subqos);
1.1 misho 589: /*
590: * mqtt_readUNSUBSCRIBE() Read UNSUBSCRIBE message
591: *
592: * @buf = Message buffer
593: * @msgID = MessageID
594: * @subscr = Subscriptions, must be free after use with mqtt_subFree()
1.2 misho 595: * return: -1 error or >-1 elements into subscr
1.1 misho 596: */
1.2 misho 597: int mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, unsigned short *msgID,
1.1 misho 598: mqtt_subscr_t **subscr);
599: /*
600: * mqtt_readUNSUBACK() Read UNSUBACK message
601: *
602: * @buf = Message buffer
603: * return: -1 error or MessageID
604: */
1.2 misho 605: unsigned short mqtt_readUNSUBACK(mqtt_msg_t * __restrict buf);
1.1 misho 606:
607:
608: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>