mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Christoph Fritz <chf.fritz@googlemail.com>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/1] net: add multiple nameserver support
Date: Sat, 22 Sep 2012 21:25:57 +0200	[thread overview]
Message-ID: <1348341957.24868.6.camel@mars> (raw)
In-Reply-To: <1348338458-30735-1-git-send-email-plagnioj@jcrosoft.com>

On Sat, 2012-09-22 at 20:27 +0200, Jean-Christophe PLAGNIOL-VILLARD
wrote:

> +
>  static int do_host(int argc, char *argv[])
>  {
>  	IPaddr_t ip;
> diff --git a/net/net.c b/net/net.c
> index 3ac098f..edadf51 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -677,7 +677,8 @@ static int net_init(void)
>  		NetRxPackets[i] = net_alloc_packet();
>  
>  	register_device(&net_device);
> -	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
> +	dev_add_param(&net_device, "nameserver0", NULL, NULL, 0);
> +	dev_add_param(&net_device, "nameserver1", NULL, NULL, 0);

What do you think about a function that checks if nameserver0/1 is
really an IP, like this:

+static int net_set_namesrv(struct device_d *dev, struct param_d *param, const char *val)
+{
+	IPaddr_t ip;
+
+	if (!val)
+		return -EINVAL;
+
+	if (string_to_ip(val, &ip))
+		return -EINVAL;
+
+	dev_param_set_generic(dev, param, val);
+
+	return 0;
+}
+
 static int net_init(void)
 {
 	int i;
@@ -677,7 +692,8 @@ static int net_init(void)
 		NetRxPackets[i] = net_alloc_packet();
 
 	register_device(&net_device);
-	dev_add_param(&net_device, "nameserver", NULL, NULL, 0);
+	dev_add_param(&net_device, "nameserver0", net_set_namesrv, NULL, 0);
+	dev_add_param(&net_device, "nameserver1", net_set_namesrv, NULL, 0);
 	dev_add_param(&net_device, "domainname", NULL, NULL, 0);
 
 	return 0;
---

It has the benefit that you get an error message ("set parameter:
Invalid argument") if it's defined wrong.

Thanks,
 -- Christoph


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-09-22 19:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-22 10:58 [PATCH 1/2] net: add nameserver IPs to kernel-parameter ip= Christoph Fritz
2012-09-22 11:43 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-22 15:41   ` [PATCH 1/2][v2] " Christoph Fritz
2012-09-22 18:24     ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-22 18:27     ` [PATCH 1/1] net: add multiple nameserver support Jean-Christophe PLAGNIOL-VILLARD
2012-09-22 19:25       ` Christoph Fritz [this message]
2012-09-22 20:16         ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-23 12:11           ` [PATCH] " Christoph Fritz
2012-09-23 13:29             ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-23 13:57               ` Christoph Fritz
2012-12-10 11:23                 ` Christoph Fritz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1348341957.24868.6.camel@mars \
    --to=chf.fritz@googlemail.com \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox