mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-02-27 02:51:27 +01:00
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>
This commit is contained in:
parent
3299bffc7c
commit
8d89b16ea4
@ -35,7 +35,7 @@ static u8_t ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p,
|
||||
struct ping_ctx *ctx = arg;
|
||||
struct icmp_echo_hdr *iecho = ctx->iecho;
|
||||
|
||||
if (addr->addr != ctx->target.addr)
|
||||
if (!ip_addr_eq(addr, &ctx->target))
|
||||
return 0;
|
||||
|
||||
if ((p->tot_len >= (IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
|
||||
|
||||
@ -93,13 +93,13 @@ static int dhcp_loop(struct udevice *udev)
|
||||
sprintf(maskstr, "netmask%d", idx);
|
||||
sprintf(gwstr, "gatewayip%d", idx);
|
||||
} else {
|
||||
net_ip.s_addr = dhcp->offered_ip_addr.addr;
|
||||
net_ip.s_addr = ip_addr_get_ip4_u32(&dhcp->offered_ip_addr);
|
||||
}
|
||||
|
||||
env_set(ipstr, ip4addr_ntoa(&dhcp->offered_ip_addr));
|
||||
env_set(maskstr, ip4addr_ntoa(&dhcp->offered_sn_mask));
|
||||
env_set("serverip", ip4addr_ntoa(&dhcp->server_ip_addr));
|
||||
if (dhcp->offered_gw_addr.addr != 0)
|
||||
if (!ip4_addr_isany(&dhcp->offered_gw_addr))
|
||||
env_set(gwstr, ip4addr_ntoa(&dhcp->offered_gw_addr));
|
||||
|
||||
#ifdef CONFIG_PROT_DNS_LWIP
|
||||
|
||||
@ -28,13 +28,10 @@ static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
|
||||
|
||||
dns_cb_arg->done = true;
|
||||
|
||||
if (!ipaddr) {
|
||||
if (!ipaddr)
|
||||
printf("DNS: host not found\n");
|
||||
dns_cb_arg->host_ipaddr.addr = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
|
||||
ip_addr_set(&dns_cb_arg->host_ipaddr, ipaddr);
|
||||
}
|
||||
|
||||
static int dns_loop(struct udevice *udev, const char *name, const char *var)
|
||||
@ -78,7 +75,7 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
|
||||
|
||||
net_lwip_remove_netif(netif);
|
||||
|
||||
if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
|
||||
if (dns_cb_arg.done && !ip_addr_isany(&dns_cb_arg.host_ipaddr)) {
|
||||
ipstr = ipaddr_ntoa(&dns_cb_arg.host_ipaddr);
|
||||
if (var)
|
||||
env_set(var, ipstr);
|
||||
|
||||
@ -59,7 +59,7 @@ static void nfs_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
int plen;
|
||||
struct rpc_t rpc_pkt;
|
||||
|
||||
if (addr->addr != ctx->nfs_server.addr)
|
||||
if (!ip_addr_eq(addr, &ctx->nfs_server))
|
||||
goto exitfree;
|
||||
|
||||
if (p->tot_len > sizeof(struct rpc_t))
|
||||
@ -120,7 +120,7 @@ static int nfs_loop(struct udevice *udev, ulong addr, char *fname,
|
||||
printf("Using %s device\n", udev->name);
|
||||
|
||||
printf("File transfer via NFS from server %s; our IP address is %s\n",
|
||||
ip4addr_ntoa(&srvip), env_get("ipaddr"));
|
||||
ipaddr_ntoa(&srvip), env_get("ipaddr"));
|
||||
|
||||
printf("\nFilename '%s/%s'.", nfs_path, nfs_filename);
|
||||
|
||||
@ -144,7 +144,7 @@ static int nfs_loop(struct udevice *udev, ulong addr, char *fname,
|
||||
|
||||
net_set_state(NETLOOP_CONTINUE);
|
||||
|
||||
sess_ctx.nfs_server.addr = srvip.addr;
|
||||
ip_addr_set(&sess_ctx.nfs_server, &srvip);
|
||||
|
||||
nfs_send();
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ static int tftp_loop(struct udevice *udev, ulong addr, char *fname,
|
||||
|
||||
printf("Using %s device\n", udev->name);
|
||||
printf("TFTP from server %s; our IP address is %s\n",
|
||||
ip4addr_ntoa(&srvip), env_get("ipaddr"));
|
||||
ipaddr_ntoa(&srvip), env_get("ipaddr"));
|
||||
printf("Filename '%s'.\n", fname);
|
||||
printf("Load address: 0x%lx\n", ctx.daddr);
|
||||
printf("Loading: ");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user