version 1.1.1.1.2.1, 2012/04/07 20:54:57
|
version 1.1.1.1.2.2, 2012/04/26 11:49:12
|
Line 270 mqtt_msgUNSUBACK(mqtt_msg_t * __restrict buf, u_short
|
Line 270 mqtt_msgUNSUBACK(mqtt_msg_t * __restrict buf, u_short
|
* @buf = Message buffer |
* @buf = Message buffer |
* @msgID = MessageID |
* @msgID = MessageID |
* @subscr = Subscriptions, must be free after use with mqtt_subFree() |
* @subscr = Subscriptions, must be free after use with mqtt_subFree() |
* return: NULL error or !=NULL MQTT fixed header | * return: -1 error or >-1 elements into subscr |
*/ |
*/ |
struct mqtthdr * | int |
mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_short *msgID, mqtt_subscr_t **subscr) |
mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_short *msgID, mqtt_subscr_t **subscr) |
{ |
{ |
register int i; |
register int i; |
Line 284 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
Line 284 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
caddr_t pos; |
caddr_t pos; |
|
|
if (!buf || !msgID || !subscr) |
if (!buf || !msgID || !subscr) |
return NULL; | return -1; |
|
|
hdr = _mqtt_readHEADER(buf, MQTT_TYPE_SUBSCRIBE, &ret, &len); |
hdr = _mqtt_readHEADER(buf, MQTT_TYPE_SUBSCRIBE, &ret, &len); |
if (!hdr) |
if (!hdr) |
return NULL; | return -1; |
pos = buf->msg_base + ret + 1; |
pos = buf->msg_base + ret + 1; |
v = (mqtt_len_t*) pos; |
v = (mqtt_len_t*) pos; |
|
|
Line 296 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
Line 296 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
len -= sizeof(mqtt_len_t); |
len -= sizeof(mqtt_len_t); |
if (len < 0) { |
if (len < 0) { |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; | return -1; |
} else { |
} else { |
*msgID = ntohs(v->val); |
*msgID = ntohs(v->val); |
pos += sizeof(mqtt_len_t); |
pos += sizeof(mqtt_len_t); |
Line 304 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
Line 304 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
|
|
subs = mqtt_subAlloc(0); |
subs = mqtt_subAlloc(0); |
if (!subs) |
if (!subs) |
return NULL; | return -1; |
else |
else |
*subscr = subs; |
*subscr = subs; |
|
|
Line 315 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
Line 315 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
if (len < 0) { |
if (len < 0) { |
mqtt_subFree(subscr); |
mqtt_subFree(subscr); |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; | return -1; |
} |
} |
subs = mqtt_subRealloc(subs, i + 1); |
subs = mqtt_subRealloc(subs, i + 1); |
if (!subs) { |
if (!subs) { |
mqtt_subFree(subscr); |
mqtt_subFree(subscr); |
return NULL; | return -1; |
} else |
} else |
*subscr = subs; |
*subscr = subs; |
|
|
Line 330 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
Line 330 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
if (!subs[i].sub_topic.msg_base) { |
if (!subs[i].sub_topic.msg_base) { |
LOGERR; |
LOGERR; |
mqtt_subFree(subscr); |
mqtt_subFree(subscr); |
return NULL; | return -1; |
} else |
} else |
memcpy(subs[i].sub_topic.msg_base, var->var_data, subs[i].sub_topic.msg_len); |
memcpy(subs[i].sub_topic.msg_base, var->var_data, subs[i].sub_topic.msg_len); |
pos += MQTTHDR_VAR_SIZEOF(var); |
pos += MQTTHDR_VAR_SIZEOF(var); |
Line 339 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
Line 339 mqtt_readSUBSCRIBE(mqtt_msg_t * __restrict buf, u_shor
|
pos++; |
pos++; |
} |
} |
|
|
return hdr; | return i; |
} |
} |
|
|
/* |
/* |
Line 394 mqtt_readSUBACK(mqtt_msg_t * __restrict buf, u_short *
|
Line 394 mqtt_readSUBACK(mqtt_msg_t * __restrict buf, u_short *
|
* @buf = Message buffer |
* @buf = Message buffer |
* @msgID = MessageID |
* @msgID = MessageID |
* @subscr = Subscriptions, must be free after use with mqtt_subFree() |
* @subscr = Subscriptions, must be free after use with mqtt_subFree() |
* return: NULL error or !=NULL MQTT fixed header | * return: -1 error or >-1 elements into subscr |
*/ |
*/ |
struct mqtthdr * | int |
mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_short *msgID, mqtt_subscr_t **subscr) |
mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_short *msgID, mqtt_subscr_t **subscr) |
{ |
{ |
register int i; |
register int i; |
Line 408 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
Line 408 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
caddr_t pos; |
caddr_t pos; |
|
|
if (!buf || !msgID || !subscr) |
if (!buf || !msgID || !subscr) |
return NULL; | return -1; |
|
|
hdr = _mqtt_readHEADER(buf, MQTT_TYPE_UNSUBSCRIBE, &ret, &len); |
hdr = _mqtt_readHEADER(buf, MQTT_TYPE_UNSUBSCRIBE, &ret, &len); |
if (!hdr) |
if (!hdr) |
return NULL; | return -1; |
pos = buf->msg_base + ret + 1; |
pos = buf->msg_base + ret + 1; |
v = (mqtt_len_t*) pos; |
v = (mqtt_len_t*) pos; |
|
|
Line 420 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
Line 420 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
len -= sizeof(mqtt_len_t); |
len -= sizeof(mqtt_len_t); |
if (len < 0) { |
if (len < 0) { |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; | return -1; |
} else { |
} else { |
*msgID = ntohs(v->val); |
*msgID = ntohs(v->val); |
pos += sizeof(mqtt_len_t); |
pos += sizeof(mqtt_len_t); |
Line 428 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
Line 428 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
|
|
subs = mqtt_subAlloc(0); |
subs = mqtt_subAlloc(0); |
if (!subs) |
if (!subs) |
return NULL; | return -1; |
else |
else |
*subscr = subs; |
*subscr = subs; |
|
|
Line 439 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
Line 439 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
if (len < 0) { |
if (len < 0) { |
mqtt_subFree(subscr); |
mqtt_subFree(subscr); |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
mqtt_SetErr(EINVAL, "Short message length %d", len); |
return NULL; | return -1; |
} |
} |
subs = mqtt_subRealloc(subs, i + 1); |
subs = mqtt_subRealloc(subs, i + 1); |
if (!subs) { |
if (!subs) { |
mqtt_subFree(subscr); |
mqtt_subFree(subscr); |
return NULL; | return -1; |
} else |
} else |
*subscr = subs; |
*subscr = subs; |
|
|
Line 454 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
Line 454 mqtt_readUNSUBSCRIBE(mqtt_msg_t * __restrict buf, u_sh
|
if (!subs[i].sub_topic.msg_base) { |
if (!subs[i].sub_topic.msg_base) { |
LOGERR; |
LOGERR; |
mqtt_subFree(subscr); |
mqtt_subFree(subscr); |
return NULL; | return -1; |
} else |
} else |
memcpy(subs[i].sub_topic.msg_base, var->var_data, subs[i].sub_topic.msg_len); |
memcpy(subs[i].sub_topic.msg_base, var->var_data, subs[i].sub_topic.msg_len); |
pos += MQTTHDR_VAR_SIZEOF(var); |
pos += MQTTHDR_VAR_SIZEOF(var); |
} |
} |
|
|
return hdr; | return i; |
} |
} |
|
|
/* |
/* |