1*4801Swnj /* ip.h 1.6 81/11/08 */ 24571Swnj 34662Swnj /* 44662Swnj * Definitions for internet protocol version 4. 54662Swnj * Per RFC 791, September 1981. 64662Swnj */ 74662Swnj #define IPVERSION 4 84662Swnj 94662Swnj /* 104662Swnj * Structure of an internet header, naked of options. 114662Swnj * 124662Swnj * SHOULD MAKE A VERSION OF THIS FOR KERNEL SO USER 134662Swnj * VERSION CAN BE union FREE AND INITIALIZABLE. 144662Swnj */ 154571Swnj struct ip { 164571Swnj u_char ip_hl:4, /* header length */ 174571Swnj ip_v:4; /* version */ 184571Swnj u_char ip_tos; /* type of service */ 194662Swnj /* we copy the IP_MF to ip_tos on input */ 204662Swnj #define ip_mff ip_tos /* more fragments flag */ 214647Swnj /* by rights, ip_len should be a u_short, but this makes operations */ 224647Swnj /* on it very dangerous as comparisons become unsigned and comparing */ 234647Swnj /* against negative numbers then fails... we don't expect any > 32767 */ 244647Swnj /* byte packets, so pragmatically delcare it to be a short */ 254647Swnj short ip_len; /* total length */ 264571Swnj u_short ip_id; /* identification */ 274647Swnj /* ip_off should also, by rights, be u_short, ala ip_len */ 284647Swnj short ip_off; /* fragment offset field */ 294662Swnj #define IP_DF 0x4000 /* dont fragment flag */ 304662Swnj #define IP_MF 0x2000 /* more fragments flag */ 314571Swnj u_char ip_ttl; /* time to live */ 324571Swnj u_char ip_p; /* protocol */ 334571Swnj u_short ip_sum; /* checksum */ 344498Swnj union { 35*4801Swnj struct ip_addr ip_s; /* source address */ 364571Swnj struct ip *ip_nxt; /* next fragment */ 374498Swnj } I_sun; 384571Swnj #define ip_src I_sun.ip_s 394571Swnj #define ip_next I_sun.ip_nxt 404498Swnj union { 41*4801Swnj struct ip_addr ip_d; /* destination address */ 424571Swnj struct ip *ip_prv; /* prev fragment */ 434498Swnj } I_dun; 444571Swnj #define ip_dst I_dun.ip_d 454571Swnj #define ip_prev I_dun.ip_prv 464498Swnj }; 474498Swnj 484571Swnj /* 494662Swnj * Definitions for options. 504571Swnj */ 514662Swnj #define IPOPT_COPIED(o) ((o)&0x80) 524662Swnj #define IPOPT_CLASS(o) ((o)&0x40) 534662Swnj #define IPOPT_NUMBER(o) ((o)&0x3f) 544662Swnj 554662Swnj #define IPOPT_CONTROL 0x00 564662Swnj #define IPOPT_RESERVED1 0x10 574662Swnj #define IPOPT_DEBMEAS 0x20 584662Swnj #define IPOPT_RESERVED2 0x30 594662Swnj 604662Swnj #define IPOPT_EOL 0 /* end of option list */ 614662Swnj #define IPOPT_NOP 1 /* no operation */ 624662Swnj 634662Swnj #define IPOPT_RR 7 /* record packet route */ 644662Swnj #define IPOPT_TS 68 /* timestamp */ 654662Swnj #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 664662Swnj #define IPOPT_LSRR 131 /* loose source route */ 674662Swnj #define IPOPT_SATID 136 /* satnet id */ 684662Swnj #define IPOPT_SSRR 137 /* strict source route */ 694662Swnj 704662Swnj /* 714662Swnj * Time stamp option structure. 724662Swnj */ 734662Swnj struct ip_timestamp { 744662Swnj u_char ipt_code; /* IPOPT_TS */ 754662Swnj u_char ipt_len; /* size of structure (variable) */ 764662Swnj u_char ipt_ptr; /* index of current entry */ 774662Swnj u_char ipt_flg:4, /* flags, see below */ 784662Swnj ipt_oflw:4; /* overflow counter */ 794662Swnj union { 804662Swnj n_long ipt_time[1]; 814662Swnj struct ipt_ta { 82*4801Swnj struct ip_addr ipt_addr; 834662Swnj n_long ipt_time; 844662Swnj } ipt_ta[1]; 854662Swnj } 864662Swnj }; 874662Swnj 884662Swnj /* flag bits for ipt_flg */ 894662Swnj #define IPOPT_TS_TSONLY 0 /* timestamps only */ 904662Swnj #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 914662Swnj #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 924662Swnj 934662Swnj /* bits for security (not byte swapped) */ 944662Swnj #define IPOPT_SECUR_UNCLASS 0x0000 954662Swnj #define IPOPT_SECUR_CONFID 0xf135 964662Swnj #define IPOPT_SECUR_EFTO 0x789a 974662Swnj #define IPOPT_SECUR_MMMM 0xbc4d 984662Swnj #define IPOPT_SECUR_RESTR 0xaf13 994662Swnj #define IPOPT_SECUR_SECRET 0xd788 1004662Swnj #define IPOPT_SECUR_TOPSECRET 0x6bc5 1014662Swnj 1024662Swnj /* 1034662Swnj * Ip reassembly queue structure. Each fragment 1044662Swnj * being reassambled is attached to one of these structures. 1054662Swnj * They are timed out after ipq_ttl drops to 0, and may also 1064662Swnj * be reclaimed if memory becomes tight. 1074662Swnj */ 1084571Swnj struct ipq { 1094662Swnj struct ipq *next,*prev; /* to other reass headers */ 1104662Swnj u_char ipq_ttl; /* time for reass q to live */ 1114662Swnj u_char ipq_p; /* protocol of this fragment */ 1124662Swnj u_short ipq_id; /* sequence id for reassembly */ 1134662Swnj struct ip *ipq_next,*ipq_prev; /* to ip headers of fragments */ 114*4801Swnj struct ip_addr ipq_src,ipq_dst; 1154498Swnj }; 1164498Swnj 1174662Swnj /* 1184662Swnj * Internet implementation parameters. 1194662Swnj */ 1204571Swnj #define MAXTTL 255 /* maximum time to live (seconds) */ 1214662Swnj #define IPFRAGTTL 15 /* time to live for frag chains */ 1224498Swnj 1234662Swnj #ifdef KERNEL 1244662Swnj struct ipq ipq; /* ip reass. queue */ 1254662Swnj struct ipq *ip_freef(); 1264662Swnj u_short ip_id; /* ip packet ctr, for ids */ 1274662Swnj #endif 128