#ifndef _CONSTRUCT_PACKET_H #define _CONSTRUCT_PACKET_H #ifdef __cpluscplus extern "C" { #endif #include #include #define TCP_URG_FLAG 0x20 #define TCP_ACK_FLAG 0x10 #define TCP_PSH_FLAG 0x08 #define TCP_RST_FLAG 0x04 #define TCP_SYN_FLAG 0x02 #define TCP_FIN_FLAG 0x01 #define TCP_FLAG_ALL 0x3F int tcp_header_construct(char *buffer, uint16_t src_port, uint16_t dst_port, uint32_t seq, uint32_t ack, u_char flags, uint16_t window, uint16_t urgent, const char *options, uint16_t options_len); int ipv4_header_construct(char *buffer, uint16_t carry_layer_len, struct in_addr *src_addr, struct in_addr *dst_addr, u_char tos, uint16_t id, uint16_t frag, u_char ttl, u_char protocol); int ipv6_header_construct(char *buffer, uint16_t carry_layer_len, struct in6_addr *src_addr, struct in6_addr *dst_addr, u_char ttl, u_char protocol); int vlan_header_construct(char *buffer, uint16_t tci, uint16_t type); int ether_header_construct(char *buffer, struct ether_addr *src_mac, struct ether_addr *dst_mac, uint16_t type); int tcp_packet_v4_construct( char *buffer, // buffer struct ether_addr *src_mac, struct ether_addr *dst_mac, uint16_t vlan_tci, uint16_t l3_protocol, // Ether struct in_addr *src_addr, struct in_addr *dst_addr, u_char tos, u_char ttl, uint16_t id, // IPv4 uint16_t src_port, uint16_t dst_port, uint32_t seq, uint32_t ack, u_char flags, uint16_t window, // TCP Header const char *tcp_options, uint16_t tcp_options_len, // TCP Options const char *payload, uint16_t payload_len); // Payload int tcp_packet_v6_construct( char *buffer, // buffer struct ether_addr *src_mac, struct ether_addr *dst_mac, uint16_t vlan_tci, uint16_t l3_protocol, // Ether struct in6_addr *src_addr, struct in6_addr *dst_addr, u_char ttl, // IPv6 uint16_t src_port, uint16_t dst_port, uint32_t seq, uint32_t ack, u_char flags, uint16_t window, // TCP Header const char *tcp_options, uint16_t tcp_options_len, // TCP Options const char *payload, uint16_t payload_len); // Payload #ifdef __cpluscplus } #endif #endif