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.6 (Berkeley) 02/22/88 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 BYTE_ORDER == LITTLE_ENDIAN 30 u_char ip_hl:4, /* header length */ 31 ip_v:4; /* version */ 32 #endif 33 #if BYTE_ORDER == BIG_ENDIAN 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 #define IP_MAXPACKET 65535 /* maximum packet size */ 50 51 /* 52 * Definitions for options. 53 */ 54 #define IPOPT_COPIED(o) ((o)&0x80) 55 #define IPOPT_CLASS(o) ((o)&0x60) 56 #define IPOPT_NUMBER(o) ((o)&0x1f) 57 58 #define IPOPT_CONTROL 0x00 59 #define IPOPT_RESERVED1 0x20 60 #define IPOPT_DEBMEAS 0x40 61 #define IPOPT_RESERVED2 0x60 62 63 #define IPOPT_EOL 0 /* end of option list */ 64 #define IPOPT_NOP 1 /* no operation */ 65 66 #define IPOPT_RR 7 /* record packet route */ 67 #define IPOPT_TS 68 /* timestamp */ 68 #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 69 #define IPOPT_LSRR 131 /* loose source route */ 70 #define IPOPT_SATID 136 /* satnet id */ 71 #define IPOPT_SSRR 137 /* strict source route */ 72 73 /* 74 * Offsets to fields in options other than EOL and NOP. 75 */ 76 #define IPOPT_OPTVAL 0 /* option ID */ 77 #define IPOPT_OLEN 1 /* option length */ 78 #define IPOPT_OFFSET 2 /* offset within option */ 79 #define IPOPT_MINOFF 4 /* min value of above */ 80 81 /* 82 * Time stamp option structure. 83 */ 84 struct ip_timestamp { 85 u_char ipt_code; /* IPOPT_TS */ 86 u_char ipt_len; /* size of structure (variable) */ 87 u_char ipt_ptr; /* index of current entry */ 88 #if BYTE_ORDER == LITTLE_ENDIAN 89 u_char ipt_flg:4, /* flags, see below */ 90 ipt_oflw:4; /* overflow counter */ 91 #endif 92 #if BYTE_ORDER == BIG_ENDIAN 93 u_char ipt_oflw:4, /* overflow counter */ 94 ipt_flg:4; /* flags, see below */ 95 #endif 96 union ipt_timestamp { 97 n_long ipt_time[1]; 98 struct ipt_ta { 99 struct in_addr ipt_addr; 100 n_long ipt_time; 101 } ipt_ta[1]; 102 } ipt_timestamp; 103 }; 104 105 /* flag bits for ipt_flg */ 106 #define IPOPT_TS_TSONLY 0 /* timestamps only */ 107 #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 108 #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 109 110 /* bits for security (not byte swapped) */ 111 #define IPOPT_SECUR_UNCLASS 0x0000 112 #define IPOPT_SECUR_CONFID 0xf135 113 #define IPOPT_SECUR_EFTO 0x789a 114 #define IPOPT_SECUR_MMMM 0xbc4d 115 #define IPOPT_SECUR_RESTR 0xaf13 116 #define IPOPT_SECUR_SECRET 0xd788 117 #define IPOPT_SECUR_TOPSECRET 0x6bc5 118 119 /* 120 * Internet implementation parameters. 121 */ 122 #define MAXTTL 255 /* maximum time to live (seconds) */ 123 #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 124 #define IPTTLDEC 1 /* subtracted when forwarding */ 125 126 #define IP_MSS 576 /* default maximum segment size */ 127