refactor: packet module (split to parse/build/layer/tunnel/utils)

This commit is contained in:
luwenpeng
2024-06-24 17:07:05 +08:00
parent d8963af5f8
commit 71422ebb36
36 changed files with 796 additions and 724 deletions

View File

@@ -6,7 +6,7 @@ extern "C"
#endif
#include <stdint.h>
#include "packet_priv.h"
#include "stellar/packet.h"
/******************************************************************************
* metadata utils
@@ -40,15 +40,40 @@ enum packet_action packet_get_action(const struct packet *pkt);
void packet_set_origin_ctx(struct packet *pkt, void *ctx);
const void *packet_get_origin_ctx(const struct packet *pkt);
/******************************************************************************
* tuple uitls
******************************************************************************/
// return 0: found
// return -1: not found
int packet_get_innermost_tuple2(const struct packet *pkt, struct tuple2 *tuple);
int packet_get_outermost_tuple2(const struct packet *pkt, struct tuple2 *tuple);
// return 0: found
// return -1: not found
int packet_get_innermost_tuple4(const struct packet *pkt, struct tuple4 *tuple);
int packet_get_outermost_tuple4(const struct packet *pkt, struct tuple4 *tuple);
// return 0: found
// return -1: not found
int packet_get_innermost_tuple6(const struct packet *pkt, struct tuple6 *tuple);
int packet_get_outermost_tuple6(const struct packet *pkt, struct tuple6 *tuple);
/******************************************************************************
* other uitls
******************************************************************************/
int packet_is_fragment(const struct packet *pkt);
const char *packet_get_raw_data(const struct packet *pkt);
uint16_t packet_get_raw_len(const struct packet *pkt);
const char *packet_get_payload(const struct packet *pkt);
uint16_t packet_get_payload_len(const struct packet *pkt);
struct packet *packet_new(uint16_t pkt_len);
struct packet *packet_dup(const struct packet *pkt);
void packet_free(struct packet *pkt);
int packet_is_fragment(const struct packet *pkt);
void layer_convert(const struct raw_layer *in, struct layer *out);
#ifdef __cplusplus