summaryrefslogtreecommitdiff
path: root/nuttx/net
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-06-27 17:51:32 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-06-27 17:51:32 -0600
commitecdeb1753ab553b2081217fbac9dfd04d0620469 (patch)
tree07971b493bebcfb847c2de1f4cbecd78b43191b7 /nuttx/net
parent2829ffe832cb656645f8eb3378ace9d402dce2ff (diff)
downloadpx4-nuttx-ecdeb1753ab553b2081217fbac9dfd04d0620469.tar.gz
px4-nuttx-ecdeb1753ab553b2081217fbac9dfd04d0620469.tar.bz2
px4-nuttx-ecdeb1753ab553b2081217fbac9dfd04d0620469.zip
Clean-up naming associated with network checksums
Diffstat (limited to 'nuttx/net')
-rw-r--r--nuttx/net/README.txt31
-rw-r--r--nuttx/net/icmp/icmp_input.c1
-rw-r--r--nuttx/net/icmp/icmp_send.c3
-rw-r--r--nuttx/net/igmp/igmp_input.c2
-rw-r--r--nuttx/net/igmp/igmp_send.c2
-rw-r--r--nuttx/net/tcp/tcp_input.c21
-rw-r--r--nuttx/net/tcp/tcp_send.c3
-rw-r--r--nuttx/net/udp/udp_input.c1
-rw-r--r--nuttx/net/udp/udp_send.c3
-rw-r--r--nuttx/net/uip/uip_input.c16
-rw-r--r--nuttx/net/utils/Kconfig21
-rw-r--r--nuttx/net/utils/net_chksum.c165
-rw-r--r--nuttx/net/utils/utils.h43
13 files changed, 247 insertions, 65 deletions
diff --git a/nuttx/net/README.txt b/nuttx/net/README.txt
index f072c0786..db1f6aa98 100644
--- a/nuttx/net/README.txt
+++ b/nuttx/net/README.txt
@@ -12,6 +12,7 @@ Directory Structure
+- devif - Stack/device interface layer
+- icmp - Internet Control Message Protocol
+- iob - I/O buffering logic
+ +- ipv6 - Logic unique to IPv6
+- netdev - Socket network device interface
+- pkt - "Raw" packet socket support
+- socket - BSD socket interface
@@ -21,18 +22,18 @@ Directory Structure
`- utils - Miscellaneous utility functions
- +-------------------------------------------------------------+
- | Application layer |
- +-------------------------------------------------------------+
- +-------------------------------------------------------------+
- | Socket layer (socket/) |
- +-------------------------------------------------------------+
- +------------++-----------------------------------------------+
- | Network || Protocol stacks (arp, icmp, pkt, tcp, udp) |
- | Device |+-----------------------------------------------+
- | Interface |+---------------------------------++------------+
- | (netdev/) ||Network Device Interface (devif/)|| Utilities |
- +------------++---------------------------------++------------+
- +-------------------------------------------------------------+
- | Network Device Drivers |
- +-------------------------------------------------------------+
+ +----------------------------------------------------------------+
+ | Application layer |
+ +----------------------------------------------------------------+
+ +----------------------------------------------------------------+
+ | Socket layer (socket/) |
+ +----------------------------------------------------------------+
+ +------------++--------------------------------------------------+
+ | Network || Protocol stacks (arp, ipv6, icmp, pkt, tcp, udp) |
+ | Device |+--------------------------------------------------+
+ | Interface |+------------------------------------++------------+
+ | (netdev/) || Network Device Interface (devif/) || Utilities |
+ +------------++------------------------------------++------------+
+ +----------------------------------------------------------------+
+ | Network Device Drivers |
+ +----------------------------------------------------------------+
diff --git a/nuttx/net/icmp/icmp_input.c b/nuttx/net/icmp/icmp_input.c
index 2958b323f..e891ccdfd 100644
--- a/nuttx/net/icmp/icmp_input.c
+++ b/nuttx/net/icmp/icmp_input.c
@@ -56,6 +56,7 @@
#include "uip/uip.h"
#include "icmp/icmp.h"
+#include "utils/utils.h"
#ifdef CONFIG_NET_ICMP
diff --git a/nuttx/net/icmp/icmp_send.c b/nuttx/net/icmp/icmp_send.c
index 7ee1fb1fa..5f1911ad6 100644
--- a/nuttx/net/icmp/icmp_send.c
+++ b/nuttx/net/icmp/icmp_send.c
@@ -48,6 +48,7 @@
#include <nuttx/net/netstats.h>
#include "uip/uip.h"
+#include "utils/utils.h"
#include "icmp/icmp.h"
/****************************************************************************
@@ -144,7 +145,7 @@ void icmp_send(FAR struct net_driver_s *dev, FAR uip_ipaddr_t *destaddr)
/* Calculate IP checksum. */
picmp->ipchksum = 0;
- picmp->ipchksum = ~(uip_ipchksum(dev));
+ picmp->ipchksum = ~(ip_chksum(dev));
#endif /* CONFIG_NET_IPv6 */
diff --git a/nuttx/net/igmp/igmp_input.c b/nuttx/net/igmp/igmp_input.c
index 76061bb82..856e99ada 100644
--- a/nuttx/net/igmp/igmp_input.c
+++ b/nuttx/net/igmp/igmp_input.c
@@ -133,7 +133,7 @@ void igmp_input(struct net_driver_s *dev)
/* Calculate and check the IGMP checksum */
- if (uip_chksum((uint16_t*)&IGMPBUF->type, UIP_IGMPH_LEN) != 0)
+ if (net_chksum((uint16_t*)&IGMPBUF->type, UIP_IGMPH_LEN) != 0)
{
IGMP_STATINCR(g_netstats.igmp.chksum_errors);
nlldbg("Checksum error\n");
diff --git a/nuttx/net/igmp/igmp_send.c b/nuttx/net/igmp/igmp_send.c
index a73c16a86..8ff5ac698 100644
--- a/nuttx/net/igmp/igmp_send.c
+++ b/nuttx/net/igmp/igmp_send.c
@@ -91,7 +91,7 @@
static uint16_t igmp_chksum(FAR uint8_t *buffer, int buflen)
{
- uint16_t sum = uip_chksum((FAR uint16_t*)buffer, buflen);
+ uint16_t sum = net_chksum((FAR uint16_t*)buffer, buflen);
return sum ? sum : 0xffff;
}
diff --git a/nuttx/net/tcp/tcp_input.c b/nuttx/net/tcp/tcp_input.c
index 909996a23..d85d1f431 100644
--- a/nuttx/net/tcp/tcp_input.c
+++ b/nuttx/net/tcp/tcp_input.c
@@ -57,6 +57,7 @@
#include <nuttx/net/netstats.h>
#include "uip/uip.h"
+#include "utils/utils.h"
#include "tcp/tcp.h"
/****************************************************************************
@@ -210,7 +211,7 @@ void tcp_input(struct net_driver_s *dev)
goto drop;
}
- uip_incr32(conn->rcvseq, 1);
+ net_incr32(conn->rcvseq, 1);
/* Parse the TCP MSS option, if present. */
@@ -474,7 +475,7 @@ found:
if (dev->d_len > 0)
{
flags |= UIP_NEWDATA;
- uip_incr32(conn->rcvseq, dev->d_len);
+ net_incr32(conn->rcvseq, dev->d_len);
}
dev->d_sndlen = 0;
@@ -557,7 +558,7 @@ found:
conn->tcpstateflags = UIP_ESTABLISHED;
memcpy(conn->rcvseq, pbuf->seqno, 4);
- uip_incr32(conn->rcvseq, 1);
+ net_incr32(conn->rcvseq, 1);
conn->unacked = 0;
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
@@ -623,7 +624,7 @@ found:
* been closed.
*/
- uip_incr32(conn->rcvseq, dev->d_len + 1);
+ net_incr32(conn->rcvseq, dev->d_len + 1);
flags |= UIP_CLOSE;
if (dev->d_len > 0)
@@ -657,7 +658,7 @@ found:
dev->d_urglen = dev->d_len;
}
- uip_incr32(conn->rcvseq, dev->d_urglen);
+ net_incr32(conn->rcvseq, dev->d_urglen);
dev->d_len -= dev->d_urglen;
dev->d_urgdata = dev->d_appdata;
dev->d_appdata += dev->d_urglen;
@@ -724,7 +725,7 @@ found:
{
/* Update the sequence number using the saved length */
- uip_incr32(conn->rcvseq, len);
+ net_incr32(conn->rcvseq, len);
}
/* Send the response, ACKing the data or not, as appropriate */
@@ -757,7 +758,7 @@ found:
if (dev->d_len > 0)
{
- uip_incr32(conn->rcvseq, dev->d_len);
+ net_incr32(conn->rcvseq, dev->d_len);
}
if ((pbuf->flags & TCP_FIN) != 0)
@@ -775,7 +776,7 @@ found:
nllvdbg("TCP state: UIP_CLOSING\n");
}
- uip_incr32(conn->rcvseq, 1);
+ net_incr32(conn->rcvseq, 1);
(void)tcp_callback(dev, conn, UIP_CLOSE);
tcp_send(dev, conn, TCP_ACK, UIP_IPTCPH_LEN);
return;
@@ -799,7 +800,7 @@ found:
case UIP_FIN_WAIT_2:
if (dev->d_len > 0)
{
- uip_incr32(conn->rcvseq, dev->d_len);
+ net_incr32(conn->rcvseq, dev->d_len);
}
if ((pbuf->flags & TCP_FIN) != 0)
@@ -808,7 +809,7 @@ found:
conn->timer = 0;
nllvdbg("TCP state: UIP_TIME_WAIT\n");
- uip_incr32(conn->rcvseq, 1);
+ net_incr32(conn->rcvseq, 1);
(void)tcp_callback(dev, conn, UIP_CLOSE);
tcp_send(dev, conn, TCP_ACK, UIP_IPTCPH_LEN);
return;
diff --git a/nuttx/net/tcp/tcp_send.c b/nuttx/net/tcp/tcp_send.c
index f404e9d59..ddc6a3e46 100644
--- a/nuttx/net/tcp/tcp_send.c
+++ b/nuttx/net/tcp/tcp_send.c
@@ -54,6 +54,7 @@
#include <nuttx/net/netstats.h>
#include "uip/uip.h"
+#include "utils/utils.h"
/****************************************************************************
* Pre-processor Definitions
@@ -139,7 +140,7 @@ static void tcp_sendcomplete(FAR struct net_driver_s *dev)
/* Calculate IP checksum. */
pbuf->ipchksum = 0;
- pbuf->ipchksum = ~(uip_ipchksum(dev));
+ pbuf->ipchksum = ~(ip_chksum(dev));
#endif /* CONFIG_NET_IPv6 */
diff --git a/nuttx/net/udp/udp_input.c b/nuttx/net/udp/udp_input.c
index 43408f4cf..d2b8b1307 100644
--- a/nuttx/net/udp/udp_input.c
+++ b/nuttx/net/udp/udp_input.c
@@ -54,6 +54,7 @@
#include <nuttx/net/netstats.h>
#include "uip/uip.h"
+#include "utils/utils.h"
#include "udp/udp.h"
/****************************************************************************
diff --git a/nuttx/net/udp/udp_send.c b/nuttx/net/udp/udp_send.c
index db9b74dd6..431f06e16 100644
--- a/nuttx/net/udp/udp_send.c
+++ b/nuttx/net/udp/udp_send.c
@@ -53,6 +53,7 @@
#include <nuttx/net/netstats.h>
#include "uip/uip.h"
+#include "utils/utils.h"
#include "udp/udp.h"
/****************************************************************************
@@ -144,7 +145,7 @@ void udp_send(struct net_driver_s *dev, struct udp_conn_s *conn)
/* Calculate IP checksum. */
pudpbuf->ipchksum = 0;
- pudpbuf->ipchksum = ~(uip_ipchksum(dev));
+ pudpbuf->ipchksum = ~(ip_chksum(dev));
#endif /* CONFIG_NET_IPv6 */
diff --git a/nuttx/net/uip/uip_input.c b/nuttx/net/uip/uip_input.c
index eaddac9bf..190b3647c 100644
--- a/nuttx/net/uip/uip_input.c
+++ b/nuttx/net/uip/uip_input.c
@@ -107,8 +107,8 @@
/* Macros. */
-#define BUF ((struct uip_ip_hdr *)&dev->d_buf[UIP_LLH_LEN])
-#define FBUF ((struct uip_ip_hdr *)&uip_reassbuf[0])
+#define BUF ((FAR struct net_iphdr_s *)&dev->d_buf[UIP_LLH_LEN])
+#define FBUF ((FAR struct net_iphdr_s *)&uip_reassbuf[0])
/* IP fragment re-assembly */
@@ -149,8 +149,8 @@ static uint8_t uip_reassflags;
#if UIP_REASSEMBLY && !defined(CONFIG_NET_IPv6)
static uint8_t uip_reass(void)
{
- struct uip_ip_hdr *pbuf = BUF;
- struct uip_ip_hdr *pfbuf = FBUF;
+ FAR struct net_iphdr_s *pbuf = BUF;
+ FAR struct net_iphdr_s *pfbuf = FBUF;
uint16_t offset;
uint16_t len;
uint16_t i;
@@ -277,7 +277,7 @@ static uint8_t uip_reass(void)
pbuf->len[0] = uip_reasslen >> 8;
pbuf->len[1] = uip_reasslen & 0xff;
pbuf->ipchksum = 0;
- pbuf->ipchksum = ~(uip_ipchksum(dev));
+ pbuf->ipchksum = ~(ip_chksum(dev));
return uip_reasslen;
}
@@ -307,9 +307,9 @@ nullreturn:
*
****************************************************************************/
-int uip_input(struct net_driver_s *dev)
+int uip_input(FAR struct net_driver_s *dev)
{
- struct uip_ip_hdr *pbuf = BUF;
+ FAR struct net_iphdr_s *pbuf = BUF;
uint16_t iplen;
/* This is where the input processing starts. */
@@ -491,7 +491,7 @@ int uip_input(struct net_driver_s *dev)
}
#ifndef CONFIG_NET_IPv6
- if (uip_ipchksum(dev) != 0xffff)
+ if (ip_chksum(dev) != 0xffff)
{
/* Compute and check the IP header checksum. */
diff --git a/nuttx/net/utils/Kconfig b/nuttx/net/utils/Kconfig
index ae2bf3130..412ece03e 100644
--- a/nuttx/net/utils/Kconfig
+++ b/nuttx/net/utils/Kconfig
@@ -2,3 +2,24 @@
# For a description of the syntax of this configuration file,
# see misc/tools/kconfig-language.txt.
#
+
+config NET_ARCH_INCR32
+ bool "Architecture-specific net_incr32()"
+ default n
+ ---help---
+ Define if you architecture provided an optimized version of
+ net_incr32() with prototype:
+
+ void net_incr32(FAR uint8_t *op32, uint16_t op16)
+
+config NET_ARCH_CHKSUM
+ bool "Architecture-specific net_chksum()"
+ default n
+ ---help---
+ Define if you architecture provided an optimized version of
+ functions with the following prototypes:
+
+ uint16_t net_chksum(FAR uint16_t *data, uint16_t len)
+ uint16_t ip_chksum(FAR struct net_driver_s *dev)
+ uint16_t tcp_chksum(FAR struct net_driver_s *dev);
+ uint16_t udp_chksum(FAR struct net_driver_s *dev);
diff --git a/nuttx/net/utils/net_chksum.c b/nuttx/net/utils/net_chksum.c
index c6e93873f..ff8438678 100644
--- a/nuttx/net/utils/net_chksum.c
+++ b/nuttx/net/utils/net_chksum.c
@@ -54,7 +54,7 @@
* Pre-processor Definitions
****************************************************************************/
-#define BUF ((struct uip_ip_hdr *)&dev->d_buf[UIP_LLH_LEN])
+#define BUF ((struct net_iphdr_s *)&dev->d_buf[UIP_LLH_LEN])
#define ICMPBUF ((struct icmp_iphdr_s *)&dev->d_buf[UIP_LLH_LEN])
/****************************************************************************
@@ -65,7 +65,11 @@
* Private Functions
****************************************************************************/
-#if !UIP_ARCH_CHKSUM
+/****************************************************************************
+ * Name: chksum
+ ****************************************************************************/
+
+#if !CONFIG_NET_ARCH_CHKSUM
static uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len)
{
uint16_t t;
@@ -103,10 +107,16 @@ static uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len)
return sum;
}
+#endif /* CONFIG_NET_ARCH_CHKSUM */
+
+/****************************************************************************
+ * Name: upper_layer_chksum
+ ****************************************************************************/
+#if !CONFIG_NET_ARCH_CHKSUM
static uint16_t upper_layer_chksum(FAR struct net_driver_s *dev, uint8_t proto)
{
- struct uip_ip_hdr *pbuf = BUF;
+ FAR struct net_iphdr_s *pbuf = BUF;
uint16_t upper_layer_len;
uint16_t sum;
@@ -132,20 +142,31 @@ static uint16_t upper_layer_chksum(FAR struct net_driver_s *dev, uint8_t proto)
return (sum == 0) ? 0xffff : htons(sum);
}
+#endif /* CONFIG_NET_ARCH_CHKSUM */
+/****************************************************************************
+ * Name: icmp_6chksum
+ ****************************************************************************/
+
+#if !CONFIG_NET_ARCH_CHKSUM
#ifdef CONFIG_NET_IPv6
static uint16_t icmp_6chksum(FAR struct net_driver_s *dev)
{
return upper_layer_chksum(dev, UIP_PROTO_ICMP6);
}
#endif /* CONFIG_NET_IPv6 */
+#endif /* CONFIG_NET_ARCH_CHKSUM */
-#endif /* UIP_ARCH_CHKSUM */
-
-/* Calculate the Internet checksum over a buffer. */
+/****************************************************************************
+ * Name: net_carry32
+ *
+ * Description:
+ * Calculate the Internet checksum over a buffer.
+ *
+ ****************************************************************************/
-#if !UIP_ARCH_ADD32
-static inline void uip_carry32(FAR uint8_t *sum, uint16_t op16)
+#if !CONFIG_NET_ARCH_INCR32
+static inline void net_carry32(FAR uint8_t *sum, uint16_t op16)
{
if (sum[2] < (op16 >> 8))
{
@@ -169,64 +190,154 @@ static inline void uip_carry32(FAR uint8_t *sum, uint16_t op16)
}
}
}
-#endif /* UIP_ARCH_ADD32 */
+#endif /* CONFIG_NET_ARCH_INCR32 */
/****************************************************************************
* Public Functions
****************************************************************************/
-#if !UIP_ARCH_ADD32
-void uip_incr32(FAR uint8_t *op32, uint16_t op16)
+/****************************************************************************
+ * Name: net_incr32
+ *
+ * Description:
+ *
+ * Carry out a 32-bit addition.
+ *
+ * By defining CONFIG_NET_ARCH_INCR32, the architecture can replace
+ * net_incr32 with hardware assisted solutions.
+ *
+ * Input Parameters:
+ * op32 - A pointer to a 4-byte array representing a 32-bit integer in
+ * network byte order (big endian). This value may not be word
+ * aligned. The value pointed to by op32 is modified in place
+ *
+ * op16 - A 16-bit integer in host byte order.
+ *
+ ****************************************************************************/
+
+#if !CONFIG_NET_ARCH_INCR32
+void net_incr32(FAR uint8_t *op32, uint16_t op16)
{
op32[3] += (op16 & 0xff);
op32[2] += (op16 >> 8);
- uip_carry32(op32, op16);
+ net_carry32(op32, op16);
}
-#endif /* UIP_ARCH_ADD32 */
+#endif /* CONFIG_NET_ARCH_INCR32 */
-#if !UIP_ARCH_CHKSUM
-uint16_t uip_chksum(FAR uint16_t *data, uint16_t len)
+/****************************************************************************
+ * Name: net_chksum
+ *
+ * Description:
+ * Calculate the Internet checksum over a buffer.
+ *
+ * The Internet checksum is the one's complement of the one's complement
+ * sum of all 16-bit words in the buffer.
+ *
+ * See RFC1071.
+ *
+ * If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
+ * provided by architecture-specific logic.
+ *
+ * Input Parameters:
+ *
+ * buf - A pointer to the buffer over which the checksum is to be computed.
+ *
+ * len - The length of the buffer over which the checksum is to be computed.
+ *
+ * Returned Value:
+ * The Internet checksum of the buffer.
+ *
+ ****************************************************************************/
+
+#if !CONFIG_NET_ARCH_CHKSUM
+uint16_t net_chksum(FAR uint16_t *data, uint16_t len)
{
return htons(chksum(0, (uint8_t *)data, len));
}
+#endif /* CONFIG_NET_ARCH_CHKSUM */
-/* Calculate the IP header checksum of the packet header in d_buf. */
+/****************************************************************************
+ * Name: ip_chksum
+ *
+ * Description:
+ * Calculate the IP header checksum of the packet header in d_buf.
+ *
+ * The IP header checksum is the Internet checksum of the 20 bytes of
+ * the IP header.
+ *
+ * If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
+ * provided by architecture-specific logic.
+ *
+ * Returned Value:
+ * The IP header checksum of the IP header in the d_buf buffer.
+ *
+ ****************************************************************************/
-#ifndef UIP_ARCH_IPCHKSUM
-uint16_t uip_ipchksum(FAR struct net_driver_s *dev)
+#if !CONFIG_NET_ARCH_CHKSUM
+uint16_t ip_chksum(FAR struct net_driver_s *dev)
{
uint16_t sum;
sum = chksum(0, &dev->d_buf[UIP_LLH_LEN], UIP_IPH_LEN);
return (sum == 0) ? 0xffff : htons(sum);
}
-#endif
+#endif /* CONFIG_NET_ARCH_CHKSUM */
-/* Calculate the TCP checksum of the packet in d_buf and d_appdata. */
+/****************************************************************************
+ * Name: tcp_chksum
+ *
+ * Description:
+ * Calculate the TCP checksum of the packet in d_buf and d_appdata.
+ *
+ * The TCP checksum is the Internet checksum of data contents of the
+ * TCP segment, and a pseudo-header as defined in RFC793.
+ *
+ * Note: The d_appdata pointer that points to the packet data may
+ * point anywhere in memory, so it is not possible to simply calculate
+ * the Internet checksum of the contents of the d_buf buffer.
+ *
+ * Returned Value:
+ * The TCP checksum of the TCP segment in d_buf and pointed to by
+ * d_appdata.
+ *
+ ****************************************************************************/
+#if !CONFIG_NET_ARCH_CHKSUM
uint16_t tcp_chksum(FAR struct net_driver_s *dev)
{
return upper_layer_chksum(dev, UIP_PROTO_TCP);
}
+#endif /* CONFIG_NET_ARCH_CHKSUM */
-/* Calculate the UDP checksum of the packet in d_buf and d_appdata. */
+/****************************************************************************
+ * Name: udp_chksum
+ *
+ * Description:
+ * Calculate the UDP checksum of the packet in d_buf and d_appdata.
+ *
+ ****************************************************************************/
-#ifdef CONFIG_NET_UDP_CHECKSUMS
+#if defined(CONFIG_NET_UDP_CHECKSUMS) && !defined(CONFIG_NET_ARCH_CHKSUM)
uint16_t udp_chksum(FAR struct net_driver_s *dev)
{
return upper_layer_chksum(dev, UIP_PROTO_UDP);
}
-#endif
+#endif /* CONFIG_NET_UDP_CHECKSUMS && !CONFIG_NET_ARCH_CHKSUM */
-/* Calculate the checksum of the ICMP message */
+/****************************************************************************
+ * Name: icmp_chksum
+ *
+ * Description:
+ * Calculate the checksum of the ICMP message
+ *
+ ****************************************************************************/
#if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING)
uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len)
{
FAR struct icmp_iphdr_s *picmp = ICMPBUF;
- return uip_chksum((uint16_t*)&picmp->type, len);
+ return net_chksum((uint16_t*)&picmp->type, len);
}
-#endif
+#endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */
-#endif /* UIP_ARCH_CHKSUM */
#endif /* CONFIG_NET */
diff --git a/nuttx/net/utils/utils.h b/nuttx/net/utils/utils.h
index 10c386edf..1ccd0aedc 100644
--- a/nuttx/net/utils/utils.h
+++ b/nuttx/net/utils/utils.h
@@ -87,6 +87,49 @@ extern "C"
struct timeval;
void net_dsec2timeval(uint16_t dsec, FAR struct timeval *tv);
+/****************************************************************************
+ * Name: tcp_chksum
+ *
+ * Description:
+ * Calculate the TCP checksum of the packet in d_buf and d_appdata.
+ *
+ * The TCP checksum is the Internet checksum of data contents of the
+ * TCP segment, and a pseudo-header as defined in RFC793.
+ *
+ * Note: The d_appdata pointer that points to the packet data may
+ * point anywhere in memory, so it is not possible to simply calculate
+ * the Internet checksum of the contents of the d_buf buffer.
+ *
+ * Returned Value:
+ * The TCP checksum of the TCP segment in d_buf and pointed to by
+ * d_appdata.
+ *
+ ****************************************************************************/
+
+uint16_t tcp_chksum(FAR struct net_driver_s *dev);
+
+/****************************************************************************
+ * Name: udp_chksum
+ *
+ * Description:
+ * Calculate the UDP checksum of the packet in d_buf and d_appdata.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_UDP_CHECKSUMS
+uint16_t udp_chksum(FAR struct net_driver_s *dev);
+#endif
+
+/****************************************************************************
+ * Name: icmp_chksum
+ *
+ * Description:
+ * Calculate the checksum of the ICMP message
+ *
+ ****************************************************************************/
+
+uint16_t icmp_chksum(FAR struct net_driver_s *dev, int len);
+
#undef EXTERN
#ifdef __cplusplus
}