MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / netdev_low_level_set_link_status

Function netdev_low_level_set_link_status

components/net/netdev/src/netdev.c:1070–1105  ·  view source on GitHub ↗

* This function will set network interface device active link status. * @NOTE it can only be called in the network interface device driver. * * @param netdev the network interface device to change * @param is_up the new link status */

Source from the content-addressed store, hash-verified

1068 * @param is_up the new link status
1069 */
1070void netdev_low_level_set_link_status(struct netdev *netdev, rt_bool_t is_up)
1071{
1072 if (netdev && netdev_is_link_up(netdev) != is_up)
1073 {
1074 if (is_up)
1075 {
1076 netdev->flags |= NETDEV_FLAG_LINK_UP;
1077
1078#ifdef RT_USING_SAL
1079 /* set network interface device flags to internet up */
1080 if (netdev_is_up(netdev) && !ip_addr_isany(&(netdev->ip_addr)))
1081 {
1082 sal_check_netdev_internet_up(netdev);
1083 }
1084#endif /* RT_USING_SAL */
1085 }
1086 else
1087 {
1088 netdev->flags &= ~NETDEV_FLAG_LINK_UP;
1089
1090 /* set network interface device flags to internet down */
1091 netdev->flags &= ~NETDEV_FLAG_INTERNET_UP;
1092
1093#ifdef NETDEV_USING_AUTO_DEFAULT
1094 /* change to the first link_up network interface device automatically */
1095 netdev_auto_change_default(netdev);
1096#endif /* NETDEV_USING_AUTO_DEFAULT */
1097 }
1098
1099 /* execute link status change callback function */
1100 if (netdev->status_callback)
1101 {
1102 netdev->status_callback(netdev, is_up ? NETDEV_CB_STATUS_LINK_UP : NETDEV_CB_STATUS_LINK_DOWN);
1103 }
1104 }
1105}
1106
1107/**
1108 * This function will set network interface device active internet status.

Callers 7

netif_set_link_upFunction · 0.85
netif_set_link_downFunction · 0.85
netif_set_link_upFunction · 0.85
netif_set_link_downFunction · 0.85
netif_set_link_upFunction · 0.85
netif_set_link_downFunction · 0.85
test_netdev_status_setFunction · 0.85

Calls 3

ip_addr_isanyFunction · 0.85

Tested by 1

test_netdev_status_setFunction · 0.68