|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7: * Reserved. This file contains Original Code and/or Modifications of
8: * Original Code as defined in and that are subject to the Apple Public
9: * Source License Version 1.1 (the "License"). You may not use this file
10: * except in compliance with the License. Please obtain a copy of the
11: * License at http://www.apple.com/publicsource and read it before using
12: * this file.
13: *
14: * The Original Code and all software distributed under the License are
15: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
19: * License for the specific language governing rights and limitations
20: * under the License.
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24:
25: /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
26: /*
27: * Copyright (c) 1982, 1986, 1993
28: * The Regents of the University of California. All rights reserved.
29: *
30: * Redistribution and use in source and binary forms, with or without
31: * modification, are permitted provided that the following conditions
32: * are met:
33: * 1. Redistributions of source code must retain the above copyright
34: * notice, this list of conditions and the following disclaimer.
35: * 2. Redistributions in binary form must reproduce the above copyright
36: * notice, this list of conditions and the following disclaimer in the
37: * documentation and/or other materials provided with the distribution.
38: * 3. All advertising materials mentioning features or use of this software
39: * must display the following acknowledgement:
40: * This product includes software developed by the University of
41: * California, Berkeley and its contributors.
42: * 4. Neither the name of the University nor the names of its contributors
43: * may be used to endorse or promote products derived from this software
44: * without specific prior written permission.
45: *
46: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
47: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
48: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
49: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
50: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
51: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
52: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
54: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
55: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56: * SUCH DAMAGE.
57: *
58: * @(#)ip_var.h 8.2 (Berkeley) 1/9/95
59: */
60:
61: /*
62: * Overlay for ip header used by other protocols (tcp, udp).
63: */
64: struct ipovly {
65: caddr_t ih_next, ih_prev; /* for protocol sequence q's */
66: u_char ih_x1; /* (unused) */
67: u_char ih_pr; /* protocol */
68: short ih_len; /* protocol length */
69: struct in_addr ih_src; /* source internet address */
70: struct in_addr ih_dst; /* destination internet address */
71: };
72:
73: /*
74: * Ip reassembly queue structure. Each fragment
75: * being reassembled is attached to one of these structures.
76: * They are timed out after ipq_ttl drops to 0, and may also
77: * be reclaimed if memory becomes tight.
78: */
79: struct ipq {
80: struct ipq *next,*prev; /* to other reass headers */
81: u_char ipq_ttl; /* time for reass q to live */
82: u_char ipq_p; /* protocol of this fragment */
83: u_short ipq_id; /* sequence id for reassembly */
84: struct ipasfrag *ipq_next,*ipq_prev;
85: /* to ip headers of fragments */
86: struct in_addr ipq_src,ipq_dst;
87: };
88:
89: /*
90: * Ip header, when holding a fragment.
91: *
92: * Note: ipf_next must be at same offset as ipq_next above
93: */
94: struct ipasfrag {
95: #if BYTE_ORDER == LITTLE_ENDIAN
96: u_char ip_hl:4,
97: ip_v:4;
98: #endif
99: #if BYTE_ORDER == BIG_ENDIAN
100: u_char ip_v:4,
101: ip_hl:4;
102: #endif
103: u_char ipf_mff; /* XXX overlays ip_tos: use low bit
104: * to avoid destroying tos;
105: * copied from (ip_off&IP_MF) */
106: short ip_len;
107: u_short ip_id;
108: short ip_off;
109: u_char ip_ttl;
110: u_char ip_p;
111: u_short ip_sum;
112: struct ipasfrag *ipf_next; /* next fragment */
113: struct ipasfrag *ipf_prev; /* previous fragment */
114: };
115:
116: /*
117: * Structure stored in mbuf in inpcb.ip_options
118: * and passed to ip_output when ip options are in use.
119: * The actual length of the options (including ipopt_dst)
120: * is in m_len.
121: */
122: #define MAX_IPOPTLEN 40
123:
124: struct ipoption {
125: struct in_addr ipopt_dst; /* first-hop dst if source routed */
126: char ipopt_list[MAX_IPOPTLEN]; /* options proper */
127: };
128:
129: /*
130: * Structure attached to inpcb.ip_moptions and
131: * passed to ip_output when IP multicast options are in use.
132: */
133: struct ip_moptions {
134: struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
135: u_char imo_multicast_ttl; /* TTL for outgoing multicasts */
136: u_char imo_multicast_loop; /* 1 => hear sends if a member */
137: u_short imo_num_memberships; /* no. memberships this socket */
138: struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
139: };
140:
141: struct ipstat {
142: u_long ips_total; /* total packets received */
143: u_long ips_badsum; /* checksum bad */
144: u_long ips_tooshort; /* packet too short */
145: u_long ips_toosmall; /* not enough data */
146: u_long ips_badhlen; /* ip header length < data size */
147: u_long ips_badlen; /* ip length < ip header length */
148: u_long ips_fragments; /* fragments received */
149: u_long ips_fragdropped; /* frags dropped (dups, out of space) */
150: u_long ips_fragtimeout; /* fragments timed out */
151: u_long ips_forward; /* packets forwarded */
152: u_long ips_cantforward; /* packets rcvd for unreachable dest */
153: u_long ips_redirectsent; /* packets forwarded on same net */
154: u_long ips_noproto; /* unknown or unsupported protocol */
155: u_long ips_delivered; /* datagrams delivered to upper level*/
156: u_long ips_localout; /* total ip packets generated here */
157: u_long ips_odropped; /* lost packets due to nobufs, etc. */
158: u_long ips_reassembled; /* total packets reassembled ok */
159: u_long ips_fragmented; /* datagrams sucessfully fragmented */
160: u_long ips_ofragments; /* output fragments created */
161: u_long ips_cantfrag; /* don't fragment flag was set, etc. */
162: u_long ips_badoptions; /* error in option processing */
163: u_long ips_noroute; /* packets discarded due to no route */
164: u_long ips_badvers; /* ip version != 4 */
165: u_long ips_rawout; /* total raw ip packets generated */
166: };
167:
168: #ifdef _KERNEL
169: /* flags passed to ip_output as last parameter */
170: #define IP_FORWARDING 0x1 /* most of ip header exists */
171: #define IP_RAWOUTPUT 0x2 /* raw ip header exists */
172: #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
173: #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
174:
175: extern struct ipstat ipstat;
176: extern struct ipq ipq; /* ip reass. queue */
177: extern u_short ip_id; /* ip packet ctr, for ids */
178: extern int ip_defttl; /* default IP ttl */
179:
180: int in_control __P((struct socket *, u_long, caddr_t, struct ifnet *));
181: int ip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
182: void ip_deq __P((struct ipasfrag *));
183: int ip_dooptions __P((struct mbuf *));
184: void ip_drain __P((void));
185: void ip_enq __P((struct ipasfrag *, struct ipasfrag *));
186: void ip_forward __P((struct mbuf *, int));
187: void ip_freef __P((struct ipq *));
188: void ip_freemoptions __P((struct ip_moptions *));
189: int ip_getmoptions __P((int, struct ip_moptions *, struct mbuf **));
190: void ip_init __P((void));
191: int ip_mforward __P((struct mbuf *, struct ifnet *));
192: int ip_optcopy __P((struct ip *, struct ip *));
193: int ip_output __P((struct mbuf *,
194: struct mbuf *, struct route *, int, struct ip_moptions *));
195: int ip_pcbopts __P((struct mbuf **, struct mbuf *));
196: struct ip *
197: ip_reass __P((struct ipasfrag *, struct ipq *));
198: struct in_ifaddr *
199: ip_rtaddr __P((struct in_addr));
200: int ip_setmoptions __P((int, struct ip_moptions **, struct mbuf *));
201: void ip_slowtimo __P((void));
202: struct mbuf *
203: ip_srcroute __P((void));
204: void ip_stripoptions __P((struct mbuf *, struct mbuf *));
205: int ip_sysctl __P((int *, u_int, void *, size_t *, void *, size_t));
206: void ipintr __P((void));
207: int rip_ctloutput __P((int, struct socket *, int, int, struct mbuf **));
208: void rip_init __P((void));
209: void rip_input __P((struct mbuf *));
210: int rip_output __P((struct mbuf *, struct socket *, u_long));
211: int rip_usrreq __P((struct socket *,
212: int, struct mbuf *, struct mbuf *, struct mbuf *));
213: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.