version 1.2, 2012/06/20 15:02:24
|
version 1.4, 2013/05/30 09:18:33
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 64 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
Line 64 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
u_char Dup, u_char QOS, u_char Retain, const void *pData, int datlen) |
u_char Dup, u_char QOS, u_char Retain, const void *pData, int datlen) |
{ |
{ |
int len, siz; |
int len, siz; |
u_int n; | u_int n, *l; |
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
mqtthdr_var_t *topic; |
mqtthdr_var_t *topic; |
mqtt_len_t *mid; |
mqtt_len_t *mid; |
Line 104 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
Line 104 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
hdr->mqtt_msg.qos = QOS; |
hdr->mqtt_msg.qos = QOS; |
hdr->mqtt_msg.dup = Dup ? 1 : 0; |
hdr->mqtt_msg.dup = Dup ? 1 : 0; |
hdr->mqtt_msg.retain = Retain ? 1 : 0; |
hdr->mqtt_msg.retain = Retain ? 1 : 0; |
*(u_int*) hdr->mqtt_len = n; | l = (u_int*) hdr->mqtt_len; |
| *l = n; |
data += siz; |
data += siz; |
|
|
/* variable header */ |
/* variable header */ |
Line 127 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
Line 128 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
static int |
static int |
_mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd, u_short msgID) |
_mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd, u_short msgID) |
{ |
{ |
int siz = 0; | int siz = sizeof(struct mqtthdr); |
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
mqtt_len_t *v; |
mqtt_len_t *v; |
|
|
Line 136 _mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd,
|
Line 137 _mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd,
|
|
|
if (mqtt_msgRealloc(buf, sizeof(struct mqtthdr) + sizeof(mqtt_len_t)) == -1) |
if (mqtt_msgRealloc(buf, sizeof(struct mqtthdr) + sizeof(mqtt_len_t)) == -1) |
return -1; |
return -1; |
else { | else |
hdr = (struct mqtthdr *) (buf->msg_base + siz); | hdr = (struct mqtthdr *) buf->msg_base; |
siz += sizeof(struct mqtthdr); | |
v = (mqtt_len_t*) (buf->msg_base + siz); | |
siz += sizeof(mqtt_len_t); | |
} | |
|
|
/* fixed header */ |
/* fixed header */ |
MQTTHDR_MSGINIT(hdr); |
MQTTHDR_MSGINIT(hdr); |
Line 149 _mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd,
|
Line 146 _mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd,
|
*hdr->mqtt_len = sizeof(mqtt_len_t); |
*hdr->mqtt_len = sizeof(mqtt_len_t); |
|
|
/* MessageID */ |
/* MessageID */ |
|
v = (mqtt_len_t*) (buf->msg_base + siz); |
v->val = htons(msgID); |
v->val = htons(msgID); |
|
siz += sizeof(mqtt_len_t); |
|
|
return siz; |
return siz; |
} |
} |
Line 161 _mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd,
|
Line 160 _mqtt_msgPUB_(mqtt_msg_t * __restrict buf, u_char cmd,
|
* @msgID = MessageID |
* @msgID = MessageID |
* return: -1 error or >-1 message size for send |
* return: -1 error or >-1 message size for send |
*/ |
*/ |
inline int | int |
mqtt_msgPUBACK(mqtt_msg_t * __restrict buf, u_short msgID) |
mqtt_msgPUBACK(mqtt_msg_t * __restrict buf, u_short msgID) |
{ |
{ |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBACK, msgID); |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBACK, msgID); |
Line 174 mqtt_msgPUBACK(mqtt_msg_t * __restrict buf, u_short ms
|
Line 173 mqtt_msgPUBACK(mqtt_msg_t * __restrict buf, u_short ms
|
* @msgID = MessageID |
* @msgID = MessageID |
* return: -1 error or >-1 message size for send |
* return: -1 error or >-1 message size for send |
*/ |
*/ |
inline int | int |
mqtt_msgPUBREC(mqtt_msg_t * __restrict buf, u_short msgID) |
mqtt_msgPUBREC(mqtt_msg_t * __restrict buf, u_short msgID) |
{ |
{ |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBREC, msgID); |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBREC, msgID); |
Line 187 mqtt_msgPUBREC(mqtt_msg_t * __restrict buf, u_short ms
|
Line 186 mqtt_msgPUBREC(mqtt_msg_t * __restrict buf, u_short ms
|
* @msgID = MessageID |
* @msgID = MessageID |
* return: -1 error or >-1 message size for send |
* return: -1 error or >-1 message size for send |
*/ |
*/ |
inline int | int |
mqtt_msgPUBREL(mqtt_msg_t * __restrict buf, u_short msgID) |
mqtt_msgPUBREL(mqtt_msg_t * __restrict buf, u_short msgID) |
{ |
{ |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBREL, msgID); |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBREL, msgID); |
Line 200 mqtt_msgPUBREL(mqtt_msg_t * __restrict buf, u_short ms
|
Line 199 mqtt_msgPUBREL(mqtt_msg_t * __restrict buf, u_short ms
|
* @msgID = MessageID |
* @msgID = MessageID |
* return: -1 error or >-1 message size for send |
* return: -1 error or >-1 message size for send |
*/ |
*/ |
inline int | int |
mqtt_msgPUBCOMP(mqtt_msg_t * __restrict buf, u_short msgID) |
mqtt_msgPUBCOMP(mqtt_msg_t * __restrict buf, u_short msgID) |
{ |
{ |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBCOMP, msgID); |
return _mqtt_msgPUB_(buf, MQTT_TYPE_PUBCOMP, msgID); |