version 1.3.12.3, 2022/09/15 15:04:44
|
version 1.3.12.4, 2022/09/16 04:14:03
|
Line 54 SUCH DAMAGE.
|
Line 54 SUCH DAMAGE.
|
* return: NULL error or allocated SUBSCRIBE message |
* return: NULL error or allocated SUBSCRIBE message |
*/ |
*/ |
mqtt_msg_t * |
mqtt_msg_t * |
mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, u_short msgID) | mqtt_msgSUBSCRIBE(mqtt_subscr_t * __restrict Topics, u_short msgID) |
{ |
{ |
int len, siz; |
int len, siz; |
u_int n, *l; |
u_int n, *l; |
Line 65 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
Line 65 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
void *data; |
void *data; |
mqtt_msg_t *msg = NULL; |
mqtt_msg_t *msg = NULL; |
|
|
if (!Topics || !*Topics) | if (!Topics) |
return NULL; |
return NULL; |
if (!msgID) { |
if (!msgID) { |
mqtt_SetErr(EINVAL, "Invalid MessageID parameter must be >0"); |
mqtt_SetErr(EINVAL, "Invalid MessageID parameter must be >0"); |
Line 74 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
Line 74 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
|
|
/* calculate message size */ |
/* calculate message size */ |
len = sizeof(mqtt_len_t); /* msgid */ |
len = sizeof(mqtt_len_t); /* msgid */ |
for (t = *Topics; t && t->sub_topic.msg_base; t++) /* subscribes & qos */ | for (t = Topics; t && t->sub_topic.msg_base; t++) /* subscribes & qos */ |
len += sizeof(mqtt_len_t) + t->sub_topic.msg_len + 1; |
len += sizeof(mqtt_len_t) + t->sub_topic.msg_len + 1; |
|
|
/* calculate header size */ |
/* calculate header size */ |
Line 102 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
Line 102 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
data += sizeof(mqtt_len_t); |
data += sizeof(mqtt_len_t); |
|
|
/* payload with subscriptions */ |
/* payload with subscriptions */ |
for (t = *Topics; t && t->sub_topic.msg_base; t++) { | for (t = Topics; t && t->sub_topic.msg_base; t++) { |
topic = (mqtthdr_var_t*) data; |
topic = (mqtthdr_var_t*) data; |
topic->var_sb.val = htons(t->sub_topic.msg_len); |
topic->var_sb.val = htons(t->sub_topic.msg_len); |
memcpy(topic->var_data, t->sub_topic.msg_base, ntohs(topic->var_sb.val)); |
memcpy(topic->var_data, t->sub_topic.msg_base, ntohs(topic->var_sb.val)); |
Line 122 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
Line 122 mqtt_msgSUBSCRIBE(mqtt_subscr_t ** __restrict Topics,
|
* return: NULL error or allocated SUBACK message |
* return: NULL error or allocated SUBACK message |
*/ |
*/ |
mqtt_msg_t * |
mqtt_msg_t * |
mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_short msgID) | mqtt_msgSUBACK(mqtt_subscr_t * __restrict Topics, u_short msgID) |
{ |
{ |
int siz = 0; |
int siz = 0; |
struct mqtthdr *hdr; |
struct mqtthdr *hdr; |
Line 131 mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s
|
Line 131 mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s
|
u_char *qos; |
u_char *qos; |
mqtt_msg_t *msg = NULL; |
mqtt_msg_t *msg = NULL; |
|
|
if (!Topics || !*Topics) | if (!Topics) |
return NULL; |
return NULL; |
|
|
if (!(msg = mqtt_msgAlloc(MQTTMSG_MAX))) |
if (!(msg = mqtt_msgAlloc(MQTTMSG_MAX))) |
Line 147 mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s
|
Line 147 mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s
|
v->val = htons(msgID); |
v->val = htons(msgID); |
|
|
/* QoS payload from subscriptions */ |
/* QoS payload from subscriptions */ |
for (t = *Topics; t && t->sub_topic.msg_base; t++, siz++) { | for (t = Topics; t && t->sub_topic.msg_base; t++, siz++) { |
qos = (msg->msg_base + siz); |
qos = (msg->msg_base + siz); |
*qos = t->sub_qos; |
*qos = t->sub_qos; |
} |
} |
Line 169 mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s
|
Line 169 mqtt_msgSUBACK(mqtt_subscr_t ** __restrict Topics, u_s
|
* return: NULL error or allocated UNSUBSCRIBE message |
* return: NULL error or allocated UNSUBSCRIBE message |
*/ |
*/ |
mqtt_msg_t * |
mqtt_msg_t * |
mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics, u_short msgID, | mqtt_msgUNSUBSCRIBE(mqtt_subscr_t * __restrict Topics, u_short msgID, |
u_char Dup, u_char QOS) |
u_char Dup, u_char QOS) |
{ |
{ |
int len, siz = 0; |
int len, siz = 0; |
Line 181 mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics
|
Line 181 mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics
|
void *data; |
void *data; |
mqtt_msg_t *msg = NULL; |
mqtt_msg_t *msg = NULL; |
|
|
if (!Topics || !*Topics) | if (!Topics) |
return NULL; |
return NULL; |
if (QOS > MQTT_QOS_EXACTLY) { |
if (QOS > MQTT_QOS_EXACTLY) { |
mqtt_SetErr(EINVAL, "Invalid QoS parameter"); |
mqtt_SetErr(EINVAL, "Invalid QoS parameter"); |
Line 194 mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics
|
Line 194 mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics
|
|
|
/* calculate message size */ |
/* calculate message size */ |
len = sizeof(mqtt_len_t); /* msgid */ |
len = sizeof(mqtt_len_t); /* msgid */ |
for (t = *Topics; t && t->sub_topic.msg_base; t++) /* subscribes */ | for (t = Topics; t && t->sub_topic.msg_base; t++) /* subscribes */ |
len += sizeof(mqtt_len_t) + t->sub_topic.msg_len; |
len += sizeof(mqtt_len_t) + t->sub_topic.msg_len; |
|
|
/* calculate header size */ |
/* calculate header size */ |
Line 224 mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics
|
Line 224 mqtt_msgUNSUBSCRIBE(mqtt_subscr_t ** __restrict Topics
|
data += sizeof(mqtt_len_t); |
data += sizeof(mqtt_len_t); |
|
|
/* payload with subscriptions */ |
/* payload with subscriptions */ |
for (t = *Topics; t && t->sub_topic.msg_base; t++) { | for (t = Topics; t && t->sub_topic.msg_base; t++) { |
topic = (mqtthdr_var_t*) data; |
topic = (mqtthdr_var_t*) data; |
topic->var_sb.val = htons(t->sub_topic.msg_len); |
topic->var_sb.val = htons(t->sub_topic.msg_len); |
memcpy(topic->var_data, t->sub_topic.msg_base, ntohs(topic->var_sb.val)); |
memcpy(topic->var_data, t->sub_topic.msg_base, ntohs(topic->var_sb.val)); |