net: move device buffer define to common header
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
6908b6823c
commit
a8d3286258
@ -251,7 +251,6 @@
|
||||
* header.
|
||||
*/
|
||||
|
||||
#define ETHBUF ((struct eth_hdr_s *)priv->eth_dev.d_buf)
|
||||
#define ETH8021QWBUF ((struct eth_8021qhdr_s *)priv->eth_dev.d_buf)
|
||||
|
||||
/****************************************************************************
|
||||
@ -934,10 +933,12 @@ static void lpc54_eth_reply(struct lpc54_ethdriver_s *priv)
|
||||
|
||||
static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
{
|
||||
struct net_driver_s *dev = &priv->eth_dev;
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
/* When packet sockets are enabled, feed the frame into the tap */
|
||||
|
||||
pkt_input(&priv->eth_dev);
|
||||
pkt_input(dev);
|
||||
#endif
|
||||
|
||||
/* We only accept IP packets of the configured type and ARP packets */
|
||||
@ -946,14 +947,14 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
if (ETHBUF->type == HTONS(ETHTYPE_IP))
|
||||
{
|
||||
ninfo("IPv4 packet\n");
|
||||
NETDEV_RXIPV4(&priv->eth_dev);
|
||||
NETDEV_RXIPV4(dev);
|
||||
|
||||
/* Handle ARP on input,
|
||||
* then dispatch IPv4 packet to the network layer
|
||||
*/
|
||||
|
||||
arp_ipin(&priv->eth_dev);
|
||||
ipv4_input(&priv->eth_dev);
|
||||
arp_ipin(dev);
|
||||
ipv4_input(dev);
|
||||
|
||||
/* Check for a reply to the IPv4 packet */
|
||||
|
||||
@ -965,11 +966,11 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
|
||||
{
|
||||
ninfo("IPv6 packet\n");
|
||||
NETDEV_RXIPV6(&priv->eth_dev);
|
||||
NETDEV_RXIPV6(dev);
|
||||
|
||||
/* Dispatch IPv6 packet to the network layer */
|
||||
|
||||
ipv6_input(&priv->eth_dev);
|
||||
ipv6_input(dev);
|
||||
|
||||
/* Check for a reply to the IPv6 packet */
|
||||
|
||||
@ -981,11 +982,11 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
if (ETH8021QWBUF->tpid == HTONS(TPID_8021QVLAN))
|
||||
{
|
||||
ninfo("IEEE 802.1q packet\n");
|
||||
NETDEV_RXQVLAN(&priv->eth_dev);
|
||||
NETDEV_RXQVLAN(dev);
|
||||
|
||||
/* Dispatch the 802.1q VLAN packet to the network layer */
|
||||
|
||||
qvlan_input(&priv->eth_dev);
|
||||
qvlan_input(dev);
|
||||
|
||||
/* Check for a reply to the 802.1q VLAN packet */
|
||||
|
||||
@ -1001,20 +1002,20 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
|
||||
/* Dispatch the ARP packet to the network layer */
|
||||
|
||||
arp_arpin(&priv->eth_dev);
|
||||
NETDEV_RXARP(&priv->eth_dev);
|
||||
arp_arpin(dev);
|
||||
NETDEV_RXARP(dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, d_len field will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (priv->eth_dev.d_len > 0)
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
chan = lpc54_eth_getring(priv);
|
||||
txring = &priv->eth_txring[chan];
|
||||
|
||||
(txring->tr_buffers)[txring->tr_supply] =
|
||||
(uint32_t *)priv->eth_dev.d_buf;
|
||||
(uint32_t *)dev->d_buf;
|
||||
|
||||
lpc54_eth_transmit(priv, chan);
|
||||
}
|
||||
@ -1022,7 +1023,7 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
NETDEV_RXDROPPED(&priv->eth_dev);
|
||||
NETDEV_RXDROPPED(dev);
|
||||
}
|
||||
|
||||
/* On entry, d_buf refers to the receive buffer as set by logic in
|
||||
@ -1032,13 +1033,13 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||
* receive buffer and we will need to dispose of it here.
|
||||
*/
|
||||
|
||||
if (priv->eth_dev.d_buf != NULL)
|
||||
if (dev->d_buf != NULL)
|
||||
{
|
||||
lpc54_pktbuf_free(priv, (uint32_t *)priv->eth_dev.d_buf);
|
||||
lpc54_pktbuf_free(priv, (uint32_t *)dev->d_buf);
|
||||
}
|
||||
|
||||
priv->eth_dev.d_buf = NULL;
|
||||
priv->eth_dev.d_len = 0;
|
||||
dev->d_buf = NULL;
|
||||
dev->d_len = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -158,10 +158,6 @@
|
||||
|
||||
#define TIVA_TXTIMEOUT (60*CLK_TCK)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of Ethernet header */
|
||||
|
||||
#define ETHBUF ((struct eth_hdr_s *)priv->ld_dev.d_buf)
|
||||
|
||||
#define TIVA_MAX_MDCCLK 2500000
|
||||
|
||||
/****************************************************************************
|
||||
@ -675,10 +671,11 @@ static int tiva_txpoll(struct net_driver_s *dev)
|
||||
|
||||
static void tiva_receive(struct tiva_driver_s *priv)
|
||||
{
|
||||
struct net_driver_s *dev = &priv->ld_dev;
|
||||
uint32_t regval;
|
||||
uint8_t *dbuf;
|
||||
int pktlen;
|
||||
int bytesleft;
|
||||
int bytesleft;
|
||||
int pktlen;
|
||||
|
||||
/* Loop while there are incoming packets to be processed */
|
||||
|
||||
@ -686,13 +683,13 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
{
|
||||
/* Update statistics */
|
||||
|
||||
NETDEV_RXPACKETS(&priv->ld_dev);
|
||||
NETDEV_RXPACKETS(dev);
|
||||
|
||||
/* Copy the data data from the hardware to priv->ld_dev.d_buf. Set
|
||||
* amount of data in priv->ld_dev.d_len
|
||||
/* Copy the data data from the hardware to dev->d_buf. Set
|
||||
* amount of data in dev->d_len
|
||||
*/
|
||||
|
||||
dbuf = priv->ld_dev.d_buf;
|
||||
dbuf = dev->d_buf;
|
||||
|
||||
/* The packet frame length begins in the LS 16-bits of the first
|
||||
* word from the FIFO followed by the Ethernet header beginning
|
||||
@ -719,7 +716,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
/* We will have to drop this packet */
|
||||
|
||||
nwarn("WARNING: Bad packet size dropped (%d)\n", pktlen);
|
||||
NETDEV_RXERRORS(&priv->ld_dev);
|
||||
NETDEV_RXERRORS(dev);
|
||||
|
||||
/* The number of bytes and words left to read is pktlen - 4
|
||||
* (including, the final, possibly partial word) because we've
|
||||
@ -789,14 +786,14 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
* and 4 bytes for the FCS.
|
||||
*/
|
||||
|
||||
priv->ld_dev.d_len = pktlen - 6;
|
||||
dev->d_len = pktlen - 6;
|
||||
tiva_dumppacket("Received packet",
|
||||
priv->ld_dev.d_buf, priv->ld_dev.d_len);
|
||||
dev->d_buf, dev->d_len);
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
/* When packet sockets are enabled, feed the frame into the tap */
|
||||
|
||||
pkt_input(&priv->ld_dev);
|
||||
pkt_input(dev);
|
||||
#endif
|
||||
|
||||
/* We only accept IP packets of the configured type and ARP packets */
|
||||
@ -805,33 +802,33 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
if (ETHBUF->type == HTONS(ETHTYPE_IP))
|
||||
{
|
||||
ninfo("IPv4 frame\n");
|
||||
NETDEV_RXIPV4(&priv->ld_dev);
|
||||
NETDEV_RXIPV4(dev);
|
||||
|
||||
/* Handle ARP on input then give the IPv4 packet to the network
|
||||
* layer
|
||||
*/
|
||||
|
||||
arp_ipin(&priv->ld_dev);
|
||||
ipv4_input(&priv->ld_dev);
|
||||
arp_ipin(dev);
|
||||
ipv4_input(dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, d_len field will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (priv->ld_dev.d_len > 0)
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
/* Update the Ethernet header with the correct MAC address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (IFF_IS_IPv4(priv->ld_dev.d_flags))
|
||||
if (IFF_IS_IPv4(dev->d_flags))
|
||||
#endif
|
||||
{
|
||||
arp_out(&priv->ld_dev);
|
||||
arp_out(dev);
|
||||
}
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
else
|
||||
{
|
||||
neighbor_out(&priv->ld_dev);
|
||||
neighbor_out(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -846,12 +843,12 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
|
||||
{
|
||||
ninfo("IPv6 frame\n");
|
||||
NETDEV_RXIPV6(&priv->ld_dev);
|
||||
NETDEV_RXIPV6(dev);
|
||||
|
||||
/* Give the IPv6 packet to the network layer */
|
||||
|
||||
arp_ipin(&priv->ld_dev);
|
||||
ipv6_input(&priv->ld_dev);
|
||||
arp_ipin(dev);
|
||||
ipv6_input(dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, d_len field will set to a value > 0.
|
||||
@ -862,15 +859,15 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
/* Update the Ethernet header with the correct MAC address */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
if (IFF_IS_IPv4(priv->ld_dev.d_flags))
|
||||
if (IFF_IS_IPv4(dev->d_flags))
|
||||
{
|
||||
arp_out(&priv->ld_dev);
|
||||
arp_out(dev);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
{
|
||||
neighbor_out(&priv->ld_dev);
|
||||
neighbor_out(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -885,15 +882,15 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
if (ETHBUF->type == HTONS(ETHTYPE_ARP))
|
||||
{
|
||||
ninfo("ARP packet received (%02x)\n", ETHBUF->type);
|
||||
NETDEV_RXARP(&priv->ld_dev);
|
||||
NETDEV_RXARP(dev);
|
||||
|
||||
arp_arpin(&priv->ld_dev);
|
||||
arp_arpin(dev);
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, d_len field will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (priv->ld_dev.d_len > 0)
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
tiva_transmit(priv);
|
||||
}
|
||||
@ -903,7 +900,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
||||
{
|
||||
nwarn("WARNING: Unsupported packet type dropped (%02x)\n",
|
||||
HTONS(ETHBUF->type));
|
||||
NETDEV_RXDROPPED(&priv->ld_dev);
|
||||
NETDEV_RXDROPPED(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,10 +247,6 @@ extern uint8_t _RAM_ADDR_U_INIT_PARAM[];
|
||||
|
||||
#define EMAC_TXTIMEOUT (60*CLK_TCK)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of Ethernet header */
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)priv->dev.d_buf)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -59,11 +59,6 @@
|
||||
# error Worker thread support is required (CONFIG_SCHED_WORKQUEUE)
|
||||
#endif
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the IP header */
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)priv->lo_dev.d_buf)
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)priv->lo_dev.d_buf)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -109,11 +109,6 @@
|
||||
|
||||
#define SLIP_WDDELAY (1*1000000)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the ip header */
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)priv->dev.d_buf)
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)priv->dev.d_buf)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -603,6 +598,7 @@ static inline void slip_receive(FAR struct slip_driver_s *priv)
|
||||
static int slip_rxtask(int argc, FAR char *argv[])
|
||||
{
|
||||
FAR struct slip_driver_s *priv;
|
||||
FAR struct net_driver_s *dev;
|
||||
unsigned int index = *(argv[1]) - '0';
|
||||
int ch;
|
||||
|
||||
@ -618,6 +614,7 @@ static int slip_rxtask(int argc, FAR char *argv[])
|
||||
|
||||
/* Loop forever */
|
||||
|
||||
dev = &priv->dev;
|
||||
for (; ; )
|
||||
{
|
||||
/* Wait for the next character to be available on the input stream. */
|
||||
|
@ -113,11 +113,6 @@
|
||||
# define BUF ((FAR struct eth_hdr_s *)priv->dev.d_buf)
|
||||
#endif
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the ip header */
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen))
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -619,16 +614,18 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
|
||||
|
||||
static void tun_net_receive_tun(FAR struct tun_device_s *priv)
|
||||
{
|
||||
/* Copy the data data from the hardware to priv->dev.d_buf. Set amount of
|
||||
* data in priv->dev.d_len
|
||||
FAR struct net_driver_s *dev = &priv->dev;
|
||||
|
||||
/* Copy the data data from the hardware to dev->d_buf. Set amount of
|
||||
* data in dev->d_len
|
||||
*/
|
||||
|
||||
NETDEV_RXPACKETS(&priv->dev);
|
||||
NETDEV_RXPACKETS(dev);
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
/* When packet sockets are enabled, feed the frame into the tap */
|
||||
|
||||
pkt_input(&priv->dev);
|
||||
pkt_input(dev);
|
||||
#endif
|
||||
|
||||
/* We only accept IP packets of the configured type */
|
||||
@ -637,11 +634,11 @@ static void tun_net_receive_tun(FAR struct tun_device_s *priv)
|
||||
if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION)
|
||||
{
|
||||
ninfo("IPv4 frame\n");
|
||||
NETDEV_RXIPV4(&priv->dev);
|
||||
NETDEV_RXIPV4(dev);
|
||||
|
||||
/* Give the IPv4 packet to the network layer. */
|
||||
|
||||
ipv4_input(&priv->dev);
|
||||
ipv4_input(dev);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@ -649,26 +646,26 @@ static void tun_net_receive_tun(FAR struct tun_device_s *priv)
|
||||
if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION)
|
||||
{
|
||||
ninfo("IPv6 frame\n");
|
||||
NETDEV_RXIPV6(&priv->dev);
|
||||
NETDEV_RXIPV6(dev);
|
||||
|
||||
/* Give the IPv6 packet to the network layer. */
|
||||
|
||||
ipv6_input(&priv->dev);
|
||||
ipv6_input(dev);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
NETDEV_RXDROPPED(&priv->dev);
|
||||
priv->dev.d_len = 0;
|
||||
NETDEV_RXDROPPED(dev);
|
||||
dev->d_len = 0;
|
||||
}
|
||||
|
||||
/* If the above function invocation resulted in data that should be
|
||||
* sent out on the network, d_len field will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (priv->dev.d_len > 0)
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
priv->write_d_len = priv->dev.d_len;
|
||||
priv->write_d_len = dev->d_len;
|
||||
tun_fd_transmit(priv);
|
||||
}
|
||||
}
|
||||
|
@ -154,6 +154,21 @@
|
||||
# define NETDEV_ERRORS(dev)
|
||||
#endif
|
||||
|
||||
/* There are some helper pointers for accessing the contents of the Ethernet
|
||||
* headers
|
||||
*/
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
||||
|
||||
/* There are some helper pointers for accessing the contents of the IP
|
||||
* headers
|
||||
*/
|
||||
|
||||
#define IPBUF(hl) ((FAR void *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)IPBUF(0))
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)IPBUF(0))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -456,11 +471,10 @@ typedef CODE int (*devif_poll_callback_t)(FAR struct net_driver_s *dev);
|
||||
* Ethernet, you will need to call the network ARP code before calling
|
||||
* this function:
|
||||
*
|
||||
* #define BUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
||||
* dev->d_len = ethernet_devicedrver_poll();
|
||||
* if (dev->d_len > 0)
|
||||
* {
|
||||
* if (BUF->type == HTONS(ETHTYPE_IP))
|
||||
* if (ETHBUF->type == HTONS(ETHTYPE_IP))
|
||||
* {
|
||||
* arp_ipin();
|
||||
* ipv4_input(dev);
|
||||
@ -470,7 +484,7 @@ typedef CODE int (*devif_poll_callback_t)(FAR struct net_driver_s *dev);
|
||||
* devicedriver_send();
|
||||
* }
|
||||
* }
|
||||
* else if (BUF->type == HTONS(ETHTYPE_ARP))
|
||||
* else if (ETHBUF->type == HTONS(ETHTYPE_ARP))
|
||||
* {
|
||||
* arp_arpin();
|
||||
* if (dev->d_len > 0)
|
||||
|
@ -79,6 +79,11 @@
|
||||
&(dev)->d_conncb_tail)
|
||||
#define arp_callback_free(dev,cb) devif_dev_callback_free(dev, cb)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the IP header */
|
||||
|
||||
#define ARPBUF ((FAR struct arp_hdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
#define ARPIPBUF ((FAR struct arp_iphdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -55,13 +55,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ARP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
||||
#define ARPBUF ((FAR struct arp_hdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -55,13 +55,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ARP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
||||
#define ARPBUF ((FAR struct arp_hdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -52,13 +52,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ARP_IPIN
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
||||
#define IPBUF ((FAR struct arp_iphdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -87,10 +80,10 @@ void arp_ipin(FAR struct net_driver_s *dev)
|
||||
* packet comes from a host on the local network.
|
||||
*/
|
||||
|
||||
srcipaddr = net_ip4addr_conv32(IPBUF->eh_srcipaddr);
|
||||
srcipaddr = net_ip4addr_conv32(ARPIPBUF->eh_srcipaddr);
|
||||
if (net_ipv4addr_maskcmp(srcipaddr, dev->d_ipaddr, dev->d_netmask))
|
||||
{
|
||||
arp_hdr_update(dev, IPBUF->eh_srcipaddr, ETHBUF->src);
|
||||
arp_hdr_update(dev, ARPIPBUF->eh_srcipaddr, ETHBUF->src);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,14 +55,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ARP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
||||
#define ARPBUF ((FAR struct arp_hdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
#define IPBUF ((FAR struct arp_iphdr_s *)&dev->d_buf[ETH_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -140,7 +132,7 @@ void arp_out(FAR struct net_driver_s *dev)
|
||||
{
|
||||
struct ether_addr ethaddr;
|
||||
FAR struct eth_hdr_s *peth = ETHBUF;
|
||||
FAR struct arp_iphdr_s *pip = IPBUF;
|
||||
FAR struct arp_iphdr_s *pip = ARPIPBUF;
|
||||
in_addr_t ipaddr;
|
||||
in_addr_t destipaddr;
|
||||
int ret;
|
||||
|
@ -66,7 +66,7 @@ void can_poll(FAR struct net_driver_s *dev, FAR struct can_conn_s *conn)
|
||||
|
||||
/* Setup for the application callback */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(0);
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
|
@ -31,15 +31,6 @@
|
||||
#include <nuttx/net/pkt.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the ip header */
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)(dev->d_buf + dev->d_llhdrlen))
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)(dev->d_buf + dev->d_llhdrlen))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -104,14 +104,6 @@
|
||||
#include "ipforward/ipforward.h"
|
||||
#include "devif/devif.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -140,7 +132,7 @@
|
||||
|
||||
int ipv4_input(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct ipv4_hdr_s *ipv4 = BUF;
|
||||
FAR struct ipv4_hdr_s *ipv4 = IPv4BUF;
|
||||
in_addr_t destipaddr;
|
||||
uint16_t llhdrlen;
|
||||
uint16_t totlen;
|
||||
|
@ -56,10 +56,7 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define PAYLOAD ((FAR uint8_t *)&dev->d_buf[NET_LL_HDRLEN(dev)] + IPv6_HDRLEN)
|
||||
#define PAYLOAD ((FAR uint8_t *)TCPIPv6BUF)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
@ -68,8 +68,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPBUF(hl) ((FAR struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
#define ICMPSIZE(hl) ((dev)->d_len - (hl))
|
||||
|
||||
/****************************************************************************
|
||||
@ -172,8 +170,7 @@ static uint16_t icmp_datahandler(FAR struct net_driver_s *dev,
|
||||
/* Copy the new ICMP reply into the I/O buffer chain (without waiting) */
|
||||
|
||||
buflen = ICMPSIZE(iphdrlen);
|
||||
ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPBUF(iphdrlen),
|
||||
buflen, offset, true);
|
||||
ret = iob_trycopyin(iob, IPBUF(iphdrlen), buflen, offset, true);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* On a failure, iob_copyin return a negated error value but does
|
||||
@ -246,7 +243,7 @@ void icmp_input(FAR struct net_driver_s *dev)
|
||||
|
||||
/* The ICMP header immediately follows the IP header */
|
||||
|
||||
icmp = ICMPBUF(iphdrlen);
|
||||
icmp = IPBUF(iphdrlen);
|
||||
|
||||
/* ICMP echo (i.e., ping) processing. This is simple, we only change the
|
||||
* ICMP type from ECHO to ECHO_REPLY and adjust the ICMP checksum before
|
||||
|
@ -66,7 +66,7 @@ void icmp_poll(FAR struct net_driver_s *dev, FAR struct icmp_conn_s *conn)
|
||||
|
||||
/* Setup for the application callback */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev) + IPICMP_HDRLEN];
|
||||
dev->d_appdata = IPBUF(IPICMP_HDRLEN);
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
|
@ -43,8 +43,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPBUF ((FAR struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define ICMPSIZE ((dev)->d_len - IPv4_HDRLEN)
|
||||
|
||||
/****************************************************************************
|
||||
@ -134,7 +132,7 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Check if it is for us */
|
||||
|
||||
icmp = ICMPBUF;
|
||||
icmp = IPBUF(IPv4_HDRLEN);
|
||||
if (conn->id != icmp->id)
|
||||
{
|
||||
ninfo("Wrong ID: %u vs %u\n", icmp->id, conn->id);
|
||||
@ -156,7 +154,7 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Copy the ICMP ECHO reply to the user provided buffer */
|
||||
|
||||
memcpy(pstate->recv_buf, ICMPBUF, recvsize);
|
||||
memcpy(pstate->recv_buf, IPBUF(IPv4_HDRLEN), recvsize);
|
||||
|
||||
/* Return the size of the returned data */
|
||||
|
||||
|
@ -51,8 +51,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/* RFC 1812:
|
||||
* 4.3.2.3, Original Message Header
|
||||
* ...
|
||||
|
@ -55,15 +55,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ICMP_SOCKET
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF \
|
||||
((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPBUF \
|
||||
((FAR struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -141,7 +132,7 @@ static void sendto_request(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Copy the ICMP header and payload into place after the IPv4 header */
|
||||
|
||||
icmp = ICMPBUF;
|
||||
icmp = IPBUF(IPv4_HDRLEN);
|
||||
memcpy(icmp, pstate->snd_buf, pstate->snd_buflen);
|
||||
|
||||
/* Calculate IP checksum. */
|
||||
|
@ -41,15 +41,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define ICMPv6ADVERTISE \
|
||||
((FAR struct icmpv6_neighbor_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -103,7 +94,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Set up the ICMPv6 Neighbor Advertise response */
|
||||
|
||||
adv = ICMPv6ADVERTISE;
|
||||
adv = IPBUF(IPv6_HDRLEN);
|
||||
adv->type = ICMPv6_NEIGHBOR_ADVERTISE; /* Message type */
|
||||
adv->code = 0; /* Message qualifier */
|
||||
adv->flags[0] = ICMPv6_NADV_FLAG_S |
|
||||
|
@ -46,9 +46,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPv6BUF ((FAR struct icmpv6_hdr_s *) \
|
||||
(&dev->d_buf[NET_LL_HDRLEN(dev)] + iplen))
|
||||
#define ICMPv6REPLY ((FAR struct icmpv6_echo_reply_s *)icmpv6)
|
||||
#define ICMPv6SIZE ((dev)->d_len - iplen)
|
||||
|
||||
@ -154,7 +151,7 @@ static uint16_t icmpv6_datahandler(FAR struct net_driver_s *dev,
|
||||
/* Copy the new ICMPv6 reply into the I/O buffer chain (without waiting) */
|
||||
|
||||
buflen = ICMPv6SIZE;
|
||||
icmpv6 = ICMPv6BUF;
|
||||
icmpv6 = IPBUF(iplen);
|
||||
|
||||
ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPv6REPLY, buflen, offset, true);
|
||||
if (ret < 0)
|
||||
@ -219,7 +216,7 @@ drop:
|
||||
void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF;
|
||||
FAR struct icmpv6_hdr_s *icmpv6 = ICMPv6BUF;
|
||||
FAR struct icmpv6_hdr_s *icmpv6 = IPBUF(iplen);
|
||||
|
||||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.icmpv6.recv++;
|
||||
|
@ -67,7 +67,7 @@ void icmpv6_poll(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Setup for the application callback */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev) + IPICMPv6_HDRLEN];
|
||||
dev->d_appdata = IPBUF(IPICMPv6_HDRLEN);
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
|
@ -41,15 +41,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_ROUTER
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define ICMPv6ADVERTISE \
|
||||
((FAR struct icmpv6_router_advertise_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -163,7 +154,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set up the ICMPv6 Router Advertise response */
|
||||
|
||||
adv = ICMPv6ADVERTISE;
|
||||
adv = IPBUF(IPv6_HDRLEN);
|
||||
adv->type = ICMPV6_ROUTER_ADVERTISE; /* Message type */
|
||||
adv->code = 0; /* Message qualifier */
|
||||
adv->hoplimit = 64; /* Current hop limit */
|
||||
|
@ -43,10 +43,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6_BUF \
|
||||
((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPv6_BUF \
|
||||
((FAR struct icmpv6_echo_reply_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
#define ICMPv6_SIZE \
|
||||
((dev)->d_len - IPv6_HDRLEN)
|
||||
|
||||
@ -139,7 +135,7 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
|
||||
* REVISIT: What if there are IPv6 extension headers present?
|
||||
*/
|
||||
|
||||
icmpv6 = ICMPv6_BUF;
|
||||
icmpv6 = IPBUF(IPv6_HDRLEN);
|
||||
if (conn->id != icmpv6->id)
|
||||
{
|
||||
ninfo("Wrong ID: %u vs %u\n", icmpv6->id, conn->id);
|
||||
@ -163,7 +159,7 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
|
||||
* REVISIT: What if there are IPv6 extension headers present?
|
||||
*/
|
||||
|
||||
memcpy(pstate->recv_buf, ICMPv6_BUF, recvsize);
|
||||
memcpy(pstate->recv_buf, IPBUF(IPv6_HDRLEN), recvsize);
|
||||
|
||||
/* Return the size of the returned data */
|
||||
|
||||
@ -172,7 +168,7 @@ static uint16_t recvfrom_eventhandler(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Return the IPv6 address of the sender from the IPv6 header */
|
||||
|
||||
ipv6 = IPv6_BUF;
|
||||
ipv6 = IPBUF(0);
|
||||
net_ipv6addr_hdrcopy(&pstate->recv_from, ipv6->srcipaddr);
|
||||
|
||||
/* Decrement the count of outstanding requests. I suppose this
|
||||
|
@ -51,8 +51,6 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/* The latest drafts declared increase in minimal mtu up to 1280. */
|
||||
|
||||
#define ICMPv6_MINMTULEN 1280
|
||||
|
@ -39,14 +39,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPv6RSOLICIT \
|
||||
((FAR struct icmpv6_router_solicit_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -108,7 +100,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set up the ICMPv6 Router Solicitation message */
|
||||
|
||||
sol = ICMPv6RSOLICIT;
|
||||
sol = IPBUF(IPv6_HDRLEN);
|
||||
sol->type = ICMPV6_ROUTER_SOLICIT; /* Message type */
|
||||
sol->code = 0; /* Message qualifier */
|
||||
sol->flags[0] = 0; /* flags */
|
||||
|
@ -54,15 +54,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF \
|
||||
((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPv6BUF \
|
||||
((FAR struct icmpv6_echo_request_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@ -136,7 +127,7 @@ static void sendto_request(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Copy the ICMPv6 request and payload into place after the IPv6 header */
|
||||
|
||||
icmpv6 = ICMPv6BUF;
|
||||
icmpv6 = IPBUF(IPv6_HDRLEN);
|
||||
memcpy(icmpv6, pstate->snd_buf, pstate->snd_buflen);
|
||||
|
||||
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
|
||||
|
@ -39,14 +39,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPv6SOLICIT \
|
||||
((FAR struct icmpv6_neighbor_solicit_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
@ -119,7 +111,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Set up the ICMPv6 Neighbor Solicitation message */
|
||||
|
||||
sol = ICMPv6SOLICIT;
|
||||
sol = IPBUF(IPv6_HDRLEN);
|
||||
sol->type = ICMPv6_NEIGHBOR_SOLICIT; /* Message type */
|
||||
sol->code = 0; /* Message qualifier */
|
||||
sol->flags[0] = 0; /* flags */
|
||||
|
@ -60,13 +60,6 @@
|
||||
|
||||
#ifdef CONFIG_NET_IGMP
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct igmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IGMPBUF(hl) ((FAR struct igmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -115,7 +108,7 @@
|
||||
|
||||
void igmp_input(struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct igmp_iphdr_s *ipv4 = IPv4BUF;
|
||||
FAR struct igmp_iphdr_s *ipv4 = IPBUF(0);
|
||||
FAR struct igmp_hdr_s *igmp;
|
||||
FAR struct igmp_group_s *group;
|
||||
in_addr_t destipaddr;
|
||||
@ -132,7 +125,7 @@ void igmp_input(struct net_driver_s *dev)
|
||||
|
||||
/* The IGMP header immediately follows the IP header */
|
||||
|
||||
igmp = IGMPBUF(iphdrlen);
|
||||
igmp = IPBUF(iphdrlen);
|
||||
|
||||
/* Verify the message length */
|
||||
|
||||
|
@ -66,8 +66,6 @@
|
||||
/* Buffer layout */
|
||||
|
||||
#define RASIZE (4)
|
||||
#define IPv4BUF ((FAR struct igmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IGMPBUF(hl) ((FAR struct igmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -157,9 +155,9 @@ void igmp_poll(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Setup the poll operation */
|
||||
|
||||
iphdrlen = IPv4_HDRLEN + RASIZE;
|
||||
iphdrlen = IPv4_HDRLEN + RASIZE;
|
||||
|
||||
dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev) + iphdrlen + IGMP_HDRLEN];
|
||||
dev->d_appdata = IPBUF(iphdrlen + IGMP_HDRLEN);
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
|
@ -62,8 +62,6 @@
|
||||
/* Buffer layout */
|
||||
|
||||
#define RASIZE (4)
|
||||
#define IPv4BUF ((FAR struct igmp_iphdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IGMPBUF(hl) ((FAR struct igmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -104,7 +102,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,
|
||||
FAR const in_addr_t *destipaddr, uint8_t msgid)
|
||||
{
|
||||
FAR struct igmp_iphdr_s *ipv4 = IPv4BUF;
|
||||
FAR struct igmp_iphdr_s *ipv4 = IPBUF(0);
|
||||
FAR struct igmp_hdr_s *igmp;
|
||||
uint16_t iphdrlen;
|
||||
|
||||
@ -113,7 +111,7 @@ void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
||||
/* The IGMP header immediately follows the IP header */
|
||||
|
||||
iphdrlen = IPv4_HDRLEN + RASIZE;
|
||||
igmp = IGMPBUF(iphdrlen);
|
||||
igmp = IPBUF(iphdrlen);
|
||||
|
||||
/* The total length to send is the size of the IP and IGMP headers and 4
|
||||
* bytes for the ROUTER ALERT (and, eventually, the Ethernet header)
|
||||
|
@ -82,7 +82,7 @@ static inline void forward_ipselect(FAR struct forward_s *fwd)
|
||||
|
||||
/* Set the offset to the beginning of the UDP data payload */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[IPv4UDP_HDRLEN + NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(IPv4UDP_HDRLEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -92,7 +92,7 @@ static inline void forward_ipselect(FAR struct forward_s *fwd)
|
||||
|
||||
/* Set the offset to the beginning of the UDP data payload */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[IPv6UDP_HDRLEN + NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(IPv6UDP_HDRLEN);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -54,20 +54,19 @@
|
||||
static int ipfwd_packet_proto(FAR struct net_driver_s *dev)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6;
|
||||
int llhdrlen = NET_LL_HDRLEN(dev);
|
||||
|
||||
/* Make sure the there is something in buffer that is at least as large as
|
||||
* the IPv6_HDR.
|
||||
*/
|
||||
|
||||
if (dev->d_len > (IPv6_HDRLEN + llhdrlen))
|
||||
if (dev->d_len > (IPv6_HDRLEN + NET_LL_HDRLEN(dev)))
|
||||
{
|
||||
if (dev->d_lltype == NET_LL_IEEE802154 ||
|
||||
dev->d_lltype == NET_LL_PKTRADIO)
|
||||
{
|
||||
/* There should be an IPv6 packet at the beginning of the buffer */
|
||||
|
||||
ipv6 = (FAR struct ipv6_hdr_s *)&dev->d_buf[llhdrlen];
|
||||
ipv6 = IPv6BUF;
|
||||
if ((ipv6->vtc & IP_VERSION_MASK) == IPv6_VERSION)
|
||||
{
|
||||
/* Yes.. return the L2 protocol of the packet */
|
||||
|
@ -376,7 +376,7 @@ int ipv4_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg)
|
||||
* d_buf.
|
||||
*/
|
||||
|
||||
ipv4 = (FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)];
|
||||
ipv4 = IPv4BUF;
|
||||
|
||||
/* Send the packet asynchrously on the forwarding device. */
|
||||
|
||||
|
@ -512,7 +512,7 @@ int ipv6_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg)
|
||||
* d_buf.
|
||||
*/
|
||||
|
||||
ipv6 = (FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)];
|
||||
ipv6 = IPv6BUF;
|
||||
|
||||
/* Send the packet asynchrously on the forwarding device. */
|
||||
|
||||
|
@ -60,7 +60,7 @@ void mld_poll(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Setup the poll operation */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN];
|
||||
dev->d_appdata = IPBUF(IPv6_HDRLEN);
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
|
@ -41,12 +41,6 @@
|
||||
#include "mld/mld.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -59,20 +59,6 @@
|
||||
#define RASIZE sizeof(struct ipv6_router_alert_s)
|
||||
#define MLD_HDRLEN (IPv6_HDRLEN + RASIZE)
|
||||
|
||||
/* Buffer layout */
|
||||
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define RABUF ((FAR struct ipv6_router_alert_s *) \
|
||||
(&dev->d_buf[NET_LL_HDRLEN(dev)] + IPv6_HDRLEN))
|
||||
#define QUERYBUF ((FAR struct mld_mcast_listen_query_s *) \
|
||||
(&dev->d_buf[NET_LL_HDRLEN(dev)] + MLD_HDRLEN))
|
||||
#define V1REPORTBUF ((FAR struct mld_mcast_listen_report_v1_s *) \
|
||||
(&dev->d_buf[NET_LL_HDRLEN(dev)] + MLD_HDRLEN))
|
||||
#define V2REPORTBUF ((FAR struct mld_mcast_listen_report_v2_s *) \
|
||||
(&dev->d_buf[NET_LL_HDRLEN(dev)] + MLD_HDRLEN))
|
||||
#define DONEBUF ((FAR struct mld_mcast_listen_done_s *) \
|
||||
(&dev->d_buf[NET_LL_HDRLEN(dev)] + MLD_HDRLEN))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -237,7 +223,7 @@ void mld_send(FAR struct net_driver_s *dev, FAR struct mld_group_s *group,
|
||||
* The IPv6 router alert option (type 5) is defined in RFC 2711.
|
||||
*/
|
||||
|
||||
ra = RABUF;
|
||||
ra = IPBUF(IPv6_HDRLEN);
|
||||
memset(ra, 0, RASIZE);
|
||||
|
||||
ra->hbyh.nxthdr = IP_PROTO_ICMP6; /* ICMPv6 payload follows extension header */
|
||||
@ -253,7 +239,7 @@ void mld_send(FAR struct net_driver_s *dev, FAR struct mld_group_s *group,
|
||||
case MLD_SEND_GENQUERY: /* Send General Query */
|
||||
case MLD_SEND_MASQUERY: /* Send Multicast Address Specific (MAS) Query */
|
||||
{
|
||||
FAR struct mld_mcast_listen_query_s *query = QUERYBUF;
|
||||
FAR struct mld_mcast_listen_query_s *query = IPBUF(MLD_HDRLEN);
|
||||
|
||||
/* Initialize the Query payload. In a General Query, both the
|
||||
* Multicast Address field and the Number of Sources (N)
|
||||
@ -322,7 +308,8 @@ void mld_send(FAR struct net_driver_s *dev, FAR struct mld_group_s *group,
|
||||
|
||||
case MLD_SEND_V1REPORT: /* Send MLDv1 Report message */
|
||||
{
|
||||
FAR struct mld_mcast_listen_report_v1_s *report = V1REPORTBUF;
|
||||
FAR struct mld_mcast_listen_report_v1_s *report =
|
||||
IPBUF(MLD_HDRLEN);
|
||||
|
||||
/* Initialize the Report payload */
|
||||
|
||||
@ -342,7 +329,8 @@ void mld_send(FAR struct net_driver_s *dev, FAR struct mld_group_s *group,
|
||||
|
||||
case MLD_SEND_V2REPORT: /* Send MLDv2 Report message */
|
||||
{
|
||||
FAR struct mld_mcast_listen_report_v2_s *report = V2REPORTBUF;
|
||||
FAR struct mld_mcast_listen_report_v2_s *report =
|
||||
IPBUF(MLD_HDRLEN);
|
||||
FAR struct mld_mcast_addrec_v2_s *addrec;
|
||||
|
||||
/* Initialize the Report payload */
|
||||
@ -367,7 +355,7 @@ void mld_send(FAR struct net_driver_s *dev, FAR struct mld_group_s *group,
|
||||
|
||||
case MLD_SEND_DONE: /* Send Done message */
|
||||
{
|
||||
FAR struct mld_mcast_listen_done_s *done = DONEBUF;
|
||||
FAR struct mld_mcast_listen_done_s *done = IPBUF(MLD_HDRLEN);
|
||||
|
||||
/* Initialize the Done payload */
|
||||
|
||||
|
@ -37,13 +37,6 @@
|
||||
#include "icmpv6/icmpv6.h"
|
||||
#include "neighbor/neighbor.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ETHBUF ((FAR struct eth_hdr_s *)dev->d_buf)
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -65,7 +65,7 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
|
||||
{
|
||||
/* Setup for the application callback */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(0);
|
||||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
|
@ -109,7 +109,6 @@
|
||||
|
||||
/* Buffer access helpers */
|
||||
|
||||
#define IPv6BUF(dev) ((FAR struct ipv6_hdr_s *)((dev)->d_buf))
|
||||
#define TCPBUF(dev) ((FAR struct tcp_hdr_s *)&(dev)->d_buf[IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
@ -619,9 +618,13 @@ static int sixlowpan_dispatch(FAR struct radio_driver_s *radio)
|
||||
FAR struct sixlowpan_reassbuf_s *reass;
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_DUMPBUFFER
|
||||
struct net_driver_s *dev = &radio->r_dev;
|
||||
|
||||
sixlowpan_dumpbuffer("Incoming packet",
|
||||
(FAR const uint8_t *)IPv6BUF(&radio->r_dev),
|
||||
(FAR const uint8_t *)IPv6BUF,
|
||||
radio->r_dev.d_len);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_PKT
|
||||
/* When packet sockets are enabled, feed the frame into the tap */
|
||||
@ -726,6 +729,7 @@ static int sixlowpan_dispatch(FAR struct radio_driver_s *radio)
|
||||
int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
FAR struct iob_s *framelist, FAR const void *metadata)
|
||||
{
|
||||
struct net_driver_s *dev = &radio->r_dev;
|
||||
int ret = -EINVAL;
|
||||
uint8_t *d_buf_backup;
|
||||
|
||||
@ -736,7 +740,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
* returning
|
||||
*/
|
||||
|
||||
d_buf_backup = radio->r_dev.d_buf;
|
||||
d_buf_backup = dev->d_buf;
|
||||
|
||||
/* Verify that an frame has been provided. */
|
||||
|
||||
@ -781,7 +785,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
* packet.
|
||||
*/
|
||||
|
||||
if (radio->r_dev.d_len > 0)
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
FAR struct ipv6_hdr_s *ipv6hdr;
|
||||
FAR uint8_t *buffer;
|
||||
@ -794,7 +798,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
* layer protocol header.
|
||||
*/
|
||||
|
||||
ipv6hdr = IPv6BUF(&radio->r_dev);
|
||||
ipv6hdr = IPv6BUF;
|
||||
|
||||
/* Get the IEEE 802.15.4 MAC address of the destination.
|
||||
* This assumes an encoding of the MAC address in the IPv6
|
||||
@ -819,7 +823,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
#ifdef CONFIG_NET_TCP
|
||||
case IP_PROTO_TCP:
|
||||
{
|
||||
FAR struct tcp_hdr_s *tcp = TCPBUF(&radio->r_dev);
|
||||
FAR struct tcp_hdr_s *tcp = TCPBUF(dev);
|
||||
uint16_t tcplen;
|
||||
|
||||
/* The TCP header length is encoded in the top 4
|
||||
@ -854,22 +858,22 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||
}
|
||||
}
|
||||
|
||||
if (hdrlen > radio->r_dev.d_len)
|
||||
if (hdrlen > dev->d_len)
|
||||
{
|
||||
nwarn("WARNING: Packet too small: Have %u need >%zu\n",
|
||||
radio->r_dev.d_len, hdrlen);
|
||||
dev->d_len, hdrlen);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
/* Convert the outgoing packet into a frame list. */
|
||||
|
||||
buffer = radio->r_dev.d_buf + hdrlen;
|
||||
buflen = radio->r_dev.d_len - hdrlen;
|
||||
buffer = dev->d_buf + hdrlen;
|
||||
buflen = dev->d_len - hdrlen;
|
||||
|
||||
ret = sixlowpan_queue_frames(radio, ipv6hdr, buffer,
|
||||
buflen, &destmac);
|
||||
drop:
|
||||
radio->r_dev.d_len = 0;
|
||||
dev->d_len = 0;
|
||||
|
||||
/* We consumed the frame, so we must return 0. */
|
||||
|
||||
@ -881,7 +885,7 @@ drop:
|
||||
|
||||
/* Restore the d_buf back to it's original state */
|
||||
|
||||
radio->r_dev.d_buf = d_buf_backup;
|
||||
dev->d_buf = d_buf_backup;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -104,6 +104,11 @@
|
||||
|
||||
#define TCP_FAST_RETRANSMISSION_THRESH 3
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the tcp header */
|
||||
|
||||
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv4_HDRLEN))
|
||||
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)IPBUF(IPv6_HDRLEN))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
@ -69,13 +69,6 @@
|
||||
#include "arp/arp.h"
|
||||
#include "icmpv6/icmpv6.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -63,12 +63,7 @@
|
||||
#include "utils/utils.h"
|
||||
#include "tcp/tcp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPDATA(hl) (dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -288,7 +283,6 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
FAR struct tcp_hdr_s *tcp;
|
||||
union ip_binding_u uaddr;
|
||||
unsigned int tcpiplen;
|
||||
unsigned int hdrlen;
|
||||
uint16_t tmp16;
|
||||
uint16_t flags;
|
||||
uint16_t result;
|
||||
@ -306,7 +300,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
* the link layer header and the IP header.
|
||||
*/
|
||||
|
||||
tcp = (FAR struct tcp_hdr_s *)&dev->d_buf[iplen + NET_LL_HDRLEN(dev)];
|
||||
tcp = IPBUF(iplen);
|
||||
|
||||
/* Get the size of the IP header and the TCP header.
|
||||
*
|
||||
@ -318,10 +312,6 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
|
||||
tcpiplen = iplen + TCP_HDRLEN;
|
||||
|
||||
/* Get the size of the link layer header, the IP and TCP header */
|
||||
|
||||
hdrlen = tcpiplen + NET_LL_HDRLEN(dev);
|
||||
|
||||
/* Start of TCP input header processing code. */
|
||||
|
||||
if (tcp_chksum(dev) != 0xffff)
|
||||
@ -455,7 +445,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
{
|
||||
for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ; )
|
||||
{
|
||||
opt = dev->d_buf[hdrlen + i];
|
||||
opt = IPDATA(tcpiplen + i);
|
||||
if (opt == TCP_OPT_END)
|
||||
{
|
||||
/* End of options. */
|
||||
@ -470,21 +460,21 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
continue;
|
||||
}
|
||||
else if (opt == TCP_OPT_MSS &&
|
||||
dev->d_buf[hdrlen + 1 + i] == TCP_OPT_MSS_LEN)
|
||||
IPDATA(tcpiplen + 1 + i) == TCP_OPT_MSS_LEN)
|
||||
{
|
||||
uint16_t tcp_mss = TCP_MSS(dev, iplen);
|
||||
|
||||
/* An MSS option with the right option length. */
|
||||
|
||||
tmp16 = ((uint16_t)dev->d_buf[hdrlen + 2 + i] << 8) |
|
||||
(uint16_t)dev->d_buf[hdrlen + 3 + i];
|
||||
tmp16 = ((uint16_t)IPDATA(tcpiplen + 2 + i) << 8) |
|
||||
(uint16_t)IPDATA(tcpiplen + 3 + i);
|
||||
conn->mss = tmp16 > tcp_mss ? tcp_mss : tmp16;
|
||||
}
|
||||
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
||||
else if (opt == TCP_OPT_WS &&
|
||||
dev->d_buf[hdrlen + 1 + i] == TCP_OPT_WS_LEN)
|
||||
IPDATA(tcpiplen + 1 + i) == TCP_OPT_WS_LEN)
|
||||
{
|
||||
conn->snd_scale = dev->d_buf[hdrlen + 2 + i];
|
||||
conn->snd_scale = IPDATA(tcpiplen + 2 + i);
|
||||
conn->rcv_scale = CONFIG_NET_TCP_WINDOW_SCALE_FACTOR;
|
||||
conn->flags |= TCP_WSCALE;
|
||||
}
|
||||
@ -495,7 +485,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
* easily can skip past them.
|
||||
*/
|
||||
|
||||
if (dev->d_buf[hdrlen + 1 + i] == 0)
|
||||
if (IPDATA(tcpiplen + 1 + i) == 0)
|
||||
{
|
||||
/* If the length field is zero, the options are
|
||||
* malformed and we don't process them further.
|
||||
@ -505,7 +495,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
}
|
||||
}
|
||||
|
||||
i += dev->d_buf[hdrlen + 1 + i];
|
||||
i += IPDATA(tcpiplen + 1 + i);
|
||||
}
|
||||
}
|
||||
|
||||
@ -918,7 +908,7 @@ found:
|
||||
{
|
||||
for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ; )
|
||||
{
|
||||
opt = dev->d_buf[hdrlen + i];
|
||||
opt = IPDATA(tcpiplen + i);
|
||||
if (opt == TCP_OPT_END)
|
||||
{
|
||||
/* End of options. */
|
||||
@ -933,22 +923,21 @@ found:
|
||||
continue;
|
||||
}
|
||||
else if (opt == TCP_OPT_MSS &&
|
||||
dev->d_buf[hdrlen + 1 + i] == TCP_OPT_MSS_LEN)
|
||||
IPDATA(tcpiplen + 1 + i) == TCP_OPT_MSS_LEN)
|
||||
{
|
||||
uint16_t tcp_mss = TCP_MSS(dev, iplen);
|
||||
|
||||
/* An MSS option with the right option length. */
|
||||
|
||||
tmp16 =
|
||||
(dev->d_buf[hdrlen + 2 + i] << 8) |
|
||||
dev->d_buf[hdrlen + 3 + i];
|
||||
tmp16 = (IPDATA(tcpiplen + 2 + i) << 8) |
|
||||
IPDATA(tcpiplen + 3 + i);
|
||||
conn->mss = tmp16 > tcp_mss ? tcp_mss : tmp16;
|
||||
}
|
||||
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
||||
else if (opt == TCP_OPT_WS &&
|
||||
dev->d_buf[hdrlen + 1 + i] == TCP_OPT_WS_LEN)
|
||||
IPDATA(tcpiplen + 1 + i) == TCP_OPT_WS_LEN)
|
||||
{
|
||||
conn->snd_scale = dev->d_buf[hdrlen + 2 + i];
|
||||
conn->snd_scale = IPDATA(tcpiplen + 2 + i);
|
||||
conn->rcv_scale = CONFIG_NET_TCP_WINDOW_SCALE_FACTOR;
|
||||
conn->flags |= TCP_WSCALE;
|
||||
}
|
||||
@ -959,7 +948,7 @@ found:
|
||||
* easily can skip past them.
|
||||
*/
|
||||
|
||||
if (dev->d_buf[hdrlen + 1 + i] == 0)
|
||||
if (IPDATA(tcpiplen + 1 + i) == 0)
|
||||
{
|
||||
/* If the length field is zero, the options are
|
||||
* malformed and we don't process them further.
|
||||
@ -969,7 +958,7 @@ found:
|
||||
}
|
||||
}
|
||||
|
||||
i += dev->d_buf[hdrlen + 1 + i];
|
||||
i += IPDATA(tcpiplen + 1 + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ void tcp_ipv4_select(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set the offset to the beginning of the TCP data payload */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[IPv4TCP_HDRLEN + NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(IPv4TCP_HDRLEN);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
@ -76,7 +76,7 @@ void tcp_ipv6_select(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set the offset to the beginning of the TCP data payload */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[IPv6TCP_HDRLEN + NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(IPv6TCP_HDRLEN);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
|
@ -42,16 +42,6 @@
|
||||
#include "tcp/tcp.h"
|
||||
#include "socket/socket.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -62,16 +62,6 @@
|
||||
#include "tcp/tcp.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -77,9 +77,6 @@
|
||||
# define NEED_IPDOMAIN_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/* Debug */
|
||||
|
||||
#ifdef CONFIG_NET_TCP_WRBUFFER_DUMP
|
||||
|
@ -67,9 +67,6 @@
|
||||
# define NEED_IPDOMAIN_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -58,13 +58,6 @@
|
||||
#if defined(CONFIG_NET_SENDFILE) && defined(CONFIG_NET_TCP) && \
|
||||
defined(NET_TCP_HAVE_STACK)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define TCPIPv4BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define TCPIPv6BUF ((FAR struct tcp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -73,6 +73,11 @@
|
||||
|
||||
#define _UDP_ISCONNECTMODE(f) (((f) & _UDP_FLAG_CONNECTMODE) != 0)
|
||||
|
||||
/* This is a helper pointer for accessing the contents of the udp header */
|
||||
|
||||
#define UDPIPv4BUF ((FAR struct udp_hdr_s *)IPBUF(IPv4_HDRLEN))
|
||||
#define UDPIPv6BUF ((FAR struct udp_hdr_s *)IPBUF(IPv6_HDRLEN))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Type Definitions
|
||||
****************************************************************************/
|
||||
|
@ -37,16 +37,6 @@
|
||||
#include "devif/devif.h"
|
||||
#include "udp/udp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define UDPIPv4BUF ((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define UDPIPv6BUF ((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -68,13 +68,6 @@
|
||||
#include "inet/inet.h"
|
||||
#include "udp/udp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
@ -59,12 +59,6 @@
|
||||
#include "icmp/icmp.h"
|
||||
#include "icmpv6/icmpv6.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@ -97,7 +91,6 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
||||
FAR struct udp_hdr_s *udp;
|
||||
FAR struct udp_conn_s *conn;
|
||||
unsigned int udpiplen;
|
||||
unsigned int hdrlen;
|
||||
#ifdef CONFIG_NET_UDP_CHECKSUMS
|
||||
uint16_t chksum;
|
||||
#endif
|
||||
@ -113,25 +106,19 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
||||
* the link layer header and the IP header.
|
||||
*/
|
||||
|
||||
udp = (FAR struct udp_hdr_s *)&dev->d_buf[iplen + NET_LL_HDRLEN(dev)];
|
||||
udp = IPBUF(iplen);
|
||||
|
||||
/* Get the size of the IP header and the UDP header */
|
||||
|
||||
udpiplen = iplen + UDP_HDRLEN;
|
||||
|
||||
/* Get the size of the link layer header, the IP header, and the UDP
|
||||
* header
|
||||
*/
|
||||
|
||||
hdrlen = udpiplen + NET_LL_HDRLEN(dev);
|
||||
|
||||
/* UDP processing is really just a hack. We don't do anything to the UDP/IP
|
||||
* headers, but let the UDP application do all the hard work. If the
|
||||
* application sets d_sndlen, it has a packet to send.
|
||||
*/
|
||||
|
||||
dev->d_len -= udpiplen;
|
||||
dev->d_appdata = &dev->d_buf[hdrlen];
|
||||
dev->d_appdata = IPBUF(udpiplen);
|
||||
|
||||
#ifdef CONFIG_NET_UDP_CHECKSUMS
|
||||
chksum = udp->udpchksum;
|
||||
@ -191,7 +178,7 @@ static int udp_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
||||
|
||||
/* Set-up for the application callback */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[hdrlen];
|
||||
dev->d_appdata = IPBUF(udpiplen);
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
/* Perform the application callback */
|
||||
|
@ -56,7 +56,7 @@ void udp_ipv4_select(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set the offset to the beginning of the UDP data payload */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[IPv4UDP_HDRLEN + NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(IPv4UDP_HDRLEN);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
@ -77,7 +77,7 @@ void udp_ipv6_select(FAR struct net_driver_s *dev)
|
||||
|
||||
/* Set the offset to the beginning of the UDP data payload */
|
||||
|
||||
dev->d_appdata = &dev->d_buf[IPv6UDP_HDRLEN + NET_LL_HDRLEN(dev)];
|
||||
dev->d_appdata = IPBUF(IPv6UDP_HDRLEN);
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
|
@ -43,16 +43,6 @@
|
||||
#include "udp/udp.h"
|
||||
#include "socket/socket.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define UDPIPv4BUF ((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define UDPIPv6BUF ((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -61,20 +61,6 @@
|
||||
#include "utils/utils.h"
|
||||
#include "udp/udp.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF \
|
||||
((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF \
|
||||
((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
#define UDPIPv4BUF \
|
||||
((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define UDPIPv6BUF \
|
||||
((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -74,9 +74,6 @@
|
||||
# define NEED_IPDOMAIN_SUPPORT 1
|
||||
#endif
|
||||
|
||||
#define UDPIPv4BUF ((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv4_HDRLEN])
|
||||
#define UDPIPv6BUF ((FAR struct udp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + IPv6_HDRLEN])
|
||||
|
||||
/* Debug */
|
||||
|
||||
#ifdef CONFIG_NET_UDP_WRBUFFER_DUMP
|
||||
|
@ -28,15 +28,9 @@
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/icmp.h>
|
||||
|
||||
#include "icmp/icmp.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define ICMPBUF(hl) ((FAR struct icmp_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -62,7 +56,7 @@ uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len)
|
||||
|
||||
/* The ICMP header immediately follows the IP header */
|
||||
|
||||
icmp = ICMPBUF(iphdrlen);
|
||||
icmp = IPBUF(iphdrlen);
|
||||
return net_chksum((FAR uint16_t *)&icmp->type, len);
|
||||
}
|
||||
#endif /* CONFIG_NET_ICMP */
|
||||
|
@ -33,13 +33,6 @@
|
||||
|
||||
#ifdef CONFIG_NET
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
@ -100,7 +93,7 @@ uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto)
|
||||
|
||||
/* Sum IP payload data. */
|
||||
|
||||
sum = chksum(sum, &dev->d_buf[iphdrlen + NET_LL_HDRLEN(dev)], upperlen);
|
||||
sum = chksum(sum, IPBUF(iphdrlen), upperlen);
|
||||
return (sum == 0) ? 0xffff : HTONS(sum);
|
||||
}
|
||||
#endif /* CONFIG_NET_ARCH_CHKSUM */
|
||||
@ -167,7 +160,7 @@ uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev,
|
||||
|
||||
/* Sum IP payload data. */
|
||||
|
||||
sum = chksum(sum, &dev->d_buf[NET_LL_HDRLEN(dev) + iplen], upperlen);
|
||||
sum = chksum(sum, IPBUF(iplen), upperlen);
|
||||
return (sum == 0) ? 0xffff : HTONS(sum);
|
||||
}
|
||||
#endif /* CONFIG_NET_ARCH_CHKSUM */
|
||||
@ -200,7 +193,7 @@ uint16_t ipv4_chksum(FAR struct net_driver_s *dev)
|
||||
|
||||
iphdrlen = (ipv4->vhl & IPv4_HLMASK) << 2;
|
||||
|
||||
sum = chksum(0, &dev->d_buf[NET_LL_HDRLEN(dev)], iphdrlen);
|
||||
sum = chksum(0, IPBUF(0), iphdrlen);
|
||||
return (sum == 0) ? 0xffff : HTONS(sum);
|
||||
}
|
||||
#endif /* CONFIG_NET_ARCH_CHKSUM */
|
||||
|
Loading…
Reference in New Issue
Block a user