home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilss / sockets / include / netinet / h / ip < prev    next >
Encoding:
Text File  |  1995-09-11  |  5.3 KB  |  153 lines

  1. /* -*-C-*-
  2.  *
  3.  * $Header: /ax/networking:include/netinet/ip.h:networking  1.1  $
  4.  * $Source: /ax/networking:include/netinet/ip.h: $
  5.  *
  6.  * Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
  7.  *
  8.  * $Log:    ip.h,v $
  9.  * Revision 1.2  95/09/11  15:04:09  kbracey
  10.  * Changed bitfields to ints
  11.  *
  12.  * Revision 1.1  95/01/11  10:16:55  kwelton
  13.  * Initial revision
  14.  *
  15.  */
  16. #ifndef __netinet_ip_h
  17. #define __netinet_ip_h
  18.  
  19. #include "netinet/in_systm.h"
  20.  
  21. #ifndef BYTE_ORDER
  22. /*
  23.  * Definitions for byte order,
  24.  * according to byte significance from low address to high.
  25.  */
  26. #define LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
  27. #define BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
  28. #define PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
  29.  
  30. #if defined(vax) || defined(__arm)
  31. #define BYTE_ORDER      LITTLE_ENDIAN
  32. #else
  33. #define BYTE_ORDER      BIG_ENDIAN      /* mc68000, tahoe, most others */
  34. #endif
  35. #endif BYTE_ORDER
  36.  
  37. /*
  38.  * Definitions for internet protocol version 4.
  39.  * Per RFC 791, September 1981.
  40.  */
  41. #define IPVERSION       4
  42.  
  43. /*
  44.  * Structure of an internet header, naked of options.
  45.  *
  46.  * We declare ip_len and ip_off to be short, rather than u_short
  47.  * pragmatically since otherwise unsigned comparisons can result
  48.  * against negative integers quite easily, and fail in subtle ways.
  49.  */
  50. struct ip {
  51. #if BYTE_ORDER == LITTLE_ENDIAN
  52.         u_int   ip_hl:4,                /* header length */
  53.                 ip_v:4;                 /* version */
  54. #endif
  55. #if BYTE_ORDER == BIG_ENDIAN
  56.         u_int   ip_v:4,                 /* version */
  57.                 ip_hl:4;                /* header length */
  58. #endif
  59.         u_char  ip_tos;                 /* type of service */
  60.         short   ip_len;                 /* total length */
  61.         u_short ip_id;                  /* identification */
  62.         short   ip_off;                 /* fragment offset field */
  63. #define IP_DF 0x4000                    /* dont fragment flag */
  64. #define IP_MF 0x2000                    /* more fragments flag */
  65.         u_char  ip_ttl;                 /* time to live */
  66.         u_char  ip_p;                   /* protocol */
  67.         u_short ip_sum;                 /* checksum */
  68.         struct  in_addr ip_src,ip_dst;  /* source and dest address */
  69. };
  70.  
  71. #define IP_MAXPACKET    65535           /* maximum packet size */
  72.  
  73. /*
  74.  * Definitions for options.
  75.  */
  76. #define IPOPT_COPIED(o)         ((o)&0x80)
  77. #define IPOPT_CLASS(o)          ((o)&0x60)
  78. #define IPOPT_NUMBER(o)         ((o)&0x1f)
  79.  
  80. #define IPOPT_CONTROL           0x00
  81. #define IPOPT_RESERVED1         0x20
  82. #define IPOPT_DEBMEAS           0x40
  83. #define IPOPT_RESERVED2         0x60
  84.  
  85. #define IPOPT_EOL               0               /* end of option list */
  86. #define IPOPT_NOP               1               /* no operation */
  87.  
  88. #define IPOPT_RR                7               /* record packet route */
  89. #define IPOPT_TS                68              /* timestamp */
  90. #define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
  91. #define IPOPT_LSRR              131             /* loose source route */
  92. #define IPOPT_SATID             136             /* satnet id */
  93. #define IPOPT_SSRR              137             /* strict source route */
  94.  
  95. /*
  96.  * Offsets to fields in options other than EOL and NOP.
  97.  */
  98. #define IPOPT_OPTVAL            0               /* option ID */
  99. #define IPOPT_OLEN              1               /* option length */
  100. #define IPOPT_OFFSET            2               /* offset within option */
  101. #define IPOPT_MINOFF            4               /* min value of above */
  102.  
  103. /*
  104.  * Time stamp option structure.
  105.  */
  106. struct  ip_timestamp {
  107.         u_char  ipt_code;               /* IPOPT_TS */
  108.         u_char  ipt_len;                /* size of structure (variable) */
  109.         u_char  ipt_ptr;                /* index of current entry */
  110. #if BYTE_ORDER == LITTLE_ENDIAN
  111.         u_int   ipt_flg:4,              /* flags, see below */
  112.                 ipt_oflw:4;             /* overflow counter */
  113. #endif
  114. #if BYTE_ORDER == BIG_ENDIAN
  115.         u_int   ipt_oflw:4,             /* overflow counter */
  116.                 ipt_flg:4;              /* flags, see below */
  117. #endif
  118.         union ipt_timestamp {
  119.                 n_long  ipt_time[1];
  120.                 struct  ipt_ta {
  121.                         struct in_addr ipt_addr;
  122.                         n_long ipt_time;
  123.                 } ipt_ta[1];
  124.         } ipt_timestamp;
  125. };
  126.  
  127. /* flag bits for ipt_flg */
  128. #define IPOPT_TS_TSONLY         0               /* timestamps only */
  129. #define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
  130. #define IPOPT_TS_PRESPEC        3               /* specified modules only */
  131.  
  132. /* bits for security (not byte swapped) */
  133. #define IPOPT_SECUR_UNCLASS     0x0000
  134. #define IPOPT_SECUR_CONFID      0xf135
  135. #define IPOPT_SECUR_EFTO        0x789a
  136. #define IPOPT_SECUR_MMMM        0xbc4d
  137. #define IPOPT_SECUR_RESTR       0xaf13
  138. #define IPOPT_SECUR_SECRET      0xd788
  139. #define IPOPT_SECUR_TOPSECRET   0x6bc5
  140.  
  141. /*
  142.  * Internet implementation parameters.
  143.  */
  144. #define MAXTTL          255             /* maximum time to live (seconds) */
  145. #define IPFRAGTTL       60              /* time to live for frags, slowhz */
  146. #define IPTTLDEC        1               /* subtracted when forwarding */
  147.  
  148. #define IP_MSS          576             /* default maximum segment size */
  149.  
  150. #endif /* !defined(__netinet_ip_h */
  151.  
  152. /* EOF ip.h */
  153.