mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
net/: Fix a sixlowpan typo bug recently introduced; Rename g_ipv6_allzeroaddre with the more meaning g_ipv6_unspecaddr since the all-zero address is the IPv6 unspecified address (sometime IN6_ADDR_ANY). Remove more inline tests for IPv6 multicast with tcommint net_is_addr_mcast() macro. Update some comments.
This commit is contained in:
+3
-3
@@ -879,7 +879,7 @@ static void w25_cacheflush(struct w25_dev_s *priv)
|
|||||||
/* Write entire erase block to FLASH */
|
/* Write entire erase block to FLASH */
|
||||||
|
|
||||||
w25_pagewrite(priv, priv->sector, (off_t)priv->esectno << W25_SECTOR_SHIFT,
|
w25_pagewrite(priv, priv->sector, (off_t)priv->esectno << W25_SECTOR_SHIFT,
|
||||||
W25_SECTOR_SIZE);
|
W25_SECTOR_SIZE);
|
||||||
|
|
||||||
/* The case is no long dirty and the FLASH is no longer erased */
|
/* The case is no long dirty and the FLASH is no longer erased */
|
||||||
|
|
||||||
@@ -905,8 +905,8 @@ static FAR uint8_t *w25_cacheread(struct w25_dev_s *priv, off_t sector)
|
|||||||
* shift to the right by 3 to get the sector number in 4096 increments.
|
* shift to the right by 3 to get the sector number in 4096 increments.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
shift = W25_SECTOR_SHIFT - W25_SECTOR512_SHIFT;
|
shift = W25_SECTOR_SHIFT - W25_SECTOR512_SHIFT;
|
||||||
esectno = sector >> shift;
|
esectno = sector >> shift;
|
||||||
finfo("sector: %ld esectno: %d shift=%d\n", sector, esectno, shift);
|
finfo("sector: %ld esectno: %d shift=%d\n", sector, esectno, shift);
|
||||||
|
|
||||||
/* Check if the requested erase block is already in the cache */
|
/* Check if the requested erase block is already in the cache */
|
||||||
|
|||||||
+25
-8
@@ -563,7 +563,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* Name: net_is_addr_loopback
|
* Name: net_is_addr_loopback
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Is Ithe Pv6 address a the loopback address?
|
* Is Ithe Pv6 address a the loopback address? See RFC 4291 (replaces
|
||||||
|
* 3513).
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -575,7 +576,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* Name: net_is_addr_unspecified
|
* Name: net_is_addr_unspecified
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Is Ithe IPv6 address the unspecified address?
|
* Is Ithe IPv6 address the unspecified address? See RFC 4291 (replaces
|
||||||
|
* 3513).
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -587,7 +589,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* Name: net_is_addr_mcast
|
* Name: net_is_addr_mcast
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Is address a multicast address? See RFC 3513:
|
* Is address a multicast address? See RFC 4291 (replaces 3513):
|
||||||
*
|
*
|
||||||
* An IPv6 multicast address is an identifier for a group of interfaces
|
* An IPv6 multicast address is an identifier for a group of interfaces
|
||||||
* (typically on different nodes). An interface may belong to any number
|
* (typically on different nodes). An interface may belong to any number
|
||||||
@@ -598,8 +600,9 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* |11111111|flgs|scop| group ID |
|
* |11111111|flgs|scop| group ID |
|
||||||
* +--------+----+----+---------------------------------------------+
|
* +--------+----+----+---------------------------------------------+
|
||||||
*
|
*
|
||||||
* binary 11111111 at the start of the address identifies the address as
|
* Bits 120-127: Prefix == 0b11111111
|
||||||
* being a multicast address.
|
* Bits 116-119: Flags (3 defined)
|
||||||
|
* Bits 112-115: Scope
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -609,7 +612,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* Name: net_is_addr_linklocal_allnodes_mcast
|
* Name: net_is_addr_linklocal_allnodes_mcast
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Is IPv6 address a the link local all-nodes multicast address?
|
* Is IPv6 address a the link local all-nodes multicast address? See RFC
|
||||||
|
* 2375
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -621,7 +625,8 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* Name: net_is_addr_linklocal_allrouters_mcast
|
* Name: net_is_addr_linklocal_allrouters_mcast
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Is IPv6 address a the link local all-routers multicast address?
|
* Is IPv6 address a the link local all-routers multicast address? See RFC
|
||||||
|
* 2375
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@@ -633,12 +638,24 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
* Name: net_is_addr_linklocal
|
* Name: net_is_addr_linklocal
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Checks whether the address a is link local.
|
* Checks whether the address 'a' is a link local unicast address. See
|
||||||
|
* RFC 4291 (replaces 3513).
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define net_is_addr_linklocal(a) ((a)[0] == HTONS(0xfe80))
|
#define net_is_addr_linklocal(a) ((a)[0] == HTONS(0xfe80))
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: net_is_addr_sitelocal
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Checks whether the address 'a' is a site local unicast address. See
|
||||||
|
* RFC 4291 (replaces 3513).
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define net_is_addr_sitelocal(a) ((a)[0] == HTONS(0xfec0))
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,12 +324,14 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
|||||||
return udp_ipv6_input(dev);
|
return udp_ipv6_input(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* In other cases, the device must be assigned a non-zero IP address. */
|
/* In other cases, the device must be assigned a non-zero IP address
|
||||||
|
* (the all zero address is the "unspecified" address.
|
||||||
|
*/
|
||||||
|
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
#ifdef CONFIG_NET_ICMPv6
|
||||||
if (net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
/* If we are configured to use ping IP address configuration and
|
/* If we are configured to use ping IP address configuration and
|
||||||
* hasn't been assigned an IP address yet, we accept all ICMP
|
* hasn't been assigned an IP address yet, we accept all ICMP
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ int icmpv6_autoconfig(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* No off-link communications; No router address. */
|
/* No off-link communications; No router address. */
|
||||||
|
|
||||||
net_ipv6addr_copy(dev->d_ipv6draddr, g_ipv6_allzeroaddr);
|
net_ipv6addr_copy(dev->d_ipv6draddr, g_ipv6_unspecaddr);
|
||||||
|
|
||||||
/* Set a netmask for the local link address */
|
/* Set a netmask for the local link address */
|
||||||
|
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)
|
|||||||
* addresses=0xff (ff00::/8.)
|
* addresses=0xff (ff00::/8.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(ipaddr, g_ipv6_allzeroaddr) ||
|
if (net_ipv6addr_cmp(ipaddr, g_ipv6_unspecaddr) ||
|
||||||
(ipaddr[0] & NTOHS(0xff00)) == NTOHS(0xff00))
|
net_is_addr_mcast(ipaddr))
|
||||||
{
|
{
|
||||||
/* We don't need to send the Neighbor Solicitation */
|
/* We don't need to send the Neighbor Solicitation */
|
||||||
|
|
||||||
@@ -222,7 +222,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)
|
|||||||
|
|
||||||
/* Get the device that can route this request */
|
/* Get the device that can route this request */
|
||||||
|
|
||||||
dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, ipaddr);
|
dev = netdev_findby_ipv6addr(g_ipv6_unspecaddr, ipaddr);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
|
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
|
||||||
|
|||||||
@@ -388,7 +388,8 @@ ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
|
|||||||
|
|
||||||
/* Get the device that will be used to route this ICMPv6 ECHO request */
|
/* Get the device that will be used to route this ICMPv6 ECHO request */
|
||||||
|
|
||||||
dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, inaddr->sin6_addr.s6_addr16);
|
dev = netdev_findby_ipv6addr(g_ipv6_unspecaddr,
|
||||||
|
inaddr->sin6_addr.s6_addr16);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Not reachable\n");
|
nerr("ERROR: Not reachable\n");
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@ EXTERN uint16_t g_ipid;
|
|||||||
/* Well-known IPv6 addresses */
|
/* Well-known IPv6 addresses */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
EXTERN const net_ipv6addr_t g_ipv6_allzeroaddr; /* An address of all zeroes */
|
EXTERN const net_ipv6addr_t g_ipv6_unspecaddr; /* An address of all zeroes */
|
||||||
EXTERN const net_ipv6addr_t g_ipv6_allnodes; /* All link local nodes */
|
EXTERN const net_ipv6addr_t g_ipv6_allnodes; /* All link local nodes */
|
||||||
#if defined(CONFIG_NET_ICMPv6_AUTOCONF) || defined(CONFIG_NET_ICMPv6_ROUTER)
|
#if defined(CONFIG_NET_ICMPv6_AUTOCONF) || defined(CONFIG_NET_ICMPv6_ROUTER)
|
||||||
EXTERN const net_ipv6addr_t g_ipv6_allrouters; /* All link local routers */
|
EXTERN const net_ipv6addr_t g_ipv6_allrouters; /* All link local routers */
|
||||||
|
|||||||
@@ -61,12 +61,14 @@ uint16_t g_ipid;
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
|
||||||
const net_ipv6addr_t g_ipv6_allzeroaddr = /* An address of all zeroes */
|
/* Unspecified address (all zero). See RFC 4291 (replaces 3513) */
|
||||||
|
|
||||||
|
const net_ipv6addr_t g_ipv6_unspecaddr = /* An address of all zeroes */
|
||||||
{
|
{
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
|
||||||
};
|
};
|
||||||
|
|
||||||
/* IPv6 Multi-cast IP addresses */
|
/* IPv6 Multi-cast IP addresses. See RFC 2375 */
|
||||||
|
|
||||||
const net_ipv6addr_t g_ipv6_allnodes = /* All link local nodes */
|
const net_ipv6addr_t g_ipv6_allnodes = /* All link local nodes */
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -132,12 +132,12 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if bound to local INADDR6_ANY */
|
/* Check if bound to the IPv6 unspecified address */
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(lipaddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
outaddr->sin6_family = AF_INET6;
|
outaddr->sin6_family = AF_INET6;
|
||||||
memcpy(outaddr->sin6_addr.in6_u.u6_addr8, g_ipv6_allzeroaddr, 16);
|
memcpy(outaddr->sin6_addr.in6_u.u6_addr8, g_ipv6_unspecaddr, 16);
|
||||||
*addrlen = sizeof(struct sockaddr_in6);
|
*addrlen = sizeof(struct sockaddr_in6);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@@ -146,17 +146,16 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
net_lock();
|
net_lock();
|
||||||
|
|
||||||
/* Find the device matching the IPv6 address in the connection structure.
|
/* Find the device matching the IPv6 address in the connection structure.
|
||||||
* NOTE: listening sockets have no ripaddr. Work around is to use the
|
* NOTE: listening sockets have no ripaddr. Work around is to use the
|
||||||
* lipaddr when ripaddr is not available.
|
* lipaddr when ripaddr is not available.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(ripaddr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(ripaddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
ripaddr = lipaddr;
|
ripaddr = lipaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr);
|
dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr);
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
net_unlock();
|
net_unlock();
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/net/arp.h>
|
#include <nuttx/net/arp.h>
|
||||||
|
#include <nuttx/net/ip.h>
|
||||||
#include <nuttx/net/netdev.h>
|
#include <nuttx/net/netdev.h>
|
||||||
|
|
||||||
#include "route/route.h"
|
#include "route/route.h"
|
||||||
@@ -159,12 +160,7 @@ void neighbor_out(FAR struct net_driver_s *dev)
|
|||||||
* packet with an Neighbor Solicitation Request for the IPv6 address.
|
* packet with an Neighbor Solicitation Request for the IPv6 address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* First check if destination is a IPv6 multicast address. IPv6
|
/* First check if destination is a IPv6 multicast address.
|
||||||
* multicast addresses in IPv6 have the prefix ff00::/8
|
|
||||||
*
|
|
||||||
* Bits 120-127: Prefix
|
|
||||||
* Bits 116-119: Flags (1, 2, or 3 defined)
|
|
||||||
* Bits 112-115: Scope
|
|
||||||
*
|
*
|
||||||
* REVISIT: Need to revisit IPv6 broadcast support. Broadcast
|
* REVISIT: Need to revisit IPv6 broadcast support. Broadcast
|
||||||
* IP addresses are not used with IPv6; multicast is used instead.
|
* IP addresses are not used with IPv6; multicast is used instead.
|
||||||
@@ -172,7 +168,7 @@ void neighbor_out(FAR struct net_driver_s *dev)
|
|||||||
* broadcast Ethernet address?
|
* broadcast Ethernet address?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((ip->destipaddr[0] & HTONS(0xff00)) == HTONS(0xff00))
|
if (net_is_addr_mcast(ip->destipaddr))
|
||||||
{
|
{
|
||||||
memcpy(eth->dest, g_broadcast_ethaddr.ether_addr_octet,
|
memcpy(eth->dest, g_broadcast_ethaddr.ether_addr_octet,
|
||||||
ETHER_ADDR_LEN);
|
ETHER_ADDR_LEN);
|
||||||
|
|||||||
@@ -304,9 +304,11 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
|||||||
|
|
||||||
if (net_is_addr_mcast(ripaddr))
|
if (net_is_addr_mcast(ripaddr))
|
||||||
{
|
{
|
||||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
/* Yes.. Check the local, bound address. Is it the IPv6 unspecified
|
||||||
|
* address?
|
||||||
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(lipaddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
/* Yes.. In this case, I think we are supposed to send the
|
/* Yes.. In this case, I think we are supposed to send the
|
||||||
* broadcast packet out ALL locally available networks. I am not
|
* broadcast packet out ALL locally available networks. I am not
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ static int ifconf_ipv6_callback(FAR struct net_driver_s *dev, FAR void *arg)
|
|||||||
* state.
|
* state.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_allzeroaddr) &&
|
if (!net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_unspecaddr) &&
|
||||||
(dev->d_flags & IFF_UP) != 0)
|
(dev->d_flags & IFF_UP) != 0)
|
||||||
{
|
{
|
||||||
/* Check if we would exceed the buffer space provided by the caller.
|
/* Check if we would exceed the buffer space provided by the caller.
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ static int sixlowpan_tcp_header(FAR struct tcp_conn_s *conn,
|
|||||||
/* Copy the source and destination addresses */
|
/* Copy the source and destination addresses */
|
||||||
|
|
||||||
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.destipaddr, conn->u.ipv6.raddr);
|
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.destipaddr, conn->u.ipv6.raddr);
|
||||||
if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, conn->u.ipv6.laddr);
|
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, conn->u.ipv6.laddr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
|||||||
/* Copy the source and destination addresses */
|
/* Copy the source and destination addresses */
|
||||||
|
|
||||||
net_ipv6addr_hdrcopy(ipv6udp.ipv6.destipaddr, to6->sin6_addr.in6_u.u6_addr16);
|
net_ipv6addr_hdrcopy(ipv6udp.ipv6.destipaddr, to6->sin6_addr.in6_u.u6_addr16);
|
||||||
if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, conn->u.ipv6.laddr);
|
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, conn->u.ipv6.laddr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ int sixlowpan_destaddrfromip(FAR struct radio_driver_s *radio,
|
|||||||
|
|
||||||
/* Check for a multicast address */
|
/* Check for a multicast address */
|
||||||
|
|
||||||
if (net_is_addr_mcast(ipaddr[0]))
|
if (net_is_addr_mcast(ipaddr))
|
||||||
{
|
{
|
||||||
DEBUGASSERT(radio->r_properties != NULL);
|
DEBUGASSERT(radio->r_properties != NULL);
|
||||||
ret = radio->r_properties(radio, &properties);
|
ret = radio->r_properties(radio, &properties);
|
||||||
|
|||||||
+8
-8
@@ -179,13 +179,13 @@ tcp_ipv6_listener(const net_ipv6addr_t ipaddr, uint16_t portno)
|
|||||||
if (conn->tcpstateflags != TCP_CLOSED && conn->lport == portno)
|
if (conn->tcpstateflags != TCP_CLOSED && conn->lport == portno)
|
||||||
{
|
{
|
||||||
/* If there are multiple interface devices, then the local IP
|
/* If there are multiple interface devices, then the local IP
|
||||||
* address of the connection must also match. INADDR_ANY is a
|
* address of the connection must also match. The IPv6
|
||||||
* special case: There can only be instance of a port number
|
* unspecified address is a special case: There can only be
|
||||||
* with INADDR_ANY.
|
* one instance of a port number with the unspecified address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr) ||
|
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr) ||
|
||||||
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
/* The port number is in use, return the connection */
|
/* The port number is in use, return the connection */
|
||||||
|
|
||||||
@@ -408,8 +408,8 @@ static inline FAR struct tcp_conn_s *
|
|||||||
* - The remote port number is checked if the connection is bound
|
* - The remote port number is checked if the connection is bound
|
||||||
* to a remote port.
|
* to a remote port.
|
||||||
* - Insist that the destination IP matches the bound address. If
|
* - Insist that the destination IP matches the bound address. If
|
||||||
* a socket is bound to INADDRY_ANY, then it should receive all
|
* a socket is bound to the IPv6 unspecified address, then it
|
||||||
* packets directed to the port.
|
* should receive all packets directed to the port.
|
||||||
* - Finally, if the connection is bound to a remote IP address,
|
* - Finally, if the connection is bound to a remote IP address,
|
||||||
* the source IP address of the packet is checked.
|
* the source IP address of the packet is checked.
|
||||||
*
|
*
|
||||||
@@ -420,7 +420,7 @@ static inline FAR struct tcp_conn_s *
|
|||||||
if (conn->tcpstateflags != TCP_CLOSED &&
|
if (conn->tcpstateflags != TCP_CLOSED &&
|
||||||
tcp->destport == conn->lport &&
|
tcp->destport == conn->lport &&
|
||||||
tcp->srcport == conn->rport &&
|
tcp->srcport == conn->rport &&
|
||||||
(net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr) ||
|
(net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr) ||
|
||||||
net_ipv6addr_cmp(*destipaddr, conn->u.ipv6.laddr)) &&
|
net_ipv6addr_cmp(*destipaddr, conn->u.ipv6.laddr)) &&
|
||||||
net_ipv6addr_cmp(*srcipaddr, conn->u.ipv6.raddr))
|
net_ipv6addr_cmp(*srcipaddr, conn->u.ipv6.raddr))
|
||||||
{
|
{
|
||||||
@@ -563,7 +563,7 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn,
|
|||||||
/* Back out the local address setting */
|
/* Back out the local address setting */
|
||||||
|
|
||||||
conn->lport = 0;
|
conn->lport = 0;
|
||||||
net_ipv6addr_copy(conn->u.ipv6.laddr, g_ipv6_allzeroaddr);
|
net_ipv6addr_copy(conn->u.ipv6.laddr, g_ipv6_unspecaddr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,12 +131,12 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return success without using device notification if the locally bound
|
/* Return success without using device notification if the locally bound
|
||||||
* address is IN6ADDR_ANY. In this case, there may be multiple devices
|
* address is the IPv6 unspecified address. In this case, there may be
|
||||||
* that can provide data so the exceptional events from any particular
|
* multiple devices* that can provide data so the exceptional events from
|
||||||
* device are not important.
|
* any particular device are not important.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(addr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(addr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -177,7 +177,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint8_t domain,
|
|||||||
{
|
{
|
||||||
if (conn->lport == portno &&
|
if (conn->lport == portno &&
|
||||||
(net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr->ipv6.laddr) ||
|
(net_ipv6addr_cmp(conn->u.ipv6.laddr, ipaddr->ipv6.laddr) ||
|
||||||
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr)))
|
net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr)))
|
||||||
{
|
{
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
@@ -463,10 +463,11 @@ static inline FAR struct udp_conn_s *
|
|||||||
/* Check if the local port accepts any address on this port or
|
/* Check if the local port accepts any address on this port or
|
||||||
* that there is an exact match between the destipaddr and the
|
* that there is an exact match between the destipaddr and the
|
||||||
* bound local address. This catches the case of the all nodes
|
* bound local address. This catches the case of the all nodes
|
||||||
* multicast when the socket is bound to INADDR6_ANY.
|
* multicast when the socket is bound to the IPv6 unspecified
|
||||||
|
* address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr) ||
|
(net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr) ||
|
||||||
net_ipv6addr_hdrcmp(ip->destipaddr, conn->u.ipv6.laddr))))
|
net_ipv6addr_hdrcmp(ip->destipaddr, conn->u.ipv6.laddr))))
|
||||||
{
|
{
|
||||||
/* Check if the socket is connection mode. In this case, only
|
/* Check if the socket is connection mode. In this case, only
|
||||||
@@ -489,7 +490,7 @@ static inline FAR struct udp_conn_s *
|
|||||||
* address, then accept the packet.
|
* address, then accept the packet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(net_ipv6addr_cmp(conn->u.ipv6.raddr, g_ipv6_allzeroaddr) ||
|
(net_ipv6addr_cmp(conn->u.ipv6.raddr, g_ipv6_unspecaddr) ||
|
||||||
#ifdef CONFIG_NET_BROADCAST
|
#ifdef CONFIG_NET_BROADCAST
|
||||||
net_ipv6addr_hdrcmp(ip->destipaddr, g_ipv6_allnodes) ||
|
net_ipv6addr_hdrcmp(ip->destipaddr, g_ipv6_allnodes) ||
|
||||||
#endif
|
#endif
|
||||||
@@ -887,7 +888,7 @@ int udp_connect(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
net_ipv6addr_copy(conn->u.ipv6.raddr, g_ipv6_allzeroaddr);
|
net_ipv6addr_copy(conn->u.ipv6.raddr, g_ipv6_unspecaddr);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,11 +105,12 @@ FAR struct net_driver_s *udp_find_laddr_device(FAR struct udp_conn_s *conn)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* Make sure that the socket is bound to some non-zero, local
|
/* Make sure that the socket is bound to some non-zero, local
|
||||||
* address. Zero is used as an indication that the laddr is
|
* address. The IPv6 unspecified address is used as an indication
|
||||||
* uninitialized and that the socket is, hence, not bound.
|
* that the laddr is uninitialized and that the socket is, hence,
|
||||||
|
* not bound.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -198,11 +199,12 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn)
|
|||||||
if (net_is_addr_mcast(conn->u.ipv6.raddr))
|
if (net_is_addr_mcast(conn->u.ipv6.raddr))
|
||||||
{
|
{
|
||||||
/* Make sure that the socket is bound to some non-zero, local
|
/* Make sure that the socket is bound to some non-zero, local
|
||||||
* address. Zero is used as an indication that the laddr is
|
* address. The IPv6 unspecified address is used as an
|
||||||
* uninitialized and that the socket is, hence, not bound.
|
* indication that the laddr is uninitialized and that the
|
||||||
|
* socket is, hence, not bound.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
if (net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_unspecaddr))
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user