Add packet IO module
* support marsio
* support dumpfile ( 1 thread read dumpfile & N thread handle packet)
This commit is contained in:
59
src/packet/packet_utils.h
Normal file
59
src/packet/packet_utils.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef _PACKET_UTILS_H
|
||||
#define _PACKET_UTILS_H
|
||||
|
||||
#ifdef __cpluscplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "packet.h"
|
||||
|
||||
void packet_set_io_ctx(struct packet *pkt, void *ctx);
|
||||
void *packet_get_io_ctx(const struct packet *pkt);
|
||||
|
||||
int packet_set_sid(struct packet *pkt, uint16_t *sid, int num); // return 0 success; return -1 failed
|
||||
int packet_get_sid(const struct packet *pkt, uint16_t *sid, int size); // return number of sid
|
||||
int packet_prepend_sid(struct packet *pkt, uint16_t sid); // return 0 success; return -1 failed
|
||||
int packet_append_sid(struct packet *pkt, uint16_t sid); // return 0 success; return -1 failed
|
||||
|
||||
int packet_set_route_ctx(struct packet *pkt, const char *route, int len); // return 0 success; return -1 failed
|
||||
int packet_get_route_ctx(const struct packet *pkt, char *buff, int size); // return len of route ctx
|
||||
|
||||
void packet_set_session_id(struct packet *pkt, uint64_t session_id);
|
||||
uint64_t packet_get_session_id(const struct packet *pkt);
|
||||
|
||||
#define PACKET_DIRECTION_I2E 0
|
||||
#define PACKET_DIRECTION_E2I 1
|
||||
|
||||
void packet_set_direction(struct packet *pkt, uint8_t direction);
|
||||
uint8_t packet_get_direction(const struct packet *pkt);
|
||||
|
||||
#define PACKET_TYPE_DATA 0
|
||||
#define PACKET_TYPE_CTRL 1
|
||||
|
||||
void packet_set_type(struct packet *pkt, uint8_t type);
|
||||
uint8_t packet_get_type(const struct packet *pkt);
|
||||
|
||||
#define PACKET_ACTION_FORWARD 0
|
||||
#define PACKET_ACTION_DROP 1
|
||||
|
||||
void packet_set_action(struct packet *pkt, uint8_t action);
|
||||
uint8_t packet_get_action(const struct packet *pkt);
|
||||
|
||||
struct packet *packet_new(uint16_t len);
|
||||
void packet_free(struct packet *pkt);
|
||||
struct packet *packet_dup(const struct packet *pkt);
|
||||
|
||||
const char *packet_get_data(const struct packet *pkt);
|
||||
uint16_t packet_get_len(const struct packet *pkt);
|
||||
|
||||
bool paket_is_fragment(const struct packet *pkt);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user