The state change of netif can set the callback function,
There are three main changes,
1 netif up or down,address change,address state change(IPv6)
2 link up or down;
3 netif removal
These three state changes can trigger a user-written callback function
1 #if LWIP_NETIF_STATUS_CALLBACK 2 /** This function is called when the netif state is set to up or down 3 */ 4 netif_status_callback_fn status_callback; 5 #endif /* LWIP_NETIF_STATUS_CALLBACK */ 6 #if LWIP_NETIF_LINK_CALLBACK 7 /** This function is called when the netif link is set to up or down 8 */ 9 netif_status_callback_fn link_callback; 10 #endif /* LWIP_NETIF_LINK_CALLBACK */ 11 #if LWIP_NETIF_REMOVE_CALLBACK 12 /** This function is called when the netif has been removed */ 13 netif_status_callback_fn remove_callback; 14 #endif /* LWIP_NETIF_REMOVE_CALLBACK */
In addition, netif changes can also trigger protocols such as IP, using netif_issue_reports,
The main changes of netif are: 1 netif up; 2 link up; 3 address change; 4 address state change (IPv6)
For IPv4, ARP, IGMP can be sent; for IPv6, MLD can be sent, RS re-sent, etc.
1 /** Send ARP/IGMP/MLD/RS events, e.g. on link-up/netif-up or addr-change 2 */ 3 static void 4 netif_issue_reports(struct netif* netif, u8_t report_type) 5 { 6 #if LWIP_IPV4 7 if ((report_type & NETIF_REPORT_TYPE_IPV4) && 8 !ip4_addr_isany_val(*netif_ip4_addr(netif))) { 9 #if LWIP_ARP 10 /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ 11 if (netif->flags & (NETIF_FLAG_ETHARP)) { 12 etharp_gratuitous(netif); 13 } 14 #endif /* LWIP_ARP */ 15 16 #if LWIP_IGMP 17 /* resend IGMP memberships */ 18 if (netif->flags & NETIF_FLAG_IGMP) { 19 igmp_report_groups(netif); 20 } 21 #endif /* LWIP_IGMP */ 22 } 23 #endif /* LWIP_IPV4 */ 24 25 #if LWIP_IPV6 26 if (report_type & NETIF_REPORT_TYPE_IPV6) { 27 #if LWIP_IPV6_MLD 28 /* send mld memberships */ 29 mld6_report_groups(netif); 30 #endif /* LWIP_IPV6_MLD */ 31 #if LWIP_IPV6_SEND_ROUTER_SOLICIT 32 /* Send Router Solicitation messages. */ 33 netif->rs_count = LWIP_ND6_MAX_MULTICAST_SOLICIT; 34 #endif /* LWIP_IPV6_SEND_ROUTER_SOLICIT */ 35 } 36 #endif /* LWIP_IPV6 */ 37 }
For the ND protocol, rs_count is mainly set to the initial value.
1 netif up;
2 link up;
3 address change;
4 address state change(IPv6)