45
45
#include "6LoWPAN/ws/ws_common_defines.h"
46
46
#include "6LoWPAN/ws/ws_llc.h"
47
47
#include "6LoWPAN/ws/ws_neighbor_class.h"
48
+ #include "6LoWPAN/ws/ws_ie_lib.h"
48
49
#include "6LoWPAN/lowpan_adaptation_interface.h"
49
50
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
50
51
#include "platform/topo_trace.h"
@@ -262,75 +263,6 @@ static bool ws_bootstrap_network_name_matches(const struct mcps_data_ie_list *ie
262
263
return true;
263
264
}
264
265
265
- static bool ws_bootstrap_unicast_schedule_read (uint8_t * ptr , uint16_t length , ws_hopping_schedule_t * uc_hopping )
266
- {
267
- mac_nested_payload_IE_t nested_payload_ie ;
268
- nested_payload_ie .id = WP_PAYLOAD_IE_US_TYPE ;
269
- nested_payload_ie .type_long = true;
270
-
271
- if (0 == mac_ie_nested_discover (ptr , length , & nested_payload_ie )) {
272
- tr_warn ("No unicast schedule" );
273
- return false;
274
- }
275
- if (nested_payload_ie .length < 4 ) {
276
- tr_warn ("corrupetd schedule" );
277
- return false;
278
- }
279
- if (!uc_hopping ) {
280
- // all OK no data read
281
- return true;
282
- }
283
- uc_hopping -> fhss_uc_dwell_interval = nested_payload_ie .content_ptr [0 ];
284
- uc_hopping -> clock_drift = nested_payload_ie .content_ptr [1 ];
285
- uc_hopping -> timing_accurancy = nested_payload_ie .content_ptr [2 ];
286
- uc_hopping -> channel_plan = (nested_payload_ie .content_ptr [3 ] & 0x03 );
287
- uc_hopping -> channel_function = (nested_payload_ie .content_ptr [3 ] & 0x38 ) >> 3 ;
288
-
289
- // TODO missing rest of the fields
290
-
291
- return true;
292
- }
293
-
294
- static bool ws_bootstrap_pan_information_read (uint8_t * ptr , uint16_t length , ws_pan_information_t * pan_information )
295
- {
296
- mac_nested_payload_IE_t nested_payload_ie ;
297
- nested_payload_ie .id = WP_PAYLOAD_IE_PAN_TYPE ;
298
- nested_payload_ie .type_long = true;
299
-
300
- if (0 == mac_ie_nested_discover (ptr , length , & nested_payload_ie )) {
301
- tr_warn ("No PAN information" );
302
- return false;
303
- }
304
- if (nested_payload_ie .length < 5 ) {
305
- tr_warn ("corrupetd PAN information" );
306
- return false;
307
- }
308
- if (pan_information ) {
309
- pan_information -> pan_size = common_read_16_bit_inverse (nested_payload_ie .content_ptr );
310
- pan_information -> routing_cost = common_read_16_bit_inverse (nested_payload_ie .content_ptr + 2 );
311
- pan_information -> use_parent_bs = (nested_payload_ie .content_ptr [4 ] & 0x10 ) == 0x10 ;
312
- pan_information -> rpl_routing_method = (nested_payload_ie .content_ptr [4 ] & 0x20 ) == 0x20 ;
313
- pan_information -> version = (nested_payload_ie .content_ptr [4 ]& 0xe0 ) >> 5 ;
314
- }
315
-
316
- return true;
317
- }
318
-
319
- static bool ws_bootstrap_ufsi_read (uint8_t * ptr , uint16_t length , uint_fast24_t * ufsi )
320
- {
321
- mac_header_IE_t utt_ie ;
322
- utt_ie .id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID ;
323
-
324
- if (4 != mac_ie_header_sub_id_discover (ptr , length , & utt_ie , WH_IE_UTT_TYPE )) {
325
- // NO UTT header
326
- return false;
327
- }
328
- if (ufsi ) {
329
- * ufsi = common_read_24_bit_inverse (& utt_ie .content_ptr [1 ]);
330
- }
331
- return true;
332
- }
333
-
334
266
static void ws_bootstrap_pan_advertisement_analyse (struct protocol_interface_info_entry * cur , const struct mcps_data_ind_s * data , const struct mcps_data_ie_list * ie_ext )
335
267
{
336
268
@@ -350,25 +282,25 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
350
282
return ;
351
283
}
352
284
353
- uint_fast24_t ufsi ;
285
+ ws_utt_ie_t ws_utt ;
354
286
355
- if (!ws_bootstrap_ufsi_read (ie_ext -> headerIeList , ie_ext -> headerIeListLength , & ufsi )) {
287
+ if (!ws_wh_utt_read (ie_ext -> headerIeList , ie_ext -> headerIeListLength , & ws_utt )) {
356
288
// Corrupted
357
289
tr_error ("No ufsi" );
358
290
return ;
359
291
}
360
292
361
293
ws_pan_information_t pan_information ;
362
- ws_hopping_schedule_t hopping_schedule = { 0 } ;
294
+ ws_us_ie_t ws_us ;
363
295
364
- if (!ws_bootstrap_pan_information_read (ie_ext -> payloadIeList , ie_ext -> payloadIeListLength , & pan_information )) {
296
+ if (!ws_wp_nested_pan_read (ie_ext -> payloadIeList , ie_ext -> payloadIeListLength , & pan_information )) {
365
297
// Corrupted
366
298
tr_error ("No pan information" );
367
299
return ;
368
300
}
369
301
370
302
// TODO create own function to read just dwell time
371
- if (!ws_bootstrap_unicast_schedule_read (ie_ext -> payloadIeList , ie_ext -> payloadIeListLength , & hopping_schedule )) {
303
+ if (!ws_wp_nested_us_read (ie_ext -> payloadIeList , ie_ext -> payloadIeListLength , & ws_us )) {
372
304
// Corrupted
373
305
tr_error ("No unicast schedule" );
374
306
return ;
@@ -390,9 +322,9 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
390
322
}
391
323
392
324
ws_neighbor -> fhss_data .utt_timestamp = data -> timestamp ;
393
- ws_neighbor -> fhss_data .ufsi = ufsi ;
394
- ws_neighbor -> fhss_data .channel_function = hopping_schedule . channel_function ;
395
- ws_neighbor -> fhss_data .unicast_dwell = hopping_schedule . fhss_uc_dwell_interval ;
325
+ ws_neighbor -> fhss_data .ufsi = ws_utt . ut ;
326
+ ws_neighbor -> fhss_data .channel_function = ws_us . channle_function ;
327
+ ws_neighbor -> fhss_data .unicast_dwell = ws_us . dwell_interval ;
396
328
397
329
398
330
@@ -406,9 +338,9 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
406
338
407
339
408
340
// Parent valid store information
409
- cur -> ws_info -> parent_info .ufsi = ufsi ;
341
+ cur -> ws_info -> parent_info .ufsi = ws_utt . ut ;
410
342
// Saved from unicast IE
411
- cur -> ws_info -> parent_info .dwell_interval = hopping_schedule . fhss_uc_dwell_interval ;
343
+ cur -> ws_info -> parent_info .dwell_interval = ws_us . dwell_interval ;
412
344
413
345
// Saved from Pan information
414
346
cur -> ws_info -> parent_info .pan_configuration = pan_information ;
@@ -439,17 +371,17 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
439
371
return ;
440
372
}
441
373
442
- uint_fast24_t ufsi ;
443
- ws_hopping_schedule_t hopping_schedule = { 0 } ;
374
+ ws_utt_ie_t ws_utt ;
375
+ ws_us_ie_t ws_us ;
444
376
445
- if (!ws_bootstrap_ufsi_read (ie_ext -> headerIeList , ie_ext -> headerIeListLength , & ufsi )) {
377
+ if (!ws_wh_utt_read (ie_ext -> headerIeList , ie_ext -> headerIeListLength , & ws_utt )) {
446
378
// Corrupted
447
379
tr_error ("No ufsi" );
448
380
return ;
449
381
}
450
382
451
383
// TODO create own function to read just dwell time
452
- if (!ws_bootstrap_unicast_schedule_read (ie_ext -> payloadIeList , ie_ext -> payloadIeListLength , & hopping_schedule )) {
384
+ if (!ws_wp_nested_us_read (ie_ext -> payloadIeList , ie_ext -> payloadIeListLength , & ws_us )) {
453
385
// Corrupted
454
386
tr_error ("No unicast schedule" );
455
387
return ;
@@ -465,9 +397,9 @@ static void ws_bootstrap_pan_advertisement_solicit_analyse(struct protocol_inter
465
397
}
466
398
467
399
ws_neighbor -> fhss_data .utt_timestamp = data -> timestamp ;
468
- ws_neighbor -> fhss_data .ufsi = ufsi ;
469
- ws_neighbor -> fhss_data .channel_function = hopping_schedule . channel_function ;
470
- ws_neighbor -> fhss_data .unicast_dwell = hopping_schedule . fhss_uc_dwell_interval ;
400
+ ws_neighbor -> fhss_data .ufsi = ws_utt . ut ;
401
+ ws_neighbor -> fhss_data .channel_function = ws_us . channle_function ;
402
+ ws_neighbor -> fhss_data .unicast_dwell = ws_us . dwell_interval ;
471
403
472
404
trickle_inconsistent_heard (& cur -> ws_info -> trickle_pan_advertisement ,& trickle_params_pan_advertisement );
473
405
}
0 commit comments