diff options
| author | luwenpeng <[email protected]> | 2024-09-13 15:53:49 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-09-13 18:07:40 +0800 |
| commit | 06c498409f0fef942e59143d1484e9679bd212d2 (patch) | |
| tree | e312b96a1de2ae19846ccb513040b4e07e6e44c5 | |
| parent | 16b5174d94da63895e21198689de158e71693602 (diff) | |
feature: add packet_manager API definition
| -rw-r--r-- | include/stellar/packet.h | 18 | ||||
| -rw-r--r-- | include/stellar/packet_manager.h | 25 |
2 files changed, 34 insertions, 9 deletions
diff --git a/include/stellar/packet.h b/include/stellar/packet.h index fedd82f..d1431a0 100644 --- a/include/stellar/packet.h +++ b/include/stellar/packet.h @@ -171,17 +171,8 @@ enum packet_action { PACKET_ACTION_FORWARD = 0, PACKET_ACTION_DROP = 1, - PACKET_ACTION_FAST_FORWARD = 2, - }; -#include <stdbool.h> - -void packet_mark_as_drop(struct packet *pkt, bool drop); - -void packet_free(struct packet *pkt); - - void packet_set_action(struct packet *pkt, enum packet_action action); enum packet_action packet_get_action(const struct packet *pkt); @@ -194,6 +185,15 @@ 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); +enum packet_stage +{ + PACKET_STAGE_PREROUTING, + PACKET_STAGE_INPUT, + PACKET_STAGE_FORWARD, + PACKET_STAGE_OUTPUT, + PACKET_STAGE_POSTROUTING, + PACKET_STAGE_MAX, +}; #ifdef __cplusplus } diff --git a/include/stellar/packet_manager.h b/include/stellar/packet_manager.h new file mode 100644 index 0000000..2a31974 --- /dev/null +++ b/include/stellar/packet_manager.h @@ -0,0 +1,25 @@ +#pragma once + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "packet.h" + +struct packet_manager; +struct packet_manager_schema; +struct packet_manager_runtime; + +struct packet_manager_schema *packet_manager_get_schema(struct packet_manager *pkt_mgr); +struct packet_manager_runtime *packet_manager_get_runtime(struct packet_manager *pkt_mgr, uint16_t thr_idx); + +typedef void on_packet_stage_callback(enum packet_stage stage, struct packet *pkt, void *args); +int packet_manager_schema_add_subscriber(struct packet_manager_schema *schema, enum packet_stage stage, on_packet_stage_callback cb, void *args); + +void packet_manager_runtime_take_packet(struct packet_manager_runtime *pkt_mgr_rt, struct packet *pkt); +void packet_manager_runtime_schedule_packet(struct packet_manager_runtime *pkt_mgr_rt, struct packet *pkt, enum packet_stage stage); + +#ifdef __cplusplus +} +#endif |
