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.1.2 (2.11BSD) 1995/10/09 13: */ 14: #ifndef BYTE_ORDER 15: /* 16: * Definitions for byte order, 17: * according to byte significance from low address to high. 18: */ 19: #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax) */ 20: #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ 21: #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp) */ 22: 23: #ifdef vax 24: #define BYTE_ORDER LITTLE_ENDIAN 25: #else 26: #ifdef pdp11 27: #define BYTE_ORDER PDP_ENDIAN 28: #else 29: #define BYTE_ORDER BIG_ENDIAN /* mc68000, tahoe, most others */ 30: #endif 31: #endif 32: #endif BYTE_ORDER 33: 34: /* 35: * Definitions for internet protocol version 4. 36: * Per RFC 791, September 1981. 37: */ 38: #define IPVERSION 4 39: 40: /* 41: * Structure of an internet header, naked of options. 42: * 43: * We declare ip_len and ip_off to be short, rather than u_short 44: * pragmatically since otherwise unsigned comparisons can result 45: * against negative integers quite easily, and fail in subtle ways. 46: */ 47: struct ip { 48: #if BYTE_ORDER == LITTLE_ENDIAN 49: u_char ip_hl:4, /* header length */ 50: ip_v:4; /* version */ 51: #endif 52: #if BYTE_ORDER == BIG_ENDIAN 53: u_char ip_v:4, /* version */ 54: ip_hl:4; /* header length */ 55: #endif 56: #if BYTE_ORDER == PDP_ENDIAN 57: u_int ip_hl:4, /* header length */ 58: ip_v:4; /* version */ 59: #endif 60: u_char ip_tos; /* type of service */ 61: short ip_len; /* total length */ 62: u_short ip_id; /* identification */ 63: short ip_off; /* fragment offset field */ 64: #define IP_DF 0x4000 /* dont fragment flag */ 65: #define IP_MF 0x2000 /* more fragments flag */ 66: u_char ip_ttl; /* time to live */ 67: u_char ip_p; /* protocol */ 68: u_short ip_sum; /* checksum */ 69: struct in_addr ip_src,ip_dst; /* source and dest address */ 70: }; 71: 72: #define IP_MAXPACKET 65535L /* maximum packet size */ 73: 74: /* 75: * Definitions for options. 76: */ 77: #define IPOPT_COPIED(o) ((o)&0x80) 78: #define IPOPT_CLASS(o) ((o)&0x60) 79: #define IPOPT_NUMBER(o) ((o)&0x1f) 80: 81: #define IPOPT_CONTROL 0x00 82: #define IPOPT_RESERVED1 0x20 83: #define IPOPT_DEBMEAS 0x40 84: #define IPOPT_RESERVED2 0x60 85: 86: #define IPOPT_EOL 0 /* end of option list */ 87: #define IPOPT_NOP 1 /* no operation */ 88: 89: #define IPOPT_RR 7 /* record packet route */ 90: #define IPOPT_TS 68 /* timestamp */ 91: #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 92: #define IPOPT_LSRR 131 /* loose source route */ 93: #define IPOPT_SATID 136 /* satnet id */ 94: #define IPOPT_SSRR 137 /* strict source route */ 95: 96: /* 97: * Offsets to fields in options other than EOL and NOP. 98: */ 99: #define IPOPT_OPTVAL 0 /* option ID */ 100: #define IPOPT_OLEN 1 /* option length */ 101: #define IPOPT_OFFSET 2 /* offset within option */ 102: #define IPOPT_MINOFF 4 /* min value of above */ 103: 104: /* 105: * Time stamp option structure. 106: */ 107: struct ip_timestamp { 108: u_char ipt_code; /* IPOPT_TS */ 109: u_char ipt_len; /* size of structure (variable) */ 110: u_char ipt_ptr; /* index of current entry */ 111: #if BYTE_ORDER == LITTLE_ENDIAN 112: u_char ipt_flg:4, /* flags, see below */ 113: ipt_oflw:4; /* overflow counter */ 114: #endif 115: #if BYTE_ORDER == BIG_ENDIAN 116: u_char ipt_oflw:4, /* overflow counter */ 117: ipt_flg:4; /* flags, see below */ 118: #endif 119: #if BYTE_ORDER == PDP_ENDIAN 120: u_char ipt_flg:4, /* flags, see below */ 121: ipt_oflw:4; /* overflow counter */ 122: #endif 123: union ipt_timestamp { 124: n_long ipt_time[1]; 125: struct ipt_ta { 126: struct in_addr ipt_addr; 127: n_long ipt_time; 128: } ipt_ta[1]; 129: } ipt_timestamp; 130: }; 131: 132: /* flag bits for ipt_flg */ 133: #define IPOPT_TS_TSONLY 0 /* timestamps only */ 134: #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 135: #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 136: 137: /* bits for security (not byte swapped) */ 138: #define IPOPT_SECUR_UNCLASS 0x0000 139: #define IPOPT_SECUR_CONFID 0xf135 140: #define IPOPT_SECUR_EFTO 0x789a 141: #define IPOPT_SECUR_MMMM 0xbc4d 142: #define IPOPT_SECUR_RESTR 0xaf13 143: #define IPOPT_SECUR_SECRET 0xd788 144: #define IPOPT_SECUR_TOPSECRET 0x6bc5 145: 146: /* 147: * Internet implementation parameters. 148: */ 149: #define MAXTTL 255 /* maximum time to live (seconds) */ 150: #define IPDEFTTL 64 /* default ttl, from RFC 1340 */ 151: #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 152: #define IPTTLDEC 1 /* subtracted when forwarding */ 153: 154: #define IP_MSS 576 /* default maximum segment size */