Commit | Line | Data |
---|---|---|
8ae0e4b4 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
2b6b6284 | 3 | * All rights reserved. |
8ae0e4b4 | 4 | * |
2b6b6284 | 5 | * Redistribution and use in source and binary forms are permitted |
616d42db KB |
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. | |
2b6b6284 | 16 | * |
616d42db | 17 | * @(#)ip_var.h 7.5 (Berkeley) %G% |
8ae0e4b4 | 18 | */ |
77e50f35 BJ |
19 | |
20 | /* | |
21 | * Overlay for ip header used by other protocols (tcp, udp). | |
22 | */ | |
23 | struct ipovly { | |
eb44bfb2 BJ |
24 | caddr_t ih_next, ih_prev; /* for protocol sequence q's */ |
25 | u_char ih_x1; /* (unused) */ | |
26 | u_char ih_pr; /* protocol */ | |
2b4b57cd BJ |
27 | short ih_len; /* protocol length */ |
28 | struct in_addr ih_src; /* source internet address */ | |
29 | struct in_addr ih_dst; /* destination internet address */ | |
77e50f35 BJ |
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 */ | |
2b4b57cd | 45 | struct in_addr ipq_src,ipq_dst; |
77e50f35 BJ |
46 | }; |
47 | ||
48 | /* | |
49 | * Ip header, when holding a fragment. | |
af8f6a21 SL |
50 | * |
51 | * Note: ipf_next must be at same offset as ipq_next above | |
77e50f35 BJ |
52 | */ |
53 | struct ipasfrag { | |
f8b9a4f5 | 54 | #if BYTE_ORDER == LITTLE_ENDIAN |
77e50f35 BJ |
55 | u_char ip_hl:4, |
56 | ip_v:4; | |
f112c673 | 57 | #endif |
f8b9a4f5 | 58 | #if BYTE_ORDER == BIG_ENDIAN |
f112c673 MK |
59 | u_char ip_v:4, |
60 | ip_hl:4; | |
498aff44 | 61 | #endif |
77e50f35 BJ |
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; | |
eb44bfb2 BJ |
69 | struct ipasfrag *ipf_next; /* next fragment */ |
70 | struct ipasfrag *ipf_prev; /* previous fragment */ | |
77e50f35 BJ |
71 | }; |
72 | ||
8b2d0afb MK |
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 | ||
2b4b57cd | 86 | struct ipstat { |
8b2d0afb MK |
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 */ | |
3f22f2b1 MK |
96 | long ips_forward; /* packets forwarded */ |
97 | long ips_cantforward; /* packets rcvd for unreachable dest */ | |
8b2d0afb | 98 | long ips_redirectsent; /* packets forwarded on same net */ |
2b4b57cd BJ |
99 | }; |
100 | ||
77e50f35 | 101 | #ifdef KERNEL |
0e3f761f | 102 | /* flags passed to ip_output as last parameter */ |
8f45cd54 MK |
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 */ | |
0e3f761f | 106 | |
2b4b57cd | 107 | struct ipstat ipstat; |
77e50f35 | 108 | struct ipq ipq; /* ip reass. queue */ |
77e50f35 | 109 | u_short ip_id; /* ip packet ctr, for ids */ |
8b2d0afb MK |
110 | |
111 | struct mbuf *ip_srcroute(); | |
77e50f35 | 112 | #endif |