feature: support crafting L3 packets with L3 payload
This commit is contained in:
@@ -56,15 +56,16 @@ struct layer
|
||||
uint16_t hdr_len;
|
||||
union
|
||||
{
|
||||
struct ethhdr *eth;
|
||||
struct ip *ip4;
|
||||
struct ip6_hdr *ip6;
|
||||
struct tcphdr *tcp;
|
||||
struct udphdr *udp;
|
||||
struct icmphdr *icmp4;
|
||||
struct icmp6_hdr *icmp6;
|
||||
struct mpls_label *mpls;
|
||||
char *raw;
|
||||
// all hdr ptr refer to raw packet, read-only
|
||||
const struct ethhdr *eth;
|
||||
const struct ip *ip4;
|
||||
const struct ip6_hdr *ip6;
|
||||
const struct tcphdr *tcp;
|
||||
const struct udphdr *udp;
|
||||
const struct icmphdr *icmp4;
|
||||
const struct icmp6_hdr *icmp6;
|
||||
const struct mpls_label *mpls;
|
||||
const char *raw; // e.g. pppoe, l2tp, gre, gtp, etc.
|
||||
} hdr;
|
||||
};
|
||||
|
||||
|
||||
@@ -42,10 +42,10 @@ uint16_t packet_get_payload_len(const struct packet *pkt);
|
||||
* 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);
|
||||
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_packet_from_scratch(const struct layer larers[], uint16_t layer_count, const char *payload, uint16_t 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 tcp_segment;
|
||||
const char *tcp_segment_get_data(const struct tcp_segment *seg);
|
||||
|
||||
Reference in New Issue
Block a user