* This function will set network interface device 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 status */
| 1035 | * @param is_up the new status |
| 1036 | */ |
| 1037 | void netdev_low_level_set_status(struct netdev *netdev, rt_bool_t is_up) |
| 1038 | { |
| 1039 | if (netdev && netdev_is_up(netdev) != is_up) |
| 1040 | { |
| 1041 | if (is_up) |
| 1042 | { |
| 1043 | netdev->flags |= NETDEV_FLAG_UP; |
| 1044 | } |
| 1045 | else |
| 1046 | { |
| 1047 | netdev->flags &= ~NETDEV_FLAG_UP; |
| 1048 | |
| 1049 | #ifdef NETDEV_USING_AUTO_DEFAULT |
| 1050 | /* change to the first link_up network interface device automatically */ |
| 1051 | netdev_auto_change_default(netdev); |
| 1052 | #endif /* NETDEV_USING_AUTO_DEFAULT */ |
| 1053 | } |
| 1054 | |
| 1055 | /* execute network interface device status change callback function */ |
| 1056 | if (netdev->status_callback) |
| 1057 | { |
| 1058 | netdev->status_callback(netdev, is_up ? NETDEV_CB_STATUS_UP : NETDEV_CB_STATUS_DOWN); |
| 1059 | } |
| 1060 | } |
| 1061 | } |
| 1062 | |
| 1063 | /** |
| 1064 | * This function will set network interface device active link status. |
no test coverage detected