MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / netdev_set_gw

Function netdev_set_gw

components/net/netdev/src/netdev.c:720–739  ·  view source on GitHub ↗

* This function will set network interface device gateway address. * * @param netdev the network interface device to change * @param gw the new gateway address * * @return 0: set gateway address successfully * -1: set gateway address failed */

Source from the content-addressed store, hash-verified

718 * -1: set gateway address failed
719 */
720int netdev_set_gw(struct netdev *netdev, const ip_addr_t *gw)
721{
722 RT_ASSERT(netdev);
723 RT_ASSERT(gw);
724
725 if (!netdev->ops || !netdev->ops->set_addr_info)
726 {
727 LOG_E("The network interface device(%s) not support to set gateway address.", netdev->name);
728 return -RT_ERROR;
729 }
730
731 if (netdev_is_dhcp_enabled(netdev))
732 {
733 LOG_E("The network interface device(%s) DHCP capability is enable, not support set gateway address.", netdev->name);
734 return -RT_ERROR;
735 }
736
737 /* execute network interface device set gateway address operations */
738 return netdev->ops->set_addr_info(netdev, RT_NULL, RT_NULL, (ip_addr_t *)gw);
739}
740
741/**
742 * This function will try to get network device and set DNS server address.

Callers 5

test_netdev_ifconfig_setFunction · 0.85
test_netdev_config_setFunction · 0.85
set_gw_wrapperFunction · 0.85
utest_tc_cleanupFunction · 0.85
netdev_set_ifFunction · 0.85

Calls

no outgoing calls

Tested by 2

test_netdev_ifconfig_setFunction · 0.68
test_netdev_config_setFunction · 0.68