mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
net: move device buffer define to common header
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
@@ -251,7 +251,6 @@
|
|||||||
* header.
|
* header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define ETHBUF ((struct eth_hdr_s *)priv->eth_dev.d_buf)
|
|
||||||
#define ETH8021QWBUF ((struct eth_8021qhdr_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)
|
static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
||||||
{
|
{
|
||||||
|
struct net_driver_s *dev = &priv->eth_dev;
|
||||||
|
|
||||||
#ifdef CONFIG_NET_PKT
|
#ifdef CONFIG_NET_PKT
|
||||||
/* When packet sockets are enabled, feed the frame into the tap */
|
/* When packet sockets are enabled, feed the frame into the tap */
|
||||||
|
|
||||||
pkt_input(&priv->eth_dev);
|
pkt_input(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We only accept IP packets of the configured type and ARP packets */
|
/* 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))
|
if (ETHBUF->type == HTONS(ETHTYPE_IP))
|
||||||
{
|
{
|
||||||
ninfo("IPv4 packet\n");
|
ninfo("IPv4 packet\n");
|
||||||
NETDEV_RXIPV4(&priv->eth_dev);
|
NETDEV_RXIPV4(dev);
|
||||||
|
|
||||||
/* Handle ARP on input,
|
/* Handle ARP on input,
|
||||||
* then dispatch IPv4 packet to the network layer
|
* then dispatch IPv4 packet to the network layer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
arp_ipin(&priv->eth_dev);
|
arp_ipin(dev);
|
||||||
ipv4_input(&priv->eth_dev);
|
ipv4_input(dev);
|
||||||
|
|
||||||
/* Check for a reply to the IPv4 packet */
|
/* 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))
|
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
|
||||||
{
|
{
|
||||||
ninfo("IPv6 packet\n");
|
ninfo("IPv6 packet\n");
|
||||||
NETDEV_RXIPV6(&priv->eth_dev);
|
NETDEV_RXIPV6(dev);
|
||||||
|
|
||||||
/* Dispatch IPv6 packet to the network layer */
|
/* Dispatch IPv6 packet to the network layer */
|
||||||
|
|
||||||
ipv6_input(&priv->eth_dev);
|
ipv6_input(dev);
|
||||||
|
|
||||||
/* Check for a reply to the IPv6 packet */
|
/* 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))
|
if (ETH8021QWBUF->tpid == HTONS(TPID_8021QVLAN))
|
||||||
{
|
{
|
||||||
ninfo("IEEE 802.1q packet\n");
|
ninfo("IEEE 802.1q packet\n");
|
||||||
NETDEV_RXQVLAN(&priv->eth_dev);
|
NETDEV_RXQVLAN(dev);
|
||||||
|
|
||||||
/* Dispatch the 802.1q VLAN packet to the network layer */
|
/* 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 */
|
/* 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 */
|
/* Dispatch the ARP packet to the network layer */
|
||||||
|
|
||||||
arp_arpin(&priv->eth_dev);
|
arp_arpin(dev);
|
||||||
NETDEV_RXARP(&priv->eth_dev);
|
NETDEV_RXARP(dev);
|
||||||
|
|
||||||
/* If the above function invocation resulted in data that should be
|
/* 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.
|
* 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);
|
chan = lpc54_eth_getring(priv);
|
||||||
txring = &priv->eth_txring[chan];
|
txring = &priv->eth_txring[chan];
|
||||||
|
|
||||||
(txring->tr_buffers)[txring->tr_supply] =
|
(txring->tr_buffers)[txring->tr_supply] =
|
||||||
(uint32_t *)priv->eth_dev.d_buf;
|
(uint32_t *)dev->d_buf;
|
||||||
|
|
||||||
lpc54_eth_transmit(priv, chan);
|
lpc54_eth_transmit(priv, chan);
|
||||||
}
|
}
|
||||||
@@ -1022,7 +1023,7 @@ static void lpc54_eth_rxdispatch(struct lpc54_ethdriver_s *priv)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NETDEV_RXDROPPED(&priv->eth_dev);
|
NETDEV_RXDROPPED(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* On entry, d_buf refers to the receive buffer as set by logic in
|
/* 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.
|
* 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;
|
dev->d_buf = NULL;
|
||||||
priv->eth_dev.d_len = 0;
|
dev->d_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -158,10 +158,6 @@
|
|||||||
|
|
||||||
#define TIVA_TXTIMEOUT (60*CLK_TCK)
|
#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
|
#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)
|
static void tiva_receive(struct tiva_driver_s *priv)
|
||||||
{
|
{
|
||||||
|
struct net_driver_s *dev = &priv->ld_dev;
|
||||||
uint32_t regval;
|
uint32_t regval;
|
||||||
uint8_t *dbuf;
|
uint8_t *dbuf;
|
||||||
int pktlen;
|
int bytesleft;
|
||||||
int bytesleft;
|
int pktlen;
|
||||||
|
|
||||||
/* Loop while there are incoming packets to be processed */
|
/* Loop while there are incoming packets to be processed */
|
||||||
|
|
||||||
@@ -686,13 +683,13 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
|||||||
{
|
{
|
||||||
/* Update statistics */
|
/* Update statistics */
|
||||||
|
|
||||||
NETDEV_RXPACKETS(&priv->ld_dev);
|
NETDEV_RXPACKETS(dev);
|
||||||
|
|
||||||
/* Copy the data data from the hardware to priv->ld_dev.d_buf. Set
|
/* Copy the data data from the hardware to dev->d_buf. Set
|
||||||
* amount of data in priv->ld_dev.d_len
|
* 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
|
/* The packet frame length begins in the LS 16-bits of the first
|
||||||
* word from the FIFO followed by the Ethernet header beginning
|
* 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 */
|
/* We will have to drop this packet */
|
||||||
|
|
||||||
nwarn("WARNING: Bad packet size dropped (%d)\n", pktlen);
|
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
|
/* The number of bytes and words left to read is pktlen - 4
|
||||||
* (including, the final, possibly partial word) because we've
|
* (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.
|
* and 4 bytes for the FCS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
priv->ld_dev.d_len = pktlen - 6;
|
dev->d_len = pktlen - 6;
|
||||||
tiva_dumppacket("Received packet",
|
tiva_dumppacket("Received packet",
|
||||||
priv->ld_dev.d_buf, priv->ld_dev.d_len);
|
dev->d_buf, dev->d_len);
|
||||||
|
|
||||||
#ifdef CONFIG_NET_PKT
|
#ifdef CONFIG_NET_PKT
|
||||||
/* When packet sockets are enabled, feed the frame into the tap */
|
/* When packet sockets are enabled, feed the frame into the tap */
|
||||||
|
|
||||||
pkt_input(&priv->ld_dev);
|
pkt_input(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We only accept IP packets of the configured type and ARP packets */
|
/* 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))
|
if (ETHBUF->type == HTONS(ETHTYPE_IP))
|
||||||
{
|
{
|
||||||
ninfo("IPv4 frame\n");
|
ninfo("IPv4 frame\n");
|
||||||
NETDEV_RXIPV4(&priv->ld_dev);
|
NETDEV_RXIPV4(dev);
|
||||||
|
|
||||||
/* Handle ARP on input then give the IPv4 packet to the network
|
/* Handle ARP on input then give the IPv4 packet to the network
|
||||||
* layer
|
* layer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
arp_ipin(&priv->ld_dev);
|
arp_ipin(dev);
|
||||||
ipv4_input(&priv->ld_dev);
|
ipv4_input(dev);
|
||||||
|
|
||||||
/* If the above function invocation resulted in data that should be
|
/* 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.
|
* 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 */
|
/* Update the Ethernet header with the correct MAC address */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
if (IFF_IS_IPv4(priv->ld_dev.d_flags))
|
if (IFF_IS_IPv4(dev->d_flags))
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
arp_out(&priv->ld_dev);
|
arp_out(dev);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
neighbor_out(&priv->ld_dev);
|
neighbor_out(dev);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -846,12 +843,12 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
|||||||
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
|
if (ETHBUF->type == HTONS(ETHTYPE_IP6))
|
||||||
{
|
{
|
||||||
ninfo("IPv6 frame\n");
|
ninfo("IPv6 frame\n");
|
||||||
NETDEV_RXIPV6(&priv->ld_dev);
|
NETDEV_RXIPV6(dev);
|
||||||
|
|
||||||
/* Give the IPv6 packet to the network layer */
|
/* Give the IPv6 packet to the network layer */
|
||||||
|
|
||||||
arp_ipin(&priv->ld_dev);
|
arp_ipin(dev);
|
||||||
ipv6_input(&priv->ld_dev);
|
ipv6_input(dev);
|
||||||
|
|
||||||
/* If the above function invocation resulted in data that should be
|
/* 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.
|
* 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 */
|
/* Update the Ethernet header with the correct MAC address */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#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
|
else
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
{
|
{
|
||||||
neighbor_out(&priv->ld_dev);
|
neighbor_out(dev);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -885,15 +882,15 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
|||||||
if (ETHBUF->type == HTONS(ETHTYPE_ARP))
|
if (ETHBUF->type == HTONS(ETHTYPE_ARP))
|
||||||
{
|
{
|
||||||
ninfo("ARP packet received (%02x)\n", ETHBUF->type);
|
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
|
/* 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.
|
* 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);
|
tiva_transmit(priv);
|
||||||
}
|
}
|
||||||
@@ -903,7 +900,7 @@ static void tiva_receive(struct tiva_driver_s *priv)
|
|||||||
{
|
{
|
||||||
nwarn("WARNING: Unsupported packet type dropped (%02x)\n",
|
nwarn("WARNING: Unsupported packet type dropped (%02x)\n",
|
||||||
HTONS(ETHBUF->type));
|
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)
|
#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
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -59,11 +59,6 @@
|
|||||||
# error Worker thread support is required (CONFIG_SCHED_WORKQUEUE)
|
# error Worker thread support is required (CONFIG_SCHED_WORKQUEUE)
|
||||||
#endif
|
#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
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+2
-5
@@ -109,11 +109,6 @@
|
|||||||
|
|
||||||
#define SLIP_WDDELAY (1*1000000)
|
#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
|
* 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[])
|
static int slip_rxtask(int argc, FAR char *argv[])
|
||||||
{
|
{
|
||||||
FAR struct slip_driver_s *priv;
|
FAR struct slip_driver_s *priv;
|
||||||
|
FAR struct net_driver_s *dev;
|
||||||
unsigned int index = *(argv[1]) - '0';
|
unsigned int index = *(argv[1]) - '0';
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
@@ -618,6 +614,7 @@ static int slip_rxtask(int argc, FAR char *argv[])
|
|||||||
|
|
||||||
/* Loop forever */
|
/* Loop forever */
|
||||||
|
|
||||||
|
dev = &priv->dev;
|
||||||
for (; ; )
|
for (; ; )
|
||||||
{
|
{
|
||||||
/* Wait for the next character to be available on the input stream. */
|
/* Wait for the next character to be available on the input stream. */
|
||||||
|
|||||||
+14
-17
@@ -113,11 +113,6 @@
|
|||||||
# define BUF ((FAR struct eth_hdr_s *)priv->dev.d_buf)
|
# define BUF ((FAR struct eth_hdr_s *)priv->dev.d_buf)
|
||||||
#endif
|
#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
|
* 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)
|
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
|
FAR struct net_driver_s *dev = &priv->dev;
|
||||||
* data in priv->dev.d_len
|
|
||||||
|
/* 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
|
#ifdef CONFIG_NET_PKT
|
||||||
/* When packet sockets are enabled, feed the frame into the tap */
|
/* When packet sockets are enabled, feed the frame into the tap */
|
||||||
|
|
||||||
pkt_input(&priv->dev);
|
pkt_input(dev);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We only accept IP packets of the configured type */
|
/* 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)
|
if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION)
|
||||||
{
|
{
|
||||||
ninfo("IPv4 frame\n");
|
ninfo("IPv4 frame\n");
|
||||||
NETDEV_RXIPV4(&priv->dev);
|
NETDEV_RXIPV4(dev);
|
||||||
|
|
||||||
/* Give the IPv4 packet to the network layer. */
|
/* Give the IPv4 packet to the network layer. */
|
||||||
|
|
||||||
ipv4_input(&priv->dev);
|
ipv4_input(dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#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)
|
if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION)
|
||||||
{
|
{
|
||||||
ninfo("IPv6 frame\n");
|
ninfo("IPv6 frame\n");
|
||||||
NETDEV_RXIPV6(&priv->dev);
|
NETDEV_RXIPV6(dev);
|
||||||
|
|
||||||
/* Give the IPv6 packet to the network layer. */
|
/* Give the IPv6 packet to the network layer. */
|
||||||
|
|
||||||
ipv6_input(&priv->dev);
|
ipv6_input(dev);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
NETDEV_RXDROPPED(&priv->dev);
|
NETDEV_RXDROPPED(dev);
|
||||||
priv->dev.d_len = 0;
|
dev->d_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the above function invocation resulted in data that should be
|
/* 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.
|
* 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);
|
tun_fd_transmit(priv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,6 +154,21 @@
|
|||||||
# define NETDEV_ERRORS(dev)
|
# define NETDEV_ERRORS(dev)
|
||||||
#endif
|
#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
|
* 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
|
* Ethernet, you will need to call the network ARP code before calling
|
||||||
* this function:
|
* this function:
|
||||||
*
|
*
|
||||||
* #define BUF ((FAR struct eth_hdr_s *)&dev->d_buf[0])
|
|
||||||
* dev->d_len = ethernet_devicedrver_poll();
|
* dev->d_len = ethernet_devicedrver_poll();
|
||||||
* if (dev->d_len > 0)
|
* if (dev->d_len > 0)
|
||||||
* {
|
* {
|
||||||
* if (BUF->type == HTONS(ETHTYPE_IP))
|
* if (ETHBUF->type == HTONS(ETHTYPE_IP))
|
||||||
* {
|
* {
|
||||||
* arp_ipin();
|
* arp_ipin();
|
||||||
* ipv4_input(dev);
|
* ipv4_input(dev);
|
||||||
@@ -470,7 +484,7 @@ typedef CODE int (*devif_poll_callback_t)(FAR struct net_driver_s *dev);
|
|||||||
* devicedriver_send();
|
* devicedriver_send();
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
* else if (BUF->type == HTONS(ETHTYPE_ARP))
|
* else if (ETHBUF->type == HTONS(ETHTYPE_ARP))
|
||||||
* {
|
* {
|
||||||
* arp_arpin();
|
* arp_arpin();
|
||||||
* if (dev->d_len > 0)
|
* if (dev->d_len > 0)
|
||||||
|
|||||||
@@ -79,6 +79,11 @@
|
|||||||
&(dev)->d_conncb_tail)
|
&(dev)->d_conncb_tail)
|
||||||
#define arp_callback_free(dev,cb) devif_dev_callback_free(dev, cb)
|
#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
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -55,13 +55,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ARP
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -55,13 +55,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ARP
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+2
-9
@@ -52,13 +52,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ARP_IPIN
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -87,10 +80,10 @@ void arp_ipin(FAR struct net_driver_s *dev)
|
|||||||
* packet comes from a host on the local network.
|
* 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))
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-9
@@ -55,14 +55,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ARP
|
#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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -140,7 +132,7 @@ void arp_out(FAR struct net_driver_s *dev)
|
|||||||
{
|
{
|
||||||
struct ether_addr ethaddr;
|
struct ether_addr ethaddr;
|
||||||
FAR struct eth_hdr_s *peth = ETHBUF;
|
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 ipaddr;
|
||||||
in_addr_t destipaddr;
|
in_addr_t destipaddr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ void can_poll(FAR struct net_driver_s *dev, FAR struct can_conn_s *conn)
|
|||||||
|
|
||||||
/* Setup for the application callback */
|
/* 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_len = 0;
|
||||||
dev->d_sndlen = 0;
|
dev->d_sndlen = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -31,15 +31,6 @@
|
|||||||
#include <nuttx/net/pkt.h>
|
#include <nuttx/net/pkt.h>
|
||||||
#include <nuttx/net/netdev.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
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -104,14 +104,6 @@
|
|||||||
#include "ipforward/ipforward.h"
|
#include "ipforward/ipforward.h"
|
||||||
#include "devif/devif.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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -140,7 +132,7 @@
|
|||||||
|
|
||||||
int ipv4_input(FAR struct net_driver_s *dev)
|
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;
|
in_addr_t destipaddr;
|
||||||
uint16_t llhdrlen;
|
uint16_t llhdrlen;
|
||||||
uint16_t totlen;
|
uint16_t totlen;
|
||||||
|
|||||||
@@ -56,10 +56,7 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Macros */
|
#define PAYLOAD ((FAR uint8_t *)TCPIPv6BUF)
|
||||||
|
|
||||||
#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)
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
|
|||||||
@@ -68,8 +68,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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))
|
#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) */
|
/* Copy the new ICMP reply into the I/O buffer chain (without waiting) */
|
||||||
|
|
||||||
buflen = ICMPSIZE(iphdrlen);
|
buflen = ICMPSIZE(iphdrlen);
|
||||||
ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPBUF(iphdrlen),
|
ret = iob_trycopyin(iob, IPBUF(iphdrlen), buflen, offset, true);
|
||||||
buflen, offset, true);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* On a failure, iob_copyin return a negated error value but does
|
/* 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 */
|
/* 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 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
|
* 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 */
|
/* 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_len = 0;
|
||||||
dev->d_sndlen = 0;
|
dev->d_sndlen = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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)
|
#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 */
|
/* Check if it is for us */
|
||||||
|
|
||||||
icmp = ICMPBUF;
|
icmp = IPBUF(IPv4_HDRLEN);
|
||||||
if (conn->id != icmp->id)
|
if (conn->id != icmp->id)
|
||||||
{
|
{
|
||||||
ninfo("Wrong ID: %u vs %u\n", icmp->id, conn->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 */
|
/* 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 */
|
/* Return the size of the returned data */
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,6 @@
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define IPv4BUF ((FAR struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
|
||||||
|
|
||||||
/* RFC 1812:
|
/* RFC 1812:
|
||||||
* 4.3.2.3, Original Message Header
|
* 4.3.2.3, Original Message Header
|
||||||
* ...
|
* ...
|
||||||
|
|||||||
+1
-10
@@ -55,15 +55,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMP_SOCKET
|
#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
|
* 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 */
|
/* 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);
|
memcpy(icmp, pstate->snd_buf, pstate->snd_buflen);
|
||||||
|
|
||||||
/* Calculate IP checksum. */
|
/* Calculate IP checksum. */
|
||||||
|
|||||||
@@ -41,15 +41,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -103,7 +94,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
/* Set up the ICMPv6 Neighbor Advertise response */
|
/* Set up the ICMPv6 Neighbor Advertise response */
|
||||||
|
|
||||||
adv = ICMPv6ADVERTISE;
|
adv = IPBUF(IPv6_HDRLEN);
|
||||||
adv->type = ICMPv6_NEIGHBOR_ADVERTISE; /* Message type */
|
adv->type = ICMPv6_NEIGHBOR_ADVERTISE; /* Message type */
|
||||||
adv->code = 0; /* Message qualifier */
|
adv->code = 0; /* Message qualifier */
|
||||||
adv->flags[0] = ICMPv6_NADV_FLAG_S |
|
adv->flags[0] = ICMPv6_NADV_FLAG_S |
|
||||||
|
|||||||
@@ -46,9 +46,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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 ICMPv6REPLY ((FAR struct icmpv6_echo_reply_s *)icmpv6)
|
||||||
#define ICMPv6SIZE ((dev)->d_len - iplen)
|
#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) */
|
/* Copy the new ICMPv6 reply into the I/O buffer chain (without waiting) */
|
||||||
|
|
||||||
buflen = ICMPv6SIZE;
|
buflen = ICMPv6SIZE;
|
||||||
icmpv6 = ICMPv6BUF;
|
icmpv6 = IPBUF(iplen);
|
||||||
|
|
||||||
ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPv6REPLY, buflen, offset, true);
|
ret = iob_trycopyin(iob, (FAR uint8_t *)ICMPv6REPLY, buflen, offset, true);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
@@ -219,7 +216,7 @@ drop:
|
|||||||
void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen)
|
||||||
{
|
{
|
||||||
FAR struct ipv6_hdr_s *ipv6 = IPv6BUF;
|
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
|
#ifdef CONFIG_NET_STATISTICS
|
||||||
g_netstats.icmpv6.recv++;
|
g_netstats.icmpv6.recv++;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ void icmpv6_poll(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
/* Setup for the application callback */
|
/* 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_len = 0;
|
||||||
dev->d_sndlen = 0;
|
dev->d_sndlen = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -41,15 +41,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6_ROUTER
|
#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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -163,7 +154,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Set up the ICMPv6 Router Advertise response */
|
/* Set up the ICMPv6 Router Advertise response */
|
||||||
|
|
||||||
adv = ICMPv6ADVERTISE;
|
adv = IPBUF(IPv6_HDRLEN);
|
||||||
adv->type = ICMPV6_ROUTER_ADVERTISE; /* Message type */
|
adv->type = ICMPV6_ROUTER_ADVERTISE; /* Message type */
|
||||||
adv->code = 0; /* Message qualifier */
|
adv->code = 0; /* Message qualifier */
|
||||||
adv->hoplimit = 64; /* Current hop limit */
|
adv->hoplimit = 64; /* Current hop limit */
|
||||||
|
|||||||
@@ -43,10 +43,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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 \
|
#define ICMPv6_SIZE \
|
||||||
((dev)->d_len - IPv6_HDRLEN)
|
((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?
|
* REVISIT: What if there are IPv6 extension headers present?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
icmpv6 = ICMPv6_BUF;
|
icmpv6 = IPBUF(IPv6_HDRLEN);
|
||||||
if (conn->id != icmpv6->id)
|
if (conn->id != icmpv6->id)
|
||||||
{
|
{
|
||||||
ninfo("Wrong ID: %u vs %u\n", icmpv6->id, conn->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?
|
* 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 */
|
/* 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 */
|
/* 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);
|
net_ipv6addr_hdrcopy(&pstate->recv_from, ipv6->srcipaddr);
|
||||||
|
|
||||||
/* Decrement the count of outstanding requests. I suppose this
|
/* Decrement the count of outstanding requests. I suppose this
|
||||||
|
|||||||
@@ -51,8 +51,6 @@
|
|||||||
* Pre-processor Definitions
|
* 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. */
|
/* The latest drafts declared increase in minimal mtu up to 1280. */
|
||||||
|
|
||||||
#define ICMPv6_MINMTULEN 1280
|
#define ICMPv6_MINMTULEN 1280
|
||||||
|
|||||||
@@ -39,14 +39,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -108,7 +100,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Set up the ICMPv6 Router Solicitation message */
|
/* Set up the ICMPv6 Router Solicitation message */
|
||||||
|
|
||||||
sol = ICMPv6RSOLICIT;
|
sol = IPBUF(IPv6_HDRLEN);
|
||||||
sol->type = ICMPV6_ROUTER_SOLICIT; /* Message type */
|
sol->type = ICMPV6_ROUTER_SOLICIT; /* Message type */
|
||||||
sol->code = 0; /* Message qualifier */
|
sol->code = 0; /* Message qualifier */
|
||||||
sol->flags[0] = 0; /* flags */
|
sol->flags[0] = 0; /* flags */
|
||||||
|
|||||||
@@ -54,15 +54,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6_SOCKET
|
#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
|
* 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 */
|
/* 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);
|
memcpy(icmpv6, pstate->snd_buf, pstate->snd_buflen);
|
||||||
|
|
||||||
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
|
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
|
||||||
|
|||||||
@@ -39,14 +39,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_ICMPv6
|
#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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -119,7 +111,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
/* Set up the ICMPv6 Neighbor Solicitation message */
|
/* Set up the ICMPv6 Neighbor Solicitation message */
|
||||||
|
|
||||||
sol = ICMPv6SOLICIT;
|
sol = IPBUF(IPv6_HDRLEN);
|
||||||
sol->type = ICMPv6_NEIGHBOR_SOLICIT; /* Message type */
|
sol->type = ICMPv6_NEIGHBOR_SOLICIT; /* Message type */
|
||||||
sol->code = 0; /* Message qualifier */
|
sol->code = 0; /* Message qualifier */
|
||||||
sol->flags[0] = 0; /* flags */
|
sol->flags[0] = 0; /* flags */
|
||||||
|
|||||||
@@ -60,13 +60,6 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_IGMP
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -115,7 +108,7 @@
|
|||||||
|
|
||||||
void igmp_input(struct net_driver_s *dev)
|
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_hdr_s *igmp;
|
||||||
FAR struct igmp_group_s *group;
|
FAR struct igmp_group_s *group;
|
||||||
in_addr_t destipaddr;
|
in_addr_t destipaddr;
|
||||||
@@ -132,7 +125,7 @@ void igmp_input(struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* The IGMP header immediately follows the IP header */
|
/* The IGMP header immediately follows the IP header */
|
||||||
|
|
||||||
igmp = IGMPBUF(iphdrlen);
|
igmp = IPBUF(iphdrlen);
|
||||||
|
|
||||||
/* Verify the message length */
|
/* Verify the message length */
|
||||||
|
|
||||||
|
|||||||
@@ -66,8 +66,6 @@
|
|||||||
/* Buffer layout */
|
/* Buffer layout */
|
||||||
|
|
||||||
#define RASIZE (4)
|
#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
|
* Private Functions
|
||||||
@@ -157,9 +155,9 @@ void igmp_poll(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Setup the poll operation */
|
/* 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_len = 0;
|
||||||
dev->d_sndlen = 0;
|
dev->d_sndlen = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,6 @@
|
|||||||
/* Buffer layout */
|
/* Buffer layout */
|
||||||
|
|
||||||
#define RASIZE (4)
|
#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
|
* 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,
|
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 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;
|
FAR struct igmp_hdr_s *igmp;
|
||||||
uint16_t iphdrlen;
|
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 */
|
/* The IGMP header immediately follows the IP header */
|
||||||
|
|
||||||
iphdrlen = IPv4_HDRLEN + RASIZE;
|
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
|
/* 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)
|
* 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 */
|
/* 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
|
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 */
|
/* 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
|
#endif
|
||||||
|
|||||||
@@ -54,20 +54,19 @@
|
|||||||
static int ipfwd_packet_proto(FAR struct net_driver_s *dev)
|
static int ipfwd_packet_proto(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct ipv6_hdr_s *ipv6;
|
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
|
/* Make sure the there is something in buffer that is at least as large as
|
||||||
* the IPv6_HDR.
|
* 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 ||
|
if (dev->d_lltype == NET_LL_IEEE802154 ||
|
||||||
dev->d_lltype == NET_LL_PKTRADIO)
|
dev->d_lltype == NET_LL_PKTRADIO)
|
||||||
{
|
{
|
||||||
/* There should be an IPv6 packet at the beginning of the buffer */
|
/* 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)
|
if ((ipv6->vtc & IP_VERSION_MASK) == IPv6_VERSION)
|
||||||
{
|
{
|
||||||
/* Yes.. return the L2 protocol of the packet */
|
/* 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.
|
* 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. */
|
/* 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.
|
* 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. */
|
/* Send the packet asynchrously on the forwarding device. */
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ void mld_poll(FAR struct net_driver_s *dev)
|
|||||||
|
|
||||||
/* Setup the poll operation */
|
/* 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_len = 0;
|
||||||
dev->d_sndlen = 0;
|
dev->d_sndlen = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -41,12 +41,6 @@
|
|||||||
#include "mld/mld.h"
|
#include "mld/mld.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#define IPv6BUF ((FAR struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+7
-19
@@ -59,20 +59,6 @@
|
|||||||
#define RASIZE sizeof(struct ipv6_router_alert_s)
|
#define RASIZE sizeof(struct ipv6_router_alert_s)
|
||||||
#define MLD_HDRLEN (IPv6_HDRLEN + RASIZE)
|
#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
|
* 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.
|
* The IPv6 router alert option (type 5) is defined in RFC 2711.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ra = RABUF;
|
ra = IPBUF(IPv6_HDRLEN);
|
||||||
memset(ra, 0, RASIZE);
|
memset(ra, 0, RASIZE);
|
||||||
|
|
||||||
ra->hbyh.nxthdr = IP_PROTO_ICMP6; /* ICMPv6 payload follows extension header */
|
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_GENQUERY: /* Send General Query */
|
||||||
case MLD_SEND_MASQUERY: /* Send Multicast Address Specific (MAS) 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
|
/* Initialize the Query payload. In a General Query, both the
|
||||||
* Multicast Address field and the Number of Sources (N)
|
* 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 */
|
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 */
|
/* 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 */
|
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;
|
FAR struct mld_mcast_addrec_v2_s *addrec;
|
||||||
|
|
||||||
/* Initialize the Report payload */
|
/* 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 */
|
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 */
|
/* Initialize the Done payload */
|
||||||
|
|
||||||
|
|||||||
@@ -37,13 +37,6 @@
|
|||||||
#include "icmpv6/icmpv6.h"
|
#include "icmpv6/icmpv6.h"
|
||||||
#include "neighbor/neighbor.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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ void pkt_poll(FAR struct net_driver_s *dev, FAR struct pkt_conn_s *conn)
|
|||||||
{
|
{
|
||||||
/* Setup for the application callback */
|
/* 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_len = 0;
|
||||||
dev->d_sndlen = 0;
|
dev->d_sndlen = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,6 @@
|
|||||||
|
|
||||||
/* Buffer access helpers */
|
/* 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])
|
#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;
|
FAR struct sixlowpan_reassbuf_s *reass;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_6LOWPAN_DUMPBUFFER
|
||||||
|
struct net_driver_s *dev = &radio->r_dev;
|
||||||
|
|
||||||
sixlowpan_dumpbuffer("Incoming packet",
|
sixlowpan_dumpbuffer("Incoming packet",
|
||||||
(FAR const uint8_t *)IPv6BUF(&radio->r_dev),
|
(FAR const uint8_t *)IPv6BUF,
|
||||||
radio->r_dev.d_len);
|
radio->r_dev.d_len);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NET_PKT
|
#ifdef CONFIG_NET_PKT
|
||||||
/* When packet sockets are enabled, feed the frame into the tap */
|
/* 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,
|
int sixlowpan_input(FAR struct radio_driver_s *radio,
|
||||||
FAR struct iob_s *framelist, FAR const void *metadata)
|
FAR struct iob_s *framelist, FAR const void *metadata)
|
||||||
{
|
{
|
||||||
|
struct net_driver_s *dev = &radio->r_dev;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
uint8_t *d_buf_backup;
|
uint8_t *d_buf_backup;
|
||||||
|
|
||||||
@@ -736,7 +740,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
|||||||
* returning
|
* returning
|
||||||
*/
|
*/
|
||||||
|
|
||||||
d_buf_backup = radio->r_dev.d_buf;
|
d_buf_backup = dev->d_buf;
|
||||||
|
|
||||||
/* Verify that an frame has been provided. */
|
/* Verify that an frame has been provided. */
|
||||||
|
|
||||||
@@ -781,7 +785,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
|||||||
* packet.
|
* packet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (radio->r_dev.d_len > 0)
|
if (dev->d_len > 0)
|
||||||
{
|
{
|
||||||
FAR struct ipv6_hdr_s *ipv6hdr;
|
FAR struct ipv6_hdr_s *ipv6hdr;
|
||||||
FAR uint8_t *buffer;
|
FAR uint8_t *buffer;
|
||||||
@@ -794,7 +798,7 @@ int sixlowpan_input(FAR struct radio_driver_s *radio,
|
|||||||
* layer protocol header.
|
* layer protocol header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ipv6hdr = IPv6BUF(&radio->r_dev);
|
ipv6hdr = IPv6BUF;
|
||||||
|
|
||||||
/* Get the IEEE 802.15.4 MAC address of the destination.
|
/* Get the IEEE 802.15.4 MAC address of the destination.
|
||||||
* This assumes an encoding of the MAC address in the IPv6
|
* 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
|
#ifdef CONFIG_NET_TCP
|
||||||
case IP_PROTO_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;
|
uint16_t tcplen;
|
||||||
|
|
||||||
/* The TCP header length is encoded in the top 4
|
/* 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",
|
nwarn("WARNING: Packet too small: Have %u need >%zu\n",
|
||||||
radio->r_dev.d_len, hdrlen);
|
dev->d_len, hdrlen);
|
||||||
goto drop;
|
goto drop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the outgoing packet into a frame list. */
|
/* Convert the outgoing packet into a frame list. */
|
||||||
|
|
||||||
buffer = radio->r_dev.d_buf + hdrlen;
|
buffer = dev->d_buf + hdrlen;
|
||||||
buflen = radio->r_dev.d_len - hdrlen;
|
buflen = dev->d_len - hdrlen;
|
||||||
|
|
||||||
ret = sixlowpan_queue_frames(radio, ipv6hdr, buffer,
|
ret = sixlowpan_queue_frames(radio, ipv6hdr, buffer,
|
||||||
buflen, &destmac);
|
buflen, &destmac);
|
||||||
drop:
|
drop:
|
||||||
radio->r_dev.d_len = 0;
|
dev->d_len = 0;
|
||||||
|
|
||||||
/* We consumed the frame, so we must return 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 */
|
/* 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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,11 @@
|
|||||||
|
|
||||||
#define TCP_FAST_RETRANSMISSION_THRESH 3
|
#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
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -69,13 +69,6 @@
|
|||||||
#include "arp/arp.h"
|
#include "arp/arp.h"
|
||||||
#include "icmpv6/icmpv6.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
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
+18
-29
@@ -63,12 +63,7 @@
|
|||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
|
|
||||||
/****************************************************************************
|
#define IPDATA(hl) (dev->d_buf[NET_LL_HDRLEN(dev) + (hl)])
|
||||||
* 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 Functions
|
* 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;
|
FAR struct tcp_hdr_s *tcp;
|
||||||
union ip_binding_u uaddr;
|
union ip_binding_u uaddr;
|
||||||
unsigned int tcpiplen;
|
unsigned int tcpiplen;
|
||||||
unsigned int hdrlen;
|
|
||||||
uint16_t tmp16;
|
uint16_t tmp16;
|
||||||
uint16_t flags;
|
uint16_t flags;
|
||||||
uint16_t result;
|
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.
|
* 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.
|
/* 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;
|
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. */
|
/* Start of TCP input header processing code. */
|
||||||
|
|
||||||
if (tcp_chksum(dev) != 0xffff)
|
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 ; )
|
for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ; )
|
||||||
{
|
{
|
||||||
opt = dev->d_buf[hdrlen + i];
|
opt = IPDATA(tcpiplen + i);
|
||||||
if (opt == TCP_OPT_END)
|
if (opt == TCP_OPT_END)
|
||||||
{
|
{
|
||||||
/* End of options. */
|
/* End of options. */
|
||||||
@@ -470,21 +460,21 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (opt == TCP_OPT_MSS &&
|
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);
|
uint16_t tcp_mss = TCP_MSS(dev, iplen);
|
||||||
|
|
||||||
/* An MSS option with the right option length. */
|
/* An MSS option with the right option length. */
|
||||||
|
|
||||||
tmp16 = ((uint16_t)dev->d_buf[hdrlen + 2 + i] << 8) |
|
tmp16 = ((uint16_t)IPDATA(tcpiplen + 2 + i) << 8) |
|
||||||
(uint16_t)dev->d_buf[hdrlen + 3 + i];
|
(uint16_t)IPDATA(tcpiplen + 3 + i);
|
||||||
conn->mss = tmp16 > tcp_mss ? tcp_mss : tmp16;
|
conn->mss = tmp16 > tcp_mss ? tcp_mss : tmp16;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
||||||
else if (opt == TCP_OPT_WS &&
|
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->rcv_scale = CONFIG_NET_TCP_WINDOW_SCALE_FACTOR;
|
||||||
conn->flags |= TCP_WSCALE;
|
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.
|
* 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
|
/* If the length field is zero, the options are
|
||||||
* malformed and we don't process them further.
|
* 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 ; )
|
for (i = 0; i < ((tcp->tcpoffset >> 4) - 5) << 2 ; )
|
||||||
{
|
{
|
||||||
opt = dev->d_buf[hdrlen + i];
|
opt = IPDATA(tcpiplen + i);
|
||||||
if (opt == TCP_OPT_END)
|
if (opt == TCP_OPT_END)
|
||||||
{
|
{
|
||||||
/* End of options. */
|
/* End of options. */
|
||||||
@@ -933,22 +923,21 @@ found:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (opt == TCP_OPT_MSS &&
|
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);
|
uint16_t tcp_mss = TCP_MSS(dev, iplen);
|
||||||
|
|
||||||
/* An MSS option with the right option length. */
|
/* An MSS option with the right option length. */
|
||||||
|
|
||||||
tmp16 =
|
tmp16 = (IPDATA(tcpiplen + 2 + i) << 8) |
|
||||||
(dev->d_buf[hdrlen + 2 + i] << 8) |
|
IPDATA(tcpiplen + 3 + i);
|
||||||
dev->d_buf[hdrlen + 3 + i];
|
|
||||||
conn->mss = tmp16 > tcp_mss ? tcp_mss : tmp16;
|
conn->mss = tmp16 > tcp_mss ? tcp_mss : tmp16;
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
#ifdef CONFIG_NET_TCP_WINDOW_SCALE
|
||||||
else if (opt == TCP_OPT_WS &&
|
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->rcv_scale = CONFIG_NET_TCP_WINDOW_SCALE_FACTOR;
|
||||||
conn->flags |= TCP_WSCALE;
|
conn->flags |= TCP_WSCALE;
|
||||||
}
|
}
|
||||||
@@ -959,7 +948,7 @@ found:
|
|||||||
* easily can skip past them.
|
* 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
|
/* If the length field is zero, the options are
|
||||||
* malformed and we don't process them further.
|
* 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 */
|
/* 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 */
|
#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 */
|
/* 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 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
|||||||
@@ -42,16 +42,6 @@
|
|||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
#include "socket/socket.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
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -62,16 +62,6 @@
|
|||||||
#include "tcp/tcp.h"
|
#include "tcp/tcp.h"
|
||||||
#include "utils/utils.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
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -77,9 +77,6 @@
|
|||||||
# define NEED_IPDOMAIN_SUPPORT 1
|
# define NEED_IPDOMAIN_SUPPORT 1
|
||||||
#endif
|
#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 */
|
/* Debug */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_TCP_WRBUFFER_DUMP
|
#ifdef CONFIG_NET_TCP_WRBUFFER_DUMP
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user