home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Networking / fping-2.2b1-MIHS / src / linux.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-08  |  3.9 KB  |  134 lines

  1. /*
  2. ** Special compatibility definitions for linux.
  3. **
  4. **    On the linux platform, several IP-related structures have
  5. **    different names. Also some of the structure fields have
  6. **    other names, although the layout is (obviously) fixed.
  7. **    Several constants are not defined in the standard files.
  8. **
  9. **    @(#)linux.h             e07@nikhef.nl (Eric Wassenaar) 960301
  10. */
  11.  
  12. #if defined(linux)
  13.  
  14. #include <endian.h>        /* to get the proper BYTE_ORDER */
  15.  
  16. #if !defined(BYTE_ORDER) || (BYTE_ORDER != BIG_ENDIAN && \
  17.      BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != PDP_ENDIAN)
  18. error "Undefined or invalid BYTE_ORDER";
  19. #endif
  20.  
  21. /*
  22.  * Structure of an ip header, without options.
  23.  */
  24.  
  25. #define    IPVERSION    4
  26.  
  27. struct ip {
  28. #if (BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN)
  29.     u_char    ip_hl:4,        /* header length */
  30.         ip_v:4;            /* version */
  31. #else
  32.     u_char    ip_v:4,            /* version */
  33.         ip_hl:4;        /* header length */
  34. #endif
  35.     u_char    ip_tos;            /* type of service */
  36.     short    ip_len;            /* total length */
  37.     u_short    ip_id;            /* identification */
  38.     short    ip_off;            /* fragment offset field */
  39. #define    IP_DF 0x4000            /* dont fragment flag */
  40. #define    IP_MF 0x2000            /* more fragments flag */
  41.     u_char    ip_ttl;            /* time to live */
  42.     u_char    ip_p;            /* protocol */
  43.     u_short    ip_sum;            /* checksum */
  44.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  45. };
  46.  
  47. #define    IP_MAXPACKET    65535        /* maximum packet size */
  48.  
  49. /*
  50.  * Structure of an icmp header.
  51.  */
  52.  
  53. struct icmp {
  54.     u_char    icmp_type;        /* type of message, see below */
  55.     u_char    icmp_code;        /* type sub code */
  56.     u_short    icmp_cksum;        /* ones complement cksum of struct */
  57.     union {
  58.         u_char ih_pptr;            /* ICMP_PARAMPROB */
  59.         struct in_addr ih_gwaddr;    /* ICMP_REDIRECT */
  60.         struct ih_idseq {
  61.             n_short    icd_id;
  62.             n_short    icd_seq;
  63.         } ih_idseq;
  64.         int ih_void;
  65.     } icmp_hun;
  66. #define    icmp_pptr    icmp_hun.ih_pptr
  67. #define    icmp_gwaddr    icmp_hun.ih_gwaddr
  68. #define    icmp_id        icmp_hun.ih_idseq.icd_id
  69. #define    icmp_seq    icmp_hun.ih_idseq.icd_seq
  70. #define    icmp_void    icmp_hun.ih_void
  71.     union {
  72.         struct id_ts {
  73.             n_time its_otime;
  74.             n_time its_rtime;
  75.             n_time its_ttime;
  76.         } id_ts;
  77.         struct id_ip  {
  78.             struct ip idi_ip;
  79.             /* options and then 64 bits of data */
  80.         } id_ip;
  81.         u_long    id_mask;
  82.         char    id_data[1];
  83.     } icmp_dun;
  84. #define    icmp_otime    icmp_dun.id_ts.its_otime
  85. #define    icmp_rtime    icmp_dun.id_ts.its_rtime
  86. #define    icmp_ttime    icmp_dun.id_ts.its_ttime
  87. #define    icmp_ip        icmp_dun.id_ip.idi_ip
  88. #define    icmp_mask    icmp_dun.id_mask
  89. #define    icmp_data    icmp_dun.id_data
  90. };
  91.  
  92. #define    ICMP_MINLEN    8        /* abs minimum */
  93.  
  94. /*
  95.  * Definition of icmp type and code field values.
  96.  */
  97.  
  98. #define    ICMP_ECHOREPLY        0        /* echo reply */
  99. #define    ICMP_UNREACH        3        /* dest unreachable, codes: */
  100. #define        ICMP_UNREACH_NET    0        /* bad net */
  101. #define        ICMP_UNREACH_HOST    1        /* bad host */
  102. #define        ICMP_UNREACH_PROTOCOL    2        /* bad protocol */
  103. #define        ICMP_UNREACH_PORT    3        /* bad port */
  104. #define        ICMP_UNREACH_NEEDFRAG    4        /* IP_DF caused drop */
  105. #define        ICMP_UNREACH_SRCFAIL    5        /* src route failed */
  106. #define    ICMP_SOURCEQUENCH    4        /* packet lost, slow down */
  107. #define    ICMP_REDIRECT        5        /* shorter route, codes: */
  108. #define        ICMP_REDIRECT_NET    0        /* for network */
  109. #define        ICMP_REDIRECT_HOST    1        /* for host */
  110. #define        ICMP_REDIRECT_TOSNET    2        /* for tos and net */
  111. #define        ICMP_REDIRECT_TOSHOST    3        /* for tos and host */
  112. #define    ICMP_ECHO        8        /* echo service */
  113. #define    ICMP_TIMXCEED        11        /* time exceeded, code: */
  114. #define        ICMP_TIMXCEED_INTRANS    0        /* ttl==0 in transit */
  115. #define        ICMP_TIMXCEED_REASS    1        /* ttl==0 in reass */
  116. #define    ICMP_PARAMPROB        12        /* ip header bad */
  117. #define    ICMP_TSTAMP        13        /* timestamp request */
  118. #define    ICMP_TSTAMPREPLY    14        /* timestamp reply */
  119. #define    ICMP_IREQ        15        /* information request */
  120. #define    ICMP_IREQREPLY        16        /* information reply */
  121. #define    ICMP_MASKREQ        17        /* address mask request */
  122. #define    ICMP_MASKREPLY        18        /* address mask reply */
  123.  
  124. /*
  125.  * Definitions needed for the udp header structure.
  126.  */
  127.  
  128. #define uh_sport    source
  129. #define uh_dport    dest
  130. #define uh_ulen        len
  131. #define uh_sum        check
  132.  
  133. #endif /* linux */
  134.