1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * @(#)ip.h 7.4 (Berkeley) 12/07/87 13 */ 14 15 /* 16 * Definitions for internet protocol version 4. 17 * Per RFC 791, September 1981. 18 */ 19 #define IPVERSION 4 20 21 /* 22 * Structure of an internet header, naked of options. 23 * 24 * We declare ip_len and ip_off to be short, rather than u_short 25 * pragmatically since otherwise unsigned comparisons can result 26 * against negative integers quite easily, and fail in subtle ways. 27 */ 28 struct ip { 29 #if ENDIAN == LITTLE 30 u_char ip_hl:4, /* header length */ 31 ip_v:4; /* version */ 32 #endif 33 #if ENDIAN == BIG 34 u_char ip_v:4, /* version */ 35 ip_hl:4; /* header length */ 36 #endif 37 u_char ip_tos; /* type of service */ 38 short ip_len; /* total length */ 39 u_short ip_id; /* identification */ 40 short ip_off; /* fragment offset field */ 41 #define IP_DF 0x4000 /* dont fragment flag */ 42 #define IP_MF 0x2000 /* more fragments flag */ 43 u_char ip_ttl; /* time to live */ 44 u_char ip_p; /* protocol */ 45 u_short ip_sum; /* checksum */ 46 struct in_addr ip_src,ip_dst; /* source and dest address */ 47 }; 48 49 /* 50 * Definitions for options. 51 */ 52 #define IPOPT_COPIED(o) ((o)&0x80) 53 #define IPOPT_CLASS(o) ((o)&0x60) 54 #define IPOPT_NUMBER(o) ((o)&0x1f) 55 56 #define IPOPT_CONTROL 0x00 57 #define IPOPT_RESERVED1 0x20 58 #define IPOPT_DEBMEAS 0x40 59 #define IPOPT_RESERVED2 0x60 60 61 #define IPOPT_EOL 0 /* end of option list */ 62 #define IPOPT_NOP 1 /* no operation */ 63 64 #define IPOPT_RR 7 /* record packet route */ 65 #define IPOPT_TS 68 /* timestamp */ 66 #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 67 #define IPOPT_LSRR 131 /* loose source route */ 68 #define IPOPT_SATID 136 /* satnet id */ 69 #define IPOPT_SSRR 137 /* strict source route */ 70 71 /* 72 * Offsets to fields in options other than EOL and NOP. 73 */ 74 #define IPOPT_OPTVAL 0 /* option ID */ 75 #define IPOPT_OLEN 1 /* option length */ 76 #define IPOPT_OFFSET 2 /* offset within option */ 77 #define IPOPT_MINOFF 4 /* min value of above */ 78 79 /* 80 * Time stamp option structure. 81 */ 82 struct ip_timestamp { 83 u_char ipt_code; /* IPOPT_TS */ 84 u_char ipt_len; /* size of structure (variable) */ 85 u_char ipt_ptr; /* index of current entry */ 86 #if ENDIAN == LITTLE 87 u_char ipt_flg:4, /* flags, see below */ 88 ipt_oflw:4; /* overflow counter */ 89 #endif 90 #if ENDIAN == BIG 91 u_char ipt_oflw:4, /* overflow counter */ 92 ipt_flg:4; /* flags, see below */ 93 #endif 94 union { 95 n_long ipt_time[1]; 96 struct ipt_ta { 97 struct in_addr ipt_addr; 98 n_long ipt_time; 99 } ipt_ta[1]; 100 } 101 }; 102 103 /* flag bits for ipt_flg */ 104 #define IPOPT_TS_TSONLY 0 /* timestamps only */ 105 #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 106 #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 107 108 /* bits for security (not byte swapped) */ 109 #define IPOPT_SECUR_UNCLASS 0x0000 110 #define IPOPT_SECUR_CONFID 0xf135 111 #define IPOPT_SECUR_EFTO 0x789a 112 #define IPOPT_SECUR_MMMM 0xbc4d 113 #define IPOPT_SECUR_RESTR 0xaf13 114 #define IPOPT_SECUR_SECRET 0xd788 115 #define IPOPT_SECUR_TOPSECRET 0x6bc5 116 117 /* 118 * Internet implementation parameters. 119 */ 120 #define MAXTTL 255 /* maximum time to live (seconds) */ 121 #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 122 #define IPTTLDEC 1 /* subtracted when forwarding */ 123 124 #define IP_MSS 576 /* default maximum segment size */ 125