@@ -156,32 +156,32 @@ static void initialize_channel_list(uint32_t channel)
156156 const int_fast8_t word_index = channel / 32 ;
157157 const int_fast8_t bit_index = channel % 32 ;
158158
159- memset (& channel_list , 0 , sizeof (channel_list ));
159+ memset (& channel_list , 0 , sizeof (channel_list ));
160160 channel_list .channel_page = CHANNEL_PAGE_0 ;
161161
162- rf_trx_part_e type = rf_radio_type_read ();
162+ rf_trx_part_e type = rf_radio_type_read ();
163163
164- switch (type ) {
165- case ATMEL_AT86RF212 :
166- tr_debug ("Using SUBGHZ radio, type = %d, channel = %d" , type , channel );
167- channel_list .channel_mask [0 ] = channel_mask_0_subghz ;
168- break ;
169- case ATMEL_AT86RF231 :
164+ switch (type ) {
165+ case ATMEL_AT86RF212 :
166+ tr_debug ("Using SUBGHZ radio, type = %d, channel = %d" , type , channel );
167+ channel_list .channel_mask [0 ] = channel_mask_0_subghz ;
168+ break ;
169+ case ATMEL_AT86RF231 :
170170 tr_debug ("Using 24GHZ radio, type = %d, channel = %d" , type , channel );
171- channel_list .channel_mask [0 ] = channel_mask_0_2_4ghz ;
172- break ;
173- default :
171+ channel_list .channel_mask [0 ] = channel_mask_0_2_4ghz ;
172+ break ;
173+ default :
174174 tr_debug ("Using UNKNOWN radio, type = %d, channel = %d" , type , channel );
175175 /* Use the 24GHZ channel mask for unknown radio types */
176- channel_list .channel_mask [0 ] = channel_mask_0_2_4ghz ;
177- break ;
178- }
179-
180- if (channel > 0 ) {
181- /* Zero channel value means listen all channels */
182- memset (& channel_list .channel_mask , 0 , sizeof (channel_list .channel_mask ));
183- channel_list .channel_mask [word_index ] |= ((uint32_t ) 1 << bit_index );
184- }
176+ channel_list .channel_mask [0 ] = channel_mask_0_2_4ghz ;
177+ break ;
178+ }
179+
180+ if (channel > 0 ) {
181+ /* Zero channel value means listen all channels */
182+ memset (& channel_list .channel_mask , 0 , sizeof (channel_list .channel_mask ));
183+ channel_list .channel_mask [word_index ] |= ((uint32_t ) 1 << bit_index );
184+ }
185185}
186186
187187static void load_config (void )
@@ -247,31 +247,31 @@ static void load_config(void)
247247 dodag_config .DAG_SEC_PCS = cfg_int (global_config , "BR_DAG_SEC_PCS" , 1 );
248248 dodag_config .DAG_OCP = cfg_int (global_config , "BR_DAG_OCP" , 1 );
249249
250- /* Bootstrap mode for the backhaul interface */
250+ /* Bootstrap mode for the backhaul interface */
251251 backhaul_bootstrap_mode = (net_ipv6_mode_e )cfg_int (global_config ,
252- "BACKHAUL_BOOTSTRAP_MODE" , NET_IPV6_BOOTSTRAP_STATIC );
253-
254- /* Backhaul default route */
255- memset (& backhaul_route , 0 , sizeof (backhaul_route ));
256- psk = cfg_string (global_config , "BACKHAUL_NEXT_HOP" , NULL );
257-
258- if (psk ) {
259- stoip6 (psk , strlen (psk ), backhaul_route .next_hop );
260- }
261-
262- psk = cfg_string (global_config , "BACKHAUL_DEFAULT_ROUTE" , NULL );
263-
264- if (psk ) {
265- char * prefix , route_buf [255 ] = {0 };
266-
267- /* copy the config value to a non-const buffer */
268- strncpy (route_buf , psk , sizeof (route_buf )- 1 );
269- prefix = strtok (route_buf , "/" );
270- backhaul_route .prefix_len = atoi (strtok (NULL , "/" ));
271-
272- stoip6 (prefix , strlen (prefix ), backhaul_route .prefix );
273- }
274-
252+ "BACKHAUL_BOOTSTRAP_MODE" , NET_IPV6_BOOTSTRAP_STATIC );
253+
254+ /* Backhaul default route */
255+ memset (& backhaul_route , 0 , sizeof (backhaul_route ));
256+ psk = cfg_string (global_config , "BACKHAUL_NEXT_HOP" , NULL );
257+
258+ if (psk ) {
259+ stoip6 (psk , strlen (psk ), backhaul_route .next_hop );
260+ }
261+
262+ psk = cfg_string (global_config , "BACKHAUL_DEFAULT_ROUTE" , NULL );
263+
264+ if (psk ) {
265+ char * prefix , route_buf [255 ] = {0 };
266+
267+ /* copy the config value to a non-const buffer */
268+ strncpy (route_buf , psk , sizeof (route_buf ) - 1 );
269+ prefix = strtok (route_buf , "/" );
270+ backhaul_route .prefix_len = atoi (strtok (NULL , "/" ));
271+
272+ stoip6 (prefix , strlen (prefix ), backhaul_route .prefix );
273+ }
274+
275275 prefix = cfg_string (global_config , "SECURITY_MODE" , "NONE" );
276276
277277 if (strcmp (prefix , "NONE" ) == 0 ) {
@@ -351,11 +351,9 @@ static int backhaul_interface_up(int8_t driver_id)
351351 backhaul_if_id = arm_nwk_interface_init (NET_INTERFACE_ETHERNET , driver_id , "bh0" );
352352 if (backhaul_if_id >= 0 ) {
353353 tr_debug ("Backhaul interface ID: %d" , backhaul_if_id );
354- if (memcmp (backhaul_prefix , (const uint8_t [8 ]) {
355- 0
356- }, 8 ) == 0 ) {
357- memcpy (backhaul_prefix , rpl_setup_info .DODAG_ID , 8 );
358- }
354+ if (memcmp (backhaul_prefix , (const uint8_t [8 ]) {0 }, 8 ) == 0 ) {
355+ memcpy (backhaul_prefix , rpl_setup_info .DODAG_ID , 8 );
356+ }
359357 arm_nwk_interface_configure_ipv6_bootstrap_set (backhaul_if_id , backhaul_bootstrap_mode , backhaul_prefix );
360358 arm_nwk_interface_up (backhaul_if_id );
361359 retval = 0 ;
@@ -457,10 +455,10 @@ static void start_6lowpan(void)
457455 uint8_t t_flags = 0 ;
458456 int8_t retval = -1 ;
459457
460- /* Channel list: listen to a channel (default: all channels) */
458+ /* Channel list: listen to a channel (default: all channels) */
461459 uint32_t channel = cfg_int (global_config , "RF_CHANNEL" , 0 );
462460 initialize_channel_list (channel );
463-
461+
464462 // configure as border router and set the operation mode
465463 retval = arm_nwk_interface_configure_6lowpan_bootstrap_set (net_6lowpan_id ,
466464 operating_mode , operating_mode_extension );
@@ -485,8 +483,8 @@ static void start_6lowpan(void)
485483 }
486484
487485 /* configure both /64 and /128 context prefixes */
488- retval = arm_nwk_6lowpan_border_router_context_update (net_6lowpan_id , ((1 << 4 )| 0x03 ),
489- 128 , 0xffff , rpl_setup_info .DODAG_ID );
486+ retval = arm_nwk_6lowpan_border_router_context_update (net_6lowpan_id , ((1 << 4 ) | 0x03 ),
487+ 128 , 0xffff , rpl_setup_info .DODAG_ID );
490488
491489 if (retval < 0 ) {
492490 tr_error ("Setting ND context failed, retval = %d" , retval );
@@ -496,18 +494,18 @@ static void start_6lowpan(void)
496494 // configure the RPL routing protocol for the 6LoWPAN mesh network
497495 if (arm_nwk_6lowpan_rpl_dodag_init (net_6lowpan_id , rpl_setup_info .DODAG_ID ,
498496 & dodag_config , rpl_setup_info .rpl_instance_id ,
499- rpl_setup_info .rpl_setups ) == 0 ) {
497+ rpl_setup_info .rpl_setups ) == 0 ) {
500498 prefix_len = 64 ;
501499 t_flags = RPL_PREFIX_ROUTER_ADDRESS_FLAG ;
502500 /* add "/64" prefix with the full BR address (DODAG ID) */
503501 arm_nwk_6lowpan_rpl_dodag_prefix_update (net_6lowpan_id , rpl_setup_info .DODAG_ID ,
504- prefix_len , t_flags , lifetime );
502+ prefix_len , t_flags , lifetime );
505503
506504 t_flags = 0 ;
507505 prefix_len = 0 ;
508506 /* add default route "::/0" */
509507 arm_nwk_6lowpan_rpl_dodag_route_update (net_6lowpan_id , rpl_setup_info .DODAG_ID ,
510- prefix_len , t_flags , lifetime );
508+ prefix_len , t_flags , lifetime );
511509 }
512510
513511 if (link_security_mode == NET_SEC_MODE_PANA_LINK_SECURITY ) {
@@ -534,10 +532,10 @@ static void start_6lowpan(void)
534532 retval = arm_nwk_set_channel_list (net_6lowpan_id , & channel_list );
535533
536534 if (retval ) {
537- tr_error ("Failed to set channel list, retval = %d" , retval );
538- return ;
535+ tr_error ("Failed to set channel list, retval = %d" , retval );
536+ return ;
539537 }
540-
538+
541539 retval = arm_nwk_interface_up (net_6lowpan_id );
542540
543541 if (retval < 0 ) {
@@ -579,29 +577,30 @@ static void app_parse_network_event(arm_event_s *event)
579577 } else {
580578 tr_debug ("Backhaul interface in ULA Mode" );
581579 }
582-
583- if (backhaul_bootstrap_mode == NET_IPV6_BOOTSTRAP_STATIC ) {
584- int8_t retval ;
585- uint8_t * next_hop_ptr ;
586-
587- if (memcmp (backhaul_route .next_hop , (const uint8_t [16 ]) {0 }, 16 ) == 0 ) {
588- next_hop_ptr = NULL ;
589- } else {
590- next_hop_ptr = backhaul_route .next_hop ;
591- }
592-
593- tr_debug ("Backhaul default route:" );
594- tr_debug (" prefix: %s" , print_ipv6_prefix (backhaul_route .prefix , backhaul_route .prefix_len ));
595- tr_debug (" next hop: %s" , next_hop_ptr ? print_ipv6 (backhaul_route .next_hop ) : "on-link" );
596-
597- retval = arm_net_route_add (backhaul_route .prefix , backhaul_route .prefix_len ,
598- next_hop_ptr , 0xffffffff , 128 , backhaul_if_id );
599-
600- if (retval < 0 ) {
601- tr_error ("Failed to add backhaul default route, retval = %d" , retval );
602- }
603- }
604-
580+
581+ if (backhaul_bootstrap_mode == NET_IPV6_BOOTSTRAP_STATIC ) {
582+ int8_t retval ;
583+ uint8_t * next_hop_ptr ;
584+
585+ if (memcmp (backhaul_route .next_hop , (const uint8_t [16 ]) {0 }, 16 ) == 0 ) {
586+ next_hop_ptr = NULL ;
587+ }
588+ else {
589+ next_hop_ptr = backhaul_route .next_hop ;
590+ }
591+
592+ tr_debug ("Backhaul default route:" );
593+ tr_debug (" prefix: %s" , print_ipv6_prefix (backhaul_route .prefix , backhaul_route .prefix_len ));
594+ tr_debug (" next hop: %s" , next_hop_ptr ? print_ipv6 (backhaul_route .next_hop ) : "on-link" );
595+
596+ retval = arm_net_route_add (backhaul_route .prefix , backhaul_route .prefix_len ,
597+ next_hop_ptr , 0xffffffff , 128 , backhaul_if_id );
598+
599+ if (retval < 0 ) {
600+ tr_error ("Failed to add backhaul default route, retval = %d" , retval );
601+ }
602+ }
603+
605604 tr_debug ("Backhaul interface addresses:" );
606605 print_interface_addr (backhaul_if_id );
607606
0 commit comments