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