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 KB |
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 | * | |
f8b9a4f5 | 12 | * @(#)ip_var.h 7.4 (Berkeley) %G% |
8ae0e4b4 | 13 | */ |
77e50f35 BJ |
14 | |
15 | /* | |
16 | * Overlay for ip header used by other protocols (tcp, udp). | |
17 | */ | |
18 | struct ipovly { | |
eb44bfb2 BJ |
19 | caddr_t ih_next, ih_prev; /* for protocol sequence q's */ |
20 | u_char ih_x1; /* (unused) */ | |
21 | u_char ih_pr; /* protocol */ | |
2b4b57cd BJ |
22 | short ih_len; /* protocol length */ |
23 | struct in_addr ih_src; /* source internet address */ | |
24 | struct in_addr ih_dst; /* destination internet address */ | |
77e50f35 BJ |
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 */ | |
2b4b57cd | 40 | struct in_addr ipq_src,ipq_dst; |
77e50f35 BJ |
41 | }; |
42 | ||
43 | /* | |
44 | * Ip header, when holding a fragment. | |
af8f6a21 SL |
45 | * |
46 | * Note: ipf_next must be at same offset as ipq_next above | |
77e50f35 BJ |
47 | */ |
48 | struct ipasfrag { | |
f8b9a4f5 | 49 | #if BYTE_ORDER == LITTLE_ENDIAN |
77e50f35 BJ |
50 | u_char ip_hl:4, |
51 | ip_v:4; | |
f112c673 | 52 | #endif |
f8b9a4f5 | 53 | #if BYTE_ORDER == BIG_ENDIAN |
f112c673 MK |
54 | u_char ip_v:4, |
55 | ip_hl:4; | |
498aff44 | 56 | #endif |
77e50f35 BJ |
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; | |
eb44bfb2 BJ |
64 | struct ipasfrag *ipf_next; /* next fragment */ |
65 | struct ipasfrag *ipf_prev; /* previous fragment */ | |
77e50f35 BJ |
66 | }; |
67 | ||
8b2d0afb MK |
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 | ||
2b4b57cd | 81 | struct ipstat { |
8b2d0afb MK |
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 */ | |
3f22f2b1 MK |
91 | long ips_forward; /* packets forwarded */ |
92 | long ips_cantforward; /* packets rcvd for unreachable dest */ | |
8b2d0afb | 93 | long ips_redirectsent; /* packets forwarded on same net */ |
2b4b57cd BJ |
94 | }; |
95 | ||
77e50f35 | 96 | #ifdef KERNEL |
0e3f761f | 97 | /* flags passed to ip_output as last parameter */ |
8f45cd54 MK |
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 */ | |
0e3f761f | 101 | |
2b4b57cd | 102 | struct ipstat ipstat; |
77e50f35 | 103 | struct ipq ipq; /* ip reass. queue */ |
77e50f35 | 104 | u_short ip_id; /* ip packet ctr, for ids */ |
8b2d0afb MK |
105 | |
106 | struct mbuf *ip_srcroute(); | |
77e50f35 | 107 | #endif |