File:  [ELWIX - Embedded LightWeight unIX -] / libaitmqtt / inc / aitmqtt.h
Revision 1.1.1.1.2.11: download - view: text, annotated - select for diffs - revision graph
Fri Apr 27 08:12:30 2012 UTC (12 years, 2 months ago) by misho
Branches: mqtt1_1
Diff to: branchpoint 1.1.1.1: preferred, unified
rework mqtt_subRealloc() more useful and always zeroed last element

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>