diff options
| author | luwenpeng <[email protected]> | 2024-09-02 17:49:33 +0800 |
|---|---|---|
| committer | luwenpeng <[email protected]> | 2024-09-02 17:49:33 +0800 |
| commit | a8206cffc0ba55c6cb2b0b1054860ee28ec4a0b8 (patch) | |
| tree | 5e3e8b2a01fc3e3f54e3bcb85b1afbfcedeec209 /test | |
| parent | f8ec4dc5a74547ac9f36f38952a21df031c7469e (diff) | |
rename flow_direction to flow_type
Diffstat (limited to 'test')
10 files changed, 66 insertions, 66 deletions
diff --git a/test/debug_plugin/debug_plugin.c b/test/debug_plugin/debug_plugin.c index 951eea6..50c8bc4 100644 --- a/test/debug_plugin/debug_plugin.c +++ b/test/debug_plugin/debug_plugin.c @@ -146,7 +146,7 @@ static void on_sess_udp_msg(struct session *sess, int topic_id, const void *msg, const struct timeval *tv = packet_get_timeval(pkt); struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx; struct session_exdata *exdata = (struct session_exdata *)session_exdata_get(sess, ctx->sess_exdata_idx); - if (session_get_current_flow_direction(sess) == FLOW_DIRECTION_C2S) + if (session_get_flow_type(sess) == FLOW_TYPE_C2S) { exdata->c2s_rx_pkts++; exdata->c2s_rx_bytes += packet_get_raw_len(pkt); @@ -182,7 +182,7 @@ static void on_sess_tcp_msg(struct session *sess, int topic_id, const void *msg, const struct timeval *tv = packet_get_timeval(pkt); struct plugin_ctx *ctx = (struct plugin_ctx *)plugin_ctx; struct session_exdata *exdata = (struct session_exdata *)session_exdata_get(sess, ctx->sess_exdata_idx); - if (session_get_current_flow_direction(sess) == FLOW_DIRECTION_C2S) + if (session_get_flow_type(sess) == FLOW_TYPE_C2S) { exdata->c2s_rx_pkts++; exdata->c2s_rx_bytes += packet_get_raw_len(pkt); @@ -225,7 +225,7 @@ static void on_sess_tcp_stream_msg(struct session *sess, int topic_id, const voi debug_plugin_log(ctx->fd, "debug plugin", "on TCP stream msg: %s", buff); pthread_spin_lock(&ctx->lock); - if (session_get_current_flow_direction(sess) == FLOW_DIRECTION_C2S) + if (session_get_flow_type(sess) == FLOW_TYPE_C2S) { debug_plugin_log(ctx->fd, "debug plugin", "rx C2S TCP segment: len: %d, data: %p", len, data); hexdump_to_fd(ctx->fd, exdata->c2s_rx_tcp_bytes, data, len); diff --git a/test/decoders/http/http_test_plug.cpp b/test/decoders/http/http_test_plug.cpp index 1370b70..d91b552 100644 --- a/test/decoders/http/http_test_plug.cpp +++ b/test/decoders/http/http_test_plug.cpp @@ -607,10 +607,10 @@ extern "C" void http_decoder_tunnel_entry(struct session *sess, int topic_id, co case HTTP_TUNNEL_ACTIVE: { - enum flow_direction curdir = session_get_current_flow_direction(sess); + enum flow_type curdir = session_get_flow_type(sess); hstring tunnel_payload = {}; http_tunnel_message_get_payload((const struct http_tunnel_message *)raw_msg, &tunnel_payload); - if (FLOW_DIRECTION_C2S == curdir) + if (FLOW_TYPE_C2S == curdir) { req_payload_block++; req_payload_size += tunnel_payload.iov_len; diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_c2s_first_payload.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_c2s_first_payload.toml index 3fd45b7..8f4a067 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_c2s_first_payload.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_c2s_first_payload.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = C2S # eg: C2S, S2C +flow_type = C2S # eg: C2S, S2C filter_pkts = 3 # can not be 0 inject_type = TCP-PAYLOAD # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_s2c_first_payload.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_s2c_first_payload.toml index 86858b3..62222df 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_s2c_first_payload.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_payload_after_recv_s2c_first_payload.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = S2C # eg: C2S, S2C +flow_type = S2C # eg: C2S, S2C filter_pkts = 3 # can not be 0 inject_type = TCP-PAYLOAD # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_payload_fin_rst_after_recv_c2s_first_payload.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_payload_fin_rst_after_recv_c2s_first_payload.toml index 6fa47ea..2933636 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_payload_fin_rst_after_recv_c2s_first_payload.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_payload_fin_rst_after_recv_c2s_first_payload.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = C2S # eg: C2S, S2C +flow_type = C2S # eg: C2S, S2C filter_pkts = 3 # can not be 0 inject_type = TCP-PAYLOAD-FIN-RST # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload.toml index 5b5f58b..5390f35 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_c2s_first_payload.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = C2S # eg: C2S, S2C +flow_type = C2S # eg: C2S, S2C filter_pkts = 3 # can not be 0 inject_type = TCP-RST # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload.toml index 5c7115a..238e230 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_s2c_first_payload.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = S2C # eg: C2S, S2C +flow_type = S2C # eg: C2S, S2C filter_pkts = 3 # can not be 0 inject_type = TCP-RST # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_sub_ack.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_sub_ack.toml index 321bfbb..25263f6 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_sub_ack.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_sub_ack.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = C2S # eg: C2S, S2C +flow_type = C2S # eg: C2S, S2C filter_pkts = 2 # can not be 0 inject_type = TCP-RST # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_syn_ack.toml b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_syn_ack.toml index 839b17b..3c7b20f 100644 --- a/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_syn_ack.toml +++ b/test/packet_inject/conf/inject_ipv4_based_tcp_rst_after_recv_syn_ack.toml @@ -2,6 +2,6 @@ [packet_inject] filter_ip = any # eg: 2001:db8::1, 192.168.1.100, any filter_port = 0 # eg: 80, 443 (0 for any) -filter_dir = S2C # eg: C2S, S2C +flow_type = S2C # eg: C2S, S2C filter_pkts = 1 # can not be 0 inject_type = TCP-RST # eg: TCP-RST, TCP-FIN, TCP-PAYLOAD, TCP-PAYLOAD-FIN-RST, UDP-PAYLOAD, CTRL-MSG diff --git a/test/packet_inject/packet_inject.c b/test/packet_inject/packet_inject.c index 6a24311..260babd 100644 --- a/test/packet_inject/packet_inject.c +++ b/test/packet_inject/packet_inject.c @@ -36,9 +36,9 @@ struct config struct sockaddr_in6 v6; } addr; uint16_t port; - uint64_t number; // inject packet after (C2S/S2C) direction receiving n packets - enum inject_type type; - enum flow_direction direction; + uint64_t number; // inject packet after (C2S/S2C) flow_type receiving n packets + enum inject_type inject_type; + enum flow_type flow_type; }; struct inject_plugin_ctx @@ -53,7 +53,7 @@ struct inject_plugin_ctx struct packet_exdata { - enum flow_direction flow_dir; + enum flow_type flow_type; union { @@ -161,23 +161,23 @@ static int load_config(struct logger *logger, struct config *config, const char } config->port = atoi(ptr); - ptr = toml_raw_in(sub, "filter_dir"); + ptr = toml_raw_in(sub, "flow_type"); if (ptr == NULL) { - INJTECT_PLUGIN_LOG_ERROR(logger, "config file missing packet_inject->filter_dir"); + INJTECT_PLUGIN_LOG_ERROR(logger, "config file missing packet_inject->flow_type"); goto error_out; } if (strcmp(ptr, "C2S") == 0) { - config->direction = FLOW_DIRECTION_C2S; + config->flow_type = FLOW_TYPE_C2S; } else if (strcmp(ptr, "S2C") == 0) { - config->direction = FLOW_DIRECTION_S2C; + config->flow_type = FLOW_TYPE_S2C; } else { - INJTECT_PLUGIN_LOG_ERROR(logger, "parse packet_inject->filter_dir failed, invalid direction: %s", ptr); + INJTECT_PLUGIN_LOG_ERROR(logger, "parse packet_inject->flow_type failed, invalid flow_type: %s", ptr); goto error_out; } @@ -202,31 +202,31 @@ static int load_config(struct logger *logger, struct config *config, const char } if (strcmp(ptr, "TCP-RST") == 0) { - config->type = INJECT_TCP_RST; + config->inject_type = INJECT_TCP_RST; } else if (strcmp(ptr, "TCP-FIN") == 0) { - config->type = INJECT_TCP_FIN; + config->inject_type = INJECT_TCP_FIN; } else if (strcmp(ptr, "TCP-PAYLOAD") == 0) { - config->type = INJECT_TCP_PAYLOAD; + config->inject_type = INJECT_TCP_PAYLOAD; } else if (strcmp(ptr, "TCP-PAYLOAD-FIN-RST") == 0) { - config->type = INJECT_TCP_PAYLOAD_FIN_RST; + config->inject_type = INJECT_TCP_PAYLOAD_FIN_RST; } else if (strcmp(ptr, "UDP-PAYLOAD") == 0) { - config->type = INJECT_UDP_PAYLOAD; + config->inject_type = INJECT_UDP_PAYLOAD; } else if (strcmp(ptr, "CTRL-MSG") == 0) { - config->type = INJECT_CTRL_MSG; + config->inject_type = INJECT_CTRL_MSG; } else { - INJTECT_PLUGIN_LOG_ERROR(logger, "parse packet_inject->inject_type failed, invalid inject type: %s", ptr); + INJTECT_PLUGIN_LOG_ERROR(logger, "parse packet_inject->inject_type failed, invalid inject_type: %s", ptr); goto error_out; } @@ -265,20 +265,20 @@ static void print_config(struct logger *logger, const struct config *config) INJTECT_PLUGIN_LOG_INFO(logger, "config->filter_ip : %s", addr_str); INJTECT_PLUGIN_LOG_INFO(logger, "config->filter_port : %d", config->port); - INJTECT_PLUGIN_LOG_INFO(logger, "config->filter_dir : %s", config->direction == FLOW_DIRECTION_C2S ? "C2S" : "S2C"); + INJTECT_PLUGIN_LOG_INFO(logger, "config->flow_type : %s", config->flow_type == FLOW_TYPE_C2S ? "C2S" : "S2C"); INJTECT_PLUGIN_LOG_INFO(logger, "config->filter_pkts : %lu", config->number); - INJTECT_PLUGIN_LOG_INFO(logger, "config->inject_type : %s", type_to_str(config->type)); + INJTECT_PLUGIN_LOG_INFO(logger, "config->inject_type : %s", type_to_str(config->inject_type)); } /****************************************************************************** * Utils ******************************************************************************/ -static inline void packet_exdata_init(const struct packet *pkt, enum flow_direction dir, struct packet_exdata *pkt_exdata) +static inline void packet_exdata_init(const struct packet *pkt, enum flow_type type, struct packet_exdata *pkt_exdata) { memset(pkt_exdata, 0, sizeof(struct packet_exdata)); - pkt_exdata->flow_dir = dir; + pkt_exdata->flow_type = type; int get_inner_addr = 0; int count = packet_get_layer_count(pkt); @@ -335,12 +335,12 @@ static inline uint32_t uint32_add(uint32_t seq, uint32_t inc) } static void build_and_send_udp_packet(struct inject_plugin_ctx *ctx, struct session *sess, struct packet_exdata *pkt_exdata, - enum flow_direction inject_dir, const char *udp_payload, uint16_t udp_payload_len) + enum flow_type type, const char *udp_payload, uint16_t udp_payload_len) { - const struct packet *origin_pkt = session_get_first_packet(sess, inject_dir); + const struct packet *origin_pkt = session_get_first_packet(sess, type); if (origin_pkt == NULL) { - INJTECT_PLUGIN_LOG_ERROR(ctx->logger, "build UDP packet failed, %s origin packet is NULL", inject_dir == FLOW_DIRECTION_C2S ? "C2S" : "S2C"); + INJTECT_PLUGIN_LOG_ERROR(ctx->logger, "build UDP packet failed, %s origin packet is NULL", type == FLOW_TYPE_C2S ? "C2S" : "S2C"); return; } @@ -355,7 +355,7 @@ static void build_and_send_udp_packet(struct inject_plugin_ctx *ctx, struct sess } static void build_and_send_tcp_packet(struct inject_plugin_ctx *ctx, struct session *sess, struct packet_exdata *pkt_exdata, - enum flow_direction inject_dir, uint8_t tcp_flags, const char *tcp_payload, uint16_t tcp_payload_len) + enum flow_type type, uint8_t tcp_flags, const char *tcp_payload, uint16_t tcp_payload_len) { uint32_t tcp_seq = 0; uint32_t tcp_ack = 0; @@ -369,11 +369,11 @@ static void build_and_send_tcp_packet(struct inject_plugin_ctx *ctx, struct sess * * for example: current packet is C2S * - * inject direction == current direction (inject C2S RST) + * inject flow_type == current flow_type (inject C2S RST) * tcp_seq = current_packet_seq * tcp_ack = current_packet_ack * - * inject direction != current direction (inject S2C RST) + * inject flow_type != current flow_type (inject S2C RST) * tcp_seq = current_packet_ack * tcp_ack = current_packet_seq + current_packet_payload_len * or if current packet is a SYN-ACK packet @@ -381,7 +381,7 @@ static void build_and_send_tcp_packet(struct inject_plugin_ctx *ctx, struct sess * tcp_ack = current_packet_ack + current_packet_payload_len + 1 */ - if (inject_dir == pkt_exdata->flow_dir) + if (type == pkt_exdata->flow_type) { tcp_seq = uint32_add(pkt_exdata->tcp_seq, pkt_exdata->inc_seq); tcp_ack = pkt_exdata->tcp_ack; @@ -398,10 +398,10 @@ static void build_and_send_tcp_packet(struct inject_plugin_ctx *ctx, struct sess pkt_exdata->inc_ack += (tcp_flags & TH_FIN) ? 1 : 0; // inject RST packer after FIN packer, ack should be increased by 1 } - const struct packet *origin_pkt = session_get_first_packet(sess, inject_dir); + const struct packet *origin_pkt = session_get_first_packet(sess, type); if (origin_pkt == NULL) { - INJTECT_PLUGIN_LOG_ERROR(ctx->logger, "build TCP packet failed, %s origin packet is NULL", inject_dir == FLOW_DIRECTION_C2S ? "C2S" : "S2C"); + INJTECT_PLUGIN_LOG_ERROR(ctx->logger, "build TCP packet failed, %s origin packet is NULL", type == FLOW_TYPE_C2S ? "C2S" : "S2C"); return; } @@ -443,14 +443,14 @@ static void on_sess_msg(struct session *sess, int topic_id, const void *msg, voi struct packet *pkt = (struct packet *)msg; struct inject_plugin_ctx *ctx = (struct inject_plugin_ctx *)plugin_ctx; struct config *config = &ctx->config; - enum flow_direction flow_dir = session_get_current_flow_direction(sess); + enum flow_type type = session_get_flow_type(sess); INJTECT_PLUGIN_LOG_INFO(ctx->logger, "handle session msg: %s (C2S received packets: %lu, S2C received packets: %lu)", session_get0_readable_addr(sess), - session_get_stat(sess, FLOW_DIRECTION_C2S, STAT_RAW_PACKETS_RECEIVED), - session_get_stat(sess, FLOW_DIRECTION_S2C, STAT_RAW_PACKETS_RECEIVED)); + session_get_stat(sess, FLOW_TYPE_C2S, STAT_RAW_PACKETS_RECEIVED), + session_get_stat(sess, FLOW_TYPE_S2C, STAT_RAW_PACKETS_RECEIVED)); struct packet_exdata pkt_exdata; - packet_exdata_init(pkt, flow_dir, &pkt_exdata); + packet_exdata_init(pkt, type, &pkt_exdata); if (config->family == AF_INET && memcmp(&config->addr.v4, &pkt_exdata.src_addr.v4, sizeof(struct in_addr)) != 0 && @@ -473,55 +473,55 @@ static void on_sess_msg(struct session *sess, int topic_id, const void *msg, voi return; } - if (session_get_stat(sess, FLOW_DIRECTION_C2S, STAT_INJECTED_PACKETS_SUCCESS) > 0 || - session_get_stat(sess, FLOW_DIRECTION_S2C, STAT_INJECTED_PACKETS_SUCCESS) > 0) + if (session_get_stat(sess, FLOW_TYPE_C2S, STAT_INJECTED_PACKETS_SUCCESS) > 0 || + session_get_stat(sess, FLOW_TYPE_S2C, STAT_INJECTED_PACKETS_SUCCESS) > 0) { return; } - if (config->direction == FLOW_DIRECTION_C2S && session_get_stat(sess, FLOW_DIRECTION_C2S, STAT_RAW_PACKETS_RECEIVED) != config->number) + if (config->flow_type == FLOW_TYPE_C2S && session_get_stat(sess, FLOW_TYPE_C2S, STAT_RAW_PACKETS_RECEIVED) != config->number) { return; } - if (config->direction == FLOW_DIRECTION_S2C && session_get_stat(sess, FLOW_DIRECTION_S2C, STAT_RAW_PACKETS_RECEIVED) != config->number) + if (config->flow_type == FLOW_TYPE_S2C && session_get_stat(sess, FLOW_TYPE_S2C, STAT_RAW_PACKETS_RECEIVED) != config->number) { return; } - switch (config->type) + switch (config->inject_type) { case INJECT_TCP_RST: - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_C2S, TH_RST | TH_ACK, NULL, 0); - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_RST | TH_ACK, NULL, 0); + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_C2S, TH_RST | TH_ACK, NULL, 0); + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_RST | TH_ACK, NULL, 0); session_set_discard(sess); break; case INJECT_TCP_FIN: - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_C2S, TH_FIN | TH_ACK, NULL, 0); - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_FIN | TH_ACK, NULL, 0); + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_C2S, TH_FIN | TH_ACK, NULL, 0); + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_FIN | TH_ACK, NULL, 0); session_set_discard(sess); break; case INJECT_TCP_PAYLOAD: snprintf(buffer, sizeof(buffer), "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s", 5 + 5 + 2, "Hello"); - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_ACK, buffer, strlen(buffer)); // inject payload to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_ACK, "World\r\n", 7); // inject payload to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_RST | TH_ACK, NULL, 0); // inject RST to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_C2S, TH_RST | TH_ACK, NULL, 0); // inject RST to server + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_ACK, buffer, strlen(buffer)); // inject payload to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_ACK, "World\r\n", 7); // inject payload to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_RST | TH_ACK, NULL, 0); // inject RST to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_C2S, TH_RST | TH_ACK, NULL, 0); // inject RST to server session_set_discard(sess); break; case INJECT_TCP_PAYLOAD_FIN_RST: snprintf(buffer, sizeof(buffer), "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s", 5 + 5 + 2, "Hello"); - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_ACK, buffer, strlen(buffer)); // inject payload to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_ACK, "World\r\n", 7); // inject payload to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_FIN | TH_ACK, NULL, 0); // inject FIN to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, TH_RST | TH_ACK, NULL, 0); // inject RST to client - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_C2S, TH_FIN | TH_ACK, NULL, 0); // inject FIN to server - build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_C2S, TH_RST | TH_ACK, NULL, 0); // inject RST to server + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_ACK, buffer, strlen(buffer)); // inject payload to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_ACK, "World\r\n", 7); // inject payload to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_FIN | TH_ACK, NULL, 0); // inject FIN to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, TH_RST | TH_ACK, NULL, 0); // inject RST to client + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_C2S, TH_FIN | TH_ACK, NULL, 0); // inject FIN to server + build_and_send_tcp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_C2S, TH_RST | TH_ACK, NULL, 0); // inject RST to server session_set_discard(sess); break; case INJECT_UDP_PAYLOAD: - build_and_send_udp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_C2S, "Hello Server", 12); - build_and_send_udp_packet(ctx, sess, &pkt_exdata, FLOW_DIRECTION_S2C, "Hello Client", 12); + build_and_send_udp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_C2S, "Hello Server", 12); + build_and_send_udp_packet(ctx, sess, &pkt_exdata, FLOW_TYPE_S2C, "Hello Client", 12); session_set_discard(sess); break; case INJECT_CTRL_MSG: |
