net/: Fix net checksum related issue

1. Remove the unused and unimplemented ipv6_chksum declaration
2. Update NET_ARCH_CHKSUM description to align with the implementation
3. Declare all checksum function prototype regardless CONFIG_NET_ARCH_CHKSUM
4. Remove the CONFIG_NET_ARCH_CHKSUM guard for tcp_ipv[4|6]_chksum
This commit is contained in:
Xiang Xiao 2020-01-30 15:45:15 +08:00 committed by Gregory Nutt
parent 5a24d499cf
commit affc32c9d1
9 changed files with 5 additions and 74 deletions

View File

@ -696,27 +696,6 @@ void net_incr32(FAR uint8_t *op32, uint16_t op16);
uint16_t ipv4_chksum(FAR struct net_driver_s *dev);
#endif
/****************************************************************************
* Name: ipv6_chksum
*
* Description:
* Calculate the IPv6 header checksum of the packet header in d_buf.
*
* The IPv6 header checksum is the Internet checksum of the 40 bytes of
* the IPv6 header.
*
* If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
* provided by architecture-specific logic.
*
* Returned Value:
* The IPv6 header checksum of the IPv6 header in the d_buf buffer.
*
****************************************************************************/
#ifdef CONFIG_NET_IPv6
uint16_t ipv6_chksum(FAR struct net_driver_s *dev);
#endif
/****************************************************************************
* Name: netdev_ipv4_hdrlen
*

View File

@ -19,9 +19,8 @@ config NET_ARCH_CHKSUM
Define if you architecture provided an optimized version of
functions with the following prototypes:
uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len)
uint16_t net_chksum(FAR uint16_t *data, uint16_t len)
uint16_t ipv4_chksum(FAR struct net_driver_s *dev)
uint16_t tcp_ipv4_chksum(FAR struct net_driver_s *dev);
uint16_t tcp_ipv6_chksum(FAR struct net_driver_s *dev);
uint16_t udp_ipv4_chksum(FAR struct net_driver_s *dev);
uint16_t udp_ipv6_chksum(FAR struct net_driver_s *dev);
uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto)
uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto, unsigned int iplen)

View File

@ -41,23 +41,8 @@
#include <nuttx/config.h>
#ifdef CONFIG_NET
#include <stdint.h>
#include <debug.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/icmp.h>
#include "utils/utils.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define IPv4BUF ((struct ipv4_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
#define IPv6BUF ((struct ipv6_hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -40,10 +40,6 @@
#include <nuttx/config.h>
#ifdef CONFIG_NET
#include <stdint.h>
#include <debug.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/icmp.h>
@ -55,7 +51,6 @@
#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 ICMPv6BUF ((struct icmp_ipv6hdr_s *)&dev->d_buf[NET_LL_HDRLEN(dev)])
/****************************************************************************
* Public Functions

View File

@ -39,16 +39,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <debug.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/ip.h>
#include <nuttx/net/icmp.h>
#include "utils/utils.h"
#ifndef CONFIG_NET_ARCH_INCR32

View File

@ -40,10 +40,8 @@
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/ip.h>

View File

@ -39,10 +39,6 @@
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include "utils/utils.h"
@ -72,7 +68,6 @@
*
****************************************************************************/
#ifndef CONFIG_NET_ARCH_CHKSUM
#ifdef CONFIG_NET_IPv4
uint16_t tcp_ipv4_chksum(FAR struct net_driver_s *dev)
{
@ -86,7 +81,6 @@ uint16_t tcp_ipv6_chksum(FAR struct net_driver_s *dev)
return ipv6_upperlayer_chksum(dev, IP_PROTO_TCP, IPv6_HDRLEN);
}
#endif /* CONFIG_NET_IPv6 */
#endif /* !CONFIG_NET_ARCH_CHKSUM */
#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NET_IPv6)
uint16_t tcp_chksum(FAR struct net_driver_s *dev)

View File

@ -39,10 +39,6 @@
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include "utils/utils.h"

View File

@ -234,9 +234,7 @@ void net_ipv6_pref2mask(uint8_t preflen, net_ipv6addr_t mask);
*
****************************************************************************/
#ifndef CONFIG_NET_ARCH_CHKSUM
uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len);
#endif
/****************************************************************************
* Name: net_chksum
@ -263,9 +261,7 @@ uint16_t chksum(uint16_t sum, FAR const uint8_t *data, uint16_t len);
*
****************************************************************************/
#ifndef CONFIG_NET_ARCH_CHKSUM
uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
#endif
/****************************************************************************
* Name: ipv4_upperlayer_chksum
@ -284,7 +280,7 @@ uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
*
****************************************************************************/
#if !defined(CONFIG_NET_ARCH_CHKSUM) && defined(CONFIG_NET_IPv4)
#ifdef CONFIG_NET_IPv4
uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto);
#endif
@ -308,7 +304,7 @@ uint16_t ipv4_upperlayer_chksum(FAR struct net_driver_s *dev, uint8_t proto);
*
****************************************************************************/
#if !defined(CONFIG_NET_ARCH_CHKSUM) && defined(CONFIG_NET_IPv6)
#ifdef CONFIG_NET_IPv6
uint16_t ipv6_upperlayer_chksum(FAR struct net_driver_s *dev,
uint8_t proto, unsigned int iplen);
#endif
@ -337,8 +333,6 @@ uint16_t tcp_ipv4_chksum(FAR struct net_driver_s *dev);
#endif
#ifdef CONFIG_NET_IPv6
/* REVIST: Is this used? */
uint16_t tcp_ipv6_chksum(FAR struct net_driver_s *dev);
#endif