* This function will disable network interface device. * * @param netdev the network interface device to change * * @return 0: set status successfully * -1: set sttaus failed */
| 554 | * -1: set sttaus failed |
| 555 | */ |
| 556 | int netdev_set_down(struct netdev *netdev) |
| 557 | { |
| 558 | int err; |
| 559 | |
| 560 | RT_ASSERT(netdev); |
| 561 | |
| 562 | if (!netdev->ops || !netdev->ops->set_down) |
| 563 | { |
| 564 | LOG_E("The network interface device(%s) not support to set status.", netdev->name); |
| 565 | return -RT_ERROR; |
| 566 | } |
| 567 | |
| 568 | /* network interface device status flags check */ |
| 569 | if (!netdev_is_up(netdev)) |
| 570 | { |
| 571 | return RT_EOK; |
| 572 | } |
| 573 | |
| 574 | /* execute disable network interface device operations by network interface driver */ |
| 575 | err = netdev->ops->set_down(netdev); |
| 576 | #if defined(SAL_USING_AF_NETLINK) |
| 577 | if (err) |
| 578 | rtnl_ip_notify(netdev, RTM_NEWLINK); |
| 579 | #endif |
| 580 | |
| 581 | return err; |
| 582 | } |
| 583 | |
| 584 | #ifdef RT_LWIP_DHCP |
| 585 | /** |
no outgoing calls