LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 897|回复: 1

struct icmp

[复制链接]
发表于 2004-6-10 22:15:17 | 显示全部楼层 |阅读模式
/usr/include/netinet/ip_icmp.h
  1.       21 /*
  2.       22  * Structure of an icmp header.
  3.       23  */
  4.       24 struct icmp {
  5.       25         u_char  icmp_type;              /* type of message, see below */
  6.       26         u_char  icmp_code;              /* type sub code */
  7.       27         u_short icmp_cksum;             /* ones complement cksum of struct */
  8.       28         union {
  9.       29                 u_char ih_pptr;                 /* ICMP_PARAMPROB */
  10.       30                 struct in_addr ih_gwaddr;       /* ICMP_REDIRECT */
  11.       31                 struct ih_idseq {
  12.       32                         n_short icd_id;
  13.       33                         n_short icd_seq;
  14.       34                 } ih_idseq;
  15.       35                 int ih_void;
  16.       36
  17.       37                 /* ICMP_UNREACH_NEEDFRAG -- Path MTU Discovery (RFC1191) */
  18.       38                 struct ih_pmtu {
  19.       39                         n_short ipm_void;
  20.       40                         n_short ipm_nextmtu;
  21.       41                 } ih_pmtu;
  22.       42
  23.       43                 struct ih_rtradv {
  24.       44                         u_char irt_num_addrs;
  25.       45                         u_char irt_wpa;
  26.       46                         u_int16_t irt_lifetime;
  27.       47                 } ih_rtradv;
  28.       48         } icmp_hun;
  29.       49 #define icmp_pptr       icmp_hun.ih_pptr
  30.       50 #define icmp_gwaddr     icmp_hun.ih_gwaddr
  31.       51 #define icmp_id         icmp_hun.ih_idseq.icd_id
  32.       52 #define icmp_seq        icmp_hun.ih_idseq.icd_seq
  33.       53 #define icmp_void       icmp_hun.ih_void
  34.       54 #define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
  35.       55 #define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
  36.       56 #define icmp_num_addrs  icmp_hun.ih_rtradv.irt_num_addrs
  37.       57 #define icmp_wpa        icmp_hun.ih_rtradv.irt_wpa
  38.       45                         u_char irt_wpa;
  39.       46                         u_int16_t irt_lifetime;
  40.       47                 } ih_rtradv;
  41.       47                 } ih_rtradv;
  42.       48         } icmp_hun;
  43.       49 #define icmp_pptr       icmp_hun.ih_pptr
  44.       50 #define icmp_gwaddr     icmp_hun.ih_gwaddr
  45.       51 #define icmp_id         icmp_hun.ih_idseq.icd_id
  46.       52 #define icmp_seq        icmp_hun.ih_idseq.icd_seq
  47.       53 #define icmp_void       icmp_hun.ih_void
  48.       54 #define icmp_pmvoid     icmp_hun.ih_pmtu.ipm_void
  49.       55 #define icmp_nextmtu    icmp_hun.ih_pmtu.ipm_nextmtu
  50.       56 #define icmp_num_addrs  icmp_hun.ih_rtradv.irt_num_addrs
  51.       57 #define icmp_wpa        icmp_hun.ih_rtradv.irt_wpa
  52.       58 #define icmp_lifetime   icmp_hun.ih_rtradv.irt_lifetime
  53.       59         union {
  54.       60                 struct id_ts {
  55.       61                         n_time its_otime;
  56.       62                         n_time its_rtime;
  57.       63                         n_time its_ttime;
  58.       64                 } id_ts;
  59.       65                 struct id_ip  {
  60.       66                         struct ip idi_ip;
  61.       67                         /* options and then 64 bits of data */
  62.       68                 } id_ip;
  63.       69                 struct icmp_ra_addr id_radv;
  64.       70                 u_int32_t id_mask;
  65.       71                 char    id_data[1];
  66.       72         } icmp_dun;
  67.       73 #define icmp_otime      icmp_dun.id_ts.its_otime
  68.       74 #define icmp_rtime      icmp_dun.id_ts.its_rtime
  69.       75 #define icmp_ttime      icmp_dun.id_ts.its_ttime
  70.       76 #define icmp_ip         icmp_dun.id_ip.idi_ip
  71.       77 #define icmp_radv       icmp_dun.id_radv
  72.       78 #define icmp_mask       icmp_dun.id_mask
  73.       79 #define icmp_data       icmp_dun.id_data
  74.       80 };
复制代码
 楼主| 发表于 2004-6-10 23:50:06 | 显示全部楼层
  1. /*
  2. * Structure of an internet header, naked of options.
  3. */
  4. struct ip {
  5. #ifdef _IP_VHL
  6.         u_char  ip_vhl;                 /* version << 4 | header length >> 2 */
  7. #else
  8. #if BYTE_ORDER == LITTLE_ENDIAN
  9.         u_int   ip_hl:4,                /* header length */
  10.                 ip_v:4;                 /* version */
  11. #endif
  12. #if BYTE_ORDER == BIG_ENDIAN
  13.         u_int   ip_v:4,                 /* version */
  14.                 ip_hl:4;                /* header length */
  15. #endif
  16. #endif /* not _IP_VHL */
  17.         u_char  ip_tos;                 /* type of service */
  18.         u_short ip_len;                 /* total length */
  19.         u_short ip_id;                  /* identification */
  20.         u_short ip_off;                 /* fragment offset field */
  21. #define IP_RF 0x8000                    /* reserved fragment flag */
  22. #define IP_DF 0x4000                    /* dont fragment flag */
  23. #define IP_MF 0x2000                    /* more fragments flag */
  24. #define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
  25.         u_char  ip_ttl;                 /* time to live */
  26.         u_char  ip_p;                   /* protocol */
  27.         u_short ip_sum;                 /* checksum */
  28.         struct  in_addr ip_src,ip_dst;  /* source and dest address */
  29. };
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表