Merge branch 'multinic'

This commit is contained in:
Gregory Nutt 2015-05-27 17:20:13 -06:00
commit c05bc8b078
6 changed files with 277 additions and 31 deletions

View File

@ -10446,4 +10446,6 @@
* net/: Extend Macs logic to ARP and ICMPv6. Also found and fix
several IPv6-related compilation errors that have crept in. IPv6
has been broken for awhile (2015-05-27).
* net/tcp: Fix an important TCP networking bug: 16-bit flags was
being converted to 8-bits in a few locations, causing loss of
status indications (2015-05-27).

View File

@ -80,12 +80,38 @@
* was last sent. (TCP only)
* OUT: Not used
*
* ARP_POLL IN: Used for polling the socket layer. This is provided
* TCP_POLL periodically from the drivers to support (1) timed
* UDP_POLL operations, and (2) to check if the socket layer has
* PKT_POLL data that it wants to send
* ICMP_POLL OUT: Not used
* ICMPv6_POLL
* ARP_POLL IN: Used for polling the socket layer. This is provided
* periodically from the drivers to support (1) timed
* operations, and (2) to check if the ARP layer needs
* to send an ARP request. This is a device oriented
* event, not associated with a socket.
* OUT: Not used
*
* ICMP_POLL IN: Used for polling the socket layer. This is provided
* periodically from the drivers to support (1) timed
* operations, and (2) to check if the ICMP layer needs
* to send an ARP request. This is a device oriented
* event, not associated with a socket. This differs
* from ICMPv6_POLL only in that the appdata pointer
* is set differently
* OUT: Not used
*
* ICMPv6_POLL IN: Used for polling the socket layer. This is provided
* periodically from the drivers to support (1) timed
* operations, and (2) to check if the ICMP layer needs
* to send an ARP request. This is a device oriented
* event, not associated with a socket. This differs
* from ICMP_POLL only in that the appdata pointer
* is set differently
* OUT: Not used
*
* TCP_POLL IN: Used for polling the socket layer. This is provided
* UDP_POLL periodically from the drivers to support (1) timed
* PKT_POLL operations, and (2) to check if the socket layer has
* data that it wants to send. These are socket oriented
* callbacks where the context depends on the specific
* set
* OUT: Not used
*
* TCP_BACKLOG IN: There is a new connection in the backlog list set
* up by the listen() command. (TCP only)
@ -115,11 +141,13 @@
* OUT: Cleared (only) by the socket layer logic to indicate
* that the reply was processed, suppressing further
* attempts to process the reply.
*
* ICMPv6_ECHOREPLY IN: An ICMP Echo Reply has been received. Used to support
* ICMP ping from the socket layer. (ICMPv6 only)
* OUT: Cleared (only) by the socket layer logic to indicate
* that the reply was processed, suppressing further
* attempts to process the reply.
*
* NETDEV_DOWN: IN: The network device has been taken down.
* OUT: Not used
*/
@ -133,19 +161,19 @@
#define TCP_SNDACK (1 << 2)
#define TCP_REXMIT (1 << 3)
#define ARP_POLL (1 << 4)
#define TCP_POLL ARP_POLL
#define UDP_POLL ARP_POLL
#define PKT_POLL ARP_POLL
#define ICMP_POLL ARP_POLL
#define ICMPv6_POLL ARP_POLL
#define TCP_BACKLOG (1 << 5)
#define TCP_CLOSE (1 << 6)
#define TCP_ABORT (1 << 7)
#define TCP_CONNECTED (1 << 8)
#define TCP_TIMEDOUT (1 << 9)
#define ICMP_ECHOREPLY (1 << 10)
#define ICMPv6_ECHOREPLY (1 << 11)
#define NETDEV_DOWN (1 << 12)
#define ICMP_POLL (1 << 5)
#define ICMPv6_POLL (1 << 6)
#define TCP_POLL (1 << 7)
#define UDP_POLL TCP_POLL
#define PKT_POLL TCP_POLL
#define TCP_BACKLOG (1 << 8)
#define TCP_CLOSE (1 << 9)
#define TCP_ABORT (1 << 10)
#define TCP_CONNECTED (1 << 11)
#define TCP_TIMEDOUT (1 << 12)
#define ICMP_ECHOREPLY (1 << 13)
#define ICMPv6_ECHOREPLY (1 << 14)
#define NETDEV_DOWN (1 << 15)
#define TCP_CONN_EVENTS (TCP_CLOSE | TCP_ABORT | TCP_CONNECTED | \
TCP_TIMEDOUT | NETDEV_DOWN)

View File

@ -77,26 +77,94 @@ EXTERN struct net_driver_s *g_netdevices;
* Public Function Prototypes
****************************************************************************/
/* netdev_register.c *********************************************************/
/****************************************************************************
* Function: netdev_seminit
*
* Description:
* Initialize the network device semaphore.
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
void netdev_seminit(void);
#endif
/****************************************************************************
* Function: netdev_semtake
*
* Description:
* Get exclusive access to the network device list.
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
void netdev_semtake(void);
#endif
/****************************************************************************
* Function: netdev_semgive
*
* Description:
* Release exclusive access to the network device list
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
void netdev_semgive(void);
#endif
/* netdev_ioctl.c ************************************************************/
/****************************************************************************
* Name: netdev_ifup / netdev_ifdown
*
* Description:
* Bring the interface up/down
*
****************************************************************************/
void netdev_ifup(FAR struct net_driver_s *dev);
void netdev_ifdown(FAR struct net_driver_s *dev);
/* netdev_findbyname.c *******************************************************/
/****************************************************************************
* Function: netdev_findbyname
*
* Description:
* Find a previously registered network device using its assigned
* network interface name
*
* Parameters:
* ifname The interface name of the device of interest
*
* Returned Value:
* Pointer to driver on success; null on failure
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
FAR struct net_driver_s *netdev_findbyname(FAR const char *ifname);
#endif
/* netdev_findbyaddr.c *******************************************************/
/****************************************************************************
* Function: netdev_findby_ipv4addr
*
* Description:
* Find a previously registered network device by matching an arbitrary
* IPv4 address.
*
* Parameters:
* lipaddr - Local, bound address of a connection. Used only if ripaddr
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
* ripaddr - Remote address of a connection to use in the lookup
*
* Returned Value:
* Pointer to driver on success; null on failure
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
#ifdef CONFIG_NET_IPv4
@ -108,6 +176,26 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
#endif
#endif
/****************************************************************************
* Function: netdev_findby_ipv6addr
*
* Description:
* Find a previously registered network device by matching an arbitrary
* IPv6 address.
*
* Parameters:
* lipaddr - Local, bound address of a connection. Used only if ripaddr
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
* ripaddr - Remote address of a connection to use in the lookup
*
* Returned Value:
* Pointer to driver on success; null on failure
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NETDEV_MULTINIC
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
@ -118,13 +206,52 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr);
#endif
#endif
/* netdev_default.c ***********************************************************/
/****************************************************************************
* Function: netdev_default
*
* Description:
* Return the default network device. REVISIT: At present this function
* arbitrarily returns the first UP device at the head of the device
* list. Perhaps the default device should be a device name
* configuration option?
*
* So why is this here: It represents my current though for what to do
* if a socket is connected with INADDY_ANY. In this case, I suppose we
* should use the IP address associated with some default device???
*
* Parameters:
* NULL
*
* Returned Value:
* Pointer to default network driver on success; null on failure
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
FAR struct net_driver_s *netdev_default(void);
#endif
/* netdev_txnotify.c *********************************************************/
/****************************************************************************
* Function: netdev_ipv4_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
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
#ifdef CONFIG_NET_IPv4
@ -135,6 +262,25 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr);
# endif
#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_NETDEV_MULTINIC
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
@ -145,9 +291,45 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr);
#endif /* CONFIG_NET_IPv6 */
#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */
/****************************************************************************
* Function: netdev_txnotify_dev
*
* Description:
* Notify the device driver that new TX data is available. This variant
* would be called when the upper level logic already understands how the
* packet will be routed.
*
* Parameters:
* dev - The network device driver state structure.
*
* Returned Value:
* None
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
void netdev_txnotify_dev(FAR struct net_driver_s *dev);
/* netdev_rxnotify.c *********************************************************/
/****************************************************************************
* Function: netdev_ipv4_rxnotify
*
* Description:
* Notify the device driver that forwards the IPv4 address that the
* application waits for RX data.
*
* Parameters:
* lipaddr - The local board IPv6 address of the socket
* ripaddr - The remote IPv4 address to send the data
*
* Returned Value:
* None
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
@ -159,6 +341,25 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr);
# endif
#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_NETDEV_MULTINIC
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
@ -186,7 +387,22 @@ void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
#endif /* CONFIG_NET_IPv6 */
#endif
/* netdev_count.c ************************************************************/
/****************************************************************************
* Function: netdev_count
*
* Description:
* Return the number of network devices
*
* Parameters:
* None
*
* Returned Value:
* The number of network devices
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
int netdev_count(void);

View File

@ -95,7 +95,7 @@
void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
{
uint8_t result;
uint16_t result;
/* Verify that the connection is established */

View File

@ -103,8 +103,8 @@ static void tcp_input(FAR struct net_driver_s *dev, unsigned int iplen)
unsigned int hdrlen;
uint16_t tmp16;
uint16_t flags;
uint16_t result;
uint8_t opt;
uint8_t result;
int len;
int i;

View File

@ -98,8 +98,8 @@
void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
int hsec)
{
uint16_t result;
uint8_t hdrlen;
uint8_t result;
/* Set up for the callback. We can't know in advance if the application
* is going to send a IPv4 or an IPv6 packet, so this setup may not