summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2016-09-15 12:51:27 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-09-22 11:30:38 +0200
commitd60230bded854fe5a357c77038cf6089defcfd24 (patch)
tree6c8b3dc4dee496cda1e1f9da5f53b1fa58a2e5ef /net
parent581272f8c59a71e8f64a15b6b33bb0d1fc5ac6ba (diff)
downloadbarebox-d60230bded854fe5a357c77038cf6089defcfd24.tar.gz
barebox-d60230bded854fe5a357c77038cf6089defcfd24.tar.xz
convert users to %pI4
Convert users of ip_to_string() and print_IPaddr() to %pI4 and remove the now unused functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'net')
-rw-r--r--net/dhcp.c6
-rw-r--r--net/dns.c6
-rw-r--r--net/lib.c19
-rw-r--r--net/net.c4
-rw-r--r--net/netconsole.c2
5 files changed, 8 insertions, 29 deletions
diff --git a/net/dhcp.c b/net/dhcp.c
index 792ece491b..c5386fe942 100644
--- a/net/dhcp.c
+++ b/net/dhcp.c
@@ -613,13 +613,13 @@ static void dhcp_handler(void *ctx, char *packet, unsigned int len)
debug ("%s: State REQUESTING\n", __func__);
if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK ) {
+ IPaddr_t ip;
if (net_read_uint32((uint32_t *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
dhcp_options_process((u8 *)&bp->bp_vend[4], bp);
bootp_copy_net_params(bp); /* Store net params from reply */
dhcp_state = BOUND;
- puts ("DHCP client bound to address ");
- print_IPaddr(net_get_ip());
- putchar('\n');
+ ip = net_get_ip();
+ printf("DHCP client bound to address %pI4\n", &ip);
return;
}
break;
diff --git a/net/dns.c b/net/dns.c
index 2acdb935ed..700c6b0259 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -221,7 +221,7 @@ IPaddr_t resolv(const char *host)
if (string_to_ip(ns, &ip))
return 0;
- debug("resolving host %s via nameserver %s\n", host, ip_to_string(ip));
+ debug("resolving host %s via nameserver %pI4\n", host, &ip);
dns_con = net_udp_new(ip, DNS_PORT, dns_handler, NULL);
if (IS_ERR(dns_con))
@@ -258,9 +258,7 @@ static int do_host(int argc, char *argv[])
if (!ip)
printf("unknown host %s\n", argv[1]);
else {
- printf("%s is at ", argv[1]);
- print_IPaddr(ip);
- printf("\n");
+ printf("%s is at %pI4\n", argv[1], &ip);
}
return 0;
diff --git a/net/lib.c b/net/lib.c
index f1c60c9a74..d4343bcedd 100644
--- a/net/lib.c
+++ b/net/lib.c
@@ -57,25 +57,6 @@ void ethaddr_to_string(const u8 enetaddr[6], char *str)
enetaddr[4], enetaddr[5]);
}
-void print_IPaddr(IPaddr_t x)
-{
- puts(ip_to_string(x));
-}
-
-char *ip_to_string(IPaddr_t x)
-{
- static char s[sizeof("xxx.xxx.xxx.xxx")];
-
- x = ntohl(x);
- sprintf(s, "%d.%d.%d.%d",
- (int) ((x >> 24) & 0xff),
- (int) ((x >> 16) & 0xff),
- (int) ((x >> 8) & 0xff), (int) ((x >> 0) & 0xff)
- );
-
- return s;
-}
-
int string_to_ip(const char *s, IPaddr_t *ip)
{
IPaddr_t addr = 0;
diff --git a/net/net.c b/net/net.c
index df1d677ba6..3c0e715601 100644
--- a/net/net.c
+++ b/net/net.c
@@ -78,9 +78,9 @@ IPaddr_t getenv_ip(const char *name)
int setenv_ip(const char *name, IPaddr_t ip)
{
- const char *str;
+ char str[sizeof("255.255.255.255")];
- str = ip_to_string(ip);
+ sprintf(str, "%pI4", &ip);
setenv(name, str);
diff --git a/net/netconsole.c b/net/netconsole.c
index 0ee6a7655b..ce3c418798 100644
--- a/net/netconsole.c
+++ b/net/netconsole.c
@@ -137,7 +137,7 @@ static int nc_set_active(struct console_device *cdev, unsigned flags)
net_udp_bind(priv->con, priv->port);
- pr_info("netconsole initialized with %s:%d\n", ip_to_string(priv->ip), priv->port);
+ pr_info("netconsole initialized with %pI4:%d\n", &priv->ip, priv->port);
return 0;
}