* This function will enable network interface device . * * @param netdev the network interface device to change * * @return 0: set status successfully * -1: set status failed */
| 518 | * -1: set status failed |
| 519 | */ |
| 520 | int netdev_set_up(struct netdev *netdev) |
| 521 | { |
| 522 | int err = 0; |
| 523 | |
| 524 | RT_ASSERT(netdev); |
| 525 | |
| 526 | if (!netdev->ops || !netdev->ops->set_up) |
| 527 | { |
| 528 | LOG_E("The network interface device(%s) not support to set status.", netdev->name); |
| 529 | return -RT_ERROR; |
| 530 | } |
| 531 | |
| 532 | /* network interface device status flags check */ |
| 533 | if (netdev_is_up(netdev)) |
| 534 | { |
| 535 | return RT_EOK; |
| 536 | } |
| 537 | |
| 538 | /* execute enable network interface device operations by network interface device driver */ |
| 539 | err = netdev->ops->set_up(netdev); |
| 540 | |
| 541 | #if defined(SAL_USING_AF_NETLINK) |
| 542 | if (err) |
| 543 | rtnl_ip_notify(netdev, RTM_NEWLINK); |
| 544 | #endif |
| 545 | |
| 546 | return err; |
| 547 | } |
| 548 | /** |
| 549 | * This function will disable network interface device. |
| 550 | * |
no outgoing calls