feature: packet manager support build packet
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "utils_internal.h"
|
||||
#include "packet_internal.h"
|
||||
#include "packet_manager.h"
|
||||
#include "packet_builder.h"
|
||||
#include "fieldstat/fieldstat_easy.h"
|
||||
|
||||
#define PACKET_MANAGER_LOG_ERROR(format, ...) STELLAR_LOG_ERROR(__thread_local_logger, "packet manager", format, ##__VA_ARGS__)
|
||||
@@ -430,6 +431,60 @@ void packet_manager_print_stat(struct packet_manager *pkt_mgr, uint16_t thread_i
|
||||
}
|
||||
}
|
||||
|
||||
struct packet *packet_manager_build_tcp_packet(struct packet_manager *pkt_mgr, const struct packet *origin_pkt, uint32_t tcp_seq, uint32_t tcp_ack, uint8_t tcp_flags,
|
||||
const char *tcp_options, uint16_t tcp_options_len, const char *tcp_payload, uint16_t tcp_payload_len)
|
||||
{
|
||||
struct packet *pkt = packet_build_tcp(origin_pkt, tcp_seq, tcp_ack, tcp_flags, tcp_options, tcp_options_len, tcp_payload, tcp_payload_len);
|
||||
if (pkt == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct exdata_runtime *ex_rte = exdata_runtime_new(pkt_mgr->sche->ex_sche);
|
||||
packet_set_user_data(pkt, ex_rte);
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
struct packet *packet_manager_build_udp_packet(struct packet_manager *pkt_mgr, const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len)
|
||||
{
|
||||
struct packet *pkt = packet_build_udp(origin_pkt, udp_payload, udp_payload_len);
|
||||
if (pkt == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct exdata_runtime *ex_rte = exdata_runtime_new(pkt_mgr->sche->ex_sche);
|
||||
packet_set_user_data(pkt, ex_rte);
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
struct packet *packet_manager_build_l3_packet(struct packet_manager *pkt_mgr, const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len)
|
||||
{
|
||||
struct packet *pkt = packet_build_l3(origin_pkt, ip_proto, l3_payload, l3_payload_len);
|
||||
if (pkt == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct exdata_runtime *ex_rte = exdata_runtime_new(pkt_mgr->sche->ex_sche);
|
||||
packet_set_user_data(pkt, ex_rte);
|
||||
|
||||
return pkt;
|
||||
}
|
||||
|
||||
void packet_manager_free_packet(struct packet_manager *pkt_mgr __attribute__((unused)), struct packet *pkt)
|
||||
{
|
||||
if (pkt)
|
||||
{
|
||||
struct exdata_runtime *ex_rte = packet_get_user_data(pkt);
|
||||
exdata_runtime_free(ex_rte);
|
||||
|
||||
packet_free(pkt);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* packet manager module
|
||||
******************************************************************************/
|
||||
|
||||
Reference in New Issue
Block a user