Lines Matching full:buf
33 * @param buf
36 static ssize_t decode_payload_length(struct net_buf_simple *buf) in decode_payload_length() argument
40 size_t buflen = buf->len; in decode_payload_length()
51 length = net_buf_simple_pull_u8(buf); in decode_payload_length()
53 length = net_buf_simple_pull_be16(buf); in decode_payload_length()
71 static void decode_flags(struct net_buf_simple *buf, struct mqtt_sn_flags *flags) in decode_flags() argument
73 uint8_t b = net_buf_simple_pull_u8(buf); in decode_flags()
86 static void decode_data(struct net_buf_simple *buf, struct mqtt_sn_data *dest) in decode_data() argument
88 dest->size = buf->len; in decode_data()
89 dest->data = net_buf_simple_pull_mem(buf, buf->len); in decode_data()
92 static int decode_empty_message(struct net_buf_simple *buf) in decode_empty_message() argument
94 if (buf->len) { in decode_empty_message()
102 static int decode_msg_advertise(struct net_buf_simple *buf, struct mqtt_sn_param_advertise *params) in decode_msg_advertise() argument
104 if (buf->len != 3) { in decode_msg_advertise()
108 params->gw_id = net_buf_simple_pull_u8(buf); in decode_msg_advertise()
109 params->duration = net_buf_simple_pull_be16(buf); in decode_msg_advertise()
114 static int decode_msg_searchgw(struct net_buf_simple *buf, struct mqtt_sn_param_searchgw *params) in decode_msg_searchgw() argument
116 if (buf->len != 1) { in decode_msg_searchgw()
120 params->radius = net_buf_simple_pull_u8(buf); in decode_msg_searchgw()
125 static int decode_msg_gwinfo(struct net_buf_simple *buf, struct mqtt_sn_param_gwinfo *params) in decode_msg_gwinfo() argument
127 if (buf->len < 1) { in decode_msg_gwinfo()
131 params->gw_id = net_buf_simple_pull_u8(buf); in decode_msg_gwinfo()
133 if (buf->len) { in decode_msg_gwinfo()
134 decode_data(buf, ¶ms->gw_add); in decode_msg_gwinfo()
142 static int decode_msg_connack(struct net_buf_simple *buf, struct mqtt_sn_param_connack *params) in decode_msg_connack() argument
144 if (buf->len != 1) { in decode_msg_connack()
148 params->ret_code = net_buf_simple_pull_u8(buf); in decode_msg_connack()
153 static int decode_msg_willtopicreq(struct net_buf_simple *buf) in decode_msg_willtopicreq() argument
155 return decode_empty_message(buf); in decode_msg_willtopicreq()
158 static int decode_msg_willmsgreq(struct net_buf_simple *buf) in decode_msg_willmsgreq() argument
160 return decode_empty_message(buf); in decode_msg_willmsgreq()
163 static int decode_msg_register(struct net_buf_simple *buf, struct mqtt_sn_param_register *params) in decode_msg_register() argument
165 if (buf->len < 5) { in decode_msg_register()
169 params->topic_id = net_buf_simple_pull_be16(buf); in decode_msg_register()
170 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_register()
171 decode_data(buf, ¶ms->topic); in decode_msg_register()
176 static int decode_msg_regack(struct net_buf_simple *buf, struct mqtt_sn_param_regack *params) in decode_msg_regack() argument
178 if (buf->len != 5) { in decode_msg_regack()
182 params->topic_id = net_buf_simple_pull_be16(buf); in decode_msg_regack()
183 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_regack()
184 params->ret_code = net_buf_simple_pull_u8(buf); in decode_msg_regack()
189 static int decode_msg_publish(struct net_buf_simple *buf, struct mqtt_sn_param_publish *params) in decode_msg_publish() argument
193 if (buf->len < 6) { in decode_msg_publish()
197 decode_flags(buf, &flags); in decode_msg_publish()
202 params->topic_id = net_buf_simple_pull_be16(buf); in decode_msg_publish()
203 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_publish()
204 decode_data(buf, ¶ms->data); in decode_msg_publish()
209 static int decode_msg_puback(struct net_buf_simple *buf, struct mqtt_sn_param_puback *params) in decode_msg_puback() argument
211 if (buf->len != 5) { in decode_msg_puback()
215 params->topic_id = net_buf_simple_pull_be16(buf); in decode_msg_puback()
216 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_puback()
217 params->ret_code = net_buf_simple_pull_u8(buf); in decode_msg_puback()
222 static int decode_msg_pubrec(struct net_buf_simple *buf, struct mqtt_sn_param_pubrec *params) in decode_msg_pubrec() argument
224 if (buf->len != 2) { in decode_msg_pubrec()
228 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_pubrec()
233 static int decode_msg_pubrel(struct net_buf_simple *buf, struct mqtt_sn_param_pubrel *params) in decode_msg_pubrel() argument
235 if (buf->len != 2) { in decode_msg_pubrel()
239 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_pubrel()
244 static int decode_msg_pubcomp(struct net_buf_simple *buf, struct mqtt_sn_param_pubcomp *params) in decode_msg_pubcomp() argument
246 if (buf->len != 2) { in decode_msg_pubcomp()
250 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_pubcomp()
255 static int decode_msg_suback(struct net_buf_simple *buf, struct mqtt_sn_param_suback *params) in decode_msg_suback() argument
259 if (buf->len != 6) { in decode_msg_suback()
263 decode_flags(buf, &flags); in decode_msg_suback()
267 params->topic_id = net_buf_simple_pull_be16(buf); in decode_msg_suback()
268 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_suback()
269 params->ret_code = net_buf_simple_pull_u8(buf); in decode_msg_suback()
274 static int decode_msg_unsuback(struct net_buf_simple *buf, struct mqtt_sn_param_unsuback *params) in decode_msg_unsuback() argument
276 if (buf->len != 2) { in decode_msg_unsuback()
280 params->msg_id = net_buf_simple_pull_be16(buf); in decode_msg_unsuback()
285 static int decode_msg_pingreq(struct net_buf_simple *buf) in decode_msg_pingreq() argument
288 return decode_empty_message(buf); in decode_msg_pingreq()
291 static int decode_msg_pingresp(struct net_buf_simple *buf) in decode_msg_pingresp() argument
293 return decode_empty_message(buf); in decode_msg_pingresp()
296 static int decode_msg_disconnect(struct net_buf_simple *buf, in decode_msg_disconnect() argument
300 return decode_empty_message(buf); in decode_msg_disconnect()
303 static int decode_msg_willtopicresp(struct net_buf_simple *buf, in decode_msg_willtopicresp() argument
306 if (buf->len != 1) { in decode_msg_willtopicresp()
310 params->ret_code = net_buf_simple_pull_u8(buf); in decode_msg_willtopicresp()
315 static int decode_msg_willmsgresp(struct net_buf_simple *buf, in decode_msg_willmsgresp() argument
318 if (buf->len != 1) { in decode_msg_willmsgresp()
322 params->ret_code = net_buf_simple_pull_u8(buf); in decode_msg_willmsgresp()
327 int mqtt_sn_decode_msg(struct net_buf_simple *buf, struct mqtt_sn_param *params) in mqtt_sn_decode_msg() argument
331 if (!buf || !buf->len) { in mqtt_sn_decode_msg()
335 len = decode_payload_length(buf); in mqtt_sn_decode_msg()
341 params->type = (enum mqtt_sn_msg_type)net_buf_simple_pull_u8(buf); in mqtt_sn_decode_msg()
347 return decode_msg_advertise(buf, ¶ms->params.advertise); in mqtt_sn_decode_msg()
349 return decode_msg_searchgw(buf, ¶ms->params.searchgw); in mqtt_sn_decode_msg()
351 return decode_msg_gwinfo(buf, ¶ms->params.gwinfo); in mqtt_sn_decode_msg()
353 return decode_msg_connack(buf, ¶ms->params.connack); in mqtt_sn_decode_msg()
355 return decode_msg_willtopicreq(buf); in mqtt_sn_decode_msg()
357 return decode_msg_willmsgreq(buf); in mqtt_sn_decode_msg()
359 return decode_msg_register(buf, ¶ms->params.reg); in mqtt_sn_decode_msg()
361 return decode_msg_regack(buf, ¶ms->params.regack); in mqtt_sn_decode_msg()
363 return decode_msg_publish(buf, ¶ms->params.publish); in mqtt_sn_decode_msg()
365 return decode_msg_puback(buf, ¶ms->params.puback); in mqtt_sn_decode_msg()
367 return decode_msg_pubrec(buf, ¶ms->params.pubrec); in mqtt_sn_decode_msg()
369 return decode_msg_pubrel(buf, ¶ms->params.pubrel); in mqtt_sn_decode_msg()
371 return decode_msg_pubcomp(buf, ¶ms->params.pubcomp); in mqtt_sn_decode_msg()
373 return decode_msg_suback(buf, ¶ms->params.suback); in mqtt_sn_decode_msg()
375 return decode_msg_unsuback(buf, ¶ms->params.unsuback); in mqtt_sn_decode_msg()
377 return decode_msg_pingreq(buf); in mqtt_sn_decode_msg()
379 return decode_msg_pingresp(buf); in mqtt_sn_decode_msg()
381 return decode_msg_disconnect(buf, ¶ms->params.disconnect); in mqtt_sn_decode_msg()
383 return decode_msg_willtopicresp(buf, ¶ms->params.willtopicresp); in mqtt_sn_decode_msg()
385 return decode_msg_willmsgresp(buf, ¶ms->params.willmsgresp); in mqtt_sn_decode_msg()