move stellar/packet_manager.h into stellar/packet.h
This commit is contained in:
@@ -16,6 +16,9 @@ extern "C"
|
|||||||
#include <linux/if_ether.h>
|
#include <linux/if_ether.h>
|
||||||
#include <linux/mpls.h>
|
#include <linux/mpls.h>
|
||||||
|
|
||||||
|
#include "stellar/exdata.h"
|
||||||
|
#include "stellar/module_manager.h"
|
||||||
|
|
||||||
struct packet;
|
struct packet;
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* layer
|
* layer
|
||||||
@@ -188,6 +191,34 @@ uint16_t packet_get_payload_len(const struct packet *pkt);
|
|||||||
void packet_set_exdata(struct packet *pkt, int idx, void *ex_ptr);
|
void packet_set_exdata(struct packet *pkt, int idx, void *ex_ptr);
|
||||||
void *packet_get_exdata(struct packet *pkt, int idx);
|
void *packet_get_exdata(struct packet *pkt, int idx);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* packet manager
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
enum packet_stage
|
||||||
|
{
|
||||||
|
PACKET_STAGE_PREROUTING,
|
||||||
|
PACKET_STAGE_INPUT,
|
||||||
|
PACKET_STAGE_FORWARD,
|
||||||
|
PACKET_STAGE_OUTPUT,
|
||||||
|
PACKET_STAGE_POSTROUTING,
|
||||||
|
PACKET_STAGE_MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct packet_manager;
|
||||||
|
struct packet_manager *stellar_module_get_packet_manager(struct stellar_module_manager *mod_mgr);
|
||||||
|
int packet_manager_new_packet_exdata_index(struct packet_manager *pkt_mgr, const char *name, exdata_free *func, void *arg);
|
||||||
|
|
||||||
|
typedef void on_packet_stage_callback(struct packet *pkt, enum packet_stage stage, void *arg);
|
||||||
|
int packet_manager_subscribe(struct packet_manager *pkt_mgr, enum packet_stage stage, on_packet_stage_callback *cb, void *arg);
|
||||||
|
|
||||||
|
// if two modules claim the same packet at the same stage, the second 'claim' fails.
|
||||||
|
// return 0 on success
|
||||||
|
// return -1 on failure
|
||||||
|
typedef void on_packet_claimed_callback(struct packet *pkt, void *arg);
|
||||||
|
int packet_manager_claim_packet(struct packet_manager *pkt_mgr, uint16_t thread_id, struct packet *pkt, on_packet_claimed_callback cb, void *arg);
|
||||||
|
void packet_manager_schedule_packet(struct packet_manager *pkt_mgr, uint16_t thread_id, struct packet *pkt, enum packet_stage stage);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "stellar/exdata.h"
|
|
||||||
#include "stellar/packet.h"
|
|
||||||
|
|
||||||
#include "stellar/module_manager.h"
|
|
||||||
|
|
||||||
enum packet_stage
|
|
||||||
{
|
|
||||||
PACKET_STAGE_PREROUTING,
|
|
||||||
PACKET_STAGE_INPUT,
|
|
||||||
PACKET_STAGE_FORWARD,
|
|
||||||
PACKET_STAGE_OUTPUT,
|
|
||||||
PACKET_STAGE_POSTROUTING,
|
|
||||||
PACKET_STAGE_MAX,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct packet_manager;
|
|
||||||
|
|
||||||
struct packet_manager *stellar_module_get_packet_manager(struct stellar_module_manager *mod_mgr);
|
|
||||||
|
|
||||||
int packet_manager_new_packet_exdata_index(struct packet_manager *pkt_mgr, const char *name, exdata_free *func, void *arg);
|
|
||||||
|
|
||||||
typedef void on_packet_stage_callback(enum packet_stage stage, struct packet *pkt, void *arg);
|
|
||||||
int packet_manager_subscribe(struct packet_manager *pkt_mgr, enum packet_stage stage, on_packet_stage_callback *cb, void *arg);
|
|
||||||
|
|
||||||
// if two modules claim the same packet at the same stage, the second 'claim' fails.
|
|
||||||
// return 0 on success
|
|
||||||
// return -1 on failure
|
|
||||||
typedef void on_packet_claimed_callback(struct packet *pkt, void *arg);
|
|
||||||
int packet_manager_claim_packet(struct packet_manager *pkt_mgr, uint16_t thread_id, struct packet *pkt, on_packet_claimed_callback cb, void *arg);
|
|
||||||
void packet_manager_schedule_packet(struct packet_manager *pkt_mgr, uint16_t thread_id, struct packet *pkt, enum packet_stage stage);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "utils_internal.h"
|
#include "utils_internal.h"
|
||||||
#include "packet_internal.h"
|
#include "packet_internal.h"
|
||||||
#include "packet_manager_internal.h"
|
#include "packet_manager.h"
|
||||||
|
|
||||||
#define PACKET_MANAGER_MODULE_NAME "packet_manager_module"
|
#define PACKET_MANAGER_MODULE_NAME "packet_manager_module"
|
||||||
|
|
||||||
@@ -113,7 +113,7 @@ static void on_packet_stage_dispatch(int topic_id, void *msg, on_msg_cb_func *cb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
((on_packet_stage_callback *)(void *)cb)(stage, pkt, cb_arg);
|
((on_packet_stage_callback *)(void *)cb)(pkt, stage, cb_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void packet_schema_free(struct packet_manager_schema *pkt_mgr_schema)
|
static void packet_schema_free(struct packet_manager_schema *pkt_mgr_schema)
|
||||||
@@ -223,7 +223,7 @@ int packet_manager_new_packet_exdata_index(struct packet_manager *pkt_mgr, const
|
|||||||
int packet_manager_subscribe(struct packet_manager *pkt_mgr, enum packet_stage stage, on_packet_stage_callback *cb, void *arg)
|
int packet_manager_subscribe(struct packet_manager *pkt_mgr, enum packet_stage stage, on_packet_stage_callback *cb, void *arg)
|
||||||
{
|
{
|
||||||
assert(pkt_mgr);
|
assert(pkt_mgr);
|
||||||
return mq_schema_subscribe(pkt_mgr->schema->mq, pkt_mgr->schema->topic_id[stage], (on_msg_cb_func *)cb, arg);
|
return mq_schema_subscribe(pkt_mgr->schema->mq, pkt_mgr->schema->topic_id[stage], (on_msg_cb_func *)(void *)cb, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
int packet_manager_init(struct packet_manager *pkt_mgr, uint16_t thread_id, struct mq_runtime *mq_rt)
|
int packet_manager_init(struct packet_manager *pkt_mgr, uint16_t thread_id, struct mq_runtime *mq_rt)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "stellar/mq.h"
|
#include "stellar/mq.h"
|
||||||
#include "stellar/packet_manager.h"
|
#include "stellar/packet.h"
|
||||||
|
|
||||||
#define PACKET_QUEUE_MAX (PACKET_STAGE_MAX + 1)
|
#define PACKET_QUEUE_MAX (PACKET_STAGE_MAX + 1)
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "packet_parser.h"
|
#include "packet_parser.h"
|
||||||
#include "packet_internal.h"
|
#include "packet_internal.h"
|
||||||
#include "packet_manager_internal.h"
|
#include "packet_manager.h"
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
* [Protocols in frame: eth:ethertype:ip:ipv6:tcp]
|
||||||
@@ -99,7 +99,7 @@ TEST(PACKET_MANAGER, NEW_FREE)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
static void on_packet_stage(enum packet_stage stage, struct packet *pkt, void *args)
|
static void on_packet_stage(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
printf("on_packet_stage: %s\n", packet_stage_to_str(stage));
|
printf("on_packet_stage: %s\n", packet_stage_to_str(stage));
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ static void packet_claimed(struct packet *pkt, void *args)
|
|||||||
free(str);
|
free(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void claim_packet_success(enum packet_stage stage, struct packet *pkt, void *args)
|
static void claim_packet_success(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ static void claim_packet_success(enum packet_stage stage, struct packet *pkt, vo
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void claim_packet_failed(enum packet_stage stage, struct packet *pkt, void *args)
|
static void claim_packet_failed(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ TEST(PACKET_MANAGER, CLAIM_PACKET)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
static void on_packet_stage_schedule_packet(enum packet_stage stage, struct packet *pkt, void *args)
|
static void on_packet_stage_schedule_packet(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ static void schedule_claimed_packet(struct packet *pkt, void *args)
|
|||||||
packet_manager_schedule_packet(pkt_mgr, thread_id, pkt, PACKET_STAGE_POSTROUTING);
|
packet_manager_schedule_packet(pkt_mgr, thread_id, pkt, PACKET_STAGE_POSTROUTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_packet_stage_claim_packet_to_schedule(enum packet_stage stage, struct packet *pkt, void *args)
|
static void on_packet_stage_claim_packet_to_schedule(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
struct packet_manager *pkt_mgr = (struct packet_manager *)args;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "stellar/exdata.h"
|
#include "stellar/packet.h"
|
||||||
#include "stellar/packet_manager.h"
|
|
||||||
#include "stellar/session_manager.h"
|
#include "stellar/session_manager.h"
|
||||||
#include "stellar/module_manager.h"
|
|
||||||
|
|
||||||
#include "utils_internal.h"
|
#include "utils_internal.h"
|
||||||
#include "session_internal.h"
|
#include "session_internal.h"
|
||||||
@@ -88,7 +86,7 @@ static void on_session_free(void *msg, void *args)
|
|||||||
session_manager_runtime_free_session(sess_mgr_rt, sess);
|
session_manager_runtime_free_session(sess_mgr_rt, sess);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_packet_forward(enum packet_stage stage, struct packet *pkt, void *args)
|
static void on_packet_forward(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
struct session_manager *sess_mgr = (struct session_manager *)args;
|
struct session_manager *sess_mgr = (struct session_manager *)args;
|
||||||
struct stellar_module_manager *mod_mgr = sess_mgr->mod_mgr;
|
struct stellar_module_manager *mod_mgr = sess_mgr->mod_mgr;
|
||||||
@@ -180,7 +178,7 @@ fast_path:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_packet_output(enum packet_stage stage, struct packet *pkt, void *args)
|
static void on_packet_output(struct packet *pkt, enum packet_stage stage, void *args)
|
||||||
{
|
{
|
||||||
struct session_manager *sess_mgr = (struct session_manager *)args;
|
struct session_manager *sess_mgr = (struct session_manager *)args;
|
||||||
struct stellar_module_manager *mod_mgr = sess_mgr->mod_mgr;
|
struct stellar_module_manager *mod_mgr = sess_mgr->mod_mgr;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "log_internal.h"
|
#include "log_internal.h"
|
||||||
#include "utils_internal.h"
|
#include "utils_internal.h"
|
||||||
#include "packet_internal.h"
|
#include "packet_internal.h"
|
||||||
#include "packet_manager_internal.h"
|
#include "packet_manager.h"
|
||||||
#include "module_manager_interna.h"
|
#include "module_manager_interna.h"
|
||||||
|
|
||||||
#define CORE_LOG_FATAL(format, ...) STELLAR_LOG_FATAL(__thread_local_logger, "core", format, ##__VA_ARGS__)
|
#define CORE_LOG_FATAL(format, ...) STELLAR_LOG_FATAL(__thread_local_logger, "core", format, ##__VA_ARGS__)
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ LIBSTELLAR_DEVEL {
|
|||||||
global:
|
global:
|
||||||
packet_get_layer_count;
|
packet_get_layer_count;
|
||||||
packet_get_layer_by_idx;
|
packet_get_layer_by_idx;
|
||||||
|
|
||||||
packet_get_tunnel_count;
|
packet_get_tunnel_count;
|
||||||
packet_get_tunnel_by_idx;
|
packet_get_tunnel_by_idx;
|
||||||
|
|
||||||
packet_prepend_sids;
|
packet_prepend_sids;
|
||||||
packet_get_direction;
|
packet_get_direction;
|
||||||
packet_set_action;
|
packet_set_action;
|
||||||
@@ -17,6 +15,14 @@ global:
|
|||||||
packet_build_tcp;
|
packet_build_tcp;
|
||||||
packet_build_udp;
|
packet_build_udp;
|
||||||
packet_build_l3;
|
packet_build_l3;
|
||||||
|
packet_manager_on_init;
|
||||||
|
packet_manager_on_exit;
|
||||||
|
packet_manager_on_thread_init;
|
||||||
|
packet_manager_on_thread_exit;
|
||||||
|
packet_manager_new_packet_exdata_index;
|
||||||
|
packet_manager_subscribe;
|
||||||
|
packet_manager_claim_packet;
|
||||||
|
packet_manager_schedule_packet;
|
||||||
|
|
||||||
exdata_*;
|
exdata_*;
|
||||||
mq_*;
|
mq_*;
|
||||||
@@ -52,15 +58,6 @@ global:
|
|||||||
log_print;
|
log_print;
|
||||||
log_check_level;
|
log_check_level;
|
||||||
|
|
||||||
packet_manager_on_init;
|
|
||||||
packet_manager_on_exit;
|
|
||||||
packet_manager_on_thread_init;
|
|
||||||
packet_manager_on_thread_exit;
|
|
||||||
packet_manager_new_packet_exdata_index;
|
|
||||||
packet_manager_subscribe;
|
|
||||||
packet_manager_claim_packet;
|
|
||||||
packet_manager_schedule_packet;
|
|
||||||
|
|
||||||
session_manager_on_init;
|
session_manager_on_init;
|
||||||
session_manager_on_exit;
|
session_manager_on_exit;
|
||||||
session_manager_on_thread_init;
|
session_manager_on_thread_init;
|
||||||
|
|||||||
Reference in New Issue
Block a user