Networking: Replace all references to net_ipaddr_t with either in_addr_t on net_ipv6addr_t. The goal is to support both IPv4 and IPv6 simultaneously. This requires that the two types be distinct and not conditionally typedef'ed to net_ipaddr_t.
This commit is contained in:
parent
75ce2c895e
commit
5e938941a6
@ -189,7 +189,7 @@ extern "C"
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int icmp_ping(net_ipaddr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
|
int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
|
||||||
int dsecs);
|
int dsecs);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
@ -94,12 +94,6 @@
|
|||||||
|
|
||||||
typedef uint16_t net_ipv6addr_t[8];
|
typedef uint16_t net_ipv6addr_t[8];
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
typedef net_ipv6addr_t net_ipaddr_t;
|
|
||||||
#else
|
|
||||||
typedef in_addr_t net_ipaddr_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Describes and address in either the IPv4 or IPv6 domain */
|
/* Describes and address in either the IPv4 or IPv6 domain */
|
||||||
|
|
||||||
union ip_addr_u
|
union ip_addr_u
|
||||||
@ -192,7 +186,7 @@ struct net_ipv6hdr_s
|
|||||||
*
|
*
|
||||||
* This function constructs an IPv4 address in network byte order.
|
* This function constructs an IPv4 address in network byte order.
|
||||||
*
|
*
|
||||||
* addr A pointer to a net_ipaddr_t variable that will be
|
* addr A pointer to a in_addr_t variable that will be
|
||||||
* filled in with the IPv4 address.
|
* filled in with the IPv4 address.
|
||||||
* addr0 The first octet of the IPv4 address.
|
* addr0 The first octet of the IPv4 address.
|
||||||
* addr1 The second octet of the IPv4 address.
|
* addr1 The second octet of the IPv4 address.
|
||||||
@ -255,7 +249,7 @@ struct net_ipv6hdr_s
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* net_ipaddr_t ipaddr1, ipaddr2;
|
* in_addr_t ipaddr1, ipaddr2;
|
||||||
*
|
*
|
||||||
* net_ipaddr(&ipaddr1, 192,16,1,2);
|
* net_ipaddr(&ipaddr1, 192,16,1,2);
|
||||||
* net_ipaddr_copy(&ipaddr2, &ipaddr1);
|
* net_ipaddr_copy(&ipaddr2, &ipaddr1);
|
||||||
@ -289,7 +283,7 @@ struct net_ipv6hdr_s
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* net_ipaddr_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_ipaddr_cmp(ipaddr2, ipaddr1))
|
||||||
@ -362,7 +356,7 @@ bool net_ipv6addr_maskcmp(const net_ipv6addr_t addr1,
|
|||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
*
|
*
|
||||||
* net_ipaddr_t ipaddr1, ipaddr2, netmask;
|
* in_addr_t ipaddr1, ipaddr2, netmask;
|
||||||
*
|
*
|
||||||
* net_ipaddr(&ipaddr1, 192,16,1,2);
|
* net_ipaddr(&ipaddr1, 192,16,1,2);
|
||||||
* net_ipaddr(&netmask, 255,255,255,0);
|
* net_ipaddr(&netmask, 255,255,255,0);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/arp/arp_send.c
|
* net/arp/arp_send.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 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
|
||||||
@ -223,7 +223,7 @@ int arp_send(in_addr_t ipaddr)
|
|||||||
/* Get the device that can route this request */
|
/* Get the device that can route this request */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
dev = netdev_findby_ipv4addr(g_allzeroaddr, ipaddr);
|
dev = netdev_findby_ipv4addr(g_ipv4_allzeroaddr, ipaddr);
|
||||||
#else
|
#else
|
||||||
dev = netdev_findby_ipv4addr(ipaddr);
|
dev = netdev_findby_ipv4addr(ipaddr);
|
||||||
#endif
|
#endif
|
||||||
@ -337,7 +337,7 @@ int arp_send(in_addr_t ipaddr)
|
|||||||
state.snd_cb->event = arp_send_interrupt;
|
state.snd_cb->event = arp_send_interrupt;
|
||||||
|
|
||||||
/* Notify the device driver that new TX data is available.
|
/* Notify the device driver that new TX data is available.
|
||||||
* NOTES: This is in essence what netdev_txnotify() does, which
|
* NOTES: This is in essence what netdev_ipv4_txnotify() does, which
|
||||||
* is not possible to call since it expects a in_addr_t as
|
* is not possible to call since it expects a in_addr_t as
|
||||||
* its single argument to lookup the network interface.
|
* its single argument to lookup the network interface.
|
||||||
*/
|
*/
|
||||||
|
@ -165,8 +165,15 @@ struct devif_callback_s
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
extern const net_ipaddr_t g_alloneaddr;
|
#ifdef CONFIG_NET_IPv4
|
||||||
extern const net_ipaddr_t g_allzeroaddr;
|
extern const in_addr_t g_ipv4_alloneaddr;
|
||||||
|
extern const in_addr_t g_ipv4_allzeroaddr;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
extern const net_ipv6addr_t g_ipv6_alloneaddr;
|
||||||
|
extern const net_ipv6addr_t g_ipv6_allzeroaddr;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Increasing number used for the IP ID field. */
|
/* Increasing number used for the IP ID field. */
|
||||||
|
|
||||||
|
@ -69,25 +69,23 @@ struct net_stats_s g_netstats;
|
|||||||
|
|
||||||
uint16_t g_ipid;
|
uint16_t g_ipid;
|
||||||
|
|
||||||
const net_ipaddr_t g_alloneaddr =
|
#ifdef CONFIG_NET_IPv4
|
||||||
#ifdef CONFIG_NET_IPv6
|
const in_addr_t g_ipv4_alloneaddr = 0xffffffff;
|
||||||
{0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
|
const in_addr_t g_ipv4_allzeroaddr = 0x00000000;
|
||||||
#else
|
|
||||||
0xffffffff;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const net_ipaddr_t g_allzeroaddr =
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
|
|
||||||
#else
|
|
||||||
0x00000000;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Reassembly timer (units: deci-seconds) */
|
/* Reassembly timer (units: deci-seconds) */
|
||||||
|
|
||||||
#if defined(CONFIG_NET_TCP_REASSEMBLY) && !defined(CONFIG_NET_IPv6)
|
#ifdef CONFIG_NET_TCP_REASSEMBLY
|
||||||
uint8_t g_reassembly_timer;
|
uint8_t g_reassembly_timer;
|
||||||
#endif
|
#endif
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
const net_ipv6addr_t g_ipv6_alloneaddr =
|
||||||
|
{0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
|
||||||
|
const net_ipv6addr_t g_ipv6_allzeroaddr =
|
||||||
|
{0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Variables
|
* Private Variables
|
||||||
|
@ -381,7 +381,8 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
|
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
|
||||||
if (pbuf->proto == IP_PROTO_UDP &&
|
if (pbuf->proto == IP_PROTO_UDP &&
|
||||||
net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr), g_alloneaddr))
|
net_ipv4addr_cmp(net_ip4addr_conv32(pbuf->destipaddr),
|
||||||
|
g_ipv4_alloneaddr))
|
||||||
{
|
{
|
||||||
return udp_ipv4_input(dev);
|
return udp_ipv4_input(dev);
|
||||||
}
|
}
|
||||||
@ -394,7 +395,7 @@ int ipv4_input(FAR struct net_driver_s *dev)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NET_ICMP
|
#ifdef CONFIG_NET_ICMP
|
||||||
if (net_ipv4addr_cmp(dev->d_ipaddr, g_allzeroaddr))
|
if (net_ipv4addr_cmp(dev->d_ipaddr, g_ipv4_allzeroaddr))
|
||||||
{
|
{
|
||||||
/* 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
|
||||||
|
@ -196,7 +196,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
|
#if defined(CONFIG_NET_BROADCAST) && defined(CONFIG_NET_UDP)
|
||||||
if (pbuf->proto == IP_PROTO_UDP &&
|
if (pbuf->proto == IP_PROTO_UDP &&
|
||||||
net_ipv6addr_cmp(pbuf->destipaddr, g_alloneaddr))
|
net_ipv6addr_cmp(pbuf->destipaddr, g_ipv6_alloneaddr))
|
||||||
{
|
{
|
||||||
return udp_ipv6_input(dev);
|
return udp_ipv6_input(dev);
|
||||||
}
|
}
|
||||||
@ -209,7 +209,7 @@ int ipv6_input(FAR struct net_driver_s *dev)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
#ifdef CONFIG_NET_ICMPv6
|
||||||
if (net_ipv6addr_cmp(dev->d_ipv6addr, g_allzeroaddr))
|
if (net_ipv6addr_cmp(dev->d_ipv6addr, g_ipv6_allzeroaddr))
|
||||||
{
|
{
|
||||||
/* 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
|
||||||
|
@ -369,9 +369,9 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen,
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(g_allzeroaddr, state.png_addr);
|
netdev_ipv4_txnotify(g_ipv4_allzeroaddr, state.png_addr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(state.png_addr);
|
netdev_ipv4_txnotify(state.png_addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Wait for either the full round trip transfer to complete or
|
/* Wait for either the full round trip transfer to complete or
|
||||||
|
@ -368,9 +368,9 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno,
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(g_allzeroaddr, state.png_addr);
|
netdev_ipv6_txnotify(g_ipv6_allzeroaddr, state.png_addr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(state.png_addr);
|
netdev_ipv6_txnotify(state.png_addr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Wait for either the full round trip transfer to complete or
|
/* Wait for either the full round trip transfer to complete or
|
||||||
|
@ -101,7 +101,7 @@ typedef FAR struct wdog_s *WDOG_ID;
|
|||||||
struct igmp_group_s
|
struct igmp_group_s
|
||||||
{
|
{
|
||||||
struct igmp_group_s *next; /* Implements a singly-linked list */
|
struct igmp_group_s *next; /* Implements a singly-linked list */
|
||||||
net_ipaddr_t grpaddr; /* Group IP address */
|
in_addr_t grpaddr; /* Group IPv4 address */
|
||||||
WDOG_ID wdog; /* WDOG used to detect timeouts */
|
WDOG_ID wdog; /* WDOG used to detect timeouts */
|
||||||
sem_t sem; /* Used to wait for message transmission */
|
sem_t sem; /* Used to wait for message transmission */
|
||||||
volatile uint8_t flags; /* See IGMP_ flags definitions */
|
volatile uint8_t flags; /* See IGMP_ flags definitions */
|
||||||
@ -120,8 +120,8 @@ extern "C"
|
|||||||
# define EXTERN extern
|
# define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN net_ipaddr_t g_allsystems;
|
EXTERN in_addr_t g_ipv4_allsystems;
|
||||||
EXTERN net_ipaddr_t g_allrouters;
|
EXTERN in_addr_t g_ipv4_allrouters;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
@ -188,7 +188,7 @@ void igmp_grpinit(void);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
|
FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
|
||||||
FAR const net_ipaddr_t *addr);
|
FAR const in_addr_t *addr);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: igmp_grpfind
|
* Name: igmp_grpfind
|
||||||
@ -202,7 +202,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
|
FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
|
||||||
FAR const net_ipaddr_t *addr);
|
FAR const in_addr_t *addr);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: igmp_grpallocfind
|
* Name: igmp_grpallocfind
|
||||||
@ -217,7 +217,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev,
|
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev,
|
||||||
FAR const net_ipaddr_t *addr);
|
FAR const in_addr_t *addr);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: igmp_grpfree
|
* Name: igmp_grpfree
|
||||||
@ -304,7 +304,7 @@ void igmp_poll(FAR struct net_driver_s *dev);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
||||||
FAR net_ipaddr_t *dest);
|
FAR in_addr_t *dest);
|
||||||
|
|
||||||
/* Defined in igmp_join.c ***************************************************/
|
/* Defined in igmp_join.c ***************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -405,7 +405,7 @@ bool igmp_cmptimer(FAR struct igmp_group_s *group, int maxticks);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip);
|
void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: igmp_removemcastmac
|
* Name: igmp_removemcastmac
|
||||||
@ -415,7 +415,7 @@ void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip);
|
void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -221,7 +221,7 @@ void igmp_grpinit(void)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
|
FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
|
||||||
FAR const net_ipaddr_t *addr)
|
FAR const in_addr_t *addr)
|
||||||
{
|
{
|
||||||
FAR struct igmp_group_s *group;
|
FAR struct igmp_group_s *group;
|
||||||
net_lock_t flags;
|
net_lock_t flags;
|
||||||
@ -284,7 +284,7 @@ FAR struct igmp_group_s *igmp_grpalloc(FAR struct net_driver_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
|
FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
|
||||||
FAR const net_ipaddr_t *addr)
|
FAR const in_addr_t *addr)
|
||||||
{
|
{
|
||||||
FAR struct igmp_group_s *group;
|
FAR struct igmp_group_s *group;
|
||||||
net_lock_t flags;
|
net_lock_t flags;
|
||||||
@ -325,7 +325,7 @@ FAR struct igmp_group_s *igmp_grpfind(FAR struct net_driver_s *dev,
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev,
|
FAR struct igmp_group_s *igmp_grpallocfind(FAR struct net_driver_s *dev,
|
||||||
FAR const net_ipaddr_t *addr)
|
FAR const in_addr_t *addr)
|
||||||
{
|
{
|
||||||
FAR struct igmp_group_s *group = igmp_grpfind(dev, addr);
|
FAR struct igmp_group_s *group = igmp_grpfind(dev, addr);
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
net_ipaddr_t g_allsystems;
|
in_addr_t g_ipv4_allsystems;
|
||||||
net_ipaddr_t g_allrouters;
|
in_addr_t g_ipv4_allrouters;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -86,8 +86,8 @@ void igmp_initialize(void)
|
|||||||
{
|
{
|
||||||
nvdbg("IGMP initializing\n");
|
nvdbg("IGMP initializing\n");
|
||||||
|
|
||||||
net_ipaddr(g_allrouters, 224, 0, 0, 2);
|
net_ipaddr(g_ipv4_allrouters, 224, 0, 0, 2);
|
||||||
net_ipaddr(g_allsystems, 224, 0, 0, 1);
|
net_ipaddr(g_ipv4_allsystems, 224, 0, 0, 1);
|
||||||
|
|
||||||
/* Initialize the group allocation logic */
|
/* Initialize the group allocation logic */
|
||||||
|
|
||||||
@ -110,12 +110,12 @@ void igmp_devinit(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Add the all systems address to the group */
|
/* Add the all systems address to the group */
|
||||||
|
|
||||||
(void)igmp_grpalloc(dev, &g_allsystems);
|
(void)igmp_grpalloc(dev, &g_ipv4_allsystems);
|
||||||
|
|
||||||
/* Allow the IGMP messages at the MAC level */
|
/* Allow the IGMP messages at the MAC level */
|
||||||
|
|
||||||
igmp_addmcastmac(dev, &g_allrouters);
|
igmp_addmcastmac(dev, &g_ipv4_allrouters);
|
||||||
igmp_addmcastmac(dev, &g_allsystems);
|
igmp_addmcastmac(dev, &g_ipv4_allsystems);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_IGMP */
|
#endif /* CONFIG_NET_IGMP */
|
||||||
|
@ -117,8 +117,8 @@
|
|||||||
void igmp_input(struct net_driver_s *dev)
|
void igmp_input(struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct igmp_group_s *group;
|
FAR struct igmp_group_s *group;
|
||||||
net_ipaddr_t destipaddr;
|
in_addr_t destipaddr;
|
||||||
net_ipaddr_t grpaddr;
|
in_addr_t grpaddr;
|
||||||
unsigned int ticks;
|
unsigned int ticks;
|
||||||
|
|
||||||
nllvdbg("IGMP message: %04x%04x\n", IGMPBUF->destipaddr[1], IGMPBUF->destipaddr[0]);
|
nllvdbg("IGMP message: %04x%04x\n", IGMPBUF->destipaddr[1], IGMPBUF->destipaddr[0]);
|
||||||
@ -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_allsystems))
|
if (net_ipaddr_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_allsystems))
|
if (!net_ipaddr_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) ||
|
||||||
|
@ -152,7 +152,7 @@ int igmp_joingroup(struct net_driver_s *dev, FAR const struct in_addr *grpaddr)
|
|||||||
|
|
||||||
/* Add the group (MAC) address to the ether drivers MAC filter list */
|
/* Add the group (MAC) address to the ether drivers MAC filter list */
|
||||||
|
|
||||||
igmp_addmcastmac(dev, (FAR net_ipaddr_t *)&grpaddr->s_addr);
|
igmp_addmcastmac(dev, (FAR in_addr_t *)&grpaddr->s_addr);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ int igmp_leavegroup(struct net_driver_s *dev, FAR const struct in_addr *grpaddr)
|
|||||||
|
|
||||||
/* And remove the group address from the ethernet drivers MAC filter set */
|
/* And remove the group address from the ethernet drivers MAC filter set */
|
||||||
|
|
||||||
igmp_removemcastmac(dev, (FAR net_ipaddr_t *)&grpaddr->s_addr);
|
igmp_removemcastmac(dev, (FAR in_addr_t *)&grpaddr->s_addr);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static void igmp_mcastmac(net_ipaddr_t *ip, FAR uint8_t *mac)
|
static void igmp_mcastmac(in_addr_t *ip, FAR uint8_t *mac)
|
||||||
{
|
{
|
||||||
/* This mapping is from the IETF IN RFC 1700 */
|
/* This mapping is from the IETF IN RFC 1700 */
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ static void igmp_mcastmac(net_ipaddr_t *ip, FAR uint8_t *mac)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip)
|
void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip)
|
||||||
{
|
{
|
||||||
uint8_t mcastmac[6];
|
uint8_t mcastmac[6];
|
||||||
|
|
||||||
@ -119,7 +119,7 @@ void igmp_addmcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR net_ipaddr_t *ip)
|
void igmp_removemcastmac(FAR struct net_driver_s *dev, FAR in_addr_t *ip)
|
||||||
{
|
{
|
||||||
uint8_t mcastmac[6];
|
uint8_t mcastmac[6];
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
static inline void igmp_sched_send(FAR struct net_driver_s *dev,
|
static inline void igmp_sched_send(FAR struct net_driver_s *dev,
|
||||||
FAR struct igmp_group_s *group)
|
FAR struct igmp_group_s *group)
|
||||||
{
|
{
|
||||||
net_ipaddr_t *dest;
|
in_addr_t *dest;
|
||||||
|
|
||||||
/* Check what kind of message we need to send. There are only two
|
/* Check what kind of message we need to send. There are only two
|
||||||
* possibilities:
|
* possibilities:
|
||||||
@ -99,7 +99,7 @@ static inline void igmp_sched_send(FAR struct net_driver_s *dev,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
|
DEBUGASSERT(group->msgid == IGMP_LEAVE_GROUP);
|
||||||
dest = &g_allrouters;
|
dest = &g_ipv4_allrouters;
|
||||||
nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
|
nllvdbg("Send IGMP_LEAVE_GROUP, dest=%08x flags=%02x\n",
|
||||||
*dest, group->flags);
|
*dest, group->flags);
|
||||||
IGMP_STATINCR(g_netstats.igmp.leave_sched);
|
IGMP_STATINCR(g_netstats.igmp.leave_sched);
|
||||||
|
@ -122,7 +122,7 @@ static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
||||||
FAR net_ipaddr_t *destipaddr)
|
FAR in_addr_t *destipaddr)
|
||||||
{
|
{
|
||||||
nllvdbg("msgid: %02x destipaddr: %08x\n", group->msgid, (int)*destipaddr);
|
nllvdbg("msgid: %02x destipaddr: %08x\n", group->msgid, (int)*destipaddr);
|
||||||
|
|
||||||
|
@ -122,27 +122,61 @@ FAR struct net_driver_s *netdev_default(void);
|
|||||||
/* netdev_txnotify.c *********************************************************/
|
/* netdev_txnotify.c *********************************************************/
|
||||||
|
|
||||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NET_MULTILINK
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
void netdev_txnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr);
|
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
|
||||||
# else
|
# else
|
||||||
void netdev_txnotify(const net_ipaddr_t ripaddr);
|
void netdev_ipv4_txnotify(in_addr_t ripaddr);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
|
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
|
FAR const net_ipv6addr_t ripaddr);
|
||||||
|
# else
|
||||||
|
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr);
|
||||||
|
# endif
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */
|
||||||
|
|
||||||
/* netdev_rxnotify.c *********************************************************/
|
/* netdev_rxnotify.c *********************************************************/
|
||||||
|
|
||||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
|
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NET_MULTILINK
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
void netdev_rxnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr);
|
void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr);
|
||||||
# else
|
# else
|
||||||
void netdev_rxnotify(const net_ipaddr_t ripaddr);
|
void netdev_ipv4_rxnotify(in_addr_t ripaddr);
|
||||||
# endif
|
# endif
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
|
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
|
FAR const net_ipv6addr_t ripaddr);
|
||||||
|
# else
|
||||||
|
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
|
||||||
|
# endif
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NET_MULTILINK
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
# define netdev_rxnotify(lipaddr,ripaddr)
|
# define netdev_ipv4_rxnotify(lipaddr,ripaddr)
|
||||||
# else
|
# else
|
||||||
# define netdev_rxnotify(ripaddr)
|
# define netdev_ipv4_rxnotify(ripaddr)
|
||||||
# endif
|
# endif
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
|
# define netdev_ipv6_rxnotify(lipaddr,ripaddr)
|
||||||
|
# else
|
||||||
|
# define netdev_ipv6_rxnotify(ripaddr)
|
||||||
|
# endif
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* netdev_count.c ************************************************************/
|
/* netdev_count.c ************************************************************/
|
||||||
|
@ -211,18 +211,18 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
|||||||
{
|
{
|
||||||
struct net_driver_s *dev;
|
struct net_driver_s *dev;
|
||||||
#ifdef CONFIG_NET_ROUTE
|
#ifdef CONFIG_NET_ROUTE
|
||||||
net_ipaddr_t router;
|
in_addr_t router;
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* First, check if this is the broadcast IP address */
|
/* First, check if this is the broadcast IP address */
|
||||||
|
|
||||||
if (net_ipv4addr_cmp(ripaddr, g_alloneaddr))
|
if (net_ipv4addr_cmp(ripaddr, g_ipv4_alloneaddr))
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
||||||
|
|
||||||
if (net_ipv4addr_cmp(lipaddr, g_allzeroaddr))
|
if (net_ipv4addr_cmp(lipaddr, g_ipv4_allzeroaddr))
|
||||||
{
|
{
|
||||||
/* 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 local networks. I am not sure
|
* broadcast packet out ALL local networks. I am not sure
|
||||||
@ -262,7 +262,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
|||||||
* address of a router that can forward packets to the external network.
|
* address of a router that can forward packets to the external network.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = net_router(ripaddr, &router);
|
ret = net_ipv4_router(ripaddr, &router);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Success... try to find the network device associated with the local
|
/* Success... try to find the network device associated with the local
|
||||||
@ -329,18 +329,18 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
|
|||||||
{
|
{
|
||||||
struct net_driver_s *dev;
|
struct net_driver_s *dev;
|
||||||
#ifdef CONFIG_NET_ROUTE
|
#ifdef CONFIG_NET_ROUTE
|
||||||
net_ipaddr_t router;
|
net_ipv6addr_t router;
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* First, check if this is the broadcast IP address */
|
/* First, check if this is the broadcast IP address */
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(ripaddr, g_alloneaddr))
|
if (net_ipv6addr_cmp(ripaddr, g_ipv6_alloneaddr))
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(lipaddr, g_allzeroaddr))
|
if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
|
||||||
{
|
{
|
||||||
/* 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 local networks. I am not sure
|
* broadcast packet out ALL local networks. I am not sure
|
||||||
@ -380,7 +380,7 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
|
|||||||
* address of a router that can forward packets to the external network.
|
* address of a router that can forward packets to the external network.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = net_router(ripaddr, router);
|
ret = net_ipv6_router(ripaddr, router);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Success... try to find the network device associated with the local
|
/* Success... try to find the network device associated with the local
|
||||||
|
@ -82,6 +82,144 @@
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: ioctl_addipv4route
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Add an IPv4 route to the routing table.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* rentry - Describes the route to be added
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv4)
|
||||||
|
static int ioctl_addipv4route(FAR struct rtentry *rtentry)
|
||||||
|
{
|
||||||
|
FAR struct sockaddr_in *addr;
|
||||||
|
in_addr_t target;
|
||||||
|
in_addr_t netmask;
|
||||||
|
in_addr_t router;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_target;
|
||||||
|
target = (in_addr_t)addr->sin_addr.s_addr;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
|
||||||
|
netmask = (in_addr_t)addr->sin_addr.s_addr;
|
||||||
|
|
||||||
|
/* The router is an optional argument */
|
||||||
|
|
||||||
|
if (rtentry->rt_router)
|
||||||
|
{
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_router;
|
||||||
|
router = (in_addr_t)addr->sin_addr.s_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
router = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return net_addroute(target, netmask, router);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: ioctl_addipv6route
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Add an IPv6 route to the routing table.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* rentry - Describes the route to be added
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6)
|
||||||
|
static int ioctl_addipv6route(FAR struct rtentry *rtentry)
|
||||||
|
{
|
||||||
|
FAR struct sockaddr_in6 *addr;
|
||||||
|
net_ipv6addr_t target;
|
||||||
|
net_ipv6addr_t netmask;
|
||||||
|
net_ipv6addr_t router;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
|
||||||
|
target = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
|
||||||
|
netmask = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
|
||||||
|
|
||||||
|
/* The router is an optional argument */
|
||||||
|
|
||||||
|
if (rtentry->rt_router)
|
||||||
|
{
|
||||||
|
addr = (FAR struct sockaddr_in6 *)rtentry->rt_router;
|
||||||
|
router = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
router = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return net_addroute(target, netmask, router);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: ioctl_delipv4route
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Delete an IPv4 route to the routing table.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* rentry - Describes the route to be deleted
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv4)
|
||||||
|
static int ioctl_delipv4route(FAR struct rtentry *rtentry)
|
||||||
|
{
|
||||||
|
FAR struct sockaddr_in *addr;
|
||||||
|
in_addr_t target;
|
||||||
|
in_addr_t netmask;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_target;
|
||||||
|
target = (in_addr_t)addr->sin_addr.s_addr;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
|
||||||
|
netmask = (in_addr_t)addr->sin_addr.s_addr;
|
||||||
|
|
||||||
|
return net_delroute(target, netmask);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: ioctl_delipv6route
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Delete an IPv6 route to the routing table.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* rentry - Describes the route to be deleted
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6)
|
||||||
|
static int ioctl_delipv6route(FAR struct rtentry *rtentry)
|
||||||
|
{
|
||||||
|
FAR struct sockaddr_in6 *addr;
|
||||||
|
net_ipv6addr_t target;
|
||||||
|
net_ipv6addr_t netmask;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
|
||||||
|
target = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
|
||||||
|
|
||||||
|
addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
|
||||||
|
netmask = (net_ipv6addr_t)addr->sin6_addr.u6_addr16;
|
||||||
|
|
||||||
|
return net_delroute(target, netmask);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ioctl_getipv4addr
|
* Name: ioctl_getipv4addr
|
||||||
*
|
*
|
||||||
@ -90,7 +228,7 @@
|
|||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* outaddr - Pointer to the user-provided memory to receive the address.
|
* outaddr - Pointer to the user-provided memory to receive the address.
|
||||||
* inaddr - The source IP adress in the device structure.
|
* inaddr - The source IP address in the device structure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -741,99 +879,67 @@ static int netdev_rtioctl(FAR struct socket *psock, int cmd,
|
|||||||
{
|
{
|
||||||
case SIOCADDRT: /* Add an entry to the routing table */
|
case SIOCADDRT: /* Add an entry to the routing table */
|
||||||
{
|
{
|
||||||
if (rtentry)
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||||
|
FAR struct sockaddr_in *addr;
|
||||||
|
#endif
|
||||||
|
/* The target address and the netmask are required values */
|
||||||
|
|
||||||
|
if (!retentry || !rtentry->rt_target || !rtentry->rt_netmask)
|
||||||
{
|
{
|
||||||
net_ipaddr_t target;
|
return -EINVAL;
|
||||||
net_ipaddr_t netmask;
|
|
||||||
net_ipaddr_t router;
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
FAR struct sockaddr_in6 *addr;
|
|
||||||
#else
|
|
||||||
FAR struct sockaddr_in *addr;
|
|
||||||
#endif
|
|
||||||
/* The target address and the netmask are required value */
|
|
||||||
|
|
||||||
if (!rtentry->rt_target || !rtentry->rt_netmask)
|
|
||||||
{
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
|
|
||||||
target = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
|
|
||||||
|
|
||||||
addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
|
|
||||||
netmask = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
|
|
||||||
|
|
||||||
/* The router is an optional argument */
|
|
||||||
|
|
||||||
if (rtentry->rt_router)
|
|
||||||
{
|
|
||||||
addr = (FAR struct sockaddr_in6 *)rtentry->rt_router;
|
|
||||||
router = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
router = NULL;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
addr = (FAR struct sockaddr_in *)rtentry->rt_target;
|
|
||||||
target = (net_ipaddr_t)addr->sin_addr.s_addr;
|
|
||||||
|
|
||||||
addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
|
|
||||||
netmask = (net_ipaddr_t)addr->sin_addr.s_addr;
|
|
||||||
|
|
||||||
/* The router is an optional argument */
|
|
||||||
|
|
||||||
if (rtentry->rt_router)
|
|
||||||
{
|
|
||||||
addr = (FAR struct sockaddr_in *)rtentry->rt_router;
|
|
||||||
router = (net_ipaddr_t)addr->sin_addr.s_addr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
router = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ret = net_addroute(target, netmask, router);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_target;
|
||||||
|
if (addr->sin_family == AF_INET)
|
||||||
|
{
|
||||||
|
ret = ioctl_addipv4route(rtentry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = ioctl_addipv6route(rtentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(CONFIG_NET_IPv4)
|
||||||
|
ret = ioctl_addipv4route(rtentry);
|
||||||
|
#elif defined(CONFIG_NET_IPv6)
|
||||||
|
ret = ioctl_addipv6route(rtentry);
|
||||||
|
#else
|
||||||
|
ret = -EAFNOSUPPORT;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SIOCDELRT: /* Delete an entry from the routing table */
|
case SIOCDELRT: /* Delete an entry from the routing table */
|
||||||
{
|
{
|
||||||
if (rtentry)
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||||
|
FAR struct sockaddr_in *addr;
|
||||||
|
#endif
|
||||||
|
/* The target address and the netmask are required values */
|
||||||
|
|
||||||
|
if (!retentry || !rtentry->rt_target || !rtentry->rt_netmask)
|
||||||
{
|
{
|
||||||
net_ipaddr_t target;
|
return -EINVAL;
|
||||||
net_ipaddr_t netmask;
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
FAR struct sockaddr_in6 *addr;
|
|
||||||
#else
|
|
||||||
FAR struct sockaddr_in *addr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The target address and the netmask are required value */
|
|
||||||
|
|
||||||
if (!rtentry->rt_target || !rtentry->rt_netmask)
|
|
||||||
{
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
|
||||||
addr = (FAR struct sockaddr_in6 *)rtentry->rt_target;
|
|
||||||
target = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
|
|
||||||
|
|
||||||
addr = (FAR struct sockaddr_in6 *)rtentry->rt_netmask;
|
|
||||||
netmask = (net_ipaddr_t)addr->sin6_addr.u6_addr16;
|
|
||||||
#else
|
|
||||||
addr = (FAR struct sockaddr_in *)rtentry->rt_target;
|
|
||||||
target = (net_ipaddr_t)addr->sin_addr.s_addr;
|
|
||||||
|
|
||||||
addr = (FAR struct sockaddr_in *)rtentry->rt_netmask;
|
|
||||||
netmask = (net_ipaddr_t)addr->sin_addr.s_addr;
|
|
||||||
#endif
|
|
||||||
ret = net_delroute(target, netmask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
|
||||||
|
addr = (FAR struct sockaddr_in *)rtentry->rt_target;
|
||||||
|
if (addr->sin_family == AF_INET)
|
||||||
|
{
|
||||||
|
ret = ioctl_delipv4route(rtentry);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = ioctl_delipv6route(rtentry);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(CONFIG_NET_IPv4)
|
||||||
|
ret = ioctl_delipv4route(rtentry);
|
||||||
|
#elif defined(CONFIG_NET_IPv6)
|
||||||
|
ret = ioctl_delipv6route(rtentry);
|
||||||
|
#else
|
||||||
|
ret = -EAFNOSUPPORT;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/netdev/netdev_rxnotify.c
|
* net/netdev/netdev_rxnotify.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-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
|
||||||
@ -75,13 +75,15 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: netdev_rxnotify
|
* Function: netdev_ipv4_rxnotify
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Notify the device driver that the application waits for RX data.
|
* Notify the device driver that forwards the IPv4 address that the
|
||||||
|
* application waits for RX data.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* ripaddr - The remote address to send the data
|
* lipaddr - The local board IPv6 address of the socket
|
||||||
|
* ripaddr - The remote IPv4 address to send the data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* None
|
||||||
@ -91,10 +93,11 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
void netdev_rxnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr)
|
void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
||||||
#else
|
#else
|
||||||
void netdev_rxnotify(const net_ipaddr_t ripaddr)
|
void netdev_ipv4_rxnotify(in_addr_t ripaddr)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
@ -114,5 +117,52 @@ void netdev_rxnotify(const net_ipaddr_t ripaddr)
|
|||||||
(void)dev->d_rxavail(dev);
|
(void)dev->d_rxavail(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: netdev_ipv6_rxnotify
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the device driver that forwards the IPv6 address that the
|
||||||
|
* application waits for RX data.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* lipaddr - The local board IPv6 address of the socket
|
||||||
|
* ripaddr - The remote IPv6 address to send the data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called from normal user mode
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
|
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
|
FAR const net_ipv6addr_t ripaddr)
|
||||||
|
#else
|
||||||
|
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
|
/* Find the device driver that serves the subnet of the remote address */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
|
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
||||||
|
#else
|
||||||
|
dev = netdev_findby_ipv6addr(ripaddr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (dev && dev->d_rxavail)
|
||||||
|
{
|
||||||
|
/* Notify the device driver that new RX data is available. */
|
||||||
|
|
||||||
|
(void)dev->d_rxavail(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && CONFIG_NET_RXAVAIL */
|
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS && CONFIG_NET_RXAVAIL */
|
||||||
|
@ -75,12 +75,14 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: netdev_txnotify
|
* Function: netdev_ipv4_txnotify
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Notify the device driver that new TX data is available.
|
* Notify the device driver that forwards the IPv4 address that new TX
|
||||||
|
* data is available.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
|
* lipaddr - The local address bound to the socket
|
||||||
* ripaddr - The remote address to send the data
|
* ripaddr - The remote address to send the data
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@ -91,11 +93,12 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_IPv4
|
||||||
void netdev_txnotify(const net_ipaddr_t lipaddr, const net_ipaddr_t ripaddr)
|
# ifdef CONFIG_NET_MULTILINK
|
||||||
#else
|
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
||||||
void netdev_txnotify(const net_ipaddr_t ripaddr)
|
# else
|
||||||
#endif
|
void netdev_ipv4_txnotify(in_addr_t ripaddr)
|
||||||
|
# endif
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
@ -114,5 +117,53 @@ void netdev_txnotify(const net_ipaddr_t ripaddr)
|
|||||||
(void)dev->d_txavail(dev);
|
(void)dev->d_txavail(dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: netdev_ipv6_txnotify
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Notify the device driver that forwards the IPv4 address that new TX
|
||||||
|
* data is available.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* lipaddr - The local address bound to the socket
|
||||||
|
* ripaddr - The remote address to send the data
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called from normal user mode
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
|
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
|
FAR const net_ipv6addr_t ripaddr)
|
||||||
|
#else
|
||||||
|
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
|
/* Find the device driver that serves the subnet of the remote address */
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
|
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
||||||
|
#else
|
||||||
|
dev = netdev_findby_ipv6addr(ripaddr);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (dev && dev->d_txavail)
|
||||||
|
{
|
||||||
|
/* Notify the device driver that new TX data is available. */
|
||||||
|
|
||||||
|
(void)dev->d_txavail(dev);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||||
|
@ -267,14 +267,14 @@ ssize_t psock_pkt_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
dev = netdev_findbyname("eth0");
|
dev = netdev_findbyname("eth0");
|
||||||
|
|
||||||
/* Notify the device driver that new TX data is available.
|
/* Notify the device driver that new TX data is available.
|
||||||
* NOTES: This is in essence what netdev_txnotify() does, which
|
* NOTES: This is in essence what netdev_ipv4_txnotify() does,
|
||||||
* is not possible to call since it expects a net_ipaddr_t as
|
* which is not possible to call since it expects a in_addr_t as
|
||||||
* its single argument to lookup the network interface.
|
* its single argument to lookup the network interface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
dev->d_txavail(dev);
|
dev->d_txavail(dev);
|
||||||
|
|
||||||
/* Wait for the send to complete or an error to occure: NOTES: (1)
|
/* Wait for the send to complete or an error to occur: NOTES: (1)
|
||||||
* net_lockedwait will also terminate if a signal is received, (2)
|
* net_lockedwait will also terminate if a signal is received, (2)
|
||||||
* interrupts may be disabled! They will be re-enabled while the
|
* interrupts may be disabled! They will be re-enabled while the
|
||||||
* task sleeps and automatically re-enabled when the task restarts.
|
* task sleeps and automatically re-enabled when the task restarts.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/route/net_addroute.c
|
* net/route/net_addroute.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013, 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
|
||||||
@ -78,8 +78,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int net_addroute(net_ipaddr_t target, net_ipaddr_t netmask,
|
int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router)
|
||||||
net_ipaddr_t router)
|
|
||||||
{
|
{
|
||||||
FAR struct net_route_s *route;
|
FAR struct net_route_s *route;
|
||||||
net_lock_t save;
|
net_lock_t save;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/route/net_delroute.c
|
* net/route/net_delroute.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013, 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
|
||||||
@ -56,8 +56,8 @@
|
|||||||
struct route_match_s
|
struct route_match_s
|
||||||
{
|
{
|
||||||
FAR struct net_route_s *prev; /* Predecessor in the list */
|
FAR struct net_route_s *prev; /* Predecessor in the list */
|
||||||
net_ipaddr_t target; /* The target IP address to match */
|
in_addr_t target; /* The target IP address to match */
|
||||||
net_ipaddr_t netmask; /* The network mask to match */
|
in_addr_t netmask; /* The network mask to match */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -134,7 +134,7 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int net_delroute(net_ipaddr_t target, net_ipaddr_t netmask)
|
int net_delroute(in_addr_t target, in_addr_t netmask)
|
||||||
{
|
{
|
||||||
struct route_match_s match;
|
struct route_match_s match;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/route/net_router.c
|
* net/route/net_router.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-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
|
||||||
@ -54,21 +54,31 @@
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
struct route_match_s
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
struct route_ipv4_match_s
|
||||||
{
|
{
|
||||||
net_ipaddr_t target; /* The target IP address on an external network to match */
|
in_addr_t target; /* Target IPv4 address on an external network to match */
|
||||||
net_ipaddr_t router; /* The IP address of the router on one of our networks*/
|
in_addr_t router; /* IPv4 address of the router on one of our networks*/
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
struct route_ipv6_match_s
|
||||||
|
{
|
||||||
|
net_ipv6addr_t target; /* arget IPv6 address on an external network to match */
|
||||||
|
net_ipv6addr_t router; /* IPv6 address of the router on one of our networks*/
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: net_match
|
* Function: net_ipv4_match
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return 1 if the route is available
|
* Return 1 if the IPv4 route is available
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* route - The next route to examine
|
* route - The next route to examine
|
||||||
@ -79,16 +89,17 @@ struct route_match_s
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int net_match(FAR struct net_route_s *route, FAR void *arg)
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
static int net_ipv4_match(FAR struct net_route_s *route, FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct route_match_s *match = (FAR struct route_match_s *)arg;
|
FAR struct route_ipv4_match_s *match = (FAR struct route_ipv4_match_s *)arg;
|
||||||
|
|
||||||
/* To match, the masked target addresses must be the same. In the event
|
/* To match, the masked target addresses must be the same. In the event
|
||||||
* of multiple matches, only the first is returned. There is not (yet) any
|
* of multiple matches, only the first is returned. There is not (yet) any
|
||||||
* concept for the precedence of networks.
|
* concept for the precedence of networks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipaddr_maskcmp(route->target, match->target, route->netmask))
|
if (net_ipv4addr_maskcmp(route->target, match->target, route->netmask))
|
||||||
{
|
{
|
||||||
/* They match.. Copy the router address */
|
/* They match.. Copy the router address */
|
||||||
|
|
||||||
@ -98,66 +109,98 @@ static int net_match(FAR struct net_route_s *route, FAR void *arg)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: net_ipv6_match
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return 1 if the IPv6 route is available
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* route - The next route to examine
|
||||||
|
* arg - The match values (cast to void*)
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 if the entry is not a match; 1 if the entry matched and was cleared.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
static int net_ipv6_match(FAR struct net_route_s *route, FAR void *arg)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
# warning Missing logic
|
||||||
|
#else
|
||||||
|
FAR struct route_ipv4_match_s *match = (FAR struct route_ipv4_match_s *)arg;
|
||||||
|
|
||||||
|
/* To match, the masked target addresses must be the same. In the event
|
||||||
|
* of multiple matches, only the first is returned. There is not (yet) any
|
||||||
|
* concept for the precedence of networks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (net_ipv6ddr_maskcmp(route->target, match->target, route->netmask))
|
||||||
|
{
|
||||||
|
/* They match.. Copy the router address */
|
||||||
|
|
||||||
|
net_ipaddr_copy(match->router, route->router);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: net_router
|
* Function: net_ipv4_router
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Given an IP address on a external network, return the address of the
|
* Given an IPv4 address on a external network, return the address of the
|
||||||
* router on a local network that can forward to the external network.
|
* router on a local network that can forward to the external network.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* target - An IP address on a remote network to use in the lookup.
|
* target - An IPv4 address on a remote network to use in the lookup.
|
||||||
* router - The address of router on a local network that can forward our
|
* router - The address of router on a local network that can forward our
|
||||||
* packets to the target.
|
* packets to the target.
|
||||||
*
|
*
|
||||||
* NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
|
|
||||||
* value. Hence, the change in the function signature.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* OK on success; Negated errno on failure.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv4
|
||||||
int net_router(net_ipaddr_t target, net_ipaddr_t router)
|
int net_ipv4_router(in_addr_t target, FAR in_addr_t *router)
|
||||||
#else
|
|
||||||
int net_router(net_ipaddr_t target, FAR net_ipaddr_t *router)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
struct route_match_s match;
|
struct route_ipv4_match_s match;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Do not route the special broadcast IP address */
|
/* Do not route the special broadcast IP address */
|
||||||
|
|
||||||
if (net_ipaddr_cmp(target, g_alloneaddr))
|
if (net_ipaddr_cmp(target, g_ipv4_alloneaddr))
|
||||||
{
|
{
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set up the comparison structure */
|
/* Set up the comparison structure */
|
||||||
|
|
||||||
memset(&match, 0, sizeof(struct route_match_s));
|
memset(&match, 0, sizeof(struct route_ipv4_match_s));
|
||||||
net_ipaddr_copy(match.target, target);
|
net_ipaddr_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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = net_foreachroute(net_match, &match);
|
ret = net_foreachroute(net_ipv4_match, &match);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
/* We found a route. Return the router address. */
|
/* We found a route. Return the router address. */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
net_ipv4addr_copy(*router, match.router);
|
||||||
net_ipaddr_copy(router, match.router);
|
|
||||||
#else
|
|
||||||
net_ipaddr_copy(*router, match.router);
|
|
||||||
#endif
|
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -169,5 +212,64 @@ int net_router(net_ipaddr_t target, FAR net_ipaddr_t *router)
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: net_ipv6_router
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Given an IPv6 address on a external network, return the address of the
|
||||||
|
* router on a local network that can forward to the external network.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* target - An IPv6 address on a remote network to use in the lookup.
|
||||||
|
* router - The address of router on a local network that can forward our
|
||||||
|
* packets to the target.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router)
|
||||||
|
{
|
||||||
|
struct route_ipv6_match_s match;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Do not route the special broadcast IP address */
|
||||||
|
|
||||||
|
if (net_ipaddr_cmp(target, g_ipv6_alloneaddr))
|
||||||
|
{
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set up the comparison structure */
|
||||||
|
|
||||||
|
memset(&match, 0, sizeof(struct route_ipv6_match_s));
|
||||||
|
net_ipaddr_copy(match.target, target);
|
||||||
|
|
||||||
|
/* Find an router entry with the routing table that can forward to this
|
||||||
|
* address
|
||||||
|
*/
|
||||||
|
|
||||||
|
ret = net_foreachroute(net_ipv6_match, &match);
|
||||||
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
/* We found a route. Return the router address. */
|
||||||
|
|
||||||
|
net_ipv6addr_copy(router, match.router);
|
||||||
|
ret = OK;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* There is no route for this address */
|
||||||
|
|
||||||
|
ret = -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/route/netdev_router.c
|
* net/route/netdev_router.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-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
|
||||||
@ -55,22 +55,24 @@
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
struct route_devmatch_s
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
struct route_ipv4_devmatch_s
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev; /* The route must use this device */
|
FAR struct net_driver_s *dev; /* The route must use this device */
|
||||||
net_ipaddr_t target; /* The target IP address on an external network to match */
|
in_addr_t target; /* Target IPv4 address on an external network to match */
|
||||||
net_ipaddr_t router; /* The IP address of the router on one of our networks*/
|
in_addr_t router; /* IPv6 address of the router on one of our networks*/
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: net_devmatch
|
* Function: net_ipv4_devmatch
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Return 1 if the route is available on the device's network.
|
* Return 1 if the IPv4 route is available on the device's network.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* route - The next route to examine
|
* route - The next route to examine
|
||||||
@ -81,9 +83,10 @@ struct route_devmatch_s
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int net_devmatch(FAR struct net_route_s *route, FAR void *arg)
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
static int net_ipv4_devmatch(FAR struct net_route_s *route, FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct route_devmatch_s *match = (FAR struct route_devmatch_s *)arg;
|
FAR struct route_ipv4_devmatch_s *match = (FAR struct route_ipv4_devmatch_s *)arg;
|
||||||
FAR struct net_driver_s *dev = match->dev;
|
FAR struct net_driver_s *dev = match->dev;
|
||||||
|
|
||||||
/* To match, (1) the masked target addresses must be the same, and (2) the
|
/* To match, (1) the masked target addresses must be the same, and (2) the
|
||||||
@ -93,59 +96,99 @@ static int net_devmatch(FAR struct net_route_s *route, FAR void *arg)
|
|||||||
* not (yet) any concept for the precedence of networks.
|
* not (yet) any concept for the precedence of networks.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipaddr_maskcmp(route->target, match->target, route->netmask) &&
|
if (net_ipv4addr_maskcmp(route->target, match->target, route->netmask) &&
|
||||||
net_ipaddr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask))
|
net_ipv4addr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask))
|
||||||
{
|
{
|
||||||
/* 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: net_ipv6_devmatch
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return 1 if the IPv6 route is available on the device's network.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* route - The next route to examine
|
||||||
|
* arg - The match values (cast to void*)
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* 0 if the entry is not a match; 1 if the entry matched and was cleared.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
static int net_ipv6_devmatch(FAR struct net_route_s *route, FAR void *arg)
|
||||||
|
{
|
||||||
|
#if 1
|
||||||
|
# warning Missing logic
|
||||||
|
#else
|
||||||
|
FAR struct route_ipv6_devmatch_s *match = (FAR struct route_ipv6_devmatch_s *)arg;
|
||||||
|
FAR struct net_driver_s *dev = match->dev;
|
||||||
|
|
||||||
|
/* To match, (1) the masked target addresses must be the same, and (2) the
|
||||||
|
* router address must like on the network provided by the device.
|
||||||
|
*
|
||||||
|
* In the event of multiple matches, only the first is returned. There
|
||||||
|
* not (yet) any concept for the precedence of networks.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (net_ipv6addr_maskcmp(route->target, match->target, route->netmask) &&
|
||||||
|
net_ipv6addr_maskcmp(route->router, dev->d_ipaddr, dev->d_netmask))
|
||||||
|
{
|
||||||
|
/* They match.. Copy the router address */
|
||||||
|
|
||||||
|
net_ipv6addr_copy(match->router, route->router);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: netdev_router
|
* Function: netdev_ipv4_router
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Given an IP address on a external network, return the address of the
|
* Given an IPv4 address on a external network, return the address of the
|
||||||
* router on a local network that can forward to the external network.
|
* router on a local network that can forward to the external network.
|
||||||
* This is similar to net_router(). However, the set of routers is
|
* This is similar to net_ipv4_router(). However, the set of routers is
|
||||||
* constrained to those accessible by the specific device
|
* constrained to those accessible by the specific device
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* dev - We are committed to using this device.
|
* dev - We are committed to using this device.
|
||||||
* target - An IP address on a remote network to use in the lookup.
|
* target - An IPv4 address on a remote network to use in the lookup.
|
||||||
* router - The address of router on a local network that can forward our
|
* router - The address of router on a local network that can forward our
|
||||||
* packets to the target.
|
* packets to the target.
|
||||||
*
|
*
|
||||||
* NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
|
|
||||||
* value. Hence, the change in the function signature.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None
|
* A router address is always returned (which may just be, perhaps,
|
||||||
|
* device's default router address)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv4
|
||||||
void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
|
void netdev_ipv4_router(FAR struct net_driver_s *dev, in_addr_t target,
|
||||||
net_ipaddr_t router)
|
FAR in_addr_t *router)
|
||||||
#else
|
|
||||||
void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
|
|
||||||
FAR net_ipaddr_t *router)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
struct route_devmatch_s match;
|
struct route_ipv4_devmatch_s match;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Set up the comparison structure */
|
/* Set up the comparison structure */
|
||||||
|
|
||||||
memset(&match, 0, sizeof(struct route_devmatch_s));
|
memset(&match, 0, sizeof(struct route_ipv4_devmatch_s));
|
||||||
match.dev = dev;
|
match.dev = dev;
|
||||||
net_ipaddr_copy(match.target, target);
|
net_ipaddr_copy(match.target, target);
|
||||||
|
|
||||||
@ -153,16 +196,12 @@ void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
|
|||||||
* address using this device.
|
* address using this device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = net_foreachroute(net_devmatch, &match);
|
ret = net_foreachroute(net_ipv4_devmatch, &match);
|
||||||
if (ret > 0)
|
if (ret > 0)
|
||||||
{
|
{
|
||||||
/* We found a route. Return the router address. */
|
/* We found a route. Return the router address. */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
net_ipv4addr_copy(*router, match.target);
|
||||||
net_ipaddr_copy(router, match.target);
|
|
||||||
#else
|
|
||||||
net_ipaddr_copy(*router, match.target);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -170,12 +209,66 @@ void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
|
|||||||
* of the device.
|
* of the device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
net_ipv4addr_copy(*router, dev->d_draddr);
|
||||||
net_ipaddr_copy(router, dev->d_draddr);
|
|
||||||
#else
|
|
||||||
net_ipaddr_copy(*router, dev->d_draddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: netdev_ipv6_router
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Given an IPv6 address on a external network, return the address of the
|
||||||
|
* router on a local network that can forward to the external network.
|
||||||
|
* This is similar to net_ipv6_router(). However, the set of routers is
|
||||||
|
* constrained to those accessible by the specific device
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* dev - We are committed to using this device.
|
||||||
|
* target - An IPv6 address on a remote network to use in the lookup.
|
||||||
|
* router - The address of router on a local network that can forward our
|
||||||
|
* packets to the target.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* A router address is always returned (which may just be, perhaps,
|
||||||
|
* device's default router address)
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv6
|
||||||
|
void netdev_ipv6_router(FAR struct net_driver_s *dev,
|
||||||
|
FAR const net_ipv6addr_t target,
|
||||||
|
FAR net_ipv6addr_t router)
|
||||||
|
{
|
||||||
|
struct route_ipv6_devmatch_s match;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
/* Set up the comparison structure */
|
||||||
|
|
||||||
|
memset(&match, 0, sizeof(struct route_ipv6_devmatch_s));
|
||||||
|
match.dev = dev;
|
||||||
|
net_ipaddr_copy(match.target, target);
|
||||||
|
|
||||||
|
/* Find an router entry with the routing table that can forward to this
|
||||||
|
* address using this device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ret = net_foreachroute(net_ipv6_devmatch, &match);
|
||||||
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
/* We found a route. Return the router address. */
|
||||||
|
|
||||||
|
net_ipv6addr_copy(router, match.target);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* There isn't a matching route.. fallback and use the default router
|
||||||
|
* of the device.
|
||||||
|
*/
|
||||||
|
|
||||||
|
net_ipv6addr_copy(router, dev->d_draddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
#endif /* CONFIG_NET && CONFIG_NET_ROUTE */
|
||||||
|
@ -67,9 +67,9 @@
|
|||||||
struct net_route_s
|
struct net_route_s
|
||||||
{
|
{
|
||||||
FAR struct net_route_s *flink; /* Supports a singly linked list */
|
FAR struct net_route_s *flink; /* Supports a singly linked list */
|
||||||
net_ipaddr_t target; /* The destination network */
|
in_addr_t target; /* The destination network */
|
||||||
net_ipaddr_t netmask; /* The network address mask */
|
in_addr_t netmask; /* The network address mask */
|
||||||
net_ipaddr_t router; /* Route packets via this router */
|
in_addr_t router; /* Route packets via this router */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Type of the call out function pointer provided to net_foreachroute() */
|
/* Type of the call out function pointer provided to net_foreachroute() */
|
||||||
@ -162,8 +162,8 @@ void net_freeroute(FAR struct net_route_s *route);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int net_addroute(net_ipaddr_t target, net_ipaddr_t netmask,
|
int net_addroute(in_addr_t target, in_addr_t netmask,
|
||||||
net_ipaddr_t router);
|
in_addr_t router);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: net_delroute
|
* Function: net_delroute
|
||||||
@ -178,22 +178,40 @@ int net_addroute(net_ipaddr_t target, net_ipaddr_t netmask,
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int net_delroute(net_ipaddr_t target, net_ipaddr_t netmask);
|
int net_delroute(in_addr_t target, in_addr_t netmask);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: net_router
|
* Function: net_ipv4_router
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Given an IP address on a external network, return the address of the
|
* Given an IPv4 address on a external network, return the address of the
|
||||||
* router on a local network that can forward to the external network.
|
* router on a local network that can forward to the external network.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* target - An IP address on a remote network to use in the lookup.
|
* target - An IPv4 address on a remote network to use in the lookup.
|
||||||
* router - The address of router on a local network that can forward our
|
* router - The address of router on a local network that can forward our
|
||||||
* packets to the target.
|
* packets to the target.
|
||||||
*
|
*
|
||||||
* NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
|
* Returned Value:
|
||||||
* value. Hence, the change in the function signature.
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
|
int net_ipv4_router(in_addr_t target, FAR in_addr_t *router);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: net_ipv6_router
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Given an IPv6 address on a external network, return the address of the
|
||||||
|
* router on a local network that can forward to the external network.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* target - An IPv6 address on a remote network to use in the lookup.
|
||||||
|
* router - The address of router on a local network that can forward our
|
||||||
|
* packets to the target.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* OK on success; Negated errno on failure.
|
* OK on success; Negated errno on failure.
|
||||||
@ -201,43 +219,62 @@ int net_delroute(net_ipaddr_t target, net_ipaddr_t netmask);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
int net_router(net_ipaddr_t target, net_ipaddr_t router);
|
int net_ipv6_router(net_ipv6addr_t target, net_ipv6addr_t router);
|
||||||
#else
|
|
||||||
int net_router(net_ipaddr_t target, FAR net_ipaddr_t *router);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: netdev_router
|
* Function: netdev_ipv4_router
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Given an IP address on a external network, return the address of the
|
* Given an IPv4 address on a external network, return the address of the
|
||||||
* router on a local network that can forward to the external network.
|
* router on a local network that can forward to the external network.
|
||||||
* This is similar to net_router(). However, the set of routers is
|
* This is similar to net_ipv4_router(). However, the set of routers is
|
||||||
* constrained to those accessible by the specific device
|
* constrained to those accessible by the specific device
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* dev - We are committed to using this device.
|
* dev - We are committed to using this device.
|
||||||
* target - An IP address on a remote network to use in the lookup.
|
* target - An IPv4 address on a remote network to use in the lookup.
|
||||||
* router - The address of router on a local network that can forward our
|
* router - The address of router on a local network that can forward our
|
||||||
* packets to the target.
|
* packets to the target.
|
||||||
*
|
*
|
||||||
* NOTE: For IPv6, router will be an array, for IPv4 it will be a scalar
|
|
||||||
* value. Hence, the change in the function signature.
|
|
||||||
*
|
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* None, a router address is always returned (which may just be, perhaps,
|
* A router address is always returned (which may just be, perhaps,
|
||||||
* device's default router address)
|
* device's default router address)
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_IPv4
|
||||||
struct net_driver_s;
|
struct net_driver_s;
|
||||||
|
void netdev_ipv4_router(FAR struct net_driver_s *dev, in_addr_t target,
|
||||||
|
FAR in_addr_t *router);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: netdev_ipv6_router
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Given an IPv6 address on a external network, return the address of the
|
||||||
|
* router on a local network that can forward to the external network.
|
||||||
|
* This is similar to net_ipv6_router(). However, the set of routers is
|
||||||
|
* constrained to those accessible by the specific device
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* dev - We are committed to using this device.
|
||||||
|
* target - An IPv6 address on a remote network to use in the lookup.
|
||||||
|
* router - The address of router on a local network that can forward our
|
||||||
|
* packets to the target.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* A router address is always returned (which may just be, perhaps,
|
||||||
|
* device's default router address)
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
|
struct net_driver_s;
|
||||||
net_ipaddr_t router);
|
void netdev_ipv6_router(FAR struct net_driver_s *dev,
|
||||||
#else
|
FAR const net_ipv6addr_t target,
|
||||||
void netdev_router(FAR struct net_driver_s *dev, net_ipaddr_t target,
|
FAR net_ipv6addr_t router);
|
||||||
FAR net_ipaddr_t *router);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* net/socket/net_close.c
|
* net/socket/net_close.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-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
|
||||||
@ -358,9 +358,9 @@ static inline int netclose_disconnect(FAR struct socket *psock)
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_SOLINGER
|
#ifdef CONFIG_NET_SOLINGER
|
||||||
|
@ -565,9 +565,9 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset,
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
net_lockedwait(&state.snd_sem);
|
net_lockedwait(&state.snd_sem);
|
||||||
}
|
}
|
||||||
|
@ -1097,9 +1097,9 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
|
|
||||||
#if 0 /* No */
|
#if 0 /* No */
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_rxnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_rxnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1196,9 +1196,9 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len,
|
|||||||
/* Notify the device driver of the receive call */
|
/* Notify the device driver of the receive call */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_rxnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_rxnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Wait for either the receive to complete or for an error/timeout to occur.
|
/* Wait for either the receive to complete or for an error/timeout to occur.
|
||||||
|
@ -420,9 +420,9 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf,
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Wait for either the receive to complete or for an error/timeout to occur.
|
/* Wait for either the receive to complete or for an error/timeout to occur.
|
||||||
|
@ -104,8 +104,7 @@ static uint16_t g_last_tcp_port;
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
static FAR struct tcp_conn_s *tcp_listener(net_ipaddr_t ipaddr,
|
static FAR struct tcp_conn_s *tcp_listener(in_addr_t ipaddr, uint16_t portno)
|
||||||
uint16_t portno)
|
|
||||||
#else
|
#else
|
||||||
static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
|
static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
|
||||||
#endif
|
#endif
|
||||||
@ -132,11 +131,11 @@ static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
|
|||||||
* with INADDR_ANY.
|
* with INADDR_ANY.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (net_ipaddr_cmp(conn->u.ipv4.laddr, ipaddr) ||
|
if (net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr) ||
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr))
|
net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr))
|
||||||
#else
|
#else
|
||||||
net_ipaddr_cmp(conn->u.ipv4.laddr, INADDR_ANY))
|
net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@ -176,7 +175,7 @@ static FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
static int tcp_selectport(net_ipaddr_t ipaddr, uint16_t portno)
|
static int tcp_selectport(in_addr_t ipaddr, uint16_t portno)
|
||||||
#else
|
#else
|
||||||
static int tcp_selectport(uint16_t portno)
|
static int tcp_selectport(uint16_t portno)
|
||||||
#endif
|
#endif
|
||||||
@ -525,7 +524,7 @@ 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_allzeroaddr) ||
|
(net_ipaddr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr) ||
|
||||||
net_ipaddr_cmp(destipaddr, conn->u.ipv4.laddr)) &&
|
net_ipaddr_cmp(destipaddr, conn->u.ipv4.laddr)) &&
|
||||||
#endif
|
#endif
|
||||||
net_ipaddr_cmp(srcipaddr, conn->u.ipv4.raddr))
|
net_ipaddr_cmp(srcipaddr, conn->u.ipv4.raddr))
|
||||||
@ -668,7 +667,7 @@ int tcp_bind(FAR struct tcp_conn_s *conn,
|
|||||||
net_lock_t flags;
|
net_lock_t flags;
|
||||||
int port;
|
int port;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
net_ipaddr_t ipaddr;
|
in_addr_t ipaddr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Verify or select a local port and address */
|
/* Verify or select a local port and address */
|
||||||
|
@ -829,9 +829,9 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
result = len;
|
result = len;
|
||||||
}
|
}
|
||||||
|
@ -597,9 +597,9 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
|
|||||||
/* Notify the device driver of the availability of TX data */
|
/* Notify the device driver of the availability of TX data */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
netdev_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
#else
|
||||||
netdev_txnotify(conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Wait for the send to complete or an error to occur: NOTES: (1)
|
/* Wait for the send to complete or an error to occur: NOTES: (1)
|
||||||
|
@ -127,8 +127,7 @@ static inline void _udp_semtake(FAR sem_t *sem)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
static FAR struct udp_conn_s *udp_find_conn(net_ipaddr_t ipaddr,
|
static FAR struct udp_conn_s *udp_find_conn(in_addr_t ipaddr, uint16_t portno)
|
||||||
uint16_t portno)
|
|
||||||
#else
|
#else
|
||||||
static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
|
static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
|
||||||
#endif
|
#endif
|
||||||
@ -150,11 +149,11 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if (conn->lport == portno &&
|
if (conn->lport == portno &&
|
||||||
(net_ipaddr_cmp(conn->u.ipv4.laddr, ipaddr) ||
|
(net_ipv4addr_cmp(conn->u.ipv4.laddr, ipaddr) ||
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr)))
|
net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr)))
|
||||||
#else
|
#else
|
||||||
net_ipaddr_cmp(conn->u.ipv4.laddr, INADDR_ANY)))
|
net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY)))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return conn;
|
return conn;
|
||||||
@ -195,7 +194,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
static uint16_t udp_select_port(net_ipaddr_t ipaddr)
|
static uint16_t udp_select_port(in_addr_t ipaddr)
|
||||||
#else
|
#else
|
||||||
static uint16_t udp_select_port(void)
|
static uint16_t udp_select_port(void)
|
||||||
#endif
|
#endif
|
||||||
@ -381,13 +380,13 @@ FAR struct udp_conn_s *udp_active(FAR struct net_driver_s *dev,
|
|||||||
if (conn->lport != 0 && udp->destport == conn->lport &&
|
if (conn->lport != 0 && udp->destport == conn->lport &&
|
||||||
(conn->rport == 0 || udp->srcport == conn->rport) &&
|
(conn->rport == 0 || udp->srcport == conn->rport) &&
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
(net_ipaddr_cmp(conn->u.ipv4.laddr, g_allzeroaddr) ||
|
(net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_allzeroaddr) ||
|
||||||
net_ipaddr_cmp(conn->u.ipv4.laddr, g_alloneaddr) ||
|
net_ipv4addr_cmp(conn->u.ipv4.laddr, g_ipv4_alloneaddr) ||
|
||||||
net_ipaddr_hdrcmp(ip->destipaddr, &conn->u.ipv4.laddr)) &&
|
net_ipv4addr_hdrcmp(ip->destipaddr, &conn->u.ipv4.laddr)) &&
|
||||||
#endif
|
#endif
|
||||||
(net_ipaddr_cmp(conn->u.ipv4.raddr, g_allzeroaddr) ||
|
(net_ipv4addr_cmp(conn->u.ipv4.raddr, g_ipv4_allzeroaddr) ||
|
||||||
net_ipaddr_cmp(conn->u.ipv4.raddr, g_alloneaddr) ||
|
net_ipv4addr_cmp(conn->u.ipv4.raddr, g_ipv4_alloneaddr) ||
|
||||||
net_ipaddr_hdrcmp(ip->srcipaddr, &conn->u.ipv4.raddr)))
|
net_ipv4addr_hdrcmp(ip->srcipaddr, &conn->u.ipv4.raddr)))
|
||||||
{
|
{
|
||||||
/* Matching connection found.. return a reference to it */
|
/* Matching connection found.. return a reference to it */
|
||||||
|
|
||||||
@ -448,7 +447,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
net_ipaddr_t ipaddr;
|
in_addr_t ipaddr;
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
/* Get the IPv6 address that we are binding to */
|
/* Get the IPv6 address that we are binding to */
|
||||||
@ -569,7 +568,7 @@ int udp_connect(FAR struct udp_conn_s *conn,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
conn->rport = 0;
|
conn->rport = 0;
|
||||||
net_ipaddr_copy(conn->u.ipv4.raddr, g_allzeroaddr);
|
net_ipv4addr_copy(conn->u.ipv4.raddr, g_ipv4_allzeroaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->ttl = IP_TTL;
|
conn->ttl = IP_TTL;
|
||||||
|
@ -143,7 +143,7 @@ static uint16_t upper_layer_chksum(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
/* Sum IP source and destination addresses. */
|
/* Sum IP source and destination addresses. */
|
||||||
|
|
||||||
sum = chksum(sum, (uint8_t *)&pbuf->srcipaddr, 2 * sizeof(net_ipaddr_t));
|
sum = chksum(sum, (uint8_t *)&pbuf->srcipaddr, 2 * sizeof(in_addr_t));
|
||||||
|
|
||||||
/* Sum TCP header and data. */
|
/* Sum TCP header and data. */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user