45 lines
960 B
C
45 lines
960 B
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include <arpa/inet.h>
|
|
#include "stellar/packet.h"
|
|
|
|
#define AFTER_RECV_C2S_N_PACKET 1
|
|
#define AFTER_RECV_S2C_N_PACKET 2
|
|
|
|
enum packet_inject_type
|
|
{
|
|
INJECT_TYPE_TCP_RST = 1,
|
|
INJECT_TYPE_TCP_FIN = 2,
|
|
INJECT_TYPE_TCP_PAYLOAD = 3,
|
|
INJECT_TYPE_TCP_PAYLOAD_FIN_RST = 4,
|
|
INJECT_TYPE_UDP_PAYLOAD = 5,
|
|
INJECT_TYPE_CTRL_MSG = 6,
|
|
};
|
|
|
|
struct packet_inject_rule
|
|
{
|
|
int family; /* AF_INET or AF_INET6 */
|
|
struct in_addr addr4; /* network order */
|
|
struct in6_addr addr6; /* network order */
|
|
uint16_t port; /* network order */
|
|
|
|
enum packet_inject_type inject_type;
|
|
|
|
// inject packet after (C2S/S2C) receiving n packets
|
|
int direction; // AFTER_RECV_C2S_N_PACKET or AFTER_RECV_S2C_N_PACKET
|
|
uint64_t number; // n packets received
|
|
};
|
|
|
|
extern struct packet_inject_rule rule;
|
|
|
|
int packet_inject_main(int argc, char **argv);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|