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