123181Smckusick /* 229140Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 332787Sbostic * All rights reserved. 423181Smckusick * 5*44477Sbostic * %sccs.include.redist.c% 632787Sbostic * 7*44477Sbostic * @(#)ip.h 7.10 (Berkeley) 06/28/90 823181Smckusick */ 94571Swnj 104662Swnj /* 114662Swnj * Definitions for internet protocol version 4. 124662Swnj * Per RFC 791, September 1981. 134662Swnj */ 144662Swnj #define IPVERSION 4 154662Swnj 164662Swnj /* 174662Swnj * Structure of an internet header, naked of options. 184662Swnj * 194884Swnj * We declare ip_len and ip_off to be short, rather than u_short 204884Swnj * pragmatically since otherwise unsigned comparisons can result 214884Swnj * against negative integers quite easily, and fail in subtle ways. 224662Swnj */ 234571Swnj struct ip { 2433283Skarels #if BYTE_ORDER == LITTLE_ENDIAN 254571Swnj u_char ip_hl:4, /* header length */ 264571Swnj ip_v:4; /* version */ 279991Ssam #endif 2833283Skarels #if BYTE_ORDER == BIG_ENDIAN 2929923Skarels u_char ip_v:4, /* version */ 3029923Skarels ip_hl:4; /* header length */ 3129923Skarels #endif 324571Swnj u_char ip_tos; /* type of service */ 334647Swnj short ip_len; /* total length */ 344571Swnj u_short ip_id; /* identification */ 354647Swnj short ip_off; /* fragment offset field */ 364662Swnj #define IP_DF 0x4000 /* dont fragment flag */ 374662Swnj #define IP_MF 0x2000 /* more fragments flag */ 384571Swnj u_char ip_ttl; /* time to live */ 394571Swnj u_char ip_p; /* protocol */ 404571Swnj u_short ip_sum; /* checksum */ 414923Swnj struct in_addr ip_src,ip_dst; /* source and dest address */ 424498Swnj }; 434498Swnj 4433518Skarels #define IP_MAXPACKET 65535 /* maximum packet size */ 4533518Skarels 464571Swnj /* 4744369Skarels * Definitions for IP type of service (ip_tos) 4844369Skarels */ 4944369Skarels #define IPTOS_LOWDELAY 0x10 5044369Skarels #define IPTOS_THROUGHPUT 0x08 5144369Skarels #define IPTOS_RELIABILITY 0x04 5244369Skarels 5344369Skarels /* 5444369Skarels * Definitions for IP precedence (also in ip_tos) (hopefully unused) 5544369Skarels */ 5644369Skarels #define IPTOS_PREC_NETCONTROL 0xe0 5744369Skarels #define IPTOS_PREC_INTERNETCONTROL 0xc0 5844369Skarels #define IPTOS_PREC_CRITIC_ECP 0xa0 5944369Skarels #define IPTOS_PREC_FLASHOVERRIDE 0x80 6044369Skarels #define IPTOS_PREC_FLASH 0x60 6144369Skarels #define IPTOS_PREC_IMMEDIATE 0x40 6244369Skarels #define IPTOS_PREC_PRIORITY 0x20 6344369Skarels #define IPTOS_PREC_ROUTINE 0x10 6444369Skarels 6544369Skarels /* 664662Swnj * Definitions for options. 674571Swnj */ 684662Swnj #define IPOPT_COPIED(o) ((o)&0x80) 6916051Skarels #define IPOPT_CLASS(o) ((o)&0x60) 7016051Skarels #define IPOPT_NUMBER(o) ((o)&0x1f) 714662Swnj 724662Swnj #define IPOPT_CONTROL 0x00 7316051Skarels #define IPOPT_RESERVED1 0x20 7416051Skarels #define IPOPT_DEBMEAS 0x40 7516051Skarels #define IPOPT_RESERVED2 0x60 764662Swnj 774662Swnj #define IPOPT_EOL 0 /* end of option list */ 784662Swnj #define IPOPT_NOP 1 /* no operation */ 794662Swnj 804662Swnj #define IPOPT_RR 7 /* record packet route */ 814662Swnj #define IPOPT_TS 68 /* timestamp */ 824662Swnj #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 834662Swnj #define IPOPT_LSRR 131 /* loose source route */ 844662Swnj #define IPOPT_SATID 136 /* satnet id */ 854662Swnj #define IPOPT_SSRR 137 /* strict source route */ 864662Swnj 874662Swnj /* 8824810Skarels * Offsets to fields in options other than EOL and NOP. 8924810Skarels */ 9024810Skarels #define IPOPT_OPTVAL 0 /* option ID */ 9124810Skarels #define IPOPT_OLEN 1 /* option length */ 9224810Skarels #define IPOPT_OFFSET 2 /* offset within option */ 9324810Skarels #define IPOPT_MINOFF 4 /* min value of above */ 9424810Skarels 9524810Skarels /* 964662Swnj * Time stamp option structure. 974662Swnj */ 984662Swnj struct ip_timestamp { 994662Swnj u_char ipt_code; /* IPOPT_TS */ 1004662Swnj u_char ipt_len; /* size of structure (variable) */ 1014662Swnj u_char ipt_ptr; /* index of current entry */ 10233283Skarels #if BYTE_ORDER == LITTLE_ENDIAN 1034662Swnj u_char ipt_flg:4, /* flags, see below */ 1044662Swnj ipt_oflw:4; /* overflow counter */ 10529923Skarels #endif 10633283Skarels #if BYTE_ORDER == BIG_ENDIAN 10729923Skarels u_char ipt_oflw:4, /* overflow counter */ 10829923Skarels ipt_flg:4; /* flags, see below */ 10929923Skarels #endif 11033283Skarels union ipt_timestamp { 1114662Swnj n_long ipt_time[1]; 1124662Swnj struct ipt_ta { 1134923Swnj struct in_addr ipt_addr; 1144662Swnj n_long ipt_time; 1154662Swnj } ipt_ta[1]; 11633283Skarels } ipt_timestamp; 1174662Swnj }; 1184662Swnj 1194662Swnj /* flag bits for ipt_flg */ 1204662Swnj #define IPOPT_TS_TSONLY 0 /* timestamps only */ 1214662Swnj #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 12236842Skarels #define IPOPT_TS_PRESPEC 3 /* specified modules only */ 1234662Swnj 1244662Swnj /* bits for security (not byte swapped) */ 1254662Swnj #define IPOPT_SECUR_UNCLASS 0x0000 1264662Swnj #define IPOPT_SECUR_CONFID 0xf135 1274662Swnj #define IPOPT_SECUR_EFTO 0x789a 1284662Swnj #define IPOPT_SECUR_MMMM 0xbc4d 1294662Swnj #define IPOPT_SECUR_RESTR 0xaf13 1304662Swnj #define IPOPT_SECUR_SECRET 0xd788 1314662Swnj #define IPOPT_SECUR_TOPSECRET 0x6bc5 1324662Swnj 1334662Swnj /* 1344662Swnj * Internet implementation parameters. 1354662Swnj */ 1364571Swnj #define MAXTTL 255 /* maximum time to live (seconds) */ 13730291Skarels #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 13816523Skarels #define IPTTLDEC 1 /* subtracted when forwarding */ 13917272Skarels 14017272Skarels #define IP_MSS 576 /* default maximum segment size */ 141