From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 7/8 v2] net: env: getenv_ip use resolv
Date: Fri, 30 Mar 2012 12:39:50 +0200 [thread overview]
Message-ID: <1333103990-15011-1-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20120330042713.GX444@game.jcrosoft.org>
Introduce getenv_ip_dns to be able to do not do the resolv when using it in
resolv for the nameserver (Do not loop).
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
v2:
replace PATCH 7/8] net: dns: export resolved ip to var resolved_ip
update git
The following changes since commit 485cee59cf64b5019c5a294074007b93509b83e0:
Merge branch 'work/imx51-babbage-clk' into next (2012-03-23 21:22:14 +0100)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git net
for you to fetch changes up to 561566cab8df8a5146590a0bd9186fbf7aa05a7c:
defaultenv: add support of etherboot_file (2012-03-30 18:50:30 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (8):
net: dhcp: reset env variable before do a dhcp request
net: dhcp: add support of tftp name server
net: dhcp: add support of tftp server ip or Etherboot file (option 150)
net: dhcp: allow to set transmitted client id
net: dhcp: allow to set transmitted client uuid
net: dhcp: allow to set transmitted user class
net: env: getenv_ip use resolv
defaultenv: add support of etherboot_file
defaultenv/bin/boot | 4 ++
include/net.h | 6 ++-
net/dhcp.c | 118 ++++++++++++++++++++++++++++++++++++++++++++-------
net/dns.c | 2 +-
net/net.c | 9 +++-
5 files changed, 118 insertions(+), 21 deletions(-)
Best Regards,
J.
include/net.h | 6 +++++-
net/dns.c | 2 +-
net/net.c | 9 ++++++---
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/include/net.h b/include/net.h
index 2eec47f..0ebe198 100644
--- a/include/net.h
+++ b/include/net.h
@@ -277,7 +277,11 @@ char *ip_to_string (IPaddr_t x, char *s);
/* Convert a string to ip address */
int string_to_ip(const char *s, IPaddr_t *ip);
-IPaddr_t getenv_ip(const char *name);
+IPaddr_t getenv_ip_dns(const char *name, int dns);
+static inline IPaddr_t getenv_ip(const char *name)
+{
+ return getenv_ip_dns(name, 0);
+}
int setenv_ip(const char *name, IPaddr_t ip);
int string_to_ethaddr(const char *str, char *enetaddr);
diff --git a/net/dns.c b/net/dns.c
index 3c7aa5f..fb1178a 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -205,7 +205,7 @@ IPaddr_t resolv(char *host)
dns_state = STATE_INIT;
- ip = getenv_ip("nameserver");
+ ip = getenv_ip_dns("nameserver", 0);
if (!ip)
return 0;
diff --git a/net/net.c b/net/net.c
index 2752884..39db75e 100644
--- a/net/net.c
+++ b/net/net.c
@@ -127,7 +127,7 @@ int string_to_ip(const char *s, IPaddr_t *ip)
return 0;
}
-IPaddr_t getenv_ip(const char *name)
+IPaddr_t getenv_ip_dns(const char *name, int dns)
{
IPaddr_t ip;
const char *var = getenv(name);
@@ -135,10 +135,13 @@ IPaddr_t getenv_ip(const char *name)
if (!var)
return 0;
- if (string_to_ip(var, &ip))
+ if (!string_to_ip(var, &ip))
+ return ip;
+
+ if (!dns)
return 0;
- return ip;
+ return resolv((char*)var);
}
int setenv_ip(const char *name, IPaddr_t ip)
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-03-30 10:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-30 4:27 [PATCH 0/8] Network update DHCP/BOOTP Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 1/8] net: dhcp: reset env variable before do a dhcp request Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 2/8] net: dhcp: add support of tftp name server Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 3/8] net: dhcp: add support of tftp server ip or Etherboot file (option 150) Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 9:21 ` Sascha Hauer
2012-03-30 10:14 ` Jean-Christophe PLAGNIOL-VILLARD
2012-04-02 10:49 ` Sascha Hauer
2012-04-02 11:18 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 4/8] net: dhcp: allow to set transmitted client id Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 5/8] net: dhcp: allow to set transmitted client uuid Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 6/8] net: dhcp: allow to set transmitted user class Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 7/8] net: dns: export resolved ip to var resolved_ip Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 9:12 ` Sascha Hauer
2012-03-30 10:16 ` Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 4:31 ` [PATCH 8/8] defaultenv: add support of etherboot_file Jean-Christophe PLAGNIOL-VILLARD
2012-03-30 10:39 ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2012-04-02 11:17 ` [PATCH 0/8] Network update DHCP/BOOTP Sascha Hauer
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=1333103990-15011-1-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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