You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ha...@apache.org on 2022/10/28 04:32:22 UTC

[incubator-nuttx] branch master updated: net: move device buffer define to common header

This is an automated email from the ASF dual-hosted git repository.

hartmannathan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new a8d3286258 net: move device buffer define to common header
a8d3286258 is described below

commit a8d32862586b47d9d3157328a0e7462cceb00486
Author: chao an <an...@xiaomi.com>
AuthorDate: Wed Oct 26 12:35:08 2022 +0800

    net: move device buffer define to common header
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 arch/arm/src/lpc54xx/lpc54_ethernet.c | 37 +++++++++++-----------
 arch/arm/src/tiva/lm/lm3s_ethernet.c  | 59 +++++++++++++++++------------------
 arch/z80/src/ez80/ez80_emac.c         |  4 ---
 drivers/net/loopback.c                |  5 ---
 drivers/net/slip.c                    |  7 ++---
 drivers/net/tun.c                     | 31 +++++++++---------
 include/nuttx/net/netdev.h            | 20 ++++++++++--
 net/arp/arp.h                         |  5 +++
 net/arp/arp_arpin.c                   |  7 -----
 net/arp/arp_format.c                  |  7 -----
 net/arp/arp_ipin.c                    | 11 ++-----
 net/arp/arp_out.c                     | 10 +-----
 net/can/can_poll.c                    |  2 +-
 net/devif/devif_loopback.c            |  9 ------
 net/devif/ipv4_input.c                | 10 +-----
 net/devif/ipv6_input.c                |  5 +--
 net/icmp/icmp_input.c                 |  7 ++---
 net/icmp/icmp_poll.c                  |  2 +-
 net/icmp/icmp_recvmsg.c               |  6 ++--
 net/icmp/icmp_reply.c                 |  2 --
 net/icmp/icmp_sendmsg.c               | 11 +------
 net/icmpv6/icmpv6_advertise.c         | 11 +------
 net/icmpv6/icmpv6_input.c             |  7 ++---
 net/icmpv6/icmpv6_poll.c              |  2 +-
 net/icmpv6/icmpv6_radvertise.c        | 11 +------
 net/icmpv6/icmpv6_recvmsg.c           | 10 ++----
 net/icmpv6/icmpv6_reply.c             |  2 --
 net/icmpv6/icmpv6_rsolicit.c          | 10 +-----
 net/icmpv6/icmpv6_sendmsg.c           | 11 +------
 net/icmpv6/icmpv6_solicit.c           | 10 +-----
 net/igmp/igmp_input.c                 | 11 ++-----
 net/igmp/igmp_poll.c                  |  6 ++--
 net/igmp/igmp_send.c                  |  6 ++--
 net/ipforward/ipfwd_forward.c         |  4 +--
 net/ipforward/ipfwd_poll.c            |  5 ++-
 net/ipforward/ipv4_forward.c          |  2 +-
 net/ipforward/ipv6_forward.c          |  2 +-
 net/mld/mld_poll.c                    |  2 +-
 net/mld/mld_query.c                   |  6 ----
 net/mld/mld_send.c                    | 26 +++++----------
 net/neighbor/neighbor_ethernet_out.c  |  7 -----
 net/pkt/pkt_poll.c                    |  2 +-
 net/sixlowpan/sixlowpan_input.c       | 28 ++++++++++-------
 net/tcp/tcp.h                         |  5 +++
 net/tcp/tcp_conn.c                    |  7 -----
 net/tcp/tcp_input.c                   | 47 +++++++++++-----------------
 net/tcp/tcp_ipselect.c                |  4 +--
 net/tcp/tcp_recvfrom.c                | 10 ------
 net/tcp/tcp_send.c                    | 10 ------
 net/tcp/tcp_send_buffered.c           |  3 --
 net/tcp/tcp_send_unbuffered.c         |  3 --
 net/tcp/tcp_sendfile.c                |  7 -----
 net/udp/udp.h                         |  5 +++
 net/udp/udp_callback.c                | 10 ------
 net/udp/udp_conn.c                    |  7 -----
 net/udp/udp_input.c                   | 19 ++---------
 net/udp/udp_ipselect.c                |  4 +--
 net/udp/udp_recvfrom.c                | 10 ------
 net/udp/udp_send.c                    | 14 ---------
 net/udp/udp_sendto_buffered.c         |  3 --
 net/utils/net_icmpchksum.c            | 10 ++----
 net/utils/net_ipchksum.c              | 13 ++------
 62 files changed, 185 insertions(+), 444 deletions(-)

diff --git a/arch/arm/src/lpc54xx/lpc54_ethernet.c b/arch/arm/src/lpc54xx/lpc54_ethernet.c
index 15c7cf1a05..7a6aa7f7e4 100644
--- a/arch/arm/src/lpc54xx/lpc54_ethernet.c
+++ b/arch/arm/src/lpc54xx/lpc54_ethernet.c
@@ -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;
 }
 
 /****************************************************************************
diff --git a/arch/arm/src/tiva/lm/lm3s_ethernet.c b/arch/arm/src/tiva/lm/lm3s_ethernet.c
index 5b545d51ed..d590e32c4b 100644
--- a/arch/arm/src/tiva/lm/lm3s_ethernet.c
+++ b/arch/arm/src/tiva/lm/lm3s_ethernet.c
@@ -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);
         }
     }
 }
diff --git a/arch/z80/src/ez80/ez80_emac.c b/arch/z80/src/ez80/ez80_emac.c
index c76151c1b0..7a8bd4dc83 100644
--- a/arch/z80/src/ez80/ez80_emac.c
+++ b/arch/z80/src/ez80/ez80_emac.c
@@ -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
  ****************************************************************************/
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c
index ea29c9ba86..20ad8154ca 100644
--- a/drivers/net/loopback.c
+++ b/drivers/net/loopback.c
@@ -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
  ****************************************************************************/
diff --git a/drivers/net/slip.c b/drivers/net/slip.c
index 15f04e3cf2..6296be9b53 100644
--- a/drivers/net/slip.c
+++ b/drivers/net/slip.c
@@ -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. */
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 4a442110a2..df6450e542 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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);
     }
 }
diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h
index 75a0d15c06..2c044ee638 100644
--- a/include/nuttx/net/netdev.h
+++ b/include/nuttx/net/netdev.h
@@ -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)
diff --git a/net/arp/arp.h b/net/arp/arp.h
index 4e760320e3..a37f851a19 100644
--- a/net/arp/arp.h
+++ b/net/arp/arp.h
@@ -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
  ****************************************************************************/
diff --git a/net/arp/arp_arpin.c b/net/arp/arp_arpin.c
index 2f1a582d9c..02d341fba0 100644
--- a/net/arp/arp_arpin.c
+++ b/net/arp/arp_arpin.c
@@ -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
  ****************************************************************************/
diff --git a/net/arp/arp_format.c b/net/arp/arp_format.c
index a424ec41e0..458a013ead 100644
--- a/net/arp/arp_format.c
+++ b/net/arp/arp_format.c
@@ -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
  ****************************************************************************/
diff --git a/net/arp/arp_ipin.c b/net/arp/arp_ipin.c
index a375d84c69..893f80327a 100644
--- a/net/arp/arp_ipin.c
+++ b/net/arp/arp_ipin.c
@@ -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);
     }
 }
 
diff --git a/net/arp/arp_out.c b/net/arp/arp_out.c
index 37ef851a0d..a6dba47420 100644
--- a/net/arp/arp_out.c
+++ b/net/arp/arp_out.c
@@ -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;
diff --git a/net/can/can_poll.c b/net/can/can_poll.c
index 3caed22544..1c7b95019d 100644
--- a/net/can/can_poll.c
+++ b/net/can/can_poll.c
@@ -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;
 
diff --git a/net/devif/devif_loopback.c b/net/devif/devif_loopback.c
index e6d538d1ec..7c377d889d 100644
--- a/net/devif/devif_loopback.c
+++ b/net/devif/devif_loopback.c
@@ -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
  ****************************************************************************/
diff --git a/net/devif/ipv4_input.c b/net/devif/ipv4_input.c
index 6f3dd14dd9..338d18f365 100644
--- a/net/devif/ipv4_input.c
+++ b/net/devif/ipv4_input.c
@@ -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;
diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c
index a380dd201f..33ebba3d76 100644
--- a/net/devif/ipv6_input.c
+++ b/net/devif/ipv6_input.c
@@ -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
diff --git a/net/icmp/icmp_input.c b/net/icmp/icmp_input.c
index c3605d378a..e44089a158 100644
--- a/net/icmp/icmp_input.c
+++ b/net/icmp/icmp_input.c
@@ -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
diff --git a/net/icmp/icmp_poll.c b/net/icmp/icmp_poll.c
index e71690bf00..290c129cd4 100644
--- a/net/icmp/icmp_poll.c
+++ b/net/icmp/icmp_poll.c
@@ -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;
 
diff --git a/net/icmp/icmp_recvmsg.c b/net/icmp/icmp_recvmsg.c
index 3312ee2c93..38c56d4ca6 100644
--- a/net/icmp/icmp_recvmsg.c
+++ b/net/icmp/icmp_recvmsg.c
@@ -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 */
 
diff --git a/net/icmp/icmp_reply.c b/net/icmp/icmp_reply.c
index 9ab08491d6..e87073af90 100644
--- a/net/icmp/icmp_reply.c
+++ b/net/icmp/icmp_reply.c
@@ -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
  * ...
diff --git a/net/icmp/icmp_sendmsg.c b/net/icmp/icmp_sendmsg.c
index 894538b64c..f04a35d4c8 100644
--- a/net/icmp/icmp_sendmsg.c
+++ b/net/icmp/icmp_sendmsg.c
@@ -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. */
diff --git a/net/icmpv6/icmpv6_advertise.c b/net/icmpv6/icmpv6_advertise.c
index 124779ea58..5485246eed 100644
--- a/net/icmpv6/icmpv6_advertise.c
+++ b/net/icmpv6/icmpv6_advertise.c
@@ -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 |
diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c
index 71a5555ca9..24d799ad3a 100644
--- a/net/icmpv6/icmpv6_input.c
+++ b/net/icmpv6/icmpv6_input.c
@@ -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++;
diff --git a/net/icmpv6/icmpv6_poll.c b/net/icmpv6/icmpv6_poll.c
index 1d2c5aa54f..7da0cd005e 100644
--- a/net/icmpv6/icmpv6_poll.c
+++ b/net/icmpv6/icmpv6_poll.c
@@ -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;
 
diff --git a/net/icmpv6/icmpv6_radvertise.c b/net/icmpv6/icmpv6_radvertise.c
index b63b37ae3a..37ff4ac236 100644
--- a/net/icmpv6/icmpv6_radvertise.c
+++ b/net/icmpv6/icmpv6_radvertise.c
@@ -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 */
diff --git a/net/icmpv6/icmpv6_recvmsg.c b/net/icmpv6/icmpv6_recvmsg.c
index 8f101c8369..9933f0c02a 100644
--- a/net/icmpv6/icmpv6_recvmsg.c
+++ b/net/icmpv6/icmpv6_recvmsg.c
@@ -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
diff --git a/net/icmpv6/icmpv6_reply.c b/net/icmpv6/icmpv6_reply.c
index 1bc730d693..c309a8100a 100644
--- a/net/icmpv6/icmpv6_reply.c
+++ b/net/icmpv6/icmpv6_reply.c
@@ -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
diff --git a/net/icmpv6/icmpv6_rsolicit.c b/net/icmpv6/icmpv6_rsolicit.c
index 958f8bbb4d..2f9953478e 100644
--- a/net/icmpv6/icmpv6_rsolicit.c
+++ b/net/icmpv6/icmpv6_rsolicit.c
@@ -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 */
diff --git a/net/icmpv6/icmpv6_sendmsg.c b/net/icmpv6/icmpv6_sendmsg.c
index 8df4997700..98c9d2eea0 100644
--- a/net/icmpv6/icmpv6_sendmsg.c
+++ b/net/icmpv6/icmpv6_sendmsg.c
@@ -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. */
diff --git a/net/icmpv6/icmpv6_solicit.c b/net/icmpv6/icmpv6_solicit.c
index ae7bbe66e3..ca039742b0 100644
--- a/net/icmpv6/icmpv6_solicit.c
+++ b/net/icmpv6/icmpv6_solicit.c
@@ -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 */
diff --git a/net/igmp/igmp_input.c b/net/igmp/igmp_input.c
index 5a4e54aa07..d79ec2b126 100644
--- a/net/igmp/igmp_input.c
+++ b/net/igmp/igmp_input.c
@@ -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 */
 
diff --git a/net/igmp/igmp_poll.c b/net/igmp/igmp_poll.c
index a2824ca4ef..47ef3d34d6 100644
--- a/net/igmp/igmp_poll.c
+++ b/net/igmp/igmp_poll.c
@@ -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;
 
diff --git a/net/igmp/igmp_send.c b/net/igmp/igmp_send.c
index 4b52d3ac02..fa001212a7 100644
--- a/net/igmp/igmp_send.c
+++ b/net/igmp/igmp_send.c
@@ -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)
diff --git a/net/ipforward/ipfwd_forward.c b/net/ipforward/ipfwd_forward.c
index 6a7f2bb2fa..00d7034030 100644
--- a/net/ipforward/ipfwd_forward.c
+++ b/net/ipforward/ipfwd_forward.c
@@ -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
diff --git a/net/ipforward/ipfwd_poll.c b/net/ipforward/ipfwd_poll.c
index dadbcf686f..e47bb929b0 100644
--- a/net/ipforward/ipfwd_poll.c
+++ b/net/ipforward/ipfwd_poll.c
@@ -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 */
diff --git a/net/ipforward/ipv4_forward.c b/net/ipforward/ipv4_forward.c
index cca0a0cbc5..c0c549dc83 100644
--- a/net/ipforward/ipv4_forward.c
+++ b/net/ipforward/ipv4_forward.c
@@ -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. */
 
diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c
index fb5c81b529..00dc3034fb 100644
--- a/net/ipforward/ipv6_forward.c
+++ b/net/ipforward/ipv6_forward.c
@@ -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. */
 
diff --git a/net/mld/mld_poll.c b/net/mld/mld_poll.c
index ccf22ef7ea..d0cd926419 100644
--- a/net/mld/mld_poll.c
+++ b/net/mld/mld_poll.c
@@ -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;
 
diff --git a/net/mld/mld_query.c b/net/mld/mld_query.c
index 2e6e20543f..706e7c8795 100644
--- a/net/mld/mld_query.c
+++ b/net/mld/mld_query.c
@@ -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
  ****************************************************************************/
diff --git a/net/mld/mld_send.c b/net/mld/mld_send.c
index 1504e9b88d..d19c1b44a3 100644
--- a/net/mld/mld_send.c
+++ b/net/mld/mld_send.c
@@ -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 */
 
diff --git a/net/neighbor/neighbor_ethernet_out.c b/net/neighbor/neighbor_ethernet_out.c
index 09d97b2198..496c892778 100644
--- a/net/neighbor/neighbor_ethernet_out.c
+++ b/net/neighbor/neighbor_ethernet_out.c
@@ -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
  ****************************************************************************/
diff --git a/net/pkt/pkt_poll.c b/net/pkt/pkt_poll.c
index 4daadd4b5c..7d6978fe84 100644
--- a/net/pkt/pkt_poll.c
+++ b/net/pkt/pkt_poll.c
@@ -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;
 
diff --git a/net/sixlowpan/sixlowpan_input.c b/net/sixlowpan/sixlowpan_input.c
index eaa83c0227..0e7bb2ac4b 100644
--- a/net/sixlowpan/sixlowpan_input.c
+++ b/net/sixlowpan/sixlowpan_input.c
@@ -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;
 }
diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index e3bf0bba66..bc3c2cab49 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -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
  ****************************************************************************/
diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c
index 3c94847029..28c23998b9 100644
--- a/net/tcp/tcp_conn.c
+++ b/net/tcp/tcp_conn.c
@@ -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
  ****************************************************************************/
diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c
index ec014cbca3..bff1aa6397 100644
--- a/net/tcp/tcp_input.c
+++ b/net/tcp/tcp_input.c
@@ -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);
                   }
               }
 
diff --git a/net/tcp/tcp_ipselect.c b/net/tcp/tcp_ipselect.c
index 26ecf2b5cf..370abadb74 100644
--- a/net/tcp/tcp_ipselect.c
+++ b/net/tcp/tcp_ipselect.c
@@ -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 */
 
diff --git a/net/tcp/tcp_recvfrom.c b/net/tcp/tcp_recvfrom.c
index 9c8cf40184..5c5bed6299 100644
--- a/net/tcp/tcp_recvfrom.c
+++ b/net/tcp/tcp_recvfrom.c
@@ -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
  ****************************************************************************/
diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c
index 7fa69f963f..a067f7ca53 100644
--- a/net/tcp/tcp_send.c
+++ b/net/tcp/tcp_send.c
@@ -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
  ****************************************************************************/
diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index 0789fd7b18..9035243d57 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -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
diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c
index 99e01f7a0a..631ccadce0 100644
--- a/net/tcp/tcp_send_unbuffered.c
+++ b/net/tcp/tcp_send_unbuffered.c
@@ -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
  ****************************************************************************/
diff --git a/net/tcp/tcp_sendfile.c b/net/tcp/tcp_sendfile.c
index d158cdfed8..1154a2db97 100644
--- a/net/tcp/tcp_sendfile.c
+++ b/net/tcp/tcp_sendfile.c
@@ -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
  ****************************************************************************/
diff --git a/net/udp/udp.h b/net/udp/udp.h
index a0abd66ab7..4d7444a1fe 100644
--- a/net/udp/udp.h
+++ b/net/udp/udp.h
@@ -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
  ****************************************************************************/
diff --git a/net/udp/udp_callback.c b/net/udp/udp_callback.c
index 2d5aec9774..a83b96772b 100644
--- a/net/udp/udp_callback.c
+++ b/net/udp/udp_callback.c
@@ -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
  ****************************************************************************/
diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c
index 787d209506..24f4085aaf 100644
--- a/net/udp/udp_conn.c
+++ b/net/udp/udp_conn.c
@@ -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
  ****************************************************************************/
diff --git a/net/udp/udp_input.c b/net/udp/udp_input.c
index 095a3144eb..aff8e6e79c 100644
--- a/net/udp/udp_input.c
+++ b/net/udp/udp_input.c
@@ -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 */
diff --git a/net/udp/udp_ipselect.c b/net/udp/udp_ipselect.c
index a590e72478..8d0db11fe1 100644
--- a/net/udp/udp_ipselect.c
+++ b/net/udp/udp_ipselect.c
@@ -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 */
 
diff --git a/net/udp/udp_recvfrom.c b/net/udp/udp_recvfrom.c
index e230bdf8ba..dbd639cad8 100644
--- a/net/udp/udp_recvfrom.c
+++ b/net/udp/udp_recvfrom.c
@@ -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
  ****************************************************************************/
diff --git a/net/udp/udp_send.c b/net/udp/udp_send.c
index ce6ac3edee..385e87bea6 100644
--- a/net/udp/udp_send.c
+++ b/net/udp/udp_send.c
@@ -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
  ****************************************************************************/
diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c
index 481c99c0b0..0ef2713252 100644
--- a/net/udp/udp_sendto_buffered.c
+++ b/net/udp/udp_sendto_buffered.c
@@ -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
diff --git a/net/utils/net_icmpchksum.c b/net/utils/net_icmpchksum.c
index 6816b94293..8a8d42c781 100644
--- a/net/utils/net_icmpchksum.c
+++ b/net/utils/net_icmpchksum.c
@@ -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 */
diff --git a/net/utils/net_ipchksum.c b/net/utils/net_ipchksum.c
index c9242cc88e..af77fbeeb6 100644
--- a/net/utils/net_ipchksum.c
+++ b/net/utils/net_ipchksum.c
@@ -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 */