#pragma pack(1)
#define ETH_ALEN 6
struct ethhdr_t {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
unsigned char h_source[ETH_ALEN]; /* source ether addr */
unsigned short h_proto; /* packet type ID field */
} __attribute__((packed));
struct iphdr_t {
unsigned char version:4, /* Version (4 digits) */
ihl:4; /* The head length (4 digits) */
unsigned char tos; /* Service Type Field (8-bit) */
unsigned short tot_len; /* The total length field (16) */
unsigned short id; /* Identification field (16bit) */
unsigned short frag_off; /* The Fragment Offset domain indicates what location in the current datagram */
unsigned char ttl; /* TTL (TIME TO LIVE) 8-bit */
unsigned char protocol; /* Protocol field (8 digits) */
unsigned short check; /* The header checksum field (16) */
unsigned int saddr; /* 32 source IP address */
unsigned int daddr; /* 32-bit IP address */
};
struct udphdr_t {
unsigned short source; /* 16-bit source port */
unsigned short dest; /* 16-bit destination port */
unsigned short len; /* Represents the length, 16 bits of the data reported */
unsigned short check; /* Check and verify */
};
struct udppkt_t {
struct ethhdr_t ethhdr;
struct iphdr_t iphdr;
struct udphdr_t udphdr;
unsigned char userdata[0];
};