@@ -110,9 +110,10 @@ STATIC enum err oscore_option_parser(const struct o_coap_option *opt,
110
110
out -> kid_context .len = * val_ptr ;
111
111
out -> kid_context .ptr = ++ val_ptr ;
112
112
val_ptr += out -> kid_context .len ;
113
- temp_kid_len = (uint8_t )(
114
- temp_kid_len -
115
- (out -> kid_context .len + 1 ));
113
+ temp_kid_len =
114
+ (uint8_t )(temp_kid_len -
115
+ (out -> kid_context .len +
116
+ 1 ));
116
117
}
117
118
118
119
/* Get KID */
@@ -285,6 +286,24 @@ decrypt_wrapper(struct byte_array *ciphertext, struct byte_array *plaintext,
285
286
return ok ;
286
287
}
287
288
289
+ static inline void set_observe_val (struct o_coap_option * options ,
290
+ uint8_t options_cnt , struct byte_array * piv )
291
+ {
292
+ uint16_t len ;
293
+ if (piv -> len > 3 ) {
294
+ len = 3 ;
295
+ } else {
296
+ len = (uint16_t )piv -> len ;
297
+ }
298
+
299
+ for (uint8_t i = 0 ; i < options_cnt ; i ++ ) {
300
+ if (options [i ].option_number == OBSERVE ) {
301
+ options [i ].value = piv -> ptr ;
302
+ options [i ].len = len ;
303
+ }
304
+ }
305
+ }
306
+
288
307
enum err oscore2coap (uint8_t * buf_in , uint32_t buf_in_len , uint8_t * buf_out ,
289
308
uint32_t * buf_out_len , struct context * c )
290
309
{
@@ -400,6 +419,12 @@ enum err oscore2coap(uint8_t *buf_in, uint32_t buf_in_len, uint8_t *buf_out,
400
419
& c -> rc .notification_num ,
401
420
& c -> rc .notification_num_initialized ,
402
421
& oscore_option .piv ));
422
+
423
+ /*set outer observe option value to the three
424
+ least significant bytes of the PIV*/
425
+ set_observe_val (oscore_packet .options ,
426
+ oscore_packet .options_cnt ,
427
+ & oscore_option .piv );
403
428
} else {
404
429
/*Notification without PIV received -- Currently not supported*/
405
430
return not_supported_feature ; //LCOV_EXCL_LINE
0 commit comments