* 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 */
| 1068 | * @param is_up the new link status |
| 1069 | */ |
| 1070 | void 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. |