@@ -59,6 +59,7 @@ sn_coap_hdr_s *sn_coap_build_response(struct coap_s *handle, sn_coap_hdr_s *coap
59
59
60
60
coap_res_ptr = sn_coap_parser_alloc_message (handle );
61
61
if (!coap_res_ptr ) {
62
+ tr_error ("sn_coap_build_response - failed to allocate message!" );
62
63
return NULL ;
63
64
}
64
65
@@ -83,6 +84,7 @@ sn_coap_hdr_s *sn_coap_build_response(struct coap_s *handle, sn_coap_hdr_s *coap
83
84
coap_res_ptr -> token_len = coap_packet_ptr -> token_len ;
84
85
coap_res_ptr -> token_ptr = handle -> sn_coap_protocol_malloc (coap_res_ptr -> token_len );
85
86
if (!coap_res_ptr -> token_ptr ) {
87
+ tr_error ("sn_coap_build_response - failed to allocate token!" );
86
88
handle -> sn_coap_protocol_free (coap_res_ptr );
87
89
return NULL ;
88
90
}
@@ -98,7 +100,6 @@ int16_t sn_coap_builder(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_ms
98
100
99
101
int16_t sn_coap_builder_2 (uint8_t * dst_packet_data_ptr , sn_coap_hdr_s * src_coap_msg_ptr , uint16_t blockwise_payload_size )
100
102
{
101
- tr_debug ("sn_coap_builder_2" );
102
103
uint8_t * base_packet_data_ptr = NULL ;
103
104
104
105
/* * * * Check given pointers * * * */
@@ -108,8 +109,8 @@ int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_
108
109
109
110
/* Initialize given Packet data memory area with zero values */
110
111
uint16_t dst_byte_count_to_be_built = sn_coap_builder_calc_needed_packet_data_size_2 (src_coap_msg_ptr , blockwise_payload_size );
111
- tr_debug ("sn_coap_builder_2 - message len: [%d]" , dst_byte_count_to_be_built );
112
112
if (!dst_byte_count_to_be_built ) {
113
+ tr_error ("sn_coap_builder_2 - failed to allocate message!" );
113
114
return -1 ;
114
115
}
115
116
@@ -123,6 +124,7 @@ int16_t sn_coap_builder_2(uint8_t *dst_packet_data_ptr, sn_coap_hdr_s *src_coap_
123
124
/* * * * * * * * * * * * * * * * * * */
124
125
if (sn_coap_builder_header_build (& dst_packet_data_ptr , src_coap_msg_ptr ) != 0 ) {
125
126
/* Header building failed */
127
+ tr_error ("sn_coap_builder_2 - header building failed!" );
126
128
return -1 ;
127
129
}
128
130
@@ -149,7 +151,6 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size(sn_coap_hdr_s *src_coap_ms
149
151
uint16_t sn_coap_builder_calc_needed_packet_data_size_2 (sn_coap_hdr_s * src_coap_msg_ptr , uint16_t blockwise_payload_size )
150
152
{
151
153
(void )blockwise_payload_size ;
152
- tr_debug ("sn_coap_builder_calc_needed_packet_data_size_2" );
153
154
uint16_t returned_byte_count = 0 ;
154
155
155
156
if (!src_coap_msg_ptr ) {
@@ -168,6 +169,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
168
169
/* TOKEN - Length is 1-8 bytes */
169
170
if (src_coap_msg_ptr -> token_ptr != NULL ) {
170
171
if (src_coap_msg_ptr -> token_len > 8 || src_coap_msg_ptr -> token_len < 1 ) { /* Check that option is not longer than defined */
172
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - token too large!" );
171
173
return 0 ;
172
174
}
173
175
@@ -180,6 +182,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
180
182
if (repeatable_option_size ) {
181
183
returned_byte_count += repeatable_option_size ;
182
184
} else {
185
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - uri path size failed!" );
183
186
return 0 ;
184
187
}
185
188
}
@@ -188,6 +191,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
188
191
/* CONTENT FORMAT - An integer option, up to 2 bytes */
189
192
if (src_coap_msg_ptr -> content_format != COAP_CT_NONE ) {
190
193
if ((uint32_t ) src_coap_msg_ptr -> content_format > 0xffff ) {
194
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - content format too large!" );
191
195
return 0 ;
192
196
}
193
197
@@ -198,6 +202,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
198
202
/* ACCEPT - An integer option, up to 2 bytes */
199
203
if (src_coap_msg_ptr -> options_list_ptr -> accept != COAP_CT_NONE ) {
200
204
if ((uint32_t ) src_coap_msg_ptr -> options_list_ptr -> accept > 0xffff ) {
205
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - accept too large!" );
201
206
return 0 ;
202
207
}
203
208
@@ -222,6 +227,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
222
227
}
223
228
224
229
else {
230
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - proxy uri too large!" );
225
231
return 0 ;
226
232
}
227
233
@@ -235,6 +241,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
235
241
if (repeatable_option_size ) {
236
242
returned_byte_count += repeatable_option_size ;
237
243
} else {
244
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - etag too large!" );
238
245
return 0 ;
239
246
}
240
247
}
@@ -249,6 +256,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
249
256
}
250
257
251
258
else {
259
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - uri host too large!" );
252
260
return 0 ;
253
261
}
254
262
@@ -261,12 +269,14 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
261
269
if (repeatable_option_size ) {
262
270
returned_byte_count += repeatable_option_size ;
263
271
} else {
272
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - location path too large!" );
264
273
return 0 ;
265
274
}
266
275
}
267
276
/* URI PORT - An integer option, up to 2 bytes */
268
277
if (src_coap_msg_ptr -> options_list_ptr -> uri_port != COAP_OPTION_URI_PORT_NONE ) {
269
278
if ((uint32_t ) src_coap_msg_ptr -> options_list_ptr -> uri_port > 0xffff ) {
279
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - uri port too large!" );
270
280
return 0 ;
271
281
}
272
282
returned_byte_count += sn_coap_builder_options_build_add_uint_option (NULL , src_coap_msg_ptr -> options_list_ptr -> uri_port , COAP_OPTION_URI_PORT , & tempInt );
@@ -278,6 +288,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
278
288
if (repeatable_option_size ) {
279
289
returned_byte_count += repeatable_option_size ;
280
290
} else {
291
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - location query too large!" );
281
292
return 0 ;
282
293
}
283
294
}
@@ -295,13 +306,15 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
295
306
if (repeatable_option_size ) {
296
307
returned_byte_count += repeatable_option_size ;
297
308
} else {
309
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - observe too large!" );
298
310
return 0 ;
299
311
}
300
312
}
301
313
302
314
/* BLOCK 1 - An integer option, up to 3 bytes */
303
315
if (src_coap_msg_ptr -> options_list_ptr -> block1 != COAP_OPTION_BLOCK_NONE ) {
304
316
if ((uint32_t ) src_coap_msg_ptr -> options_list_ptr -> block1 > 0xffffff ) {
317
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - block1 too large!" );
305
318
return 0 ;
306
319
}
307
320
returned_byte_count += sn_coap_builder_options_build_add_uint_option (NULL , src_coap_msg_ptr -> options_list_ptr -> block1 , COAP_OPTION_BLOCK1 , & tempInt );
@@ -313,6 +326,7 @@ uint16_t sn_coap_builder_calc_needed_packet_data_size_2(sn_coap_hdr_s *src_coap_
313
326
/* BLOCK 2 - An integer option, up to 3 bytes */
314
327
if (src_coap_msg_ptr -> options_list_ptr -> block2 != COAP_OPTION_BLOCK_NONE ) {
315
328
if ((uint32_t ) src_coap_msg_ptr -> options_list_ptr -> block2 > 0xffffff ) {
329
+ tr_error ("sn_coap_builder_calc_needed_packet_data_size_2 - block2 too large!" );
316
330
return 0 ;
317
331
}
318
332
returned_byte_count += sn_coap_builder_options_build_add_uint_option (NULL , src_coap_msg_ptr -> options_list_ptr -> block2 , COAP_OPTION_BLOCK2 , & tempInt );
@@ -483,6 +497,7 @@ static int8_t sn_coap_builder_header_build(uint8_t **dst_packet_data_pptr, sn_co
483
497
{
484
498
/* * * * Check validity of Header values * * * */
485
499
if (sn_coap_header_validity_check (src_coap_msg_ptr , COAP_VERSION ) != 0 ) {
500
+ tr_error ("sn_coap_builder_header_build - header build failed!" );
486
501
return -1 ;
487
502
}
488
503
@@ -526,6 +541,7 @@ static int8_t sn_coap_builder_options_build(uint8_t **dst_packet_data_pptr, sn_c
526
541
/* * * * Check if Options are used at all * * * */
527
542
if (src_coap_msg_ptr -> uri_path_ptr == NULL && src_coap_msg_ptr -> token_ptr == NULL &&
528
543
src_coap_msg_ptr -> content_format == COAP_CT_NONE && src_coap_msg_ptr -> options_list_ptr == NULL ) {
544
+ tr_error ("sn_coap_builder_options_build - options not used!" );
529
545
return 0 ;
530
546
}
531
547
0 commit comments