net: ipv4: Add IPv4 options length to net pkt

IPv4 header options length will be stored in ipv4_opts_len
in net_pkt structure. Now IPv4 header length will be in
net_pkt ip_hdr_len + ipv4_opts_len. So modified relevant
places of ip header length calculation for IPv4.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
Ravi kumar Veeramally 2019-09-30 12:17:03 +03:00 committed by Jukka Rissanen
commit cf9ad748ba
7 changed files with 81 additions and 21 deletions

View file

@ -188,6 +188,15 @@ struct net_pkt {
u8_t ipv4_ttl;
};
union {
#if defined(CONFIG_NET_IPV4)
u8_t ipv4_opts_len; /* Length if IPv4 Header Options */
#endif
#if defined(CONFIG_NET_IPV6)
u16_t ipv6_ext_len; /* length of extension headers */
#endif
};
#if NET_TC_COUNT > 1
/** Network packet priority, can be left out in which case packet
* is not prioritised.
@ -205,8 +214,6 @@ struct net_pkt {
#endif /* CONFIG_NET_VLAN */
#if defined(CONFIG_NET_IPV6)
u16_t ipv6_ext_len; /* length of extension headers */
/* Where is the start of the last header before payload data
* in IPv6 packet. This is offset value from start of the IPv6
* packet. Note that this value should be updated by who ever
@ -387,6 +394,17 @@ static inline void net_pkt_set_ipv4_ttl(struct net_pkt *pkt,
{
pkt->ipv4_ttl = ttl;
}
static inline u8_t net_pkt_ipv4_opts_len(struct net_pkt *pkt)
{
return pkt->ipv4_opts_len;
}
static inline void net_pkt_set_ipv4_opts_len(struct net_pkt *pkt,
u8_t opts_len)
{
pkt->ipv4_opts_len = opts_len;
}
#else
static inline u8_t net_pkt_ipv4_ttl(struct net_pkt *pkt)
{
@ -401,6 +419,19 @@ static inline void net_pkt_set_ipv4_ttl(struct net_pkt *pkt,
ARG_UNUSED(pkt);
ARG_UNUSED(ttl);
}
static inline u8_t net_pkt_ipv4_opts_len(struct net_pkt *pkt)
{
ARG_UNUSED(pkt);
return 0;
}
static inline void net_pkt_set_ipv4_opts_len(struct net_pkt *pkt,
u8_t opts_len)
{
ARG_UNUSED(pkt);
ARG_UNUSED(opts_len);
}
#endif
#if defined(CONFIG_NET_IPV6)
@ -526,6 +557,19 @@ static inline void net_pkt_set_ipv6_hop_limit(struct net_pkt *pkt,
}
#endif /* CONFIG_NET_IPV6 */
static inline u16_t net_pkt_ip_opts_len(struct net_pkt *pkt)
{
#if defined(CONFIG_NET_IPV6)
return pkt->ipv6_ext_len;
#elif defined(CONFIG_NET_IPV4)
return pkt->ipv4_opts_len;
#else
ARG_UNUSED(pkt);
return 0;
#endif
}
#if defined(CONFIG_NET_IPV6_FRAGMENT)
static inline u16_t net_pkt_ipv6_fragment_start(struct net_pkt *pkt)
{