UNIX環境學習筆記------原始套接字-----IP頭部定義
原始套接字學習筆記
*/
在Linux環境下,IP頭定義如下:
struct ip
{
#if _BYTE_ORDER==_LITTLE_ENDIAN
unsigned int ip_hl: 4; /*header length */
unsigned int ip_vl: 4;/*version*/
#endif
#if _BYTE_ORDER ==_BIG_ENDIAN
unsigned int ip_v:4; /*version */
unsigned int ip_hl:4; /*header length*/
#endif
u_int8_t ip_tos; /*types of service */
u_short ip_len; /*total length*/
u_short ip_id; /*identification */
u_short ip_off; /*fragment offset field*/
#define IP_RE 0x8000 /*reserved fragment flag*/
#define IP_DF 0x4000 /*dont fragment flag*/
#define IP_MF 0x2000 /*more fragment flag */
#define IP_OFFMASK 0x1fff //mask for fragmenting bits
u_int8_t ip_ttl; /* time to live*/
u_int8_t ip_p; /*protocol*/
u_short ip_sum ; /*checksum*/
struct in_addr ip_src, ip_dst; /*source and dest ip address*/
};
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.