"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: lwip: Use ipaddr helpers

The ip_addr_t of lwIP has support for both IPv6 and IPv4 addresses.
Some lwIP commans is directly accessing the internal addr field of the
ip_addr_t instead of using ipaddr helper functions.

Change to use ipaddr helper functions where appropriate to remove direct
access of the internal addr field. Also change a few instances from ip4
to the version less ipaddr helpers.

There is no intended functional change, besides the change from using
ip4 addr helper to using version less ipaddr helper.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>

authored by

Jonas Karlman and committed by
Jerome Forissier
8d89b16e 3299bffc

+10 -13
+1 -1
cmd/lwip/ping.c
··· 35 35 struct ping_ctx *ctx = arg; 36 36 struct icmp_echo_hdr *iecho = ctx->iecho; 37 37 38 - if (addr->addr != ctx->target.addr) 38 + if (!ip_addr_eq(addr, &ctx->target)) 39 39 return 0; 40 40 41 41 if ((p->tot_len >= (IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
+2 -2
net/lwip/dhcp.c
··· 93 93 sprintf(maskstr, "netmask%d", idx); 94 94 sprintf(gwstr, "gatewayip%d", idx); 95 95 } else { 96 - net_ip.s_addr = dhcp->offered_ip_addr.addr; 96 + net_ip.s_addr = ip_addr_get_ip4_u32(&dhcp->offered_ip_addr); 97 97 } 98 98 99 99 env_set(ipstr, ip4addr_ntoa(&dhcp->offered_ip_addr)); 100 100 env_set(maskstr, ip4addr_ntoa(&dhcp->offered_sn_mask)); 101 101 env_set("serverip", ip4addr_ntoa(&dhcp->server_ip_addr)); 102 - if (dhcp->offered_gw_addr.addr != 0) 102 + if (!ip4_addr_isany(&dhcp->offered_gw_addr)) 103 103 env_set(gwstr, ip4addr_ntoa(&dhcp->offered_gw_addr)); 104 104 105 105 #ifdef CONFIG_PROT_DNS_LWIP
+3 -6
net/lwip/dns.c
··· 28 28 29 29 dns_cb_arg->done = true; 30 30 31 - if (!ipaddr) { 31 + if (!ipaddr) 32 32 printf("DNS: host not found\n"); 33 - dns_cb_arg->host_ipaddr.addr = 0; 34 - return; 35 - } 36 33 37 - dns_cb_arg->host_ipaddr.addr = ipaddr->addr; 34 + ip_addr_set(&dns_cb_arg->host_ipaddr, ipaddr); 38 35 } 39 36 40 37 static int dns_loop(struct udevice *udev, const char *name, const char *var) ··· 78 75 79 76 net_lwip_remove_netif(netif); 80 77 81 - if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) { 78 + if (dns_cb_arg.done && !ip_addr_isany(&dns_cb_arg.host_ipaddr)) { 82 79 ipstr = ipaddr_ntoa(&dns_cb_arg.host_ipaddr); 83 80 if (var) 84 81 env_set(var, ipstr);
+3 -3
net/lwip/nfs.c
··· 59 59 int plen; 60 60 struct rpc_t rpc_pkt; 61 61 62 - if (addr->addr != ctx->nfs_server.addr) 62 + if (!ip_addr_eq(addr, &ctx->nfs_server)) 63 63 goto exitfree; 64 64 65 65 if (p->tot_len > sizeof(struct rpc_t)) ··· 120 120 printf("Using %s device\n", udev->name); 121 121 122 122 printf("File transfer via NFS from server %s; our IP address is %s\n", 123 - ip4addr_ntoa(&srvip), env_get("ipaddr")); 123 + ipaddr_ntoa(&srvip), env_get("ipaddr")); 124 124 125 125 printf("\nFilename '%s/%s'.", nfs_path, nfs_filename); 126 126 ··· 144 144 145 145 net_set_state(NETLOOP_CONTINUE); 146 146 147 - sess_ctx.nfs_server.addr = srvip.addr; 147 + ip_addr_set(&sess_ctx.nfs_server, &srvip); 148 148 149 149 nfs_send(); 150 150
+1 -1
net/lwip/tftp.c
··· 180 180 181 181 printf("Using %s device\n", udev->name); 182 182 printf("TFTP from server %s; our IP address is %s\n", 183 - ip4addr_ntoa(&srvip), env_get("ipaddr")); 183 + ipaddr_ntoa(&srvip), env_get("ipaddr")); 184 184 printf("Filename '%s'.\n", fname); 185 185 printf("Load address: 0x%lx\n", ctx.daddr); 186 186 printf("Loading: ");