TSG-18285 TFE的Packet IO模块支持重复流量识别

This commit is contained in:
luwenpeng
2023-12-29 17:25:18 +08:00
parent 9d3dcce1ab
commit cbd98507a2
30 changed files with 4064 additions and 1572 deletions

View File

@@ -0,0 +1,71 @@
#ifndef _IPV4_HELPERS_H
#define _IPV4_HELPERS_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include <arpa/inet.h>
#include <netinet/ip.h>
static inline uint16_t ipv4_hdr_get_ipid(const struct ip *hdr)
{
return ntohs(hdr->ip_id);
}
static inline uint8_t ipv4_hdr_get_flags(const struct ip *hdr)
{
return (ntohs(hdr->ip_off) & IP_OFFMASK) >> 13;
}
static inline uint16_t ipv4_hdr_get_frag_offset(const struct ip *hdr)
{
return ntohs(hdr->ip_off) & IP_OFFMASK;
}
static inline uint8_t ipv4_hdr_get_ttl(const struct ip *hdr)
{
return hdr->ip_ttl;
}
static inline uint8_t ipv4_hdr_get_protocol(const struct ip *hdr)
{
return hdr->ip_p;
}
static inline uint16_t ipv4_hdr_get_checksum(const struct ip *hdr)
{
return ntohs(hdr->ip_sum);
}
static inline uint32_t ipv4_hdr_get_src(const struct ip *hdr)
{
return ntohl(hdr->ip_src.s_addr);
}
static inline uint32_t ipv4_hdr_get_dst(const struct ip *hdr)
{
return ntohl(hdr->ip_dst.s_addr);
}
static inline bool ipv4_hdr_has_flag_rf(const struct ip *hdr)
{
return (ntohs(hdr->ip_off) & IP_RF) != 0;
}
static inline bool ipv4_hdr_has_flag_df(const struct ip *hdr)
{
return (ntohs(hdr->ip_off) & IP_DF) != 0;
}
static inline bool ipv4_hdr_has_flag_mf(const struct ip *hdr)
{
return (ntohs(hdr->ip_off) & IP_MF) != 0;
}
#ifdef __cpluscplus
}
#endif
#endif