1*4662Swnj /* ip.h 1.5 81/10/29 */ 24571Swnj 3*4662Swnj /* 4*4662Swnj * Definitions for internet protocol version 4. 5*4662Swnj * Per RFC 791, September 1981. 6*4662Swnj */ 7*4662Swnj #define IPVERSION 4 8*4662Swnj 9*4662Swnj /* 10*4662Swnj * Structure of an internet header, naked of options. 11*4662Swnj * 12*4662Swnj * SHOULD MAKE A VERSION OF THIS FOR KERNEL SO USER 13*4662Swnj * VERSION CAN BE union FREE AND INITIALIZABLE. 14*4662Swnj */ 154571Swnj struct ip { 164571Swnj u_char ip_hl:4, /* header length */ 174571Swnj ip_v:4; /* version */ 184571Swnj u_char ip_tos; /* type of service */ 19*4662Swnj /* we copy the IP_MF to ip_tos on input */ 20*4662Swnj #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 */ 29*4662Swnj #define IP_DF 0x4000 /* dont fragment flag */ 30*4662Swnj #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 { 354571Swnj struct socket 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 { 414571Swnj struct socket 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 /* 49*4662Swnj * Definitions for options. 504571Swnj */ 51*4662Swnj #define IPOPT_COPIED(o) ((o)&0x80) 52*4662Swnj #define IPOPT_CLASS(o) ((o)&0x40) 53*4662Swnj #define IPOPT_NUMBER(o) ((o)&0x3f) 54*4662Swnj 55*4662Swnj #define IPOPT_CONTROL 0x00 56*4662Swnj #define IPOPT_RESERVED1 0x10 57*4662Swnj #define IPOPT_DEBMEAS 0x20 58*4662Swnj #define IPOPT_RESERVED2 0x30 59*4662Swnj 60*4662Swnj #define IPOPT_EOL 0 /* end of option list */ 61*4662Swnj #define IPOPT_NOP 1 /* no operation */ 62*4662Swnj 63*4662Swnj #define IPOPT_RR 7 /* record packet route */ 64*4662Swnj #define IPOPT_TS 68 /* timestamp */ 65*4662Swnj #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */ 66*4662Swnj #define IPOPT_LSRR 131 /* loose source route */ 67*4662Swnj #define IPOPT_SATID 136 /* satnet id */ 68*4662Swnj #define IPOPT_SSRR 137 /* strict source route */ 69*4662Swnj 70*4662Swnj /* 71*4662Swnj * Time stamp option structure. 72*4662Swnj */ 73*4662Swnj struct ip_timestamp { 74*4662Swnj u_char ipt_code; /* IPOPT_TS */ 75*4662Swnj u_char ipt_len; /* size of structure (variable) */ 76*4662Swnj u_char ipt_ptr; /* index of current entry */ 77*4662Swnj u_char ipt_flg:4, /* flags, see below */ 78*4662Swnj ipt_oflw:4; /* overflow counter */ 79*4662Swnj union { 80*4662Swnj n_long ipt_time[1]; 81*4662Swnj struct ipt_ta { 82*4662Swnj struct socket ipt_addr; 83*4662Swnj n_long ipt_time; 84*4662Swnj } ipt_ta[1]; 85*4662Swnj } 86*4662Swnj }; 87*4662Swnj 88*4662Swnj /* flag bits for ipt_flg */ 89*4662Swnj #define IPOPT_TS_TSONLY 0 /* timestamps only */ 90*4662Swnj #define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ 91*4662Swnj #define IPOPT_TS_PRESPEC 2 /* specified modules only */ 92*4662Swnj 93*4662Swnj /* bits for security (not byte swapped) */ 94*4662Swnj #define IPOPT_SECUR_UNCLASS 0x0000 95*4662Swnj #define IPOPT_SECUR_CONFID 0xf135 96*4662Swnj #define IPOPT_SECUR_EFTO 0x789a 97*4662Swnj #define IPOPT_SECUR_MMMM 0xbc4d 98*4662Swnj #define IPOPT_SECUR_RESTR 0xaf13 99*4662Swnj #define IPOPT_SECUR_SECRET 0xd788 100*4662Swnj #define IPOPT_SECUR_TOPSECRET 0x6bc5 101*4662Swnj 102*4662Swnj /* 103*4662Swnj * Ip reassembly queue structure. Each fragment 104*4662Swnj * being reassambled is attached to one of these structures. 105*4662Swnj * They are timed out after ipq_ttl drops to 0, and may also 106*4662Swnj * be reclaimed if memory becomes tight. 107*4662Swnj */ 1084571Swnj struct ipq { 109*4662Swnj struct ipq *next,*prev; /* to other reass headers */ 110*4662Swnj u_char ipq_ttl; /* time for reass q to live */ 111*4662Swnj u_char ipq_p; /* protocol of this fragment */ 112*4662Swnj u_short ipq_id; /* sequence id for reassembly */ 113*4662Swnj struct ip *ipq_next,*ipq_prev; /* to ip headers of fragments */ 114*4662Swnj struct socket ipq_src,ipq_dst; 1154498Swnj }; 1164498Swnj 117*4662Swnj /* 118*4662Swnj * Internet implementation parameters. 119*4662Swnj */ 1204571Swnj #define MAXTTL 255 /* maximum time to live (seconds) */ 121*4662Swnj #define IPFRAGTTL 15 /* time to live for frag chains */ 1224498Swnj 123*4662Swnj #ifdef KERNEL 124*4662Swnj struct ipq ipq; /* ip reass. queue */ 125*4662Swnj struct ipq *ip_freef(); 126*4662Swnj u_short ip_id; /* ip packet ctr, for ids */ 127*4662Swnj #endif 128