From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eKjPf-0003o6-DK for barebox@lists.infradead.ORG; Fri, 01 Dec 2017 11:23:40 +0000 From: Sascha Hauer Date: Fri, 1 Dec 2017 12:22:35 +0100 Message-Id: <20171201112256.20196-7-s.hauer@pengutronix.de> In-Reply-To: <20171201112256.20196-1-s.hauer@pengutronix.de> References: <20171201112256.20196-1-s.hauer@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 06/27] net: Make domainname and nameserver globalvars To: Barebox List Register domainname and nameserver as globalvars rather than attaching them to a dedicated net device. the global device already exists and already contains much of the barebox configuration, so no need to add an extra device for network config. Signed-off-by: Sascha Hauer --- net/dhcp.c | 4 ++-- net/dns.c | 4 ++-- net/net.c | 25 ++++++++++--------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/net/dhcp.c b/net/dhcp.c index 4d74733d37..68696d69e8 100644 --- a/net/dhcp.c +++ b/net/dhcp.c @@ -242,7 +242,7 @@ struct dhcp_opt dhcp_options[] = { }, { .option = 6, .handle = env_ip_handle, - .barebox_var_name = "net.nameserver", + .barebox_var_name = "global.net.nameserver", }, { .option = DHCP_HOSTNAME, .copy_only_if_valid = 1, @@ -252,7 +252,7 @@ struct dhcp_opt dhcp_options[] = { }, { .option = 15, .handle = env_str_handle, - .barebox_var_name = "net.domainname", + .barebox_var_name = "global.net.domainname", }, { .option = 17, .handle = env_str_handle, diff --git a/net/dns.c b/net/dns.c index 700c6b0259..69b8a24861 100644 --- a/net/dns.c +++ b/net/dns.c @@ -77,7 +77,7 @@ static int dns_send(const char *name) header->nauth = 0; header->nother = 0; - domain = getenv("net.domainname"); + domain = getenv("global.net.domainname"); if (!strchr(name, '.') && domain && *domain) fullname = basprintf(".%s.%s.", name, domain); @@ -211,7 +211,7 @@ IPaddr_t resolv(const char *host) dns_state = STATE_INIT; - ns = getenv("net.nameserver"); + ns = getenv("global.net.nameserver"); if (!ns || !*ns) { printk("%s: no nameserver specified in $net.nameserver\n", __func__); diff --git a/net/net.c b/net/net.c index 205543a425..30977321ff 100644 --- a/net/net.c +++ b/net/net.c @@ -36,12 +36,17 @@ #include #include #include +#include +#include #include #include unsigned char *NetRxPackets[PKTBUFSRX]; /* Receive packets */ static unsigned int net_ip_id; +static IPaddr_t net_nameserver; +static char *net_domainname; + int net_checksum_ok(unsigned char *ptr, int len) { return net_checksum(ptr, len) == 0xffff; @@ -570,14 +575,6 @@ out: return ret; } -static struct device_d net_device = { - .name = "net", - .id = DEVICE_ID_SINGLE, -}; - -static char *net_nameserver; -static char *net_domainname; - static int net_init(void) { int i; @@ -585,15 +582,13 @@ static int net_init(void) for (i = 0; i < PKTBUFSRX; i++) NetRxPackets[i] = net_alloc_packet(); - register_device(&net_device); - net_nameserver = xstrdup(""); - dev_add_param_string(&net_device, "nameserver", NULL, NULL, - &net_nameserver, NULL); - net_domainname = xstrdup(""); - dev_add_param_string(&net_device, "domainname", NULL, NULL, - &net_domainname, NULL); + globalvar_add_simple_ip("net.nameserver", &net_nameserver); + globalvar_add_simple_string("net.domainname", &net_domainname); return 0; } postcore_initcall(net_init); + +BAREBOX_MAGICVAR_NAMED(global_net_nameserver, global.net.nameserver, "The DNS server used for resolving host names"); +BAREBOX_MAGICVAR_NAMED(global_net_domainname, global.net.domainname, "Domain name used for DNS requests"); -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox