1df8bae1dSRodney W. Grimes /* 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 333271ad14SGarrett Wollman * @(#)ip.h 8.2 (Berkeley) 6/1/94 34c3aac50fSPeter Wemm * $FreeBSD$ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37707f139eSPaul Richards #ifndef _NETINET_IP_H_ 38707f139eSPaul Richards #define _NETINET_IP_H_ 39707f139eSPaul Richards 40aecfcdb8SMaxime Henrion #include <sys/cdefs.h> 41aecfcdb8SMaxime Henrion 42df8bae1dSRodney W. Grimes /* 43df8bae1dSRodney W. Grimes * Definitions for internet protocol version 4. 44df8bae1dSRodney W. Grimes * Per RFC 791, September 1981. 45df8bae1dSRodney W. Grimes */ 46df8bae1dSRodney W. Grimes #define IPVERSION 4 47df8bae1dSRodney W. Grimes 48df8bae1dSRodney W. Grimes /* 49df8bae1dSRodney W. Grimes * Structure of an internet header, naked of options. 50df8bae1dSRodney W. Grimes */ 51df8bae1dSRodney W. Grimes struct ip { 52df8bae1dSRodney W. Grimes #if BYTE_ORDER == LITTLE_ENDIAN 5357d05a62SBruce Evans u_int ip_hl:4, /* header length */ 54df8bae1dSRodney W. Grimes ip_v:4; /* version */ 55df8bae1dSRodney W. Grimes #endif 56df8bae1dSRodney W. Grimes #if BYTE_ORDER == BIG_ENDIAN 5757d05a62SBruce Evans u_int ip_v:4, /* version */ 58df8bae1dSRodney W. Grimes ip_hl:4; /* header length */ 59df8bae1dSRodney W. Grimes #endif 60df8bae1dSRodney W. Grimes u_char ip_tos; /* type of service */ 6164682bc2SGarrett Wollman u_short ip_len; /* total length */ 62df8bae1dSRodney W. Grimes u_short ip_id; /* identification */ 6364682bc2SGarrett Wollman u_short ip_off; /* fragment offset field */ 64c383a33fSDima Ruban #define IP_RF 0x8000 /* reserved fragment flag */ 65df8bae1dSRodney W. Grimes #define IP_DF 0x4000 /* dont fragment flag */ 66df8bae1dSRodney W. Grimes #define IP_MF 0x2000 /* more fragments flag */ 67df8bae1dSRodney W. Grimes #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 68df8bae1dSRodney W. Grimes u_char ip_ttl; /* time to live */ 69df8bae1dSRodney W. Grimes u_char ip_p; /* protocol */ 70df8bae1dSRodney W. Grimes u_short ip_sum; /* checksum */ 71df8bae1dSRodney W. Grimes struct in_addr ip_src,ip_dst; /* source and dest address */ 72aecfcdb8SMaxime Henrion } __packed; 73df8bae1dSRodney W. Grimes 7453be11f6SPoul-Henning Kamp #ifdef CTASSERT 7553be11f6SPoul-Henning Kamp CTASSERT(sizeof (struct ip) == 20); 7661e5033fSGarrett Wollman #endif 7761e5033fSGarrett Wollman 78df8bae1dSRodney W. Grimes #define IP_MAXPACKET 65535 /* maximum packet size */ 79df8bae1dSRodney W. Grimes 80df8bae1dSRodney W. Grimes /* 81df8bae1dSRodney W. Grimes * Definitions for IP type of service (ip_tos) 82df8bae1dSRodney W. Grimes */ 83df8bae1dSRodney W. Grimes #define IPTOS_LOWDELAY 0x10 84df8bae1dSRodney W. Grimes #define IPTOS_THROUGHPUT 0x08 85df8bae1dSRodney W. Grimes #define IPTOS_RELIABILITY 0x04 862ee32961SAndrey A. Chernov #define IPTOS_MINCOST 0x02 876a800098SYoshinobu Inoue /* ECN bits proposed by Sally Floyd */ 886a800098SYoshinobu Inoue #define IPTOS_CE 0x01 /* congestion experienced */ 896a800098SYoshinobu Inoue #define IPTOS_ECT 0x02 /* ECN-capable transport */ 906a800098SYoshinobu Inoue 91df8bae1dSRodney W. Grimes 92df8bae1dSRodney W. Grimes /* 93df8bae1dSRodney W. Grimes * Definitions for IP precedence (also in ip_tos) (hopefully unused) 94df8bae1dSRodney W. Grimes */ 95df8bae1dSRodney W. Grimes #define IPTOS_PREC_NETCONTROL 0xe0 96df8bae1dSRodney W. Grimes #define IPTOS_PREC_INTERNETCONTROL 0xc0 97df8bae1dSRodney W. Grimes #define IPTOS_PREC_CRITIC_ECP 0xa0 98df8bae1dSRodney W. Grimes #define IPTOS_PREC_FLASHOVERRIDE 0x80 99df8bae1dSRodney W. Grimes #define IPTOS_PREC_FLASH 0x60 100df8bae1dSRodney W. Grimes #define IPTOS_PREC_IMMEDIATE 0x40 101df8bae1dSRodney W. Grimes #define IPTOS_PREC_PRIORITY 0x20 1022ee32961SAndrey A. Chernov #define IPTOS_PREC_ROUTINE 0x00 103df8bae1dSRodney W. Grimes 104df8bae1dSRodney W. Grimes /* 105df8bae1dSRodney W. Grimes * Definitions for options. 106df8bae1dSRodney W. Grimes */ 107df8bae1dSRodney W. Grimes #define IPOPT_COPIED(o) ((o)&0x80) 108df8bae1dSRodney W. Grimes #define IPOPT_CLASS(o) ((o)&0x60) 109df8bae1dSRodney W. Grimes #define IPOPT_NUMBER(o) ((o)&0x1f) 110df8bae1dSRodney W. Grimes 111df8bae1dSRodney W. Grimes #define IPOPT_CONTROL 0x00 112df8bae1dSRodney W. Grimes #define IPOPT_RESERVED1 0x20 113df8bae1dSRodney W. Grimes #define IPOPT_DEBMEAS 0x40 114df8bae1dSRodney W. Grimes #define IPOPT_RESERVED2 0x60 115df8bae1dSRodney W. Grimes 116df8bae1dSRodney W. Grimes #define IPOPT_EOL 0 /* end of option list */ 117df8bae1dSRodney W. Grimes #define IPOPT_NOP 1 /* no operation */ 118df8bae1dSRodney W. Grimes 119df8bae1dSRodney W. Grimes #define IPOPT_RR 7 /* record packet route */ 120df8bae1dSRodney W. Grimes #define IPOPT_TS 68 /* timestamp */ 121df8bae1dSRodney W. Grimes #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 122df8bae1dSRodney W. Grimes #define IPOPT_LSRR 131 /* loose source route */ 123365979cdSRobert Watson #define IPOPT_ESO 133 /* extended security */ 12418e2b6a9SRobert Watson #define IPOPT_CIPSO 134 /* commerical security */ 125df8bae1dSRodney W. Grimes #define IPOPT_SATID 136 /* satnet id */ 126df8bae1dSRodney W. Grimes #define IPOPT_SSRR 137 /* strict source route */ 12749fa849bSBill Fenner #define IPOPT_RA 148 /* router alert */ 128df8bae1dSRodney W. Grimes 129df8bae1dSRodney W. Grimes /* 130df8bae1dSRodney W. Grimes * Offsets to fields in options other than EOL and NOP. 131df8bae1dSRodney W. Grimes */ 132df8bae1dSRodney W. Grimes #define IPOPT_OPTVAL 0 /* option ID */ 133df8bae1dSRodney W. Grimes #define IPOPT_OLEN 1 /* option length */ 134df8bae1dSRodney W. Grimes #define IPOPT_OFFSET 2 /* offset within option */ 135df8bae1dSRodney W. Grimes #define IPOPT_MINOFF 4 /* min value of above */ 136df8bae1dSRodney W. Grimes 137df8bae1dSRodney W. Grimes /* 138df8bae1dSRodney W. Grimes * Time stamp option structure. 139df8bae1dSRodney W. Grimes */ 140df8bae1dSRodney W. Grimes struct ip_timestamp { 141df8bae1dSRodney W. Grimes u_char ipt_code; /* IPOPT_TS */ 142df8bae1dSRodney W. Grimes u_char ipt_len; /* size of structure (variable) */ 143df8bae1dSRodney W. Grimes u_char ipt_ptr; /* index of current entry */ 144df8bae1dSRodney W. Grimes #if BYTE_ORDER == LITTLE_ENDIAN 14557d05a62SBruce Evans u_int ipt_flg:4, /* flags, see below */ 146df8bae1dSRodney W. Grimes ipt_oflw:4; /* overflow counter */ 147df8bae1dSRodney W. Grimes #endif 148df8bae1dSRodney W. Grimes #if BYTE_ORDER == BIG_ENDIAN 14957d05a62SBruce Evans u_int ipt_oflw:4, /* overflow counter */ 150df8bae1dSRodney W. Grimes ipt_flg:4; /* flags, see below */ 151df8bae1dSRodney W. Grimes #endif 152df8bae1dSRodney W. Grimes union ipt_timestamp { 153df8bae1dSRodney W. Grimes n_long ipt_time[1]; 154df8bae1dSRodney W. Grimes struct ipt_ta { 155df8bae1dSRodney W. Grimes struct in_addr ipt_addr; 156df8bae1dSRodney W. Grimes n_long ipt_time; 157df8bae1dSRodney W. Grimes } ipt_ta[1]; 158df8bae1dSRodney W. Grimes } ipt_timestamp; 159df8bae1dSRodney W. Grimes }; 160df8bae1dSRodney W. Grimes 161df8bae1dSRodney W. Grimes /* flag bits for ipt_flg */ 162df8bae1dSRodney W. Grimes #define IPOPT_TS_TSONLY 0 /* timestamps only */ 163df8bae1dSRodney W. Grimes #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 164df8bae1dSRodney W. Grimes #define IPOPT_TS_PRESPEC 3 /* specified modules only */ 165df8bae1dSRodney W. Grimes 166df8bae1dSRodney W. Grimes /* bits for security (not byte swapped) */ 167df8bae1dSRodney W. Grimes #define IPOPT_SECUR_UNCLASS 0x0000 168df8bae1dSRodney W. Grimes #define IPOPT_SECUR_CONFID 0xf135 169df8bae1dSRodney W. Grimes #define IPOPT_SECUR_EFTO 0x789a 170df8bae1dSRodney W. Grimes #define IPOPT_SECUR_MMMM 0xbc4d 171df8bae1dSRodney W. Grimes #define IPOPT_SECUR_RESTR 0xaf13 172df8bae1dSRodney W. Grimes #define IPOPT_SECUR_SECRET 0xd788 173df8bae1dSRodney W. Grimes #define IPOPT_SECUR_TOPSECRET 0x6bc5 174df8bae1dSRodney W. Grimes 175df8bae1dSRodney W. Grimes /* 176df8bae1dSRodney W. Grimes * Internet implementation parameters. 177df8bae1dSRodney W. Grimes */ 178df8bae1dSRodney W. Grimes #define MAXTTL 255 /* maximum time to live (seconds) */ 179df8bae1dSRodney W. Grimes #define IPDEFTTL 64 /* default ttl, from RFC 1340 */ 180df8bae1dSRodney W. Grimes #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 181df8bae1dSRodney W. Grimes #define IPTTLDEC 1 /* subtracted when forwarding */ 182df8bae1dSRodney W. Grimes 183df8bae1dSRodney W. Grimes #define IP_MSS 576 /* default maximum segment size */ 184707f139eSPaul Richards 185707f139eSPaul Richards #endif 186