version 1.1.1.1, 2012/01/26 13:07:33
|
version 1.1.1.1.2.1, 2012/04/07 20:56:49
|
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 | Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 |
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 46 SUCH DAMAGE.
|
Line 46 SUCH DAMAGE.
|
#include "global.h" |
#include "global.h" |
|
|
|
|
/* ------------------------------------------------------------------- */ |
|
|
|
/* |
/* |
* mqtt_msgPUBLISH() Create PUBLISH message |
* mqtt_msgPUBLISH() Create PUBLISH message |
* |
* |
Line 74 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
Line 72 mqtt_msgPUBLISH(mqtt_msg_t * __restrict buf, const cha
|
if (!buf || !csTopic) |
if (!buf || !csTopic) |
return -1; |
return -1; |
if (QOS > MQTT_QOS_EXACTLY) { |
if (QOS > MQTT_QOS_EXACTLY) { |
mqtt_SetErr(EINVAL, "Error:: invalid QoS parameter"); | mqtt_SetErr(EINVAL, "Invalid QoS parameter"); |
return -1; |
return -1; |
} |
} |
if (!msgID && QOS != MQTT_QOS_ONCE) { |
if (!msgID && QOS != MQTT_QOS_ONCE) { |
mqtt_SetErr(EINVAL, "Error:: invalid MessageID parameter must be >0"); | mqtt_SetErr(EINVAL, "Invalid MessageID parameter must be >0"); |
return -1; |
return -1; |
} |
} |
|
|
Line 236 mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _
|
Line 234 mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _
|
/* topic */ |
/* topic */ |
len -= MQTTHDR_VAR_SIZEOF(var); |
len -= MQTTHDR_VAR_SIZEOF(var); |
if (len < 0) { |
if (len < 0) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; |
return NULL; |
} else { |
} else { |
memset(psTopic, 0, topicLen--); |
memset(psTopic, 0, topicLen--); |
Line 248 mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _
|
Line 246 mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _
|
|
|
len -= sizeof(mqtt_len_t); |
len -= sizeof(mqtt_len_t); |
if (len < 0) { |
if (len < 0) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; |
return NULL; |
} else { |
} else { |
*msgID = ntohs(v->val); |
*msgID = ntohs(v->val); |
Line 257 mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _
|
Line 255 mqtt_readPUBLISH(mqtt_msg_t * __restrict buf, char * _
|
|
|
/* data */ |
/* data */ |
if (len < 0) { |
if (len < 0) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; |
return NULL; |
} else { |
} else { |
if (!*datLen) { |
if (!*datLen) { |
Line 295 mqtt_readPUBACK(mqtt_msg_t * __restrict buf)
|
Line 293 mqtt_readPUBACK(mqtt_msg_t * __restrict buf)
|
if (!hdr) |
if (!hdr) |
return (u_short) -1; |
return (u_short) -1; |
if (len < sizeof(mqtt_len_t)) { |
if (len < sizeof(mqtt_len_t)) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return (u_short) -1; |
return (u_short) -1; |
} else { |
} else { |
pos = buf->msg_base + ret + 1; |
pos = buf->msg_base + ret + 1; |
Line 323 mqtt_readPUBREC(mqtt_msg_t * __restrict buf)
|
Line 321 mqtt_readPUBREC(mqtt_msg_t * __restrict buf)
|
if (!hdr) |
if (!hdr) |
return (u_short) -1; |
return (u_short) -1; |
if (len < sizeof(mqtt_len_t)) { |
if (len < sizeof(mqtt_len_t)) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return (u_short) -1; |
return (u_short) -1; |
} else { |
} else { |
pos = buf->msg_base + ret + 1; |
pos = buf->msg_base + ret + 1; |
Line 351 mqtt_readPUBREL(mqtt_msg_t * __restrict buf)
|
Line 349 mqtt_readPUBREL(mqtt_msg_t * __restrict buf)
|
if (!hdr) |
if (!hdr) |
return (u_short) -1; |
return (u_short) -1; |
if (len < sizeof(mqtt_len_t)) { |
if (len < sizeof(mqtt_len_t)) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return (u_short) -1; |
return (u_short) -1; |
} else { |
} else { |
pos = buf->msg_base + ret + 1; |
pos = buf->msg_base + ret + 1; |
Line 379 mqtt_readPUBCOMP(mqtt_msg_t * __restrict buf)
|
Line 377 mqtt_readPUBCOMP(mqtt_msg_t * __restrict buf)
|
if (!hdr) |
if (!hdr) |
return (u_short) -1; |
return (u_short) -1; |
if (len < sizeof(mqtt_len_t)) { |
if (len < sizeof(mqtt_len_t)) { |
mqtt_SetErr(EINVAL, "Error:: short message length %d", len); | mqtt_SetErr(EINVAL, "Short message length %d", len); |
return (u_short) -1; |
return (u_short) -1; |
} else { |
} else { |
pos = buf->msg_base + ret + 1; |
pos = buf->msg_base + ret + 1; |