Take IP header

xiaoxiao2021-03-06  85

TypedEf struct _ip_header

{

Unsigned char ip_verlen; // 4-bit ipv4 version

// 4-bit header Length (in 32-bit words)

Unsigned char ip_tos; // ip type of service

Unsigned short ip_totallength; // Total Length

UNSIGNED Short IP_ID; // Unique Identifier

Unsigned short ip_offset; // fragment offset field

Unsigned char ip_ttl; // time to live

Unsigned char ip_protocol; // protocol (TCP, UDP ETC)

Unsigned short ip_checksum; // ip checksum

Unsigned int ip_srcaddr; // source address

Unsigned int ip_destaddr; // source address

} Ip_header;

An example of a fill, the first unsigned char is 4-bit 4 points

IP_HEADER.IP_VERLEN = (4 << 4 | sizeof (ip_header) / sizeof (unsigned long);

IP_HEADER.IP_TOS = 0;

IP_HEADER.IP_TOTALLENGTH = HTONS (sizeof (ip_header) 20);

IP_HEADER.IP_ID = 0;

IP_HEADER.IP_OFFSET = 0;

IP_HEADER.IP_TTL = 255;

IP_HEADER.IP_PROTOCOL = ipproto_ICMP;

IP_HEADER.IP_SRCADDR = INET_ADDR ("202.198.169.128");

IP_HEADER.IP_DESTADDR = INET_ADDR ("202.198.169.255);

转载请注明原文地址:https://www.9cbs.com/read-107249.html

New Post(0)