* This function will control network interface device DHCP capability enable or disable. * * @param netdev the network interface device device to change * @param is_enable the new DHCP status * * @return 0: set DHCP status successfully * -1: set DHCP status failed */
| 592 | * -1: set DHCP status failed |
| 593 | */ |
| 594 | int netdev_dhcp_enabled(struct netdev *netdev, rt_bool_t is_enabled) |
| 595 | { |
| 596 | RT_ASSERT(netdev); |
| 597 | |
| 598 | if (!netdev->ops || !netdev->ops->set_dhcp) |
| 599 | { |
| 600 | LOG_E("The network interface device(%s) not support to set DHCP status.", netdev->name); |
| 601 | return -RT_ERROR; |
| 602 | } |
| 603 | |
| 604 | /* network interface device DHCP flags check */ |
| 605 | if (netdev_is_dhcp_enabled(netdev) == is_enabled) |
| 606 | { |
| 607 | return RT_EOK; |
| 608 | } |
| 609 | |
| 610 | /* execute network interface device DHCP capability control operations */ |
| 611 | return netdev->ops->set_dhcp(netdev, is_enabled); |
| 612 | } |
| 613 | |
| 614 | int netdev_dhcp_open(char *netdev_name) |
| 615 | { |
no outgoing calls