diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-11-23 19:15:31 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-12-14 14:30:19 +0100 |
commit | dfe2d162f3fc693bb95d3b67c674f2f264dc47e8 (patch) | |
tree | 557be9b6da351b00310ded7c10041897151cfeca /net/eth.c | |
parent | e612a5ca7aa8207efb119105a594e81a011ec7ce (diff) | |
download | barebox-dfe2d162f3fc693bb95d3b67c674f2f264dc47e8.tar.gz barebox-dfe2d162f3fc693bb95d3b67c674f2f264dc47e8.tar.xz |
net: Provide new way to configure network devices
This provides a new way to configure network interfaces based
on nvvars. A network interface can now be configured with variables
in the nv.dev.<ethname>.* namespace. There is a new network device
parameter "mode" which specifies the mode used to obtain IP settings.
The mode can be "dhcp", "static" or "disabled":
nv.dev.eth0.mode=dhcp
(ipaddr, netmask are ignored in this setting)
nv.dev.eth0.mode=static
nv.dev.eth0.ipaddr=192.168.0.17
nv.dev.eth0.netmask=255.255.0.0
nv.dev.eth0.mode=disabled
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net/eth.c')
-rw-r--r-- | net/eth.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -21,12 +21,18 @@ #include <command.h> #include <complete.h> #include <driver.h> +#include <unistd.h> #include <init.h> +#include <dhcp.h> #include <net.h> #include <of.h> #include <linux/phy.h> #include <errno.h> #include <malloc.h> +#include <globalvar.h> +#include <environment.h> +#include <linux/ctype.h> +#include <linux/stat.h> static uint64_t last_link_check; @@ -340,6 +346,12 @@ late_initcall(eth_register_of_fixup); extern IPaddr_t net_serverip; extern IPaddr_t net_gateway; +static const char * const eth_mode_names[] = { + [ETH_MODE_DHCP] = "dhcp", + [ETH_MODE_STATIC] = "static", + [ETH_MODE_DISABLED] = "disabled", +}; + int eth_register(struct eth_device *edev) { struct device_d *dev = &edev->dev; @@ -378,6 +390,9 @@ int eth_register(struct eth_device *edev) edev->ethaddr, edev); edev->bootarg = xstrdup(""); dev_add_param_string(dev, "linux.bootargs", NULL, NULL, &edev->bootarg, NULL); + dev_add_param_enum(dev, "mode", NULL, NULL, &edev->global_mode, + eth_mode_names, ARRAY_SIZE(eth_mode_names), + NULL); if (edev->init) edev->init(edev); |