refactor: rename packet_craft.cpp/h to packet_builder.cpp/h

This commit is contained in:
luwenpeng
2024-08-16 14:15:03 +08:00
parent ebf1dad62c
commit 4ee08c136a
12 changed files with 65 additions and 75 deletions

View File

@@ -41,11 +41,11 @@ uint16_t packet_get_payload_len(const struct packet *pkt);
* tcp_ack: the acknowledgment number of the new TCP packet (in host byte order) * tcp_ack: the acknowledgment number of the new TCP packet (in host byte order)
* tcp_options_len: the length of the options (must be a multiple of 4) * tcp_options_len: the length of the options (must be a multiple of 4)
*/ */
struct packet *craft_tcp_packet(const struct packet *origin_pkt, uint32_t tcp_seq, uint32_t tcp_ack, uint8_t tcp_flags, struct packet *packet_build_tcp(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_options, uint16_t tcp_options_len,
const char *tcp_payload, uint16_t tcp_payload_len); const char *tcp_payload, uint16_t tcp_payload_len);
struct packet *craft_udp_packet(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len); struct packet *packet_build_udp(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len);
struct packet *craft_l3_packet(const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len); struct packet *packet_build_l3(const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len);
struct tcp_segment; struct tcp_segment;
const char *tcp_segment_get_data(const struct tcp_segment *seg); const char *tcp_segment_get_data(const struct tcp_segment *seg);

View File

@@ -52,7 +52,7 @@ void stellar_emit_datapath_telemetry(struct packet *pkt, const char * module, c
int stellar_get_worker_thread_num(struct stellar *st); int stellar_get_worker_thread_num(struct stellar *st);
uint16_t stellar_get_current_thread_index(); uint16_t stellar_get_current_thread_index();
// only send user crafted packet, can't send packet which come from network // only send user crafted packet, can't send packet which come from network
void stellar_send_crafted_packet(struct stellar *st, struct packet *pkt); void stellar_send_build_packet(struct stellar *st, struct packet *pkt);
int stellar_run(int argc, char **argv); int stellar_run(int argc, char **argv);
#ifdef __cplusplus #ifdef __cplusplus

View File

@@ -1,6 +1,6 @@
add_library(packet add_library(packet
packet_parser.cpp packet_parser.cpp
packet_craft.cpp packet_builder.cpp
packet_filter.cpp packet_filter.cpp
packet_dump.cpp packet_dump.cpp
packet_utils.cpp packet_utils.cpp

View File

@@ -12,7 +12,7 @@
#include "packet_utils.h" #include "packet_utils.h"
#include "packet_layer.h" #include "packet_layer.h"
#include "packet_parser.h" #include "packet_parser.h"
#include "packet_craft.h" #include "packet_builder.h"
#define PACKET_CRAFT_LOG_DEBUG(format, ...) LOG_DEBUG("packet craft", format, ##__VA_ARGS__) #define PACKET_CRAFT_LOG_DEBUG(format, ...) LOG_DEBUG("packet craft", format, ##__VA_ARGS__)
#define PACKET_CRAFT_LOG_ERROR(format, ...) LOG_ERROR("packet craft", format, ##__VA_ARGS__) #define PACKET_CRAFT_LOG_ERROR(format, ...) LOG_ERROR("packet craft", format, ##__VA_ARGS__)
@@ -25,7 +25,7 @@ struct fingerprint
uint16_t tcp_win; uint16_t tcp_win;
}; };
static uint8_t append_sender_fingerprint = 0; static uint8_t append_fingerprint = 0;
/****************************************************************************** /******************************************************************************
* Private API * Private API
@@ -33,7 +33,7 @@ static uint8_t append_sender_fingerprint = 0;
static inline void calc_packet_fingerprint(struct fingerprint *finger) static inline void calc_packet_fingerprint(struct fingerprint *finger)
{ {
if (append_sender_fingerprint) if (append_fingerprint)
{ {
#define RANGE(rand, start, end) (start + rand % (end - start + 1)) // [start, end] #define RANGE(rand, start, end) (start + rand % (end - start + 1)) // [start, end]
struct timespec time; struct timespec time;
@@ -244,9 +244,9 @@ static void calculate_length_and_checksum(const struct packet *origin_pkt, int l
* Public API * Public API
******************************************************************************/ ******************************************************************************/
void append_sender_fingerprint_to_crafted_packet() void append_fingerprint_to_build_packet()
{ {
append_sender_fingerprint = 1; append_fingerprint = 1;
} }
/* /*
@@ -254,7 +254,7 @@ void append_sender_fingerprint_to_crafted_packet()
* tcp_ack: the acknowledgment number of the new TCP packet (in host byte order) * tcp_ack: the acknowledgment number of the new TCP packet (in host byte order)
* tcp_options_len: the length of the options (must be a multiple of 4) * tcp_options_len: the length of the options (must be a multiple of 4)
*/ */
struct packet *craft_tcp_packet(const struct packet *origin_pkt, uint32_t tcp_seq, uint32_t tcp_ack, uint8_t tcp_flags, struct packet *packet_build_tcp(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_options, uint16_t tcp_options_len,
const char *tcp_payload, uint16_t tcp_payload_len) const char *tcp_payload, uint16_t tcp_payload_len)
{ {
@@ -310,7 +310,7 @@ struct packet *craft_tcp_packet(const struct packet *origin_pkt, uint32_t tcp_se
return new_pkt; return new_pkt;
} }
struct packet *craft_udp_packet(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len) struct packet *packet_build_udp(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len)
{ {
// check arguments // check arguments
if (origin_pkt == NULL || (udp_payload == NULL && udp_payload_len != 0) || (udp_payload != NULL && udp_payload_len == 0)) if (origin_pkt == NULL || (udp_payload == NULL && udp_payload_len != 0) || (udp_payload != NULL && udp_payload_len == 0))
@@ -352,7 +352,7 @@ struct packet *craft_udp_packet(const struct packet *origin_pkt, const char *udp
return new_pkt; return new_pkt;
} }
struct packet *craft_l3_packet(const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len) struct packet *packet_build_l3(const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len)
{ {
if (origin_pkt == NULL || (l3_payload == NULL && l3_payload_len != 0) || (l3_payload != NULL && l3_payload_len == 0)) if (origin_pkt == NULL || (l3_payload == NULL && l3_payload_len != 0) || (l3_payload != NULL && l3_payload_len == 0))
{ {

View File

@@ -0,0 +1,14 @@
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
void append_fingerprint_to_build_packet();
#ifdef __cplusplus
}
#endif

View File

@@ -1,25 +0,0 @@
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include <stdint.h>
void append_sender_fingerprint_to_crafted_packet();
/*
* tcp_seq: the sequence number of the new TCP packet (in host byte order)
* tcp_ack: the acknowledgment number of the new TCP packet (in host byte order)
* tcp_options_len: the length of the options (must be a multiple of 4)
*/
struct packet *craft_tcp_packet(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 *craft_udp_packet(const struct packet *origin_pkt, const char *udp_payload, uint16_t udp_payload_len);
struct packet *craft_l3_packet(const struct packet *origin_pkt, uint8_t ip_proto, const char *l3_payload, uint16_t l3_payload_len);
#ifdef __cplusplus
}
#endif

View File

@@ -46,8 +46,11 @@ target_link_libraries(gtest_packet_frag packet gtest)
add_executable(gtest_packet_parser gtest_packet_parser.cpp) add_executable(gtest_packet_parser gtest_packet_parser.cpp)
target_link_libraries(gtest_packet_parser packet gtest) target_link_libraries(gtest_packet_parser packet gtest)
add_executable(gtest_packet_craft gtest_packet_craft.cpp) add_executable(gtest_packet_builder gtest_packet_builder.cpp)
target_link_libraries(gtest_packet_craft packet gtest) target_link_libraries(gtest_packet_builder packet gtest)
add_executable(gtest_packet_filter gtest_packet_filter.cpp)
target_link_libraries(gtest_packet_filter packet gtest)
add_executable(gtest_packet_ldbc gtest_packet_ldbc.cpp) add_executable(gtest_packet_ldbc gtest_packet_ldbc.cpp)
target_link_libraries(gtest_packet_ldbc packet gtest) target_link_libraries(gtest_packet_ldbc packet gtest)
@@ -69,5 +72,6 @@ gtest_discover_tests(gtest_gtp1_utils)
gtest_discover_tests(gtest_gtp2_utils) gtest_discover_tests(gtest_gtp2_utils)
gtest_discover_tests(gtest_packet_frag) gtest_discover_tests(gtest_packet_frag)
gtest_discover_tests(gtest_packet_parser) gtest_discover_tests(gtest_packet_parser)
gtest_discover_tests(gtest_packet_craft) gtest_discover_tests(gtest_packet_builder)
gtest_discover_tests(gtest_packet_filter)
gtest_discover_tests(gtest_packet_ldbc) gtest_discover_tests(gtest_packet_ldbc)

View File

@@ -12,7 +12,7 @@
#include "packet_dump.h" #include "packet_dump.h"
#include "packet_layer.h" #include "packet_layer.h"
#include "packet_parser.h" #include "packet_parser.h"
#include "packet_craft.h" #include "packet_builder.h"
#include "packet_utils.h" #include "packet_utils.h"
#define PRINT_GREEN(fmt, ...) printf("\033[0;32m" fmt "\033[0m\n", ##__VA_ARGS__) #define PRINT_GREEN(fmt, ...) printf("\033[0;32m" fmt "\033[0m\n", ##__VA_ARGS__)
@@ -123,13 +123,13 @@ unsigned char data1[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
/* /*
* craft_tcp_packet() * packet_build_tcp()
* -> ETH->IPv4->TCP * -> ETH->IPv4->TCP
* -> with TCP options * -> with TCP options
* -> with TCP payload * -> with TCP payload
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_TCP, ETH_IP4_TCP) TEST(PACKET_BUILD_TCP, ETH_IP4_TCP)
{ {
struct packet orig_pkt; struct packet orig_pkt;
memset(&orig_pkt, 0, sizeof(orig_pkt)); memset(&orig_pkt, 0, sizeof(orig_pkt));
@@ -137,7 +137,7 @@ TEST(PACKET_CRAFT_TCP, ETH_IP4_TCP)
PRINT_GREEN("origin packet:"); PRINT_GREEN("origin packet:");
packet_dump_stdio(&orig_pkt); packet_dump_stdio(&orig_pkt);
struct packet *new_pkt = craft_tcp_packet(&orig_pkt, 1, 2, TH_ACK, (const char *)&ts_pad_opt, sizeof(ts_pad_opt), "Hello", 5); struct packet *new_pkt = packet_build_tcp(&orig_pkt, 1, 2, TH_ACK, (const char *)&ts_pad_opt, sizeof(ts_pad_opt), "Hello", 5);
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);
@@ -261,12 +261,12 @@ unsigned char data2[] = {
0x04, 0x02}; 0x04, 0x02};
/* /*
* craft_tcp_packet() * packet_build_tcp()
* -> ETH->IPv4->IPv6->TCP * -> ETH->IPv4->IPv6->TCP
* -> with TCP payload * -> with TCP payload
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_TCP, ETH_IP4_IP6_TCP) TEST(PACKET_BUILD_TCP, ETH_IP4_IP6_TCP)
{ {
struct packet orig_pkt; struct packet orig_pkt;
memset(&orig_pkt, 0, sizeof(orig_pkt)); memset(&orig_pkt, 0, sizeof(orig_pkt));
@@ -274,7 +274,7 @@ TEST(PACKET_CRAFT_TCP, ETH_IP4_IP6_TCP)
PRINT_GREEN("origin packet:"); PRINT_GREEN("origin packet:");
packet_dump_stdio(&orig_pkt); packet_dump_stdio(&orig_pkt);
struct packet *new_pkt = craft_tcp_packet(&orig_pkt, 1234, 2345, TH_ACK, NULL, 0, "Hello", 5); struct packet *new_pkt = packet_build_tcp(&orig_pkt, 1234, 2345, TH_ACK, NULL, 0, "Hello", 5);
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);
@@ -477,12 +477,12 @@ unsigned char data3[] = {
0x4f, 0xe9, 0xf5, 0xf0, 0x61, 0x5d, 0x7f, 0xc4, 0xc4, 0xd1, 0x05, 0x54, 0x13, 0xdb}; 0x4f, 0xe9, 0xf5, 0xf0, 0x61, 0x5d, 0x7f, 0xc4, 0xc4, 0xd1, 0x05, 0x54, 0x13, 0xdb};
/* /*
* craft_tcp_packet() * packet_build_tcp()
* -> ETH->IPv6->UDP->GTP->IPv4->TCP * -> ETH->IPv6->UDP->GTP->IPv4->TCP
* -> with TCP payload * -> with TCP payload
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_TCP, ETH_IP6_UDP_GTP_IP4_TCP) TEST(PACKET_BUILD_TCP, ETH_IP6_UDP_GTP_IP4_TCP)
{ {
struct packet orig_pkt; struct packet orig_pkt;
memset(&orig_pkt, 0, sizeof(orig_pkt)); memset(&orig_pkt, 0, sizeof(orig_pkt));
@@ -490,7 +490,7 @@ TEST(PACKET_CRAFT_TCP, ETH_IP6_UDP_GTP_IP4_TCP)
PRINT_GREEN("origin packet:"); PRINT_GREEN("origin packet:");
packet_dump_stdio(&orig_pkt); packet_dump_stdio(&orig_pkt);
struct packet *new_pkt = craft_tcp_packet(&orig_pkt, 1, 2, TH_ACK, NULL, 0, "Hello", 5); struct packet *new_pkt = packet_build_tcp(&orig_pkt, 1, 2, TH_ACK, NULL, 0, "Hello", 5);
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);
@@ -697,13 +697,13 @@ unsigned char data4[] = {
0x00, 0x00, 0x00, 0x01, 0x30, 0x39, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02, 0x20, 0x00, 0x31, 0xa0, 0x00, 0x00}; 0x00, 0x00, 0x00, 0x01, 0x30, 0x39, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x02, 0x20, 0x00, 0x31, 0xa0, 0x00, 0x00};
/* /*
* craft_tcp_packet() * packet_build_tcp()
* -> ETH->IPv4->GRE->IPv6->TCP * -> ETH->IPv4->GRE->IPv6->TCP
* -> with TCP payload * -> with TCP payload
* -> with GRE checksum * -> with GRE checksum
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_TCP, ETH_IP4_GRE_IP6_TCP) TEST(PACKET_BUILD_TCP, ETH_IP4_GRE_IP6_TCP)
{ {
struct packet orig_pkt; struct packet orig_pkt;
memset(&orig_pkt, 0, sizeof(orig_pkt)); memset(&orig_pkt, 0, sizeof(orig_pkt));
@@ -711,7 +711,7 @@ TEST(PACKET_CRAFT_TCP, ETH_IP4_GRE_IP6_TCP)
PRINT_GREEN("origin packet:"); PRINT_GREEN("origin packet:");
packet_dump_stdio(&orig_pkt); packet_dump_stdio(&orig_pkt);
struct packet *new_pkt = craft_tcp_packet(&orig_pkt, 1, 2, TH_ACK, NULL, 0, "Hello", 5); struct packet *new_pkt = packet_build_tcp(&orig_pkt, 1, 2, TH_ACK, NULL, 0, "Hello", 5);
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);
@@ -924,13 +924,13 @@ unsigned char data5[] = {
0x33, 0x31, 0x34, 0x30, 0x65, 0x37, 0x36, 0x36, 0x37, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x01}; 0x33, 0x31, 0x34, 0x30, 0x65, 0x37, 0x36, 0x36, 0x37, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x01};
/* /*
* craft_udp_packet() * packet_build_udp()
* -> ETH->VLAN->IPv6->IPv4->GRE->PPP->IPv4->UDP->DNS * -> ETH->VLAN->IPv6->IPv4->GRE->PPP->IPv4->UDP->DNS
* -> with UDP payload * -> with UDP payload
* -> with GRE payload length * -> with GRE payload length
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_UDP, ETH_VLAN_IPv6_IPv4_GRE_PPP_IPv4_UDP_DNS) TEST(PACKET_BUILD_UDP, ETH_VLAN_IPv6_IPv4_GRE_PPP_IPv4_UDP_DNS)
{ {
struct packet orig_pkt; struct packet orig_pkt;
memset(&orig_pkt, 0, sizeof(orig_pkt)); memset(&orig_pkt, 0, sizeof(orig_pkt));
@@ -938,7 +938,7 @@ TEST(PACKET_CRAFT_UDP, ETH_VLAN_IPv6_IPv4_GRE_PPP_IPv4_UDP_DNS)
PRINT_GREEN("origin packet:"); PRINT_GREEN("origin packet:");
packet_dump_stdio(&orig_pkt); packet_dump_stdio(&orig_pkt);
struct packet *new_pkt = craft_udp_packet(&orig_pkt, "Hello", 5); struct packet *new_pkt = packet_build_udp(&orig_pkt, "Hello", 5);
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);
@@ -1027,12 +1027,12 @@ TEST(PACKET_CRAFT_UDP, ETH_VLAN_IPv6_IPv4_GRE_PPP_IPv4_UDP_DNS)
#endif #endif
/* /*
* craft_l3_packet() * packet_build_l3()
* -> ETH->IPv4->ICMP * -> ETH->IPv4->ICMP
* -> ICMPv4 checkum not include the pseudo-header of IPv4 header * -> ICMPv4 checkum not include the pseudo-header of IPv4 header
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_L3, ETH_IP4_ICMP) TEST(PACKET_BUILD_L3, ETH_IP4_ICMP)
{ {
/* /*
* Internet Control Message Protocol * Internet Control Message Protocol
@@ -1066,7 +1066,7 @@ TEST(PACKET_CRAFT_L3, ETH_IP4_ICMP)
icmp->checksum = 0; icmp->checksum = 0;
icmp->checksum = checksum(icmp, sizeof(icmp_resp)); icmp->checksum = checksum(icmp, sizeof(icmp_resp));
struct packet *new_pkt = craft_l3_packet(&orig_pkt, IPPROTO_ICMP, (const char *)icmp_resp, sizeof(icmp_resp)); struct packet *new_pkt = packet_build_l3(&orig_pkt, IPPROTO_ICMP, (const char *)icmp_resp, sizeof(icmp_resp));
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);
@@ -1116,12 +1116,12 @@ TEST(PACKET_CRAFT_L3, ETH_IP4_ICMP)
#endif #endif
/* /*
* craft_l3_packet() * packet_build_l3()
* -> ETH->IPv4->IPv6->ICMPv6 * -> ETH->IPv4->IPv6->ICMPv6
* -> ICMPv6 checkum need include the pseudo-header of IPv6 header * -> ICMPv6 checkum need include the pseudo-header of IPv6 header
*/ */
#if 1 #if 1
TEST(PACKET_CRAFT_L3, ETH_IP6_ICMP) TEST(PACKET_BUILD_L3, ETH_IP6_ICMP)
{ {
/* /*
* Internet Control Message Protocol v6 * Internet Control Message Protocol v6
@@ -1161,7 +1161,7 @@ TEST(PACKET_CRAFT_L3, ETH_IP6_ICMP)
} }
} }
struct packet *new_pkt = craft_l3_packet(&orig_pkt, IPPROTO_ICMPV6, (const char *)icmp_resp, sizeof(icmp_resp)); struct packet *new_pkt = packet_build_l3(&orig_pkt, IPPROTO_ICMPV6, (const char *)icmp_resp, sizeof(icmp_resp));
EXPECT_TRUE(new_pkt != nullptr); EXPECT_TRUE(new_pkt != nullptr);
PRINT_GREEN("new packet:"); PRINT_GREEN("new packet:");
packet_dump_stdio(new_pkt); packet_dump_stdio(new_pkt);

View File

@@ -611,7 +611,7 @@ uint16_t stellar_get_current_thread_index()
} }
// only send user crafted packet, can't send packet which come from network // only send user crafted packet, can't send packet which come from network
void stellar_send_crafted_packet(struct stellar *st, struct packet *pkt) void stellar_send_build_packet(struct stellar *st, struct packet *pkt)
{ {
uint16_t thr_idx = stellar_get_current_thread_index(); uint16_t thr_idx = stellar_get_current_thread_index();
struct packet_io *packet_io = stellar_get_packet_io(st); struct packet_io *packet_io = stellar_get_packet_io(st);

View File

@@ -13,9 +13,6 @@ struct plugin_manager_schema *stellar_get_plugin_manager(const struct stellar *s
// TODO fix plugin manager, delete this function // TODO fix plugin manager, delete this function
void stellar_set_plugin_manger(struct stellar *st, struct plugin_manager_schema *plug_mgr); void stellar_set_plugin_manger(struct stellar *st, struct plugin_manager_schema *plug_mgr);
// only send user crafted packet, can't send packet which come from network
void stellar_send_crafted_packet(struct stellar *st, struct packet *pkt);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@@ -14,9 +14,9 @@ global:
packet_get_raw_len; packet_get_raw_len;
packet_get_payload; packet_get_payload;
packet_get_payload_len; packet_get_payload_len;
craft_tcp_packet; packet_build_tcp;
craft_udp_packet; packet_build_udp;
craft_l3_packet; packet_build_l3;
tcp_segment_get_data; tcp_segment_get_data;
tcp_segment_get_len; tcp_segment_get_len;
@@ -56,7 +56,7 @@ global:
stellar_polling_plugin_register; stellar_polling_plugin_register;
stellar_get_current_thread_index; stellar_get_current_thread_index;
stellar_get_worker_thread_num; stellar_get_worker_thread_num;
stellar_send_crafted_packet; stellar_send_build_packet;
stellar_run; stellar_run;
local: *; local: *;

View File

@@ -332,14 +332,14 @@ static void craft_and_send_udp_packet(struct stellar *st, struct session *sess,
return; return;
} }
struct packet *craft_pkt = craft_udp_packet(origin_pkt, udp_payload, udp_payload_len); struct packet *craft_pkt = packet_build_udp(origin_pkt, udp_payload, udp_payload_len);
if (craft_pkt == NULL) if (craft_pkt == NULL)
{ {
LOG_ERR("craft UDP packet failed\n"); LOG_ERR("craft UDP packet failed\n");
return; return;
} }
stellar_send_crafted_packet(st, craft_pkt); stellar_send_build_packet(st, craft_pkt);
} }
static void craft_and_send_tcp_packet(struct stellar *st, struct session *sess, struct packet_exdata *pkt_exdata, static void craft_and_send_tcp_packet(struct stellar *st, struct session *sess, struct packet_exdata *pkt_exdata,
@@ -393,14 +393,14 @@ static void craft_and_send_tcp_packet(struct stellar *st, struct session *sess,
return; return;
} }
struct packet *craft_pkt = craft_tcp_packet(origin_pkt, tcp_seq, tcp_ack, tcp_flags, NULL, 0, tcp_payload, tcp_payload_len); struct packet *craft_pkt = packet_build_tcp(origin_pkt, tcp_seq, tcp_ack, tcp_flags, NULL, 0, tcp_payload, tcp_payload_len);
if (craft_pkt == NULL) if (craft_pkt == NULL)
{ {
LOG_ERR("craft TCP packet failed\n"); LOG_ERR("craft TCP packet failed\n");
return; return;
} }
stellar_send_crafted_packet(st, craft_pkt); stellar_send_build_packet(st, craft_pkt);
} }
/****************************************************************************** /******************************************************************************