2023-12-18 16:51:17 +08:00
|
|
|
#ifndef _PACKET_HELPERS_H
|
|
|
|
|
#define _PACKET_HELPERS_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "packet.h"
|
|
|
|
|
|
2023-12-22 14:45:31 +08:00
|
|
|
struct metadata
|
|
|
|
|
{
|
|
|
|
|
// TODO
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// metadata
|
|
|
|
|
struct metadata *metadata_dup(const struct metadata *metadata);
|
|
|
|
|
void metadata_free(struct metadata *metadata);
|
|
|
|
|
void packet_set0_metadata(struct packet *pkt, const struct metadata *metadata);
|
|
|
|
|
const struct metadata *packet_get0_metadata(const struct packet *pkt);
|
|
|
|
|
|
2023-12-18 16:51:17 +08:00
|
|
|
// packet
|
2023-12-22 14:45:31 +08:00
|
|
|
struct packet *packet_dup(const struct packet *pkt);
|
|
|
|
|
void packet_free(struct packet *pkt);
|
|
|
|
|
|
2023-12-18 16:51:17 +08:00
|
|
|
uint64_t packet_get_zone_id(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_raw_len(const struct packet *pkt);
|
|
|
|
|
const char *packet_get0_raw_data(const struct packet *pkt);
|
|
|
|
|
|
|
|
|
|
bool paket_is_fragment(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp(const struct packet *pkt);
|
|
|
|
|
bool packet_has_udp(const struct packet *pkt);
|
|
|
|
|
|
|
|
|
|
// foreach layer
|
|
|
|
|
uint8_t packet_get_layer_count(const struct packet *pkt);
|
|
|
|
|
enum layer_type packet_get_layer_type(const struct packet *pkt, uint8_t index);
|
|
|
|
|
const char *packet_get_layer_hdr_ptr(const struct packet *pkt, uint8_t index);
|
|
|
|
|
const char *packet_get_layer_pld_ptr(const struct packet *pkt, uint8_t index);
|
|
|
|
|
uint16_t packet_get_layer_hdr_len(const struct packet *pkt, uint8_t index);
|
|
|
|
|
uint16_t packet_get_layer_pld_len(const struct packet *pkt, uint8_t index);
|
|
|
|
|
|
|
|
|
|
// get tcp layer
|
|
|
|
|
const struct layer_record *packet_get0_tcp_layer(const struct packet *pkt);
|
|
|
|
|
const char *packet_get_tcp_hdr_ptr(const struct packet *pkt);
|
|
|
|
|
const char *packet_get_tcp_pld_ptr(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_tcp_hdr_len(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_tcp_pld_len(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_tcp_sport(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_tcp_dport(const struct packet *pkt);
|
|
|
|
|
uint32_t packet_get_tcp_seq(const struct packet *pkt);
|
|
|
|
|
uint32_t packet_get_tcp_ack(const struct packet *pkt);
|
|
|
|
|
uint8_t packet_get_tcp_flags(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp_flag_urg(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp_flag_ack(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp_flag_psh(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp_flag_rst(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp_flag_syn(const struct packet *pkt);
|
|
|
|
|
bool packet_has_tcp_flag_fin(const struct packet *pkt);
|
|
|
|
|
|
|
|
|
|
// get inner udp layer
|
|
|
|
|
const struct layer_record *packet_get0_inner_udp_layer(const struct packet *pkt);
|
|
|
|
|
const char *packet_get_inner_udp_hdr_ptr(const struct packet *pkt);
|
|
|
|
|
const char *packet_get_inner_udp_pld_ptr(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_inner_udp_hdr_len(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_inner_udp_pld_len(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_inner_udp_sport(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_inner_udp_dport(const struct packet *pkt);
|
|
|
|
|
|
|
|
|
|
// get outer udp layer
|
|
|
|
|
const struct layer_record *packet_get0_outer_udp_layer(const struct packet *pkt);
|
|
|
|
|
const char *packet_get_outer_udp_hdr_ptr(const struct packet *pkt);
|
|
|
|
|
const char *packet_get_outer_udp_pld_ptr(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_outer_udp_hdr_len(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_outer_udp_pld_len(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_outer_udp_sport(const struct packet *pkt);
|
|
|
|
|
uint16_t packet_get_outer_udp_dport(const struct packet *pkt);
|
|
|
|
|
|
|
|
|
|
#ifdef __cpluscplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|