123181Smckusick /* 2*29140Smckusick * 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*29140Smckusick * @(#)ip.h 7.1 (Berkeley) 06/05/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 { 239991Ssam #ifdef vax 244571Swnj u_char ip_hl:4, /* header length */ 254571Swnj ip_v:4; /* version */ 269991Ssam #endif 274571Swnj u_char ip_tos; /* type of service */ 284647Swnj short ip_len; /* total length */ 294571Swnj u_short ip_id; /* identification */ 304647Swnj short ip_off; /* fragment offset field */ 314662Swnj #define IP_DF 0x4000 /* dont fragment flag */ 324662Swnj #define IP_MF 0x2000 /* more fragments flag */ 334571Swnj u_char ip_ttl; /* time to live */ 344571Swnj u_char ip_p; /* protocol */ 354571Swnj u_short ip_sum; /* checksum */ 364923Swnj struct in_addr ip_src,ip_dst; /* source and dest address */ 374498Swnj }; 384498Swnj 394571Swnj /* 404662Swnj * Definitions for options. 414571Swnj */ 424662Swnj #define IPOPT_COPIED(o) ((o)&0x80) 4316051Skarels #define IPOPT_CLASS(o) ((o)&0x60) 4416051Skarels #define IPOPT_NUMBER(o) ((o)&0x1f) 454662Swnj 464662Swnj #define IPOPT_CONTROL 0x00 4716051Skarels #define IPOPT_RESERVED1 0x20 4816051Skarels #define IPOPT_DEBMEAS 0x40 4916051Skarels #define IPOPT_RESERVED2 0x60 504662Swnj 514662Swnj #define IPOPT_EOL 0 /* end of option list */ 524662Swnj #define IPOPT_NOP 1 /* no operation */ 534662Swnj 544662Swnj #define IPOPT_RR 7 /* record packet route */ 554662Swnj #define IPOPT_TS 68 /* timestamp */ 564662Swnj #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 574662Swnj #define IPOPT_LSRR 131 /* loose source route */ 584662Swnj #define IPOPT_SATID 136 /* satnet id */ 594662Swnj #define IPOPT_SSRR 137 /* strict source route */ 604662Swnj 614662Swnj /* 6224810Skarels * Offsets to fields in options other than EOL and NOP. 6324810Skarels */ 6424810Skarels #define IPOPT_OPTVAL 0 /* option ID */ 6524810Skarels #define IPOPT_OLEN 1 /* option length */ 6624810Skarels #define IPOPT_OFFSET 2 /* offset within option */ 6724810Skarels #define IPOPT_MINOFF 4 /* min value of above */ 6824810Skarels 6924810Skarels /* 704662Swnj * Time stamp option structure. 714662Swnj */ 724662Swnj struct ip_timestamp { 734662Swnj u_char ipt_code; /* IPOPT_TS */ 744662Swnj u_char ipt_len; /* size of structure (variable) */ 754662Swnj u_char ipt_ptr; /* index of current entry */ 764662Swnj u_char ipt_flg:4, /* flags, see below */ 774662Swnj ipt_oflw:4; /* overflow counter */ 784662Swnj union { 794662Swnj n_long ipt_time[1]; 804662Swnj struct ipt_ta { 814923Swnj struct in_addr ipt_addr; 824662Swnj n_long ipt_time; 834662Swnj } ipt_ta[1]; 844662Swnj } 854662Swnj }; 864662Swnj 874662Swnj /* flag bits for ipt_flg */ 884662Swnj #define IPOPT_TS_TSONLY 0 /* timestamps only */ 894662Swnj #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 904662Swnj #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 914662Swnj 924662Swnj /* bits for security (not byte swapped) */ 934662Swnj #define IPOPT_SECUR_UNCLASS 0x0000 944662Swnj #define IPOPT_SECUR_CONFID 0xf135 954662Swnj #define IPOPT_SECUR_EFTO 0x789a 964662Swnj #define IPOPT_SECUR_MMMM 0xbc4d 974662Swnj #define IPOPT_SECUR_RESTR 0xaf13 984662Swnj #define IPOPT_SECUR_SECRET 0xd788 994662Swnj #define IPOPT_SECUR_TOPSECRET 0x6bc5 1004662Swnj 1014662Swnj /* 1024662Swnj * Internet implementation parameters. 1034662Swnj */ 1044571Swnj #define MAXTTL 255 /* maximum time to live (seconds) */ 1054662Swnj #define IPFRAGTTL 15 /* time to live for frag chains */ 10616523Skarels #define IPTTLDEC 1 /* subtracted when forwarding */ 10717272Skarels 10817272Skarels #define IP_MSS 576 /* default maximum segment size */ 109