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,77 @@
#ifndef _TCP_HELPERS_H
#define _TCP_HELPERS_H
#ifdef __cpluscplus
extern "C"
{
#endif
#include <arpa/inet.h>
#define __FAVOR_BSD 1
#include <netinet/tcp.h>
static inline uint16_t tcp_hdr_get_sport(const struct tcphdr *hdr)
{
return ntohs(hdr->th_sport);
}
static inline uint16_t tcp_hdr_get_dport(const struct tcphdr *hdr)
{
return ntohs(hdr->th_dport);
}
static inline uint32_t tcp_hdr_get_seq(const struct tcphdr *hdr)
{
return ntohl(hdr->th_seq);
}
static inline uint32_t tcp_hdr_get_ack(const struct tcphdr *hdr)
{
return ntohl(hdr->th_ack);
}
static inline uint8_t tcp_hdr_get_flags(const struct tcphdr *hdr)
{
return hdr->th_flags;
}
static inline uint16_t tcp_hdr_get_checksum(const struct tcphdr *hdr)
{
return hdr->th_sum;
}
static inline bool tcp_hdr_has_flag_urg(const struct tcphdr *hdr)
{
return hdr->th_flags & TH_URG;
}
static inline bool tcp_hdr_has_flag_ack(const struct tcphdr *hdr)
{
return hdr->th_flags & TH_ACK;
}
static inline bool tcp_hdr_has_flag_psh(const struct tcphdr *hdr)
{
return hdr->th_flags & TH_PUSH;
}
static inline bool tcp_hdr_has_flag_rst(const struct tcphdr *hdr)
{
return hdr->th_flags & TH_RST;
}
static inline bool tcp_hdr_has_flag_syn(const struct tcphdr *hdr)
{
return hdr->th_flags & TH_SYN;
}
static inline bool tcp_hdr_has_flag_fin(const struct tcphdr *hdr)
{
return hdr->th_flags & TH_FIN;
}
#ifdef __cpluscplus
}
#endif
#endif