2007-08-26 23:12:17 +00:00
|
|
|
/****************************************************************************
|
2014-06-24 09:28:44 -06:00
|
|
|
* include/nuttx/net/netdev.h
|
2016-05-30 09:51:15 -06:00
|
|
|
* Defines architecture-specific device driver interfaces to the NuttX
|
|
|
|
|
* network.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2018-06-25 12:08:10 -06:00
|
|
|
* Copyright (C) 2007, 2009, 2011-2018 Gregory Nutt. All rights reserved.
|
2012-03-03 23:18:34 +00:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2021-01-28 16:33:53 +01:00
|
|
|
* Derived largely from portions of uIP with has a similar BSD-styple
|
|
|
|
|
* license:
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
|
|
|
|
* Copyright (c) 2001-2003, Adam Dunkels.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
|
* distribution.
|
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
|
* without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-06-24 09:28:44 -06:00
|
|
|
#ifndef __INCLUDE_NUTTX_NET_NETDEV_H
|
|
|
|
|
#define __INCLUDE_NUTTX_NET_NETDEV_H
|
2012-03-03 23:18:34 +00:00
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Included Files
|
|
|
|
|
****************************************************************************/
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2007-09-16 17:46:25 +00:00
|
|
|
#include <nuttx/config.h>
|
2009-12-14 23:32:23 +00:00
|
|
|
|
2007-09-16 17:46:25 +00:00
|
|
|
#include <sys/ioctl.h>
|
2009-12-14 23:32:23 +00:00
|
|
|
#include <stdint.h>
|
2020-02-01 02:47:00 +08:00
|
|
|
#include <queue.h>
|
Squashed commit of the following:
net/mld: The MLD logic now compiles and is much less toxic. It still is not a proper MLD implementation: (1) It is basically a port of IGMP, tweaked to work with IPv6 and ICMPv6 MLD messages, (2) it needs a proper analysis and comparison with RFC 3810, and (3) it is completely untested. For this reason, it will remain EXPERIMENTAL for some time.
net/mld: Add some missing macros, more fixes related to IPv6 vs IPv4 types,
net/mld: More compilation cleaning. Most fixups for IPv6 vs IPv4 types.
net/mld: Hook crudely converted .c files into build system and resolve a few of the many, many compilation/design problems.
net/mld: Add support for MLD statistics.
net/mld: Hook in MLD poll and packet transmission logic.
net/mld: Change references to IPv4 definitions to IPv6 definitions; Remove mld_input() since MLD piggybacks on ICMPv6 input. Add functions to catch MLD messages dispatched by ICMPv6 input logic.
net/mld: As a starting point, copy all net/igmp/*.c files to net/mld/. and change all occurrences of igmp (or IGMP) to mld (or MLD).
net/mld: More compilation cleaning. Most fixups for IPv6 vs IPv4 types.
net/mld: Hook crudely converted .c files into build system and resolve a few of the many, many compilation/design problems.
net/mld: Add support for MLD statistics.
net/mld: Hook in MLD poll and packet transmission logic.
net/mld: Change references to IPv4 definitions to IPv6 definitions; Remove mld_input() since MLD piggybacks on ICMPv6 input. Add functions to catch MLD messages dispatched by ICMPv6 input logic.
net/mld: As a starting point, copy all net/igmp/*.c files to net/mld/. and change all occurrences of igmp (or IGMP) to mld (or MLD).
2018-11-01 15:18:40 -06:00
|
|
|
|
|
|
|
|
#include <net/if.h>
|
2014-07-04 19:13:08 -06:00
|
|
|
#include <net/ethernet.h>
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
2017-04-22 11:52:45 -06:00
|
|
|
#include <nuttx/net/netconfig.h>
|
|
|
|
|
#include <nuttx/net/ip.h>
|
|
|
|
|
|
2010-07-08 00:59:51 +00:00
|
|
|
#ifdef CONFIG_NET_IGMP
|
2014-06-24 10:14:15 -06:00
|
|
|
# include <nuttx/net/igmp.h>
|
2010-07-08 00:59:51 +00:00
|
|
|
#endif
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2018-10-31 15:03:51 -06:00
|
|
|
#ifdef CONFIG_NET_MLD
|
|
|
|
|
# include <nuttx/net/mld.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-08-26 23:12:17 +00:00
|
|
|
/****************************************************************************
|
2009-12-14 23:32:23 +00:00
|
|
|
* Pre-processor Definitions
|
2007-08-26 23:12:17 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
2017-07-30 19:10:51 -06:00
|
|
|
/* Determine the largest possible address */
|
|
|
|
|
|
|
|
|
|
#if defined(CONFIG_WIRELESS_IEEE802154) && defined(CONFIG_WIRELESS_PKTRADIO)
|
|
|
|
|
# if CONFIG_PKTRADIO_ADDRLEN > 8
|
|
|
|
|
# define RADIO_MAX_ADDRLEN CONFIG_PKTRADIO_ADDRLEN
|
|
|
|
|
# else
|
|
|
|
|
# define RADIO_MAX_ADDRLEN 8
|
|
|
|
|
# endif
|
|
|
|
|
#elif defined(CONFIG_WIRELESS_IEEE802154)
|
|
|
|
|
# define RADIO_MAX_ADDRLEN 8
|
2018-03-31 14:55:03 -06:00
|
|
|
#elif defined(CONFIG_WIRELESS_BLUETOOTH)
|
|
|
|
|
# if CONFIG_PKTRADIO_ADDRLEN > 6
|
|
|
|
|
# define RADIO_MAX_ADDRLEN CONFIG_PKTRADIO_ADDRLEN
|
|
|
|
|
# else
|
|
|
|
|
# define RADIO_MAX_ADDRLEN 6
|
|
|
|
|
# endif
|
2017-07-30 19:10:51 -06:00
|
|
|
#else /* if defined(CONFIG_WIRELESS_PKTRADIO) */
|
|
|
|
|
# define RADIO_MAX_ADDRLEN CONFIG_PKTRADIO_ADDRLEN
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-11-26 12:08:09 -06:00
|
|
|
/* Helper macros for network device statistics */
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NETDEV_STATISTICS
|
|
|
|
|
# define NETDEV_RESET_STATISTICS(dev) \
|
|
|
|
|
memset(&(dev)->d_statistics, 0, sizeof(struct netdev_statistics_s))
|
|
|
|
|
|
2015-11-26 14:44:07 -06:00
|
|
|
# define _NETDEV_STATISTIC(dev,name) ((dev)->d_statistics.name++)
|
2015-11-26 12:08:09 -06:00
|
|
|
# define _NETDEV_ERROR(dev,name) \
|
|
|
|
|
do \
|
|
|
|
|
{ \
|
|
|
|
|
(dev)->d_statistics.name++; \
|
|
|
|
|
(dev)->d_statistics.errors++; \
|
|
|
|
|
} \
|
|
|
|
|
while (0)
|
|
|
|
|
|
|
|
|
|
# define NETDEV_RXPACKETS(dev) _NETDEV_STATISTIC(dev,rx_packets)
|
|
|
|
|
# define NETDEV_RXFRAGMENTS(dev) _NETDEV_STATISTIC(dev,rx_fragments)
|
|
|
|
|
# define NETDEV_RXERRORS(dev) _NETDEV_ERROR(dev,rx_errors)
|
|
|
|
|
# ifdef CONFIG_NET_IPv4
|
|
|
|
|
# define NETDEV_RXIPV4(dev) _NETDEV_STATISTIC(dev,rx_ipv4)
|
|
|
|
|
# else
|
|
|
|
|
# define NETDEV_RXIPV4(dev)
|
|
|
|
|
# endif
|
|
|
|
|
# ifdef CONFIG_NET_IPv6
|
|
|
|
|
# define NETDEV_RXIPV6(dev) _NETDEV_STATISTIC(dev,rx_ipv6)
|
|
|
|
|
# else
|
|
|
|
|
# define NETDEV_RXIPV6(dev)
|
|
|
|
|
# endif
|
|
|
|
|
# ifdef CONFIG_NET_ARP
|
|
|
|
|
# define NETDEV_RXARP(dev) _NETDEV_STATISTIC(dev,rx_arp)
|
|
|
|
|
# else
|
|
|
|
|
# define NETDEV_RXARP(dev)
|
|
|
|
|
# endif
|
|
|
|
|
# define NETDEV_RXDROPPED(dev) _NETDEV_STATISTIC(dev,rx_dropped)
|
|
|
|
|
|
|
|
|
|
# define NETDEV_TXPACKETS(dev) _NETDEV_STATISTIC(dev,tx_packets)
|
|
|
|
|
# define NETDEV_TXDONE(dev) _NETDEV_STATISTIC(dev,tx_done)
|
|
|
|
|
# define NETDEV_TXERRORS(dev) _NETDEV_ERROR(dev,tx_errors)
|
|
|
|
|
# define NETDEV_TXTIMEOUTS(dev) _NETDEV_ERROR(dev,tx_timeouts)
|
|
|
|
|
|
|
|
|
|
# define NETDEV_ERRORS(dev) _NETDEV_STATISTIC(dev,errors)
|
|
|
|
|
|
|
|
|
|
#else
|
2015-11-26 12:51:45 -06:00
|
|
|
# define NETDEV_RESET_STATISTICS(dev)
|
2015-11-26 12:08:09 -06:00
|
|
|
# define NETDEV_RXPACKETS(dev)
|
|
|
|
|
# define NETDEV_RXFRAGMENTS(dev)
|
|
|
|
|
# define NETDEV_RXERRORS(dev)
|
|
|
|
|
# define NETDEV_RXIPV4(dev)
|
|
|
|
|
# define NETDEV_RXIPV6(dev)
|
|
|
|
|
# define NETDEV_RXARP(dev)
|
|
|
|
|
# define NETDEV_RXDROPPED(dev)
|
|
|
|
|
|
|
|
|
|
# define NETDEV_TXPACKETS(dev)
|
|
|
|
|
# define NETDEV_TXDONE(dev)
|
|
|
|
|
# define NETDEV_TXERRORS(dev)
|
|
|
|
|
# define NETDEV_TXTIMEOUTS(dev)
|
|
|
|
|
|
|
|
|
|
# define NETDEV_ERRORS(dev)
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-09-15 22:45:45 +00:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Public Types
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2015-11-26 12:08:09 -06:00
|
|
|
#ifdef CONFIG_NETDEV_STATISTICS
|
|
|
|
|
/* If CONFIG_NETDEV_STATISTICS is enabled and if the driver supports
|
|
|
|
|
* statistics, then this structure holds the counts of network driver
|
|
|
|
|
* events.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct netdev_statistics_s
|
|
|
|
|
{
|
|
|
|
|
/* Rx Status */
|
|
|
|
|
|
|
|
|
|
uint32_t rx_packets; /* Number of packets received */
|
|
|
|
|
uint32_t rx_fragments; /* Number of fragments received */
|
|
|
|
|
uint32_t rx_errors; /* Number of receive errors */
|
|
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
|
uint32_t rx_ipv4; /* Number of Rx IPv4 packets received */
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
|
uint32_t rx_ipv6; /* Number of Rx IPv6 packets received */
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef CONFIG_NET_ARP
|
|
|
|
|
uint32_t rx_arp; /* Number of Rx ARP packets received */
|
|
|
|
|
#endif
|
|
|
|
|
uint32_t rx_dropped; /* Unsupported Rx packets received */
|
|
|
|
|
|
|
|
|
|
/* Tx Status */
|
|
|
|
|
|
|
|
|
|
uint32_t tx_packets; /* Number of Tx packets queued */
|
2015-11-26 13:41:57 -06:00
|
|
|
uint32_t tx_done; /* Number of packets completed */
|
2015-11-26 12:08:09 -06:00
|
|
|
uint32_t tx_errors; /* Number of receive errors (incl timeouts) */
|
|
|
|
|
uint32_t tx_timeouts; /* Number of Tx timeout errors */
|
|
|
|
|
|
|
|
|
|
/* Other status */
|
|
|
|
|
|
2020-03-03 09:11:57 -06:00
|
|
|
uint32_t errors; /* Total number of errors */
|
2015-11-26 12:08:09 -06:00
|
|
|
};
|
|
|
|
|
#endif
|
2015-05-27 09:26:00 -06:00
|
|
|
|
2018-03-31 14:55:03 -06:00
|
|
|
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_BLUETOOTH) || \
|
|
|
|
|
defined(CONFIG_NET_IEEE802154)
|
2017-07-30 19:10:51 -06:00
|
|
|
/* This structure is used to represent addresses of varying length. This
|
|
|
|
|
* structure is used to represent the address assigned to a radio.
|
2018-03-31 14:55:03 -06:00
|
|
|
*
|
|
|
|
|
* NOTE: the Bluetooth address is not variable, but shares struct
|
|
|
|
|
* radio_driver_s which depends on this type.
|
2017-07-30 19:10:51 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct netdev_maxaddr_s
|
|
|
|
|
{
|
|
|
|
|
uint8_t nm_addr[RADIO_MAX_ADDRLEN];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct netdev_varaddr_s
|
|
|
|
|
{
|
|
|
|
|
uint8_t nv_addr[RADIO_MAX_ADDRLEN];
|
2018-11-09 15:41:23 -06:00
|
|
|
uint8_t nv_addrlen;
|
2017-07-30 19:10:51 -06:00
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
2007-09-15 22:45:45 +00:00
|
|
|
/* This structure collects information that is specific to a specific network
|
2021-01-28 16:33:53 +01:00
|
|
|
* interface driver. If the hardware platform supports only a single
|
|
|
|
|
* instance of this structure.
|
2007-09-15 22:45:45 +00:00
|
|
|
*/
|
|
|
|
|
|
2015-11-26 12:08:09 -06:00
|
|
|
struct devif_callback_s; /* Forward reference */
|
|
|
|
|
|
2014-06-27 16:48:12 -06:00
|
|
|
struct net_driver_s
|
2007-09-15 22:45:45 +00:00
|
|
|
{
|
2007-09-16 17:46:25 +00:00
|
|
|
/* This link is used to maintain a single-linked list of ethernet drivers.
|
|
|
|
|
* Must be the first field in the structure due to blink type casting.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-11 15:47:25 -06:00
|
|
|
#ifdef CONFIG_NET
|
2014-06-27 16:48:12 -06:00
|
|
|
FAR struct net_driver_s *flink;
|
2007-09-16 17:46:25 +00:00
|
|
|
|
2021-01-28 16:33:53 +01:00
|
|
|
/* This is the name of network device assigned when netdev_register was
|
|
|
|
|
* called.
|
2007-09-16 17:46:25 +00:00
|
|
|
* This name is only used to support socket ioctl lookups by device name
|
|
|
|
|
* Examples: "eth0"
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
char d_ifname[IFNAMSIZ];
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-11-04 18:54:04 +00:00
|
|
|
/* Drivers interface flags. See IFF_* definitions in include/net/if.h */
|
|
|
|
|
|
|
|
|
|
uint8_t d_flags;
|
|
|
|
|
|
2021-01-28 16:33:53 +01:00
|
|
|
/* Multi network devices using multiple link layer protocols are
|
|
|
|
|
* supported
|
|
|
|
|
*/
|
2014-11-15 08:22:51 -06:00
|
|
|
|
2015-01-19 14:57:55 -06:00
|
|
|
uint8_t d_lltype; /* See enum net_lltype_e */
|
2015-01-15 13:08:28 -06:00
|
|
|
uint8_t d_llhdrlen; /* Link layer header size */
|
2018-06-25 12:08:10 -06:00
|
|
|
#ifdef CONFIG_NETDEV_IFINDEX
|
|
|
|
|
uint8_t d_ifindex; /* Device index */
|
|
|
|
|
#endif
|
|
|
|
|
|
2018-07-04 14:10:40 -06:00
|
|
|
uint16_t d_pktsize; /* Maximum packet size */
|
2007-09-16 22:12:04 +00:00
|
|
|
|
2017-04-22 11:10:30 -06:00
|
|
|
/* Link layer address */
|
|
|
|
|
|
|
|
|
|
union
|
|
|
|
|
{
|
2011-03-12 15:36:28 +00:00
|
|
|
#ifdef CONFIG_NET_ETHERNET
|
2017-04-22 11:10:30 -06:00
|
|
|
/* Ethernet device identity */
|
2014-11-15 08:22:51 -06:00
|
|
|
|
2017-04-22 11:10:30 -06:00
|
|
|
struct ether_addr ether; /* Device Ethernet MAC address */
|
2017-04-22 11:52:45 -06:00
|
|
|
#endif
|
2017-07-30 19:10:51 -06:00
|
|
|
|
2018-03-31 14:55:03 -06:00
|
|
|
#if defined(CONFIG_NET_6LOWPAN) || defined(CONFIG_NET_BLUETOOTH) || \
|
|
|
|
|
defined(CONFIG_NET_IEEE802154)
|
2017-07-30 19:10:51 -06:00
|
|
|
/* The address assigned to an IEEE 802.15.4 or generic packet radio. */
|
2017-04-22 11:52:45 -06:00
|
|
|
|
2017-08-19 08:48:52 -06:00
|
|
|
struct netdev_varaddr_s radio;
|
2018-03-31 14:55:03 -06:00
|
|
|
#endif
|
2017-04-22 11:10:30 -06:00
|
|
|
} d_mac;
|
2007-09-16 22:12:04 +00:00
|
|
|
|
|
|
|
|
/* Network identity */
|
|
|
|
|
|
2015-01-15 13:08:28 -06:00
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
|
in_addr_t d_ipaddr; /* Host IPv4 address assigned to the network interface */
|
|
|
|
|
in_addr_t d_draddr; /* Default router IP address */
|
|
|
|
|
in_addr_t d_netmask; /* Network subnet mask */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
|
net_ipv6addr_t d_ipv6addr; /* Host IPv6 address assigned to the network interface */
|
|
|
|
|
net_ipv6addr_t d_ipv6draddr; /* Default router IPv6 address */
|
|
|
|
|
net_ipv6addr_t d_ipv6netmask; /* Network IPv6 subnet mask */
|
|
|
|
|
#endif
|
2007-09-16 22:12:04 +00:00
|
|
|
|
2016-11-29 16:08:36 -06:00
|
|
|
/* The d_buf array is used to hold incoming and outgoing packets. The
|
2019-02-25 19:20:29 -06:00
|
|
|
* device driver should place incoming data into this buffer. When sending
|
2016-11-29 16:08:36 -06:00
|
|
|
* data, the device driver should read the link level headers and the
|
2019-02-25 19:20:29 -06:00
|
|
|
* TCP/IP headers from this buffer. The size of the link level headers is
|
2014-11-15 13:13:23 -06:00
|
|
|
* configured by the NET_LL_HDRLEN(dev) define.
|
2007-09-15 22:45:45 +00:00
|
|
|
*
|
2016-05-30 09:51:15 -06:00
|
|
|
* The network will handle only a single buffer for both incoming and
|
2016-11-29 16:08:36 -06:00
|
|
|
* outgoing packets. However, the driver design may be concurrently
|
|
|
|
|
* sending and filling separate, break-off buffers. That buffer
|
|
|
|
|
* management must be controlled by the driver.
|
2019-02-25 19:20:29 -06:00
|
|
|
*
|
|
|
|
|
* The d_buf array must be aligned to two-byte, 16-bit address boundaries
|
|
|
|
|
* in order to support aligned 16-bit accesses performed by the network.
|
2007-09-15 22:45:45 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-11-29 16:08:36 -06:00
|
|
|
FAR uint8_t *d_buf;
|
2007-09-15 22:45:45 +00:00
|
|
|
|
|
|
|
|
/* d_appdata points to the location where application data can be read from
|
2017-05-11 13:35:56 -06:00
|
|
|
* or written to in the packet buffer.
|
2007-09-15 22:45:45 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-02-01 02:47:00 +08:00
|
|
|
FAR uint8_t *d_appdata;
|
2007-09-15 22:45:45 +00:00
|
|
|
|
2007-11-22 14:42:52 +00:00
|
|
|
#ifdef CONFIG_NET_TCPURGDATA
|
|
|
|
|
/* This pointer points to any urgent TCP data that has been received. Only
|
2021-01-28 16:33:53 +01:00
|
|
|
* present if compiled with support for urgent data(CONFIG_NET_TCPURGDATA).
|
2007-11-22 14:42:52 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-02-01 02:47:00 +08:00
|
|
|
FAR uint8_t *d_urgdata;
|
2007-11-22 14:42:52 +00:00
|
|
|
|
|
|
|
|
/* Length of the (received) urgent data */
|
|
|
|
|
|
2009-12-14 23:32:23 +00:00
|
|
|
uint16_t d_urglen;
|
2007-11-22 14:42:52 +00:00
|
|
|
#endif
|
|
|
|
|
|
2007-09-15 22:45:45 +00:00
|
|
|
/* The length of the packet in the d_buf buffer.
|
|
|
|
|
*
|
|
|
|
|
* Holds the length of the packet in the d_buf buffer.
|
|
|
|
|
*
|
2016-05-30 09:51:15 -06:00
|
|
|
* When the network device driver calls the network input function,
|
2007-09-15 22:45:45 +00:00
|
|
|
* d_len should be set to the length of the packet in the d_buf
|
|
|
|
|
* buffer.
|
|
|
|
|
*
|
|
|
|
|
* When sending packets, the device driver should use the contents of
|
|
|
|
|
* the d_len variable to determine the length of the outgoing
|
|
|
|
|
* packet.
|
|
|
|
|
*/
|
|
|
|
|
|
2009-12-14 23:32:23 +00:00
|
|
|
uint16_t d_len;
|
2007-09-15 22:45:45 +00:00
|
|
|
|
2021-01-28 16:33:53 +01:00
|
|
|
/* When d_buf contains outgoing xmit data, d_sndlen is non-zero and
|
|
|
|
|
* represents the amount of application data after d_appdata
|
2007-09-15 22:45:45 +00:00
|
|
|
*/
|
|
|
|
|
|
2009-12-14 23:32:23 +00:00
|
|
|
uint16_t d_sndlen;
|
2007-11-02 20:20:34 +00:00
|
|
|
|
2018-11-03 07:06:30 -06:00
|
|
|
/* Multicast group support */
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IGMP
|
2018-11-03 07:15:37 -06:00
|
|
|
sq_queue_t d_igmp_grplist; /* IGMP group list */
|
2018-11-03 07:06:30 -06:00
|
|
|
#endif
|
2018-11-03 07:15:37 -06:00
|
|
|
#ifdef CONFIG_NET_MLD
|
2018-11-11 11:38:29 -06:00
|
|
|
struct mld_netdev_s d_mld; /* MLD state information */
|
2010-07-08 00:59:51 +00:00
|
|
|
#endif
|
|
|
|
|
|
2015-11-26 12:08:09 -06:00
|
|
|
#ifdef CONFIG_NETDEV_STATISTICS
|
|
|
|
|
/* If CONFIG_NETDEV_STATISTICS is enabled and if the driver supports
|
|
|
|
|
* statistics, then this structure holds the counts of network driver
|
|
|
|
|
* events.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
struct netdev_statistics_s d_statistics;
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-05-27 09:26:00 -06:00
|
|
|
/* Application callbacks:
|
|
|
|
|
*
|
|
|
|
|
* Network device event handlers are retained in a 'list' and are called
|
|
|
|
|
* for events specified in the flags set within struct devif_callback_s.
|
|
|
|
|
*
|
2015-05-28 12:01:38 -06:00
|
|
|
* There are two lists associated with each device:
|
|
|
|
|
*
|
2017-07-08 09:56:08 -06:00
|
|
|
* 1) d_conncb - For connection/port oriented events for certain
|
2015-05-28 12:01:38 -06:00
|
|
|
* socket-less packet transfers. There events include:
|
|
|
|
|
*
|
2017-07-08 09:56:08 -06:00
|
|
|
* ICMP data receipt: ICMP_NEWDATA, ICMPv6_NEWDATA
|
2015-05-28 12:01:38 -06:00
|
|
|
* Driver Tx poll events: ARP_POLL, ICMP_POLL. ICMPv6_POLL
|
2017-07-08 09:56:08 -06:00
|
|
|
* IP Forwarding: IPFWD_POLL
|
2015-05-28 12:01:38 -06:00
|
|
|
*
|
|
|
|
|
* 2) d_devcb - For non-data, device related events that apply to all
|
|
|
|
|
* transfers or connections involving this device:
|
|
|
|
|
*
|
|
|
|
|
* NETDEV_DOWN - The network is down
|
2015-05-27 09:26:00 -06:00
|
|
|
*/
|
|
|
|
|
|
net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.
Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-08-29 23:57:26 +03:00
|
|
|
FAR struct devif_callback_s *d_conncb; /* This is the list head */
|
|
|
|
|
FAR struct devif_callback_s *d_conncb_tail; /* This is the list tail */
|
2015-05-28 12:01:38 -06:00
|
|
|
FAR struct devif_callback_s *d_devcb;
|
2015-05-27 09:26:00 -06:00
|
|
|
|
2007-11-02 20:20:34 +00:00
|
|
|
/* Driver callbacks */
|
|
|
|
|
|
2014-08-16 14:08:04 -06:00
|
|
|
int (*d_ifup)(FAR struct net_driver_s *dev);
|
|
|
|
|
int (*d_ifdown)(FAR struct net_driver_s *dev);
|
|
|
|
|
int (*d_txavail)(FAR struct net_driver_s *dev);
|
2018-10-31 15:03:51 -06:00
|
|
|
#ifdef CONFIG_NET_MCASTGROUP
|
2014-08-16 14:08:04 -06:00
|
|
|
int (*d_addmac)(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
|
|
|
|
|
int (*d_rmmac)(FAR struct net_driver_s *dev, FAR const uint8_t *mac);
|
2010-07-11 15:17:11 +00:00
|
|
|
#endif
|
2017-03-13 09:51:31 -06:00
|
|
|
#ifdef CONFIG_NETDEV_IOCTL
|
2017-04-15 09:33:27 -06:00
|
|
|
int (*d_ioctl)(FAR struct net_driver_s *dev, int cmd,
|
|
|
|
|
unsigned long arg);
|
2014-06-27 09:30:41 -06:00
|
|
|
#endif
|
2007-11-02 20:20:34 +00:00
|
|
|
|
|
|
|
|
/* Drivers may attached device-specific, private information */
|
|
|
|
|
|
2020-02-01 02:47:00 +08:00
|
|
|
FAR void *d_private;
|
2007-09-15 22:45:45 +00:00
|
|
|
};
|
|
|
|
|
|
2019-08-26 17:28:21 -06:00
|
|
|
typedef CODE int (*devif_poll_callback_t)(FAR struct net_driver_s *dev);
|
2014-06-30 18:40:41 -06:00
|
|
|
|
2007-09-15 22:45:45 +00:00
|
|
|
/****************************************************************************
|
2015-10-02 16:30:35 -06:00
|
|
|
* Public Data
|
2007-09-15 22:45:45 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
2008-08-02 17:22:22 +00:00
|
|
|
* Public Function Prototypes
|
2007-09-15 22:45:45 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
2014-06-30 19:03:01 -06:00
|
|
|
/****************************************************************************
|
2016-05-30 09:51:15 -06:00
|
|
|
* Network device driver functions
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
|
|
|
|
* These functions are used by a network device driver for interacting
|
2016-05-30 09:51:15 -06:00
|
|
|
* with the NuttX network.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2015-01-15 08:03:56 -06:00
|
|
|
* Process an incoming IP packet.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
|
|
|
|
* This function should be called when the device driver has received
|
|
|
|
|
* a packet from the network. The packet from the device driver must
|
2007-09-15 22:45:45 +00:00
|
|
|
* be present in the d_buf buffer, and the length of the packet
|
|
|
|
|
* should be placed in the d_len field.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
|
|
|
|
* When the function returns, there may be an outbound packet placed
|
2007-09-15 22:45:45 +00:00
|
|
|
* in the d_buf packet buffer. If so, the d_len field is set to
|
2007-08-26 23:12:17 +00:00
|
|
|
* the length of the packet. If no packet is to be sent out, the
|
2007-09-15 22:45:45 +00:00
|
|
|
* d_len field is set to 0.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
|
|
|
|
* The usual way of calling the function is presented by the source
|
|
|
|
|
* code below.
|
|
|
|
|
*
|
2007-09-15 22:45:45 +00:00
|
|
|
* dev->d_len = devicedriver_poll();
|
2014-04-12 12:53:19 -06:00
|
|
|
* if (dev->d_len > 0)
|
|
|
|
|
* {
|
2015-01-15 08:03:56 -06:00
|
|
|
* ipv4_input(dev);
|
2014-04-12 12:53:19 -06:00
|
|
|
* if (dev->d_len > 0)
|
|
|
|
|
* {
|
|
|
|
|
* devicedriver_send();
|
|
|
|
|
* }
|
2007-08-26 23:12:17 +00:00
|
|
|
* }
|
|
|
|
|
*
|
2016-05-30 09:51:15 -06:00
|
|
|
* Note: If you are writing a network device driver that needs ARP
|
|
|
|
|
* (Address Resolution Protocol), e.g., when running the network over
|
|
|
|
|
* Ethernet, you will need to call the network ARP code before calling
|
2007-08-26 23:12:17 +00:00
|
|
|
* this function:
|
|
|
|
|
*
|
2022-01-18 00:09:14 +02:00
|
|
|
* #define BUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
2007-09-15 22:45:45 +00:00
|
|
|
* dev->d_len = ethernet_devicedrver_poll();
|
2014-04-12 12:53:19 -06:00
|
|
|
* if (dev->d_len > 0)
|
|
|
|
|
* {
|
2014-07-04 15:40:49 -06:00
|
|
|
* if (BUF->type == HTONS(ETHTYPE_IP))
|
2014-04-12 12:53:19 -06:00
|
|
|
* {
|
2014-05-30 12:13:06 -06:00
|
|
|
* arp_ipin();
|
2015-01-15 08:03:56 -06:00
|
|
|
* ipv4_input(dev);
|
2014-04-12 12:53:19 -06:00
|
|
|
* if (dev->d_len > 0)
|
|
|
|
|
* {
|
2014-05-30 12:13:06 -06:00
|
|
|
* arp_out();
|
2014-04-12 12:53:19 -06:00
|
|
|
* devicedriver_send();
|
|
|
|
|
* }
|
|
|
|
|
* }
|
2014-07-04 15:40:49 -06:00
|
|
|
* else if (BUF->type == HTONS(ETHTYPE_ARP))
|
2014-04-12 12:53:19 -06:00
|
|
|
* {
|
2014-05-30 12:13:06 -06:00
|
|
|
* arp_arpin();
|
2014-04-12 12:53:19 -06:00
|
|
|
* if (dev->d_len > 0)
|
|
|
|
|
* {
|
|
|
|
|
* devicedriver_send();
|
|
|
|
|
* }
|
|
|
|
|
* }
|
2014-06-30 19:03:01 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2015-01-15 08:03:56 -06:00
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
|
int ipv4_input(FAR struct net_driver_s *dev);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
|
int ipv6_input(FAR struct net_driver_s *dev);
|
|
|
|
|
#endif
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2017-03-27 18:15:20 -06:00
|
|
|
#ifdef CONFIG_NET_6LOWPAN
|
2017-08-20 07:10:48 -06:00
|
|
|
struct radio_driver_s; /* Forward reference. See radiodev.h */
|
|
|
|
|
struct iob_s; /* Forward reference See iob.h */
|
|
|
|
|
|
2017-08-19 08:48:52 -06:00
|
|
|
int sixlowpan_input(FAR struct radio_driver_s *ieee,
|
2017-07-30 19:10:51 -06:00
|
|
|
FAR struct iob_s *framelist, FAR const void *metadata);
|
2017-03-27 18:15:20 -06:00
|
|
|
#endif
|
|
|
|
|
|
2014-06-30 19:03:01 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Polling of connections
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2016-05-30 09:51:15 -06:00
|
|
|
* These functions will traverse each active network connection structure
|
|
|
|
|
* and perform appropriate operations: devif_timer() will perform TCP timer
|
2014-06-30 18:40:41 -06:00
|
|
|
* operations (and UDP polling operations); devif_poll() will perform TCP
|
2007-11-07 22:54:51 +00:00
|
|
|
* and UDP polling operations. The CAN driver MUST implement logic to
|
2014-06-30 18:40:41 -06:00
|
|
|
* periodically call devif_timer(); devif_poll() may be called asynchronously
|
2007-11-07 22:54:51 +00:00
|
|
|
* from the network driver can accept another outgoing packet.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2007-11-07 22:54:51 +00:00
|
|
|
* In both cases, these functions will call the provided callback function
|
|
|
|
|
* for every active connection. Polling will continue until all connections
|
2014-06-30 18:40:41 -06:00
|
|
|
* have been polled or until the user-supplied function returns a non-zero
|
2007-11-07 22:54:51 +00:00
|
|
|
* value (which it should do only if it cannot accept further write data).
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2007-11-05 23:04:16 +00:00
|
|
|
* When the callback function is called, there may be an outbound packet
|
2016-05-30 09:51:15 -06:00
|
|
|
* waiting for service in the device packet buffer, and if so the d_len field
|
2007-11-07 22:54:51 +00:00
|
|
|
* is set to a value larger than zero. The device driver should then send
|
|
|
|
|
* out the packet.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2007-11-05 23:04:16 +00:00
|
|
|
* Example:
|
2014-08-16 14:08:04 -06:00
|
|
|
* int driver_callback(FAR struct net_driver_s *dev)
|
2007-11-05 23:04:16 +00:00
|
|
|
* {
|
|
|
|
|
* if (dev->d_len > 0)
|
2007-09-02 21:58:35 +00:00
|
|
|
* {
|
2007-11-05 23:04:16 +00:00
|
|
|
* devicedriver_send();
|
|
|
|
|
* return 1; <-- Terminates polling if necessary
|
2007-08-26 23:12:17 +00:00
|
|
|
* }
|
2007-11-05 23:04:16 +00:00
|
|
|
* return 0;
|
|
|
|
|
* }
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2007-11-05 23:04:16 +00:00
|
|
|
* ...
|
2014-06-30 18:40:41 -06:00
|
|
|
* devif_poll(dev, driver_callback);
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2016-05-30 09:51:15 -06:00
|
|
|
* Note: If you are writing a network device driver that needs ARP (Address
|
|
|
|
|
* Resolution Protocol), e.g., when running the networ over Ethernet, you
|
|
|
|
|
* will need to call the arp_out() function in the callback function
|
2007-11-05 23:04:16 +00:00
|
|
|
* before sending the packet:
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-08-16 14:08:04 -06:00
|
|
|
* int driver_callback(FAR struct net_driver_s *dev)
|
2007-11-05 23:04:16 +00:00
|
|
|
* {
|
|
|
|
|
* if (dev->d_len > 0)
|
2007-09-02 23:11:10 +00:00
|
|
|
* {
|
2014-05-30 12:13:06 -06:00
|
|
|
* arp_out();
|
2007-11-05 23:04:16 +00:00
|
|
|
* devicedriver_send();
|
|
|
|
|
* return 1; <-- Terminates polling if necessary
|
2007-08-26 23:12:17 +00:00
|
|
|
* }
|
2014-07-02 17:23:25 -06:00
|
|
|
*
|
2007-11-05 23:04:16 +00:00
|
|
|
* return 0;
|
|
|
|
|
* }
|
2014-06-30 19:03:01 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2014-08-16 14:08:04 -06:00
|
|
|
int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback);
|
2015-01-20 14:37:02 -06:00
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: neighbor_out
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* This function should be called before sending out an IPv6 packet. The
|
|
|
|
|
* function checks the destination IPv6 address of the IPv6 packet to see
|
2018-11-09 14:21:49 -06:00
|
|
|
* what L2 address that should be used as a destination L2 address.
|
2015-01-20 14:37:02 -06:00
|
|
|
*
|
|
|
|
|
* If the destination IPv6 address is in the local network (determined
|
|
|
|
|
* by logical ANDing of netmask and our IPv6 address), the function
|
|
|
|
|
* checks the Neighbor Table to see if an entry for the destination IPv6
|
2018-11-09 14:21:49 -06:00
|
|
|
* address is found. If so, an L2 header is pre-pended at the beginning
|
|
|
|
|
* of the packet and the function returns.
|
2015-01-20 14:37:02 -06:00
|
|
|
*
|
|
|
|
|
* If no Neighbor Table entry is found for the destination IPv6 address,
|
2018-11-09 14:21:49 -06:00
|
|
|
* the packet in the d_buf is replaced by an ICMPv6 Neighbor Solicit
|
2017-05-03 09:40:42 -06:00
|
|
|
* request packet for the IPv6 address. The IPv6 packet is dropped and
|
2015-01-20 14:37:02 -06:00
|
|
|
* it is assumed that the higher level protocols (e.g., TCP) eventually
|
|
|
|
|
* will retransmit the dropped packet.
|
|
|
|
|
*
|
|
|
|
|
* Upon return in either the case, a packet to be sent is present in the
|
2018-11-09 14:21:49 -06:00
|
|
|
* d_buf buffer and the d_len field holds the length of the L2 frame that
|
|
|
|
|
* should be transmitted.
|
2015-01-20 14:37:02 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
|
void neighbor_out(FAR struct net_driver_s *dev);
|
|
|
|
|
#endif /* CONFIG_NET_IPv6 */
|
2014-01-21 10:21:45 -06:00
|
|
|
|
2018-08-24 09:21:33 -06:00
|
|
|
/****************************************************************************
|
2018-08-25 08:33:21 -06:00
|
|
|
* Name: devif_loopback
|
2018-08-24 09:21:33 -06:00
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* This function should be called before sending out a packet. The function
|
2021-01-28 16:33:53 +01:00
|
|
|
* checks the destination address of the packet to see whether the target
|
|
|
|
|
* of packet is ourself and then consume the packet directly by calling
|
|
|
|
|
* input process functions.
|
2018-08-24 09:21:33 -06:00
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* Zero is returned if the packet don't loop back to ourself, otherwise
|
2020-03-03 09:11:57 -06:00
|
|
|
* a non-zero value is returned.
|
2018-08-24 09:21:33 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2018-08-25 08:33:21 -06:00
|
|
|
int devif_loopback(FAR struct net_driver_s *dev);
|
2018-08-24 09:21:33 -06:00
|
|
|
|
2014-06-30 19:03:01 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Carrier detection
|
|
|
|
|
*
|
2021-01-28 16:33:53 +01:00
|
|
|
* Call netdev_carrier_on when the carrier has become available and the
|
|
|
|
|
* device is ready to receive/transmit packets.
|
2014-01-21 10:21:45 -06:00
|
|
|
*
|
2014-07-06 11:14:24 -06:00
|
|
|
* Call detdev_carrier_off when the carrier disappeared and the device has
|
|
|
|
|
* moved into non operational state.
|
2014-06-30 19:03:01 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2014-01-21 10:21:45 -06:00
|
|
|
|
2014-06-27 16:48:12 -06:00
|
|
|
int netdev_carrier_on(FAR struct net_driver_s *dev);
|
|
|
|
|
int netdev_carrier_off(FAR struct net_driver_s *dev);
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2018-08-26 14:54:26 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: net_ioctl_arglen
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Calculate the ioctl argument buffer length.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
*
|
|
|
|
|
* cmd The ioctl command
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* The argument buffer length, or error code.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
ssize_t net_ioctl_arglen(int cmd);
|
|
|
|
|
|
2014-06-27 17:51:32 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: net_chksum
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* Description:
|
|
|
|
|
* Calculate the Internet checksum over a buffer.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* The Internet checksum is the one's complement of the one's complement
|
|
|
|
|
* sum of all 16-bit words in the buffer.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* See RFC1071.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
|
|
|
|
|
* provided by architecture-specific logic.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* Input Parameters:
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* buf - A pointer to the buffer over which the checksum is to be computed.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2021-01-28 16:33:53 +01:00
|
|
|
* len - The length of the buffer over which the checksum is to be
|
|
|
|
|
* computed.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* Returned Value:
|
|
|
|
|
* The Internet checksum of the buffer.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2014-06-27 17:51:32 -06:00
|
|
|
uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2014-06-27 17:51:32 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: net_incr32
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* Description:
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* Carry out a 32-bit addition.
|
|
|
|
|
*
|
|
|
|
|
* By defining CONFIG_NET_ARCH_INCR32, the architecture can replace
|
|
|
|
|
* net_incr32 with hardware assisted solutions.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* op32 - A pointer to a 4-byte array representing a 32-bit integer in
|
|
|
|
|
* network byte order (big endian). This value may not be word
|
|
|
|
|
* aligned. The value pointed to by op32 is modified in place
|
|
|
|
|
*
|
|
|
|
|
* op16 - A 16-bit integer in host byte order.
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2014-06-27 17:51:32 -06:00
|
|
|
void net_incr32(FAR uint8_t *op32, uint16_t op16);
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2014-06-27 17:51:32 -06:00
|
|
|
/****************************************************************************
|
2015-01-14 16:10:38 -06:00
|
|
|
* Name: ipv4_chksum
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* Description:
|
2015-01-14 16:10:38 -06:00
|
|
|
* Calculate the IPv4 header checksum of the packet header in d_buf.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2015-01-14 16:10:38 -06:00
|
|
|
* The IPv4 header checksum is the Internet checksum of the 20 bytes of
|
|
|
|
|
* the IPv4 header.
|
2007-08-26 23:12:17 +00:00
|
|
|
*
|
2014-06-27 17:51:32 -06:00
|
|
|
* If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
|
|
|
|
|
* provided by architecture-specific logic.
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
2015-01-14 16:10:38 -06:00
|
|
|
* The IPv4 header checksum of the IPv4 header in the d_buf buffer.
|
2014-06-27 17:51:32 -06:00
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
2007-08-26 23:12:17 +00:00
|
|
|
|
2015-01-14 16:10:38 -06:00
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
|
uint16_t ipv4_chksum(FAR struct net_driver_s *dev);
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-04-13 13:53:13 -06:00
|
|
|
/****************************************************************************
|
2017-04-21 16:33:14 -06:00
|
|
|
* Name: netdev_ipv4_hdrlen
|
2015-04-13 13:53:13 -06:00
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Provide header length for interface based on device
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* dev Device structure pointer
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv4
|
|
|
|
|
# define netdev_ipv4_hdrlen(dev) (dev->d_llhdrlen)
|
|
|
|
|
#endif /* CONFIG_NET_IPv4 */
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
2017-04-21 16:33:14 -06:00
|
|
|
* Name: netdev_ipv6_hdrlen
|
2015-04-13 13:53:13 -06:00
|
|
|
*
|
|
|
|
|
* Description:
|
2015-05-27 11:39:44 -06:00
|
|
|
* Provide header length for interface based on device
|
2015-04-13 13:53:13 -06:00
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* dev Device structure pointer
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_IPv6
|
|
|
|
|
# define netdev_ipv6_hdrlen(dev) dev->d_llhdrlen
|
|
|
|
|
#endif /* CONFIG_NET_IPv6 */
|
|
|
|
|
|
2018-11-09 16:05:11 -06:00
|
|
|
/****************************************************************************
|
|
|
|
|
* Name: netdev_lladdrsize
|
|
|
|
|
*
|
|
|
|
|
* Description:
|
|
|
|
|
* Returns the size of the MAC address associated with a network device.
|
|
|
|
|
*
|
|
|
|
|
* Input Parameters:
|
|
|
|
|
* dev - A reference to the device of interest
|
|
|
|
|
*
|
|
|
|
|
* Returned Value:
|
|
|
|
|
* The size of the MAC address associated with this device
|
|
|
|
|
*
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
int netdev_lladdrsize(FAR struct net_driver_s *dev);
|
|
|
|
|
|
2014-06-24 09:28:44 -06:00
|
|
|
#endif /* __INCLUDE_NUTTX_NET_NETDEV_H */
|