@ -39,7 +39,8 @@ static void dsa_iface_find_cb(struct net_if *iface, void *user_data)
@@ -39,7 +39,8 @@ static void dsa_iface_find_cb(struct net_if *iface, void *user_data)
if ( user = = NULL ) {
continue ;
}
LOG_INF ( " User interface %d found. " , i ) ;
LOG_INF ( " [%d] User interface %d found. " , i ,
net_if_get_by_iface ( user ) ) ;
ifaces - > lan [ i ] = user ;
}
@ -48,12 +49,40 @@ static void dsa_iface_find_cb(struct net_if *iface, void *user_data)
@@ -48,12 +49,40 @@ static void dsa_iface_find_cb(struct net_if *iface, void *user_data)
}
}
# if defined(CONFIG_NET_MGMT_EVENT)
# define EVENT_MASK (NET_EVENT_IF_UP)
static struct net_mgmt_event_callback mgmt_cb ;
static void event_handler ( struct net_mgmt_event_callback * cb ,
uint32_t mgmt_event , struct net_if * iface )
{
ARG_UNUSED ( iface ) ;
ARG_UNUSED ( cb ) ;
if ( mgmt_event = = NET_EVENT_IF_UP ) {
LOG_INF ( " Port %d is up " , net_if_get_by_iface ( iface ) ) ;
# if defined(CONFIG_NET_DHCPV4)
net_dhcpv4_start ( iface ) ;
# endif
return ;
}
}
# endif /* CONFIG_NET_MGMT_EVENT */
int main ( void )
{
/* Initialize interfaces - read them to user_data */
( void ) memset ( & user_data , 0 , sizeof ( user_data ) ) ;
net_if_foreach ( dsa_iface_find_cb , & user_data ) ;
# if defined(CONFIG_NET_MGMT_EVENT)
net_mgmt_init_event_callback ( & mgmt_cb ,
event_handler , EVENT_MASK ) ;
net_mgmt_add_event_callback ( & mgmt_cb ) ;
# endif /* CONFIG_NET_MGMT_EVENT */
# if defined(CONFIG_NET_SAMPLE_DSA_LLDP)
dsa_lldp ( & user_data ) ;
# endif