net: extract l3 header build code into new functions

Signed-off-by: liyi <liyi25@xiaomi.com>
This commit is contained in:
liyi
2022-11-29 11:23:43 +08:00
committed by Xiang Xiao
parent d54a20b393
commit 391b501639
23 changed files with 398 additions and 522 deletions
+9
View File
@@ -88,6 +88,7 @@
#ifdef CONFIG_NET_IPv4
# define IPv4_HDRLEN 20 /* Size of IPv4 header (without options) */
# define IPv4_HLMASK 0x0f /* Isolates headler length in VHL field */
# define IPV4_OPTMAX 40 /* The limit of ip option length */
#endif
#ifdef CONFIG_NET_IPv6
@@ -164,6 +165,14 @@ struct ipv4_hdr_s
uint16_t srcipaddr[2]; /* 32-bit Source IP address */
uint16_t destipaddr[2]; /* 32-bit Destination IP address */
};
/* The IPv4 options */
struct ipv4_opt_s
{
uint8_t len;
uint8_t data[IPV4_OPTMAX];
};
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
-21
View File
@@ -668,27 +668,6 @@ uint16_t net_chksum(FAR uint16_t *data, uint16_t len);
void net_incr32(FAR uint8_t *op32, uint16_t op16);
/****************************************************************************
* Name: ipv4_chksum
*
* Description:
* Calculate the IPv4 header checksum of the packet header in d_buf.
*
* The IPv4 header checksum is the Internet checksum of the 20 bytes of
* the IPv4 header.
*
* If CONFIG_NET_ARCH_CHKSUM is defined, then this function must be
* provided by architecture-specific logic.
*
* Returned Value:
* The IPv4 header checksum of the IPv4 header in the d_buf buffer.
*
****************************************************************************/
#ifdef CONFIG_NET_IPv4
uint16_t ipv4_chksum(FAR struct net_driver_s *dev);
#endif
/****************************************************************************
* Name: netdev_ipv4_hdrlen
*