123181Smckusick /* 229140Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 323181Smckusick * All rights reserved. The Berkeley software License Agreement 423181Smckusick * specifies the terms and conditions for redistribution. 523181Smckusick * 6*30291Skarels * @(#)ip.h 7.3 (Berkeley) 12/15/86 723181Smckusick */ 84571Swnj 94662Swnj /* 104662Swnj * Definitions for internet protocol version 4. 114662Swnj * Per RFC 791, September 1981. 124662Swnj */ 134662Swnj #define IPVERSION 4 144662Swnj 154662Swnj /* 164662Swnj * Structure of an internet header, naked of options. 174662Swnj * 184884Swnj * We declare ip_len and ip_off to be short, rather than u_short 194884Swnj * pragmatically since otherwise unsigned comparisons can result 204884Swnj * against negative integers quite easily, and fail in subtle ways. 214662Swnj */ 224571Swnj struct ip { 2329923Skarels #if ENDIAN == LITTLE 244571Swnj u_char ip_hl:4, /* header length */ 254571Swnj ip_v:4; /* version */ 269991Ssam #endif 2729923Skarels #if ENDIAN == BIG 2829923Skarels u_char ip_v:4, /* version */ 2929923Skarels ip_hl:4; /* header length */ 3029923Skarels #endif 314571Swnj u_char ip_tos; /* type of service */ 324647Swnj short ip_len; /* total length */ 334571Swnj u_short ip_id; /* identification */ 344647Swnj short ip_off; /* fragment offset field */ 354662Swnj #define IP_DF 0x4000 /* dont fragment flag */ 364662Swnj #define IP_MF 0x2000 /* more fragments flag */ 374571Swnj u_char ip_ttl; /* time to live */ 384571Swnj u_char ip_p; /* protocol */ 394571Swnj u_short ip_sum; /* checksum */ 404923Swnj struct in_addr ip_src,ip_dst; /* source and dest address */ 414498Swnj }; 424498Swnj 434571Swnj /* 444662Swnj * Definitions for options. 454571Swnj */ 464662Swnj #define IPOPT_COPIED(o) ((o)&0x80) 4716051Skarels #define IPOPT_CLASS(o) ((o)&0x60) 4816051Skarels #define IPOPT_NUMBER(o) ((o)&0x1f) 494662Swnj 504662Swnj #define IPOPT_CONTROL 0x00 5116051Skarels #define IPOPT_RESERVED1 0x20 5216051Skarels #define IPOPT_DEBMEAS 0x40 5316051Skarels #define IPOPT_RESERVED2 0x60 544662Swnj 554662Swnj #define IPOPT_EOL 0 /* end of option list */ 564662Swnj #define IPOPT_NOP 1 /* no operation */ 574662Swnj 584662Swnj #define IPOPT_RR 7 /* record packet route */ 594662Swnj #define IPOPT_TS 68 /* timestamp */ 604662Swnj #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 614662Swnj #define IPOPT_LSRR 131 /* loose source route */ 624662Swnj #define IPOPT_SATID 136 /* satnet id */ 634662Swnj #define IPOPT_SSRR 137 /* strict source route */ 644662Swnj 654662Swnj /* 6624810Skarels * Offsets to fields in options other than EOL and NOP. 6724810Skarels */ 6824810Skarels #define IPOPT_OPTVAL 0 /* option ID */ 6924810Skarels #define IPOPT_OLEN 1 /* option length */ 7024810Skarels #define IPOPT_OFFSET 2 /* offset within option */ 7124810Skarels #define IPOPT_MINOFF 4 /* min value of above */ 7224810Skarels 7324810Skarels /* 744662Swnj * Time stamp option structure. 754662Swnj */ 764662Swnj struct ip_timestamp { 774662Swnj u_char ipt_code; /* IPOPT_TS */ 784662Swnj u_char ipt_len; /* size of structure (variable) */ 794662Swnj u_char ipt_ptr; /* index of current entry */ 8029923Skarels #if ENDIAN == LITTLE 814662Swnj u_char ipt_flg:4, /* flags, see below */ 824662Swnj ipt_oflw:4; /* overflow counter */ 8329923Skarels #endif 8429923Skarels #if ENDIAN == BIG 8529923Skarels u_char ipt_oflw:4, /* overflow counter */ 8629923Skarels ipt_flg:4; /* flags, see below */ 8729923Skarels #endif 884662Swnj union { 894662Swnj n_long ipt_time[1]; 904662Swnj struct ipt_ta { 914923Swnj struct in_addr ipt_addr; 924662Swnj n_long ipt_time; 934662Swnj } ipt_ta[1]; 944662Swnj } 954662Swnj }; 964662Swnj 974662Swnj /* flag bits for ipt_flg */ 984662Swnj #define IPOPT_TS_TSONLY 0 /* timestamps only */ 994662Swnj #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 1004662Swnj #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 1014662Swnj 1024662Swnj /* bits for security (not byte swapped) */ 1034662Swnj #define IPOPT_SECUR_UNCLASS 0x0000 1044662Swnj #define IPOPT_SECUR_CONFID 0xf135 1054662Swnj #define IPOPT_SECUR_EFTO 0x789a 1064662Swnj #define IPOPT_SECUR_MMMM 0xbc4d 1074662Swnj #define IPOPT_SECUR_RESTR 0xaf13 1084662Swnj #define IPOPT_SECUR_SECRET 0xd788 1094662Swnj #define IPOPT_SECUR_TOPSECRET 0x6bc5 1104662Swnj 1114662Swnj /* 1124662Swnj * Internet implementation parameters. 1134662Swnj */ 1144571Swnj #define MAXTTL 255 /* maximum time to live (seconds) */ 115*30291Skarels #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 11616523Skarels #define IPTTLDEC 1 /* subtracted when forwarding */ 11717272Skarels 11817272Skarels #define IP_MSS 576 /* default maximum segment size */ 119