diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/dhcp.c | 6 | ||||
-rw-r--r-- | net/dns.c | 6 | ||||
-rw-r--r-- | net/eth.c | 2 | ||||
-rw-r--r-- | net/ifup.c | 9 | ||||
-rw-r--r-- | net/lib.c | 19 | ||||
-rw-r--r-- | net/net.c | 4 | ||||
-rw-r--r-- | net/netconsole.c | 2 |
7 files changed, 19 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; @@ -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; @@ -384,6 +384,8 @@ int eth_register(struct eth_device *edev) dev_add_param_ip(dev, "netmask", NULL, NULL, &edev->netmask, edev); dev_add_param_mac(dev, "ethaddr", eth_param_set_ethaddr, NULL, edev->ethaddr, edev); + edev->bootarg = xstrdup(""); + dev_add_param_string(dev, "linux.bootargs", NULL, NULL, &edev->bootarg, NULL); if (edev->init) edev->init(edev); diff --git a/net/ifup.c b/net/ifup.c index 30ac3f5861..5113d13832 100644 --- a/net/ifup.c +++ b/net/ifup.c @@ -106,12 +106,21 @@ int ifup(const char *name, unsigned flags) ret = eth_set_param(dev, "serverip"); if (ret) goto out; + dev_set_param(dev, "linux.bootargs", "ip=dhcp"); } else if (!strcmp(ip, "static")) { + char *bootarg; for (i = 0; i < ARRAY_SIZE(vars); i++) { ret = eth_set_param(dev, vars[i]); if (ret) goto out; } + bootarg = basprintf("ip=%pI4:%pI4:%pI4:%pI4:::", + &edev->ipaddr, + &edev->serverip, + &edev->gateway, + &edev->netmask); + dev_set_param(dev, "linux.bootargs", bootarg); + free(bootarg); } else { pr_err("unknown ip type: %s\n", ip); ret = -EINVAL; @@ -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; @@ -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; } |