feature: packet IO support IP reassembly
This commit is contained in:
@@ -34,7 +34,25 @@ struct metadata
|
||||
enum packet_direction direction;
|
||||
enum packet_action action;
|
||||
struct timeval tv;
|
||||
const void *origin_ctx;
|
||||
};
|
||||
|
||||
enum origin_type
|
||||
{
|
||||
ORIGIN_TYPE_MR,
|
||||
ORIGIN_TYPE_PCAP,
|
||||
ORIGIN_TYPE_USER,
|
||||
};
|
||||
|
||||
typedef void origin_free(struct packet *pkt, void *args);
|
||||
struct packet_origin
|
||||
{
|
||||
enum origin_type type;
|
||||
void *ctx;
|
||||
|
||||
origin_free *cb;
|
||||
void *args;
|
||||
|
||||
int thr_idx;
|
||||
};
|
||||
|
||||
struct layer_private
|
||||
@@ -50,6 +68,8 @@ struct layer_private
|
||||
uint16_t hdr_offset; // header offset from data_ptr
|
||||
};
|
||||
|
||||
TAILQ_HEAD(packet_queue, packet);
|
||||
|
||||
struct packet
|
||||
{
|
||||
void *user_data;
|
||||
@@ -58,14 +78,19 @@ struct packet
|
||||
int8_t layers_used;
|
||||
int8_t layers_size;
|
||||
int8_t need_free;
|
||||
int8_t is_defraged;
|
||||
|
||||
const char *data_ptr;
|
||||
uint16_t data_len;
|
||||
uint16_t trim_len; // trim eth padding
|
||||
|
||||
TAILQ_ENTRY(packet) stage_tqe;
|
||||
TAILQ_ENTRY(packet) pool_tqe; // for packet pool
|
||||
TAILQ_ENTRY(packet) frag_tqe; // for IP reassembly
|
||||
TAILQ_ENTRY(packet) stage_tqe; // for packet manager
|
||||
struct packet_queue frag_list; // for defraged packet
|
||||
|
||||
struct metadata meta;
|
||||
struct packet_origin origin;
|
||||
};
|
||||
|
||||
enum packet_load_balance_method
|
||||
@@ -84,8 +109,8 @@ enum packet_load_balance_method
|
||||
void packet_set_route_ctx(struct packet *pkt, const struct route_ctx *ctx);
|
||||
const struct route_ctx *packet_get_route_ctx(const struct packet *pkt);
|
||||
|
||||
void packet_set_origin_ctx(struct packet *pkt, void *ctx);
|
||||
const void *packet_get_origin_ctx(const struct packet *pkt);
|
||||
void packet_set_origin(struct packet *pkt, struct packet_origin *origin);
|
||||
struct packet_origin *packet_get_origin(struct packet *pkt);
|
||||
|
||||
void packet_set_sids(struct packet *pkt, const struct sids *sids);
|
||||
const struct sids *packet_get_sids(const struct packet *pkt);
|
||||
@@ -152,6 +177,11 @@ struct packet *packet_dup(const struct packet *pkt);
|
||||
void packet_free(struct packet *pkt);
|
||||
|
||||
int packet_is_fragment(const struct packet *pkt);
|
||||
int packet_is_defraged(const struct packet *pkt);
|
||||
void packet_set_defraged(struct packet *pkt);
|
||||
|
||||
void packet_push_frag(struct packet *pkt, struct packet *frag);
|
||||
struct packet *packet_pop_frag(struct packet *pkt);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user