Networking: Replace all references to the macros net_ipaddr_copy, net_ipaddr_hdrcopy, net_ipaddr_cmp, net_ipaddr_hdrcmp, and net_ipaddr_maskcmp with the appropriate IPv4 or IPv6 version of the macro (such as net_ipv4addr_copy). The goal is to support both IPv4 and IPv6 simultaneously. This requires that the macros be distinct and not conditionally defined to one on or the other.

This commit is contained in:
Gregory Nutt 2015-01-16 13:01:08 -06:00
parent 27c95e7775
commit 2663538b0a
15 changed files with 95 additions and 102 deletions

View File

@ -105,7 +105,7 @@ union ip_addr_u
#endif #endif
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
/* IPv6 addresse */ /* IPv6 address */
net_ipv6addr_t ipv6; net_ipv6addr_t ipv6;
#endif #endif
@ -156,7 +156,7 @@ struct net_iphdr_s
uint16_t srcipaddr[2]; /* 32-bit Source IP address */ uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */ uint16_t destipaddr[2]; /* 32-bit Destination IP address */
}; };
#endif #endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
/* The IPv6 header */ /* The IPv6 header */
@ -172,7 +172,7 @@ struct net_ipv6hdr_s
net_ipv6addr_t srcipaddr; /* 128-bit Source address */ net_ipv6addr_t srcipaddr; /* 128-bit Source address */
net_ipv6addr_t destipaddr; /* 128-bit Destination address */ net_ipv6addr_t destipaddr; /* 128-bit Destination address */
}; };
#endif #endif /* CONFIG_NET_IPv6 */
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
@ -258,26 +258,24 @@ struct net_ipv6hdr_s
* src The source from where to copy. * src The source from where to copy.
*/ */
#define net_ipv4addr_copy(dest, src) \ #ifdef CONFIG_NET_IPv4
# define net_ipv4addr_copy(dest, src) \
do { \ do { \
(dest) = (in_addr_t)(src); \ (dest) = (in_addr_t)(src); \
} while (0) } while (0)
#define net_ipv4addr_hdrcopy(dest, src) \ # define net_ipv4addr_hdrcopy(dest, src) \
do { \ do { \
((uint16_t*)(dest))[0] = ((uint16_t*)(src))[0]; \ ((uint16_t*)(dest))[0] = ((uint16_t*)(src))[0]; \
((uint16_t*)(dest))[1] = ((uint16_t*)(src))[1]; \ ((uint16_t*)(dest))[1] = ((uint16_t*)(src))[1]; \
} while (0) } while (0)
#endif
#define net_ipv6addr_copy(dest, src) memcpy(&dest, &src, sizeof(net_ipv6addr_t)) #ifdef CONFIG_NET_IPv6
#define net_ipv6addr_hdrcopy(dest, src) net_ipv6addr_copy(dest, src) # define net_ipv6addr_copy(dest,src) \
memcpy(&dest, &src, sizeof(net_ipv6addr_t))
#ifndef CONFIG_NET_IPv6 # define net_ipv6addr_hdrcopy(dest,src) \
# define net_ipaddr_copy(dest, src) net_ipv4addr_copy(dest, src) net_ipv6addr_copy(dest, src)
# define net_ipaddr_hdrcopy(dest, src) net_ipv4addr_hdrcopy(dest, src) #endif
#else /* !CONFIG_NET_IPv6 */
# define net_ipaddr_copy(dest, src) net_ipv6addr_copy(dest, src)
# define net_ipaddr_hdrcopy(dest, src) net_ipv6addr_hdrcopy(dest, src)
#endif /* !CONFIG_NET_IPv6 */
/* Compare two IP addresses /* Compare two IP addresses
* *
@ -286,7 +284,7 @@ struct net_ipv6hdr_s
* in_addr_t ipaddr1, ipaddr2; * in_addr_t ipaddr1, ipaddr2;
* *
* net_ipaddr(&ipaddr1, 192,16,1,2); * net_ipaddr(&ipaddr1, 192,16,1,2);
* if (net_ipaddr_cmp(ipaddr2, ipaddr1)) * if (net_ipv4addr_cmp(ipaddr2, ipaddr1))
* { * {
* printf("They are the same"); * printf("They are the same");
* } * }
@ -295,22 +293,18 @@ struct net_ipv6hdr_s
* addr2 The second IP address. * addr2 The second IP address.
*/ */
#define net_ipv4addr_cmp(addr1, addr2) \ #ifdef CONFIG_NET_IPv4
# define net_ipv4addr_cmp(addr1, addr2) \
(addr1 == addr2) (addr1 == addr2)
#define net_ipv4addr_hdrcmp(addr1, addr2) \ # define net_ipv4addr_hdrcmp(addr1, addr2) \
net_ipv4addr_cmp(net_ip4addr_conv32(addr1), net_ip4addr_conv32(addr2)) net_ipv4addr_cmp(net_ip4addr_conv32(addr1), net_ip4addr_conv32(addr2))
#endif
#define net_ipv6addr_cmp(addr1, addr2) \ #ifdef CONFIG_NET_IPv4
(memcmp(&addr1, &addr2, sizeof(net_ipv6addr_t)) == 0) # define net_ipv6addr_cmp(addr1, addr2) \
#define net_ipv6addr_hdrcmp(addr1, addr2) \ (memcmp(&addr1, &addr2, sizeof(net_ipv6addr_t)) == 0)
net_ipv6addr_cmp(addr1, addr2) # define net_ipv6addr_hdrcmp(addr1, addr2) \
net_ipv6addr_cmp(addr1, addr2)
#if defined(CONFIG_NET_IPv4)
# define net_ipaddr_cmp(addr1, addr2) net_ipv4addr_cmp(addr1, addr2)
# define net_ipaddr_hdrcmp(addr1, addr2) net_ipv4addr_hdrcmp(addr1, addr2)
#elif defined(CONFIG_NET_IPv6)
# define net_ipaddr_cmp(addr1, addr2) net_ipv6addr_cmp(addr1, addr2)
# define net_ipaddr_hdrcmp(addr1, addr2) net_ipv6addr_hdrcmp(addr1, addr2)
#endif #endif
/* Compare two IP addresses under a netmask. The mask is used to mask /* Compare two IP addresses under a netmask. The mask is used to mask
@ -326,7 +320,7 @@ struct net_ipv6hdr_s
* net_ipaddr(&mask, 255,255,255,0); * net_ipaddr(&mask, 255,255,255,0);
* net_ipaddr(&ipaddr1, 192,16,1,2); * net_ipaddr(&ipaddr1, 192,16,1,2);
* net_ipaddr(&ipaddr2, 192,16,1,3); * net_ipaddr(&ipaddr2, 192,16,1,3);
* if (net_ipaddr_maskcmp(ipaddr1, ipaddr2, &mask)) * if (net_ipv4addr_maskcmp(ipaddr1, ipaddr2, &mask))
* { * {
* printf("They are the same"); * printf("They are the same");
* } * }
@ -336,19 +330,16 @@ struct net_ipv6hdr_s
* mask The netmask. * mask The netmask.
*/ */
#define net_ipv4addr_maskcmp(addr1, addr2, mask) \ #ifdef CONFIG_NET_IPv4
(((in_addr_t)(addr1) & (in_addr_t)(mask)) == \ # define net_ipv4addr_maskcmp(addr1, addr2, mask) \
((in_addr_t)(addr2) & (in_addr_t)(mask))) (((in_addr_t)(addr1) & (in_addr_t)(mask)) == \
((in_addr_t)(addr2) & (in_addr_t)(mask)))
#endif
#ifndef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
# define net_ipaddr_maskcmp(a,b,m) net_ipv4addr_maskcmp(a,b,m)
#else
bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1, bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
const net_ipv6addr_t addr2, const net_ipv6addr_t addr2,
const net_ipv6addr_t mask); const net_ipv6addr_t mask);
# define net_ipaddr_maskcmp(a,b,m) net_ipv6addr_maskcmp(a,b,m)
#endif #endif
/* Mask out the network part of an IP address, given the address and /* Mask out the network part of an IP address, given the address and

View File

@ -251,7 +251,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
{ {
/* Initialize the non-zero elements of the group structure */ /* Initialize the non-zero elements of the group structure */
net_ipaddr_copy(group->grpaddr, *addr); net_ipv4addr_copy(group->grpaddr, *addr);
sem_init(&group->sem, 0, 0); sem_init(&group->sem, 0, 0);
/* Initialize the group timer (but don't start it yet) */ /* Initialize the group timer (but don't start it yet) */
@ -301,7 +301,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
group = group->next) group = group->next)
{ {
grplldbg("Compare: %08x vs. %08x\n", group->grpaddr, *addr); grplldbg("Compare: %08x vs. %08x\n", group->grpaddr, *addr);
if (net_ipaddr_cmp(group->grpaddr, *addr)) if (net_ipv4addr_cmp(group->grpaddr, *addr))
{ {
grplldbg("Match!\n"); grplldbg("Match!\n");
break; break;

View File

@ -165,7 +165,7 @@ void igmp_input(struct net_driver_s *dev)
/* Check if the query was sent to all systems */ /* Check if the query was sent to all systems */
if (net_ipaddr_cmp(destipaddr, g_ipv4_allsystems)) if (net_ipv4addr_cmp(destipaddr, g_ipv4_allsystems))
{ {
/* Yes... Now check the if this this is a general or a group /* Yes... Now check the if this this is a general or a group
* specific query. * specific query.
@ -206,7 +206,7 @@ void igmp_input(struct net_driver_s *dev)
{ {
/* Skip over the all systems group entry */ /* Skip over the all systems group entry */
if (!net_ipaddr_cmp(member->grpaddr, g_ipv4_allsystems)) if (!net_ipv4addr_cmp(member->grpaddr, g_ipv4_allsystems))
{ {
ticks = net_dsec2tick((int)IGMPBUF->maxresp); ticks = net_dsec2tick((int)IGMPBUF->maxresp);
if (IS_IDLEMEMBER(member->flags) || if (IS_IDLEMEMBER(member->flags) ||

View File

@ -155,8 +155,8 @@ void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
IGMPBUF->ttl = IGMP_TTL; IGMPBUF->ttl = IGMP_TTL;
IGMPBUF->proto = IP_PROTO_IGMP; IGMPBUF->proto = IP_PROTO_IGMP;
net_ipaddr_hdrcopy(IGMPBUF->srcipaddr, &dev->d_ipaddr); net_ipv4addr_hdrcopy(IGMPBUF->srcipaddr, &dev->d_ipaddr);
net_ipaddr_hdrcopy(IGMPBUF->destipaddr, destipaddr); net_ipv4addr_hdrcopy(IGMPBUF->destipaddr, destipaddr);
/* Calculate IP checksum. */ /* Calculate IP checksum. */
@ -167,7 +167,7 @@ void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
IGMPBUF->type = group->msgid; IGMPBUF->type = group->msgid;
IGMPBUF->maxresp = 0; IGMPBUF->maxresp = 0;
net_ipaddr_hdrcopy(IGMPBUF->grpaddr, &group->grpaddr); net_ipv4addr_hdrcopy(IGMPBUF->grpaddr, &group->grpaddr);
/* Calculate the IGMP checksum. */ /* Calculate the IGMP checksum. */

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* net/netdev/netdev_findbyaddr.c * net/netdev/netdev_findbyaddr.c
* *
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -107,7 +107,8 @@ static FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr)
{ {
/* Yes.. check for an address match (under the netmask) */ /* Yes.. check for an address match (under the netmask) */
if (net_ipaddr_maskcmp(dev->d_ipaddr, ripaddr, dev->d_netmask)) if (net_ipv4addr_maskcmp(dev->d_ipaddr, ripaddr,
dev->d_netmask))
{ {
/* Its a match */ /* Its a match */
@ -160,7 +161,8 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
{ {
/* Yes.. check for an address match (under the netmask) */ /* Yes.. check for an address match (under the netmask) */
if (net_ipaddr_maskcmp(dev->d_ipv6addr, ripaddr, dev->d_ipv6netmask)) if (net_ipv6addr_maskcmp(dev->d_ipv6addr, ripaddr,
dev->d_ipv6netmask))
{ {
/* Its a match */ /* Its a match */

View File

@ -94,9 +94,9 @@ int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router)
/* Format the new route table entry */ /* Format the new route table entry */
net_ipaddr_copy(route->target, target); net_ipv4addr_copy(route->target, target);
net_ipaddr_copy(route->netmask, netmask); net_ipv4addr_copy(route->netmask, netmask);
net_ipaddr_copy(route->router, router); net_ipv4addr_copy(route->router, router);
/* Get exclusive address to the networking data structures */ /* Get exclusive address to the networking data structures */

View File

@ -87,8 +87,8 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
* must be the same. * must be the same.
*/ */
if (net_ipaddr_maskcmp(route->target, match->target, match->netmask) && if (net_ipv4addr_maskcmp(route->target, match->target, match->netmask) &&
net_ipaddr_cmp(route->netmask, match->netmask)) net_ipv4addr_cmp(route->netmask, match->netmask))
{ {
/* They match.. Remove the entry from the routing table */ /* They match.. Remove the entry from the routing table */
@ -141,8 +141,8 @@ int net_delroute(in_addr_t target, in_addr_t netmask)
/* Set up the comparison structure */ /* Set up the comparison structure */
match.prev = NULL; match.prev = NULL;
net_ipaddr_copy(match.target, target); net_ipv4addr_copy(match.target, target);
net_ipaddr_copy(match.netmask, netmask); net_ipv4addr_copy(match.netmask, netmask);
/* Then remove the entry from the routing table */ /* Then remove the entry from the routing table */

View File

@ -103,7 +103,7 @@ static int net_ipv4_match(FAR struct net_route_s *route, FAR void *arg)
{ {
/* They match.. Copy the router address */ /* They match.. Copy the router address */
net_ipaddr_copy(match->router, route->router); net_ipv4addr_copy(match->router, route->router);
return 1; return 1;
} }
@ -143,7 +143,7 @@ static int net_ipv6_match(FAR struct net_route_s *route, FAR void *arg)
{ {
/* They match.. Copy the router address */ /* They match.. Copy the router address */
net_ipaddr_copy(match->router, route->router); net_ipv6addr_copy(match->router, route->router);
return 1; return 1;
} }
#endif #endif
@ -181,7 +181,7 @@ int net_ipv4_router(in_addr_t target, FAR in_addr_t *router)
/* Do not route the special broadcast IP address */ /* Do not route the special broadcast IP address */
if (net_ipaddr_cmp(target, g_ipv4_alloneaddr)) if (net_ipv4addr_cmp(target, g_ipv4_alloneaddr))
{ {
return -ENOENT; return -ENOENT;
} }
@ -189,7 +189,7 @@ int net_ipv4_router(in_addr_t target, FAR in_addr_t *router)
/* Set up the comparison structure */ /* Set up the comparison structure */
memset(&match, 0, sizeof(struct route_ipv4_match_s)); memset(&match, 0, sizeof(struct route_ipv4_match_s));
net_ipaddr_copy(match.target, target); net_ipv4addr_copy(match.target, target);
/* Find an router entry with the routing table that can forward to this /* Find an router entry with the routing table that can forward to this
* address * address
@ -239,7 +239,7 @@ int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router)
/* Do not route the special broadcast IP address */ /* Do not route the special broadcast IP address */
if (net_ipaddr_cmp(target, g_ipv6_alloneaddr)) if (net_ipv6addr_cmp(target, g_ipv6_alloneaddr))
{ {
return -ENOENT; return -ENOENT;
} }
@ -247,7 +247,7 @@ int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router)
/* Set up the comparison structure */ /* Set up the comparison structure */
memset(&match, 0, sizeof(struct route_ipv6_match_s)); memset(&match, 0, sizeof(struct route_ipv6_match_s));
net_ipaddr_copy(match.target, target); net_ipv6addr_copy(match.target, target);
/* Find an router entry with the routing table that can forward to this /* Find an router entry with the routing table that can forward to this
* address * address

View File

@ -190,7 +190,7 @@ void netdev_ipv4_router(FAR struct net_driver_s *dev, in_addr_t target,
memset(&match, 0, sizeof(struct route_ipv4_devmatch_s)); memset(&match, 0, sizeof(struct route_ipv4_devmatch_s));
match.dev = dev; match.dev = dev;
net_ipaddr_copy(match.target, target); net_ipv4addr_copy(match.target, target);
/* Find an router entry with the routing table that can forward to this /* Find an router entry with the routing table that can forward to this
* address using this device. * address using this device.
@ -247,7 +247,7 @@ void netdev_ipv6_router(FAR struct net_driver_s *dev,
memset(&match, 0, sizeof(struct route_ipv6_devmatch_s)); memset(&match, 0, sizeof(struct route_ipv6_devmatch_s));
match.dev = dev; match.dev = dev;
net_ipaddr_copy(match.target, target); net_ipv6addr_copy(match.target, target);
/* Find an router entry with the routing table that can forward to this /* Find an router entry with the routing table that can forward to this
* address using this device. * address using this device.

View File

@ -104,18 +104,7 @@ struct accept_s
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NET_TCP #ifdef CONFIG_NET_TCP
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv4
static inline void accept_tcpsender(FAR struct tcp_conn_s *conn,
FAR struct sockaddr_in6 *addr)
{
if (addr)
{
addr->sin_family = AF_INET6;
addr->sin_port = conn->rport;
net_ipaddr_copy(addr->sin6_addr.s6_addr, conn->u.ipv4.raddr);
}
}
#else
static inline void accept_tcpsender(FAR struct tcp_conn_s *conn, static inline void accept_tcpsender(FAR struct tcp_conn_s *conn,
FAR struct sockaddr_in *addr) FAR struct sockaddr_in *addr)
{ {
@ -123,10 +112,21 @@ static inline void accept_tcpsender(FAR struct tcp_conn_s *conn,
{ {
addr->sin_family = AF_INET; addr->sin_family = AF_INET;
addr->sin_port = conn->rport; addr->sin_port = conn->rport;
net_ipaddr_copy(addr->sin_addr.s_addr, conn->u.ipv4.raddr); net_ipv4addr_copy(addr->sin_addr.s_addr, conn->u.ipv4.raddr);
} }
} }
#endif /* CONFIG_NET_IPv6 */ #else
static inline void accept_tcpsender(FAR struct tcp_conn_s *conn,
FAR struct sockaddr_in6 *addr)
{
if (addr)
{
addr->sin_family = AF_INET6;
addr->sin_port = conn->rport;
net_ipv6addr_copy(addr->sin6_addr.s6_addr, conn->u.ipv4.raddr);
}
}
#endif /* CONFIG_NET_IPv4 */
#endif /* CONFIG_NET_TCP */ #endif /* CONFIG_NET_TCP */
/**************************************************************************** /****************************************************************************

View File

@ -584,10 +584,10 @@ static inline void recvfrom_tcpsender(FAR struct net_driver_s *dev,
infrom->sin_port = TCPBUF->srcport; infrom->sin_port = TCPBUF->srcport;
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
net_ipaddr_copy(infrom->sin6_addr.s6_addr, TCPBUF->srcipaddr); net_ipv6addr_copy(infrom->sin6_addr.s6_addr, TCPBUF->srcipaddr);
#else #else
net_ipaddr_copy(infrom->sin_addr.s_addr, net_ipv4addr_copy(infrom->sin_addr.s_addr,
net_ip4addr_conv32(TCPBUF->srcipaddr)); net_ip4addr_conv32(TCPBUF->srcipaddr));
#endif #endif
} }
} }
@ -831,10 +831,10 @@ static inline void recvfrom_udpsender(struct net_driver_s *dev, struct recvfrom_
infrom->sin_port = UDPBUF->srcport; infrom->sin_port = UDPBUF->srcport;
#ifdef CONFIG_NET_IPv6 #ifdef CONFIG_NET_IPv6
net_ipaddr_copy(infrom->sin6_addr.s6_addr, UDPBUF->srcipaddr); net_ipv6addr_copy(infrom->sin6_addr.s6_addr, UDPBUF->srcipaddr);
#else #else
net_ipaddr_copy(infrom->sin_addr.s_addr, net_ipv4addr_copy(infrom->sin_addr.s_addr,
net_ip4addr_conv32(UDPBUF->srcipaddr)); net_ip4addr_conv32(UDPBUF->srcipaddr));
#endif #endif
} }
} }

View File

@ -524,10 +524,10 @@ FAR struct tcp_conn_s *tcp_active(FAR struct net_driver_s *dev,
tcp->destport == conn->lport && tcp->destport == conn->lport &&
tcp->srcport == conn->rport && tcp->srcport == conn->rport &&
#ifdef CONFIG_NETDEV_MULTINIC #ifdef CONFIG_NETDEV_MULTINIC
(net_ipaddr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr) || (net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr) ||
net_ipaddr_cmp(destipaddr, conn->u.ipv4.laddr)) && net_ipv4addr_cmp(destipaddr, conn->u.ipv4.laddr)) &&
#endif #endif
net_ipaddr_cmp(srcipaddr, conn->u.ipv4.raddr)) net_ipv4addr_cmp(srcipaddr, conn->u.ipv4.raddr))
{ {
/* Matching connection found.. break out of the loop and return a /* Matching connection found.. break out of the loop and return a
* reference to it. * reference to it.
@ -600,9 +600,9 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev,
conn->lport = tcp->destport; conn->lport = tcp->destport;
conn->rport = tcp->srcport; conn->rport = tcp->srcport;
conn->mss = TCP_INITIAL_MSS(dev); conn->mss = TCP_INITIAL_MSS(dev);
net_ipaddr_copy(conn->u.ipv4.raddr, net_ip4addr_conv32(ip->srcipaddr)); net_ipv4addr_copy(conn->u.ipv4.raddr, net_ip4addr_conv32(ip->srcipaddr));
#ifdef CONFIG_NETDEV_MULTINIC #ifdef CONFIG_NETDEV_MULTINIC
net_ipaddr_copy(conn->u.ipv4.laddr, net_ip4addr_conv32(ip->destipaddr)); net_ipv4addr_copy(conn->u.ipv4.laddr, net_ip4addr_conv32(ip->destipaddr));
#endif #endif
conn->tcpstateflags = TCP_SYN_RCVD; conn->tcpstateflags = TCP_SYN_RCVD;
@ -706,7 +706,7 @@ int tcp_bind(FAR struct tcp_conn_s *conn,
conn->lport = addr->sin_port; conn->lport = addr->sin_port;
#ifdef CONFIG_NETDEV_MULTINIC #ifdef CONFIG_NETDEV_MULTINIC
net_ipaddr_copy(conn->u.ipv4.laddr, ipaddr); net_ipv4addr_copy(conn->u.ipv4.laddr, ipaddr);
#endif #endif
return OK; return OK;
@ -800,7 +800,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn,
/* The sockaddr address is 32-bits in network order. */ /* The sockaddr address is 32-bits in network order. */
net_ipaddr_copy(conn->u.ipv4.raddr, addr->sin_addr.s_addr); net_ipv4addr_copy(conn->u.ipv4.raddr, addr->sin_addr.s_addr);
#ifdef CONFIG_NET_TCP_READAHEAD #ifdef CONFIG_NET_TCP_READAHEAD
/* Initialize the list of TCP read-ahead buffers */ /* Initialize the list of TCP read-ahead buffers */

View File

@ -187,8 +187,8 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
pbuf->srcport = conn->lport; pbuf->srcport = conn->lport;
pbuf->destport = conn->rport; pbuf->destport = conn->rport;
net_ipaddr_hdrcopy(pbuf->srcipaddr, &dev->d_ipaddr); net_ipv4addr_hdrcopy(pbuf->srcipaddr, &dev->d_ipaddr);
net_ipaddr_hdrcopy(pbuf->destipaddr, &conn->u.ipv4.raddr); net_ipv4addr_hdrcopy(pbuf->destipaddr, &conn->u.ipv4.raddr);
if (conn->tcpstateflags & TCP_STOPPED) if (conn->tcpstateflags & TCP_STOPPED)
{ {
@ -320,8 +320,8 @@ void tcp_reset(FAR struct net_driver_s *dev)
/* Swap IP addresses. */ /* Swap IP addresses. */
net_ipaddr_hdrcopy(pbuf->destipaddr, pbuf->srcipaddr); net_ipv4addr_hdrcopy(pbuf->destipaddr, pbuf->srcipaddr);
net_ipaddr_hdrcopy(pbuf->srcipaddr, &dev->d_ipaddr); net_ipv4addr_hdrcopy(pbuf->srcipaddr, &dev->d_ipaddr);
/* And send out the RST packet */ /* And send out the RST packet */

View File

@ -466,7 +466,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
* for receiving (Sending will use the default port). * for receiving (Sending will use the default port).
*/ */
net_ipaddr_copy(conn->u.ipv4.laddr, ipaddr); net_ipv4addr_copy(conn->u.ipv4.laddr, ipaddr);
#endif #endif
/* Is the user requesting to bind to any port? */ /* Is the user requesting to bind to any port? */
@ -563,7 +563,7 @@ int udp_connect(FAR struct udp_conn_s *conn,
if (addr) if (addr)
{ {
conn->rport = addr->sin_port; conn->rport = addr->sin_port;
net_ipaddr_copy(conn->u.ipv4.raddr, addr->sin_addr.s_addr); net_ipv4addr_copy(conn->u.ipv4.raddr, addr->sin_addr.s_addr);
} }
else else
{ {

View File

@ -125,8 +125,8 @@ void udp_send(struct net_driver_s *dev, struct udp_conn_s *conn)
pudpbuf->proto = IP_PROTO_UDP; pudpbuf->proto = IP_PROTO_UDP;
pudpbuf->ttl = conn->ttl; pudpbuf->ttl = conn->ttl;
net_ipaddr_copy(pudpbuf->srcipaddr, &dev->d_ipaddr); net_ipv6addr_copy(pudpbuf->srcipaddr, &dev->d_ipaddr);
net_ipaddr_copy(pudpbuf->destipaddr, &conn->u.ipv4.raddr); net_ipav6ddr_copy(pudpbuf->destipaddr, &conn->u.ipv4.raddr);
#else /* CONFIG_NET_IPv6 */ #else /* CONFIG_NET_IPv6 */
@ -142,8 +142,8 @@ void udp_send(struct net_driver_s *dev, struct udp_conn_s *conn)
pudpbuf->ttl = conn->ttl; pudpbuf->ttl = conn->ttl;
pudpbuf->proto = IP_PROTO_UDP; pudpbuf->proto = IP_PROTO_UDP;
net_ipaddr_hdrcopy(pudpbuf->srcipaddr, &dev->d_ipaddr); net_ipv4addr_hdrcopy(pudpbuf->srcipaddr, &dev->d_ipaddr);
net_ipaddr_hdrcopy(pudpbuf->destipaddr, &conn->u.ipv4.raddr); net_ipv4addr_hdrcopy(pudpbuf->destipaddr, &conn->u.ipv4.raddr);
/* Calculate IP checksum. */ /* Calculate IP checksum. */