socket 各種頭數(shù)據(jù)結(jié)構(gòu)及簡(jiǎn)要說(shuō)明
發(fā)布者: 許超 發(fā)表日期: 2006-06-12 18:44:51.153 原作者: supermgr
socket 各種頭數(shù)據(jù)結(jié)構(gòu),及簡(jiǎn)要說(shuō)明。
//DATATYPE
typedef signed char int8;
typedef signed short int16;
typedef signed long int32;
typedef signed long long int64;
typedef unsigned int uint;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned long uint32;
typedef unsigned long long uint64;
typedef float float32;
typedef double float64;
typedef wchar_t wchar;
//typedef void* ptr;
typedef int32 boolen;
//IP 頭結(jié)構(gòu)
typedef
struct _x_iphdr
{
uint8 ver; //4 位頭結(jié)構(gòu)長(zhǎng)度 ,4 位 IP 版本號(hào)
uint8 tos; //8 位服務(wù)類型 TOS
uint16 len; //16 位總長(zhǎng)度(字節(jié))
uint16 ident; //16 位數(shù)據(jù)包標(biāo)識(shí)
uint16 frag; //3 位標(biāo)志位 /13 位偏移地址
uint8 ttl; //8 位生存時(shí)間 TTL (生命期)
uint8 proto; //8 位協(xié)議 (TCP, UDP 或其他 )
uint16 sum; //16 位 IP 頭結(jié)構(gòu)校驗(yàn)和
uint32 srcip; //32 位源 IP 地址
uint32 dstip; //32 位目的 IP 地址
}x_iphdr;
//TCP 偽頭結(jié)構(gòu)
typedef
struct _x_tcphdrpsd
{
uint32 saddr; // 源地址
uint32 daddr; // 目的地址
uint8 mbz; // 沒用
uint8 proto; // 協(xié)議類型
uint16 tcpl; //TCP 長(zhǎng)度
}x_tcphdrpsd;
//TCP 頭結(jié)構(gòu)
typedef
struct _x_tcphdr
{
uint16 sport; //16 位源端口
uint16 dport; //16 位目的端口
uint32 seq; //32 位序列號(hào)
uint32 ack; //32 位確認(rèn)號(hào)
uint8 len; //4 位頭結(jié)構(gòu)長(zhǎng)度 /6 位保留字
uint8 flag; //6 位標(biāo)志位 (控制用)
uint16 win; //16 位窗口大小
uint16 sum; //16 位 TCP 校驗(yàn)和
uint16 urp; //16 位緊急數(shù)據(jù)偏移量
}x_tcphdr;
//UDP 頭結(jié)構(gòu)
typedef
struct _x_udphdr
{
uint16 sport; //16 位源端口
uint16 dport; //16 位目的端口
uint16 len; //16 位長(zhǎng)度
uint16 sum; //16 位校驗(yàn)和
}x_udphdr;
//ICMP 頭結(jié)構(gòu)
typedef
struct _x_icmphdr
{
uint8 type; //8 位類型
uint8 code; //8 位代碼
uint16 cksum; //16 位校驗(yàn)和
uint16 ident; // 識(shí)別號(hào)(一般用進(jìn)程號(hào)作為識(shí)別號(hào))
uint16 seq; // 報(bào)文序列號(hào)
uint32 tamp; // 時(shí)間戳
}x_icmphdr;
//IGMP 頭結(jié)構(gòu)
typedef
struct _x_igmphdr
{
uint8 code; //8 位代碼
uint8 type; //8 位類型
uint16 res; // 沒用
uint16 cksum; //16 位校驗(yàn)和
uint32 addr; //32 位組地址
}x_igmphdr;
posted on 2007-01-11 23:16
frank.sunny 閱讀(1645)
評(píng)論(1) 編輯 收藏 引用 所屬分類:
概念掃盲