1 /* 2 * Copyright (c) 1982, 1986 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that this notice is preserved and that due credit is given 7 * to the University of California at Berkeley. The name of the University 8 * may not be used to endorse or promote products derived from this 9 * software without specific prior written permission. This software 10 * is provided ``as is'' without express or implied warranty. 11 * 12 * @(#)ip_var.h 7.3 (Berkeley) 12/07/87 13 */ 14 15 /* 16 * Overlay for ip header used by other protocols (tcp, udp). 17 */ 18 struct ipovly { 19 caddr_t ih_next, ih_prev; /* for protocol sequence q's */ 20 u_char ih_x1; /* (unused) */ 21 u_char ih_pr; /* protocol */ 22 short ih_len; /* protocol length */ 23 struct in_addr ih_src; /* source internet address */ 24 struct in_addr ih_dst; /* destination internet address */ 25 }; 26 27 /* 28 * Ip reassembly queue structure. Each fragment 29 * being reassembled is attached to one of these structures. 30 * They are timed out after ipq_ttl drops to 0, and may also 31 * be reclaimed if memory becomes tight. 32 */ 33 struct ipq { 34 struct ipq *next,*prev; /* to other reass headers */ 35 u_char ipq_ttl; /* time for reass q to live */ 36 u_char ipq_p; /* protocol of this fragment */ 37 u_short ipq_id; /* sequence id for reassembly */ 38 struct ipasfrag *ipq_next,*ipq_prev; 39 /* to ip headers of fragments */ 40 struct in_addr ipq_src,ipq_dst; 41 }; 42 43 /* 44 * Ip header, when holding a fragment. 45 * 46 * Note: ipf_next must be at same offset as ipq_next above 47 */ 48 struct ipasfrag { 49 #if ENDIAN == LITTLE 50 u_char ip_hl:4, 51 ip_v:4; 52 #endif 53 #if ENDIAN == BIG 54 u_char ip_v:4, 55 ip_hl:4; 56 #endif 57 u_char ipf_mff; /* copied from (ip_off&IP_MF) */ 58 short ip_len; 59 u_short ip_id; 60 short ip_off; 61 u_char ip_ttl; 62 u_char ip_p; 63 u_short ip_sum; 64 struct ipasfrag *ipf_next; /* next fragment */ 65 struct ipasfrag *ipf_prev; /* previous fragment */ 66 }; 67 68 /* 69 * Structure stored in mbuf in inpcb.ip_options 70 * and passed to ip_output when ip options are in use. 71 * The actual length of the options (including ipopt_dst) 72 * is in m_len. 73 */ 74 #define MAX_IPOPTLEN 40 75 76 struct ipoption { 77 struct in_addr ipopt_dst; /* first-hop dst if source routed */ 78 char ipopt_list[MAX_IPOPTLEN]; /* options proper */ 79 }; 80 81 struct ipstat { 82 long ips_total; /* total packets received */ 83 long ips_badsum; /* checksum bad */ 84 long ips_tooshort; /* packet too short */ 85 long ips_toosmall; /* not enough data */ 86 long ips_badhlen; /* ip header length < data size */ 87 long ips_badlen; /* ip length < ip header length */ 88 long ips_fragments; /* fragments received */ 89 long ips_fragdropped; /* frags dropped (dups, out of space) */ 90 long ips_fragtimeout; /* fragments timed out */ 91 long ips_forward; /* packets forwarded */ 92 long ips_cantforward; /* packets rcvd for unreachable dest */ 93 long ips_redirectsent; /* packets forwarded on same net */ 94 }; 95 96 #ifdef KERNEL 97 /* flags passed to ip_output as last parameter */ 98 #define IP_FORWARDING 0x1 /* most of ip header exists */ 99 #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ 100 #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ 101 102 struct ipstat ipstat; 103 struct ipq ipq; /* ip reass. queue */ 104 u_short ip_id; /* ip packet ctr, for ids */ 105 106 struct mbuf *ip_srcroute(); 107 #endif 108