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