The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/netinet/ip.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 1982, 1986, 1993
    3  *      The Regents of the University of California.  All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 3. All advertising materials mentioning features or use of this software
   14  *    must display the following acknowledgement:
   15  *      This product includes software developed by the University of
   16  *      California, Berkeley and its contributors.
   17  * 4. Neither the name of the University nor the names of its contributors
   18  *    may be used to endorse or promote products derived from this software
   19  *    without specific prior written permission.
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   31  * SUCH DAMAGE.
   32  *
   33  *      @(#)ip.h        8.2 (Berkeley) 6/1/94
   34  * $FreeBSD: src/sys/netinet/ip.h,v 1.17 1999/12/22 19:13:20 shin Exp $
   35  */
   36 
   37 #ifndef _NETINET_IP_H_
   38 #define _NETINET_IP_H_
   39 
   40 #ifndef _SYS_TYPES_H_
   41 #include <sys/types.h>
   42 #endif
   43 #ifndef _NETINET_IN_H_
   44 #include <netinet/in.h>
   45 #endif
   46 #ifndef _NETINET_IN_SYSTM_H_
   47 #include <netinet/in_systm.h>
   48 #endif
   49 #include <machine/endian.h>
   50 
   51 /*
   52  * Definitions for internet protocol version 4.
   53  * Per RFC 791, September 1981.
   54  */
   55 #define IPVERSION       4
   56 
   57 /*
   58  * Structure of an internet header, naked of options.
   59  */
   60 struct ip {
   61 #ifdef _IP_VHL
   62         u_char  ip_vhl;                 /* version << 4 | header length >> 2 */
   63 #elif _BYTE_ORDER == _LITTLE_ENDIAN
   64         u_int   ip_hl:4,                /* header length */
   65                 ip_v:4;                 /* version */
   66 #elif _BYTE_ORDER == _BIG_ENDIAN
   67         u_int   ip_v:4,                 /* version */
   68                 ip_hl:4;                /* header length */
   69 #else
   70 #error "Byte order not implemented"
   71 #endif
   72         u_char  ip_tos;                 /* type of service */
   73         u_short ip_len;                 /* total length */
   74         u_short ip_id;                  /* identification */
   75         u_short ip_off;                 /* fragment offset field */
   76 #define IP_RF 0x8000                    /* reserved fragment flag */
   77 #define IP_DF 0x4000                    /* dont fragment flag */
   78 #define IP_MF 0x2000                    /* more fragments flag */
   79 #define IP_OFFMASK 0x1fff               /* mask for fragmenting bits */
   80         u_char  ip_ttl;                 /* time to live */
   81         u_char  ip_p;                   /* protocol */
   82         u_short ip_sum;                 /* checksum */
   83         struct  in_addr ip_src,ip_dst;  /* source and dest address */
   84 };
   85 
   86 #ifdef _IP_VHL
   87 #define IP_MAKE_VHL(v, hl)      ((v) << 4 | (hl))
   88 #define IP_VHL_HL(vhl)          ((vhl) & 0x0f)
   89 #define IP_VHL_V(vhl)           ((vhl) >> 4)
   90 #define IP_VHL_BORING           0x45
   91 #endif
   92 
   93 #define IP_MAXPACKET    65535           /* maximum packet size */
   94 
   95 /*
   96  * Definitions for IP type of service (ip_tos)
   97  */
   98 #define IPTOS_LOWDELAY          0x10
   99 #define IPTOS_THROUGHPUT        0x08
  100 #define IPTOS_RELIABILITY       0x04
  101 #define IPTOS_MINCOST           0x02
  102 #if 1
  103 /* ECN RFC3168 obsoletes RFC2481, and these will be deprecated soon. */
  104 #define IPTOS_CE                0x01    /* congestion experienced */
  105 #define IPTOS_ECT               0x02    /* ECN-capable transport */
  106 #endif
  107 
  108 
  109 /*
  110  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  111  */
  112 #define IPTOS_PREC_NETCONTROL           0xe0
  113 #define IPTOS_PREC_INTERNETCONTROL      0xc0
  114 #define IPTOS_PREC_CRITIC_ECP           0xa0
  115 #define IPTOS_PREC_FLASHOVERRIDE        0x80
  116 #define IPTOS_PREC_FLASH                0x60
  117 #define IPTOS_PREC_IMMEDIATE            0x40
  118 #define IPTOS_PREC_PRIORITY             0x20
  119 #define IPTOS_PREC_ROUTINE              0x00
  120 
  121 /*
  122  * ECN (Explicit Congestion Notification) codepoints in RFC3168
  123  * mapped to the lower 2 bits of the TOS field.
  124  */
  125 #define IPTOS_ECN_NOTECT        0x00    /* not-ECT */
  126 #define IPTOS_ECN_ECT1          0x01    /* ECN-capable transport (1) */
  127 #define IPTOS_ECN_ECT0          0x02    /* ECN-capable transport (0) */
  128 #define IPTOS_ECN_CE            0x03    /* congestion experienced */
  129 #define IPTOS_ECN_MASK          0x03    /* ECN field mask */
  130 
  131 /*
  132  * Definitions for options.
  133  */
  134 #define IPOPT_COPIED(o)         ((o)&0x80)
  135 #define IPOPT_CLASS(o)          ((o)&0x60)
  136 #define IPOPT_NUMBER(o)         ((o)&0x1f)
  137 
  138 #define IPOPT_CONTROL           0x00
  139 #define IPOPT_RESERVED1         0x20
  140 #define IPOPT_DEBMEAS           0x40
  141 #define IPOPT_RESERVED2         0x60
  142 
  143 #define IPOPT_EOL               0               /* end of option list */
  144 #define IPOPT_NOP               1               /* no operation */
  145 
  146 #define IPOPT_RR                7               /* record packet route */
  147 #define IPOPT_TS                68              /* timestamp */
  148 #define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
  149 #define IPOPT_LSRR              131             /* loose source route */
  150 #define IPOPT_SATID             136             /* satnet id */
  151 #define IPOPT_SSRR              137             /* strict source route */
  152 #define IPOPT_RA                148             /* router alert */
  153 
  154 /*
  155  * Offsets to fields in options other than EOL and NOP.
  156  */
  157 #define IPOPT_OPTVAL            0               /* option ID */
  158 #define IPOPT_OLEN              1               /* option length */
  159 #define IPOPT_OFFSET            2               /* offset within option */
  160 #define IPOPT_MINOFF            4               /* min value of above */
  161 
  162 /*
  163  * Time stamp option structure.
  164  */
  165 struct  ip_timestamp {
  166         u_char  ipt_code;               /* IPOPT_TS */
  167         u_char  ipt_len;                /* size of structure (variable) */
  168         u_char  ipt_ptr;                /* index of current entry */
  169 #if _BYTE_ORDER == _LITTLE_ENDIAN
  170         u_int   ipt_flg:4,              /* flags, see below */
  171                 ipt_oflw:4;             /* overflow counter */
  172 #elif _BYTE_ORDER == _BIG_ENDIAN
  173         u_int   ipt_oflw:4,             /* overflow counter */
  174                 ipt_flg:4;              /* flags, see below */
  175 #else
  176 #error "Byte order not implemented"
  177 #endif
  178         union ipt_timestamp {
  179                 n_long  ipt_time[1];
  180                 struct  ipt_ta {
  181                         struct in_addr ipt_addr;
  182                         n_long ipt_time;
  183                 } ipt_ta[1];
  184         } ipt_timestamp;
  185 };
  186 
  187 /* flag bits for ipt_flg */
  188 #define IPOPT_TS_TSONLY         0               /* timestamps only */
  189 #define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
  190 #define IPOPT_TS_PRESPEC        3               /* specified modules only */
  191 
  192 /* bits for security (not byte swapped) */
  193 #define IPOPT_SECUR_UNCLASS     0x0000
  194 #define IPOPT_SECUR_CONFID      0xf135
  195 #define IPOPT_SECUR_EFTO        0x789a
  196 #define IPOPT_SECUR_MMMM        0xbc4d
  197 #define IPOPT_SECUR_RESTR       0xaf13
  198 #define IPOPT_SECUR_SECRET      0xd788
  199 #define IPOPT_SECUR_TOPSECRET   0x6bc5
  200 
  201 /*
  202  * Internet implementation parameters.
  203  */
  204 #define MAXTTL          255             /* maximum time to live (seconds) */
  205 #define IPDEFTTL        64              /* default ttl, from RFC 1340 */
  206 #define IPFRAGTTL       60              /* time to live for frags, slowhz */
  207 #define IPTTLDEC        1               /* subtracted when forwarding */
  208 
  209 #define IP_MSS          576             /* default maximum segment size */
  210 
  211 /*
  212  * This is the real IPv4 pseudo header, used for computing the TCP and UDP
  213  * checksums. For the Internet checksum, struct ipovly can be used instead.
  214  * For stronger checksums, the real thing must be used.
  215  */
  216 struct ippseudo {
  217         struct  in_addr ippseudo_src;   /* source internet address */
  218         struct  in_addr ippseudo_dst;   /* destination internet address */
  219         u_int8_t        ippseudo_pad;   /* pad, must be zero */
  220         u_int8_t        ippseudo_p;     /* protocol */
  221         u_int16_t       ippseudo_len;   /* protocol length */
  222 } __packed;
  223 #endif

Cache object: e427657eb752a27eae26b43de98f22ab


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.