123181Smckusick /* 229140Smckusick * Copyright (c) 1982, 1986 Regents of the University of California. 332787Sbostic * All rights reserved. 423181Smckusick * 544477Sbostic * %sccs.include.redist.c% 632787Sbostic * 7*59129Smckusick * @(#)ip.h 7.12 (Berkeley) 04/18/93 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 */ 3858140Sandrew #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ 394571Swnj u_char ip_ttl; /* time to live */ 404571Swnj u_char ip_p; /* protocol */ 414571Swnj u_short ip_sum; /* checksum */ 424923Swnj struct in_addr ip_src,ip_dst; /* source and dest address */ 434498Swnj }; 444498Swnj 4533518Skarels #define IP_MAXPACKET 65535 /* maximum packet size */ 4633518Skarels 474571Swnj /* 4844369Skarels * Definitions for IP type of service (ip_tos) 4944369Skarels */ 5044369Skarels #define IPTOS_LOWDELAY 0x10 5144369Skarels #define IPTOS_THROUGHPUT 0x08 5244369Skarels #define IPTOS_RELIABILITY 0x04 5344369Skarels 5444369Skarels /* 5544369Skarels * Definitions for IP precedence (also in ip_tos) (hopefully unused) 5644369Skarels */ 5744369Skarels #define IPTOS_PREC_NETCONTROL 0xe0 5844369Skarels #define IPTOS_PREC_INTERNETCONTROL 0xc0 5944369Skarels #define IPTOS_PREC_CRITIC_ECP 0xa0 6044369Skarels #define IPTOS_PREC_FLASHOVERRIDE 0x80 6144369Skarels #define IPTOS_PREC_FLASH 0x60 6244369Skarels #define IPTOS_PREC_IMMEDIATE 0x40 6344369Skarels #define IPTOS_PREC_PRIORITY 0x20 6444369Skarels #define IPTOS_PREC_ROUTINE 0x10 6544369Skarels 6644369Skarels /* 674662Swnj * Definitions for options. 684571Swnj */ 694662Swnj #define IPOPT_COPIED(o) ((o)&0x80) 7016051Skarels #define IPOPT_CLASS(o) ((o)&0x60) 7116051Skarels #define IPOPT_NUMBER(o) ((o)&0x1f) 724662Swnj 734662Swnj #define IPOPT_CONTROL 0x00 7416051Skarels #define IPOPT_RESERVED1 0x20 7516051Skarels #define IPOPT_DEBMEAS 0x40 7616051Skarels #define IPOPT_RESERVED2 0x60 774662Swnj 784662Swnj #define IPOPT_EOL 0 /* end of option list */ 794662Swnj #define IPOPT_NOP 1 /* no operation */ 804662Swnj 814662Swnj #define IPOPT_RR 7 /* record packet route */ 824662Swnj #define IPOPT_TS 68 /* timestamp */ 834662Swnj #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 844662Swnj #define IPOPT_LSRR 131 /* loose source route */ 854662Swnj #define IPOPT_SATID 136 /* satnet id */ 864662Swnj #define IPOPT_SSRR 137 /* strict source route */ 874662Swnj 884662Swnj /* 8924810Skarels * Offsets to fields in options other than EOL and NOP. 9024810Skarels */ 9124810Skarels #define IPOPT_OPTVAL 0 /* option ID */ 9224810Skarels #define IPOPT_OLEN 1 /* option length */ 9324810Skarels #define IPOPT_OFFSET 2 /* offset within option */ 9424810Skarels #define IPOPT_MINOFF 4 /* min value of above */ 9524810Skarels 9624810Skarels /* 974662Swnj * Time stamp option structure. 984662Swnj */ 994662Swnj struct ip_timestamp { 1004662Swnj u_char ipt_code; /* IPOPT_TS */ 1014662Swnj u_char ipt_len; /* size of structure (variable) */ 1024662Swnj u_char ipt_ptr; /* index of current entry */ 10333283Skarels #if BYTE_ORDER == LITTLE_ENDIAN 1044662Swnj u_char ipt_flg:4, /* flags, see below */ 1054662Swnj ipt_oflw:4; /* overflow counter */ 10629923Skarels #endif 10733283Skarels #if BYTE_ORDER == BIG_ENDIAN 10829923Skarels u_char ipt_oflw:4, /* overflow counter */ 10929923Skarels ipt_flg:4; /* flags, see below */ 11029923Skarels #endif 11133283Skarels union ipt_timestamp { 1124662Swnj n_long ipt_time[1]; 1134662Swnj struct ipt_ta { 1144923Swnj struct in_addr ipt_addr; 1154662Swnj n_long ipt_time; 1164662Swnj } ipt_ta[1]; 11733283Skarels } ipt_timestamp; 1184662Swnj }; 1194662Swnj 1204662Swnj /* flag bits for ipt_flg */ 1214662Swnj #define IPOPT_TS_TSONLY 0 /* timestamps only */ 1224662Swnj #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 12336842Skarels #define IPOPT_TS_PRESPEC 3 /* specified modules only */ 1244662Swnj 1254662Swnj /* bits for security (not byte swapped) */ 1264662Swnj #define IPOPT_SECUR_UNCLASS 0x0000 1274662Swnj #define IPOPT_SECUR_CONFID 0xf135 1284662Swnj #define IPOPT_SECUR_EFTO 0x789a 1294662Swnj #define IPOPT_SECUR_MMMM 0xbc4d 1304662Swnj #define IPOPT_SECUR_RESTR 0xaf13 1314662Swnj #define IPOPT_SECUR_SECRET 0xd788 1324662Swnj #define IPOPT_SECUR_TOPSECRET 0x6bc5 1334662Swnj 1344662Swnj /* 1354662Swnj * Internet implementation parameters. 1364662Swnj */ 1374571Swnj #define MAXTTL 255 /* maximum time to live (seconds) */ 138*59129Smckusick #define IPDEFTTL 64 /* default ttl, from RFC 1340 */ 13930291Skarels #define IPFRAGTTL 60 /* time to live for frags, slowhz */ 14016523Skarels #define IPTTLDEC 1 /* subtracted when forwarding */ 14117272Skarels 14217272Skarels #define IP_MSS 576 /* default maximum segment size */ 143