Deleted Added
full compact
ip_reass.c (111541) ip_reass.c (111888)
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94
1/*
2 * Copyright (c) 1982, 1986, 1988, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)ip_input.c 8.2 (Berkeley) 1/4/94
34 * $FreeBSD: head/sys/netinet/ip_input.c 111541 2003-02-26 07:28:35Z silby $
34 * $FreeBSD: head/sys/netinet/ip_input.c 111888 2003-03-04 23:19:55Z jlemon $
35 */
36
37#include "opt_bootp.h"
38#include "opt_ipfw.h"
39#include "opt_ipdn.h"
40#include "opt_ipdivert.h"
41#include "opt_ipfilter.h"
42#include "opt_ipstealth.h"

--- 17 unchanged lines hidden (view full) ---

60
61#include <net/pfil.h>
62#include <net/if.h>
63#include <net/if_types.h>
64#include <net/if_var.h>
65#include <net/if_dl.h>
66#include <net/route.h>
67#include <net/netisr.h>
35 */
36
37#include "opt_bootp.h"
38#include "opt_ipfw.h"
39#include "opt_ipdn.h"
40#include "opt_ipdivert.h"
41#include "opt_ipfilter.h"
42#include "opt_ipstealth.h"

--- 17 unchanged lines hidden (view full) ---

60
61#include <net/pfil.h>
62#include <net/if.h>
63#include <net/if_types.h>
64#include <net/if_var.h>
65#include <net/if_dl.h>
66#include <net/route.h>
67#include <net/netisr.h>
68#include <net/intrq.h>
69
70#include <netinet/in.h>
71#include <netinet/in_systm.h>
72#include <netinet/in_var.h>
73#include <netinet/ip.h>
74#include <netinet/in_pcb.h>
75#include <netinet/ip_var.h>
76#include <netinet/ip_icmp.h>

--- 74 unchanged lines hidden (view full) ---

151static int ip_checkinterface = 1;
152SYSCTL_INT(_net_inet_ip, OID_AUTO, check_interface, CTLFLAG_RW,
153 &ip_checkinterface, 0, "Verify packet arrives on correct interface");
154
155#ifdef DIAGNOSTIC
156static int ipprintfs = 0;
157#endif
158
68
69#include <netinet/in.h>
70#include <netinet/in_systm.h>
71#include <netinet/in_var.h>
72#include <netinet/ip.h>
73#include <netinet/in_pcb.h>
74#include <netinet/ip_var.h>
75#include <netinet/ip_icmp.h>

--- 74 unchanged lines hidden (view full) ---

150static int ip_checkinterface = 1;
151SYSCTL_INT(_net_inet_ip, OID_AUTO, check_interface, CTLFLAG_RW,
152 &ip_checkinterface, 0, "Verify packet arrives on correct interface");
153
154#ifdef DIAGNOSTIC
155static int ipprintfs = 0;
156#endif
157
158static struct ifqueue ipintrq;
159static int ipqmaxlen = IFQ_MAXLEN;
160
161extern struct domain inetdomain;
162extern struct protosw inetsw[];
163u_char ip_protox[IPPROTO_MAX];
164struct in_ifaddrhead in_ifaddrhead; /* first inet address */
165struct in_ifaddrhashhead *in_ifaddrhashtbl; /* inet addr hash table */
166u_long in_ifaddrhmask; /* mask for hash table */

--- 61 unchanged lines hidden (view full) ---

228static void save_rte(u_char *, struct in_addr);
229static int ip_dooptions(struct mbuf *m, int,
230 struct sockaddr_in *next_hop);
231static void ip_forward(struct mbuf *m, int srcrt,
232 struct sockaddr_in *next_hop);
233static void ip_freef(struct ipqhead *, struct ipq *);
234static struct mbuf *ip_reass(struct mbuf *, struct ipqhead *,
235 struct ipq *, u_int32_t *, u_int16_t *);
159static int ipqmaxlen = IFQ_MAXLEN;
160
161extern struct domain inetdomain;
162extern struct protosw inetsw[];
163u_char ip_protox[IPPROTO_MAX];
164struct in_ifaddrhead in_ifaddrhead; /* first inet address */
165struct in_ifaddrhashhead *in_ifaddrhashtbl; /* inet addr hash table */
166u_long in_ifaddrhmask; /* mask for hash table */

--- 61 unchanged lines hidden (view full) ---

228static void save_rte(u_char *, struct in_addr);
229static int ip_dooptions(struct mbuf *m, int,
230 struct sockaddr_in *next_hop);
231static void ip_forward(struct mbuf *m, int srcrt,
232 struct sockaddr_in *next_hop);
233static void ip_freef(struct ipqhead *, struct ipq *);
234static struct mbuf *ip_reass(struct mbuf *, struct ipqhead *,
235 struct ipq *, u_int32_t *, u_int16_t *);
236static void ipintr(void);
237
238/*
239 * IP initialization: fill in IP protocol switch table.
240 * All protocols not implemented in kernel go to raw IP protocol handler.
241 */
242void
243ip_init()
244{

--- 19 unchanged lines hidden (view full) ---

264 maxnipq = nmbclusters / 32;
265 maxfragsperpacket = 16;
266
267#ifndef RANDOM_IP_ID
268 ip_id = time_second & 0xffff;
269#endif
270 ipintrq.ifq_maxlen = ipqmaxlen;
271 mtx_init(&ipintrq.ifq_mtx, "ip_inq", NULL, MTX_DEF);
236
237/*
238 * IP initialization: fill in IP protocol switch table.
239 * All protocols not implemented in kernel go to raw IP protocol handler.
240 */
241void
242ip_init()
243{

--- 19 unchanged lines hidden (view full) ---

263 maxnipq = nmbclusters / 32;
264 maxfragsperpacket = 16;
265
266#ifndef RANDOM_IP_ID
267 ip_id = time_second & 0xffff;
268#endif
269 ipintrq.ifq_maxlen = ipqmaxlen;
270 mtx_init(&ipintrq.ifq_mtx, "ip_inq", NULL, MTX_DEF);
272 ipintrq_present = 1;
273
274 register_netisr(NETISR_IP, ipintr);
271 netisr_register(NETISR_IP, ip_input, &ipintrq);
275}
276
277/*
278 * XXX watch out this one. It is perhaps used as a cache for
279 * the most recently used route ? it is cleared in in_addroute()
280 * when a new route is successfully created.
281 */
282struct route ipforward_rt;

--- 663 unchanged lines hidden (view full) ---

946 } else
947 (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
948 return;
949bad:
950 m_freem(m);
951}
952
953/*
272}
273
274/*
275 * XXX watch out this one. It is perhaps used as a cache for
276 * the most recently used route ? it is cleared in in_addroute()
277 * when a new route is successfully created.
278 */
279struct route ipforward_rt;

--- 663 unchanged lines hidden (view full) ---

943 } else
944 (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, hlen);
945 return;
946bad:
947 m_freem(m);
948}
949
950/*
954 * IP software interrupt routine - to go away sometime soon
955 */
956static void
957ipintr(void)
958{
959 struct mbuf *m;
960
961 while (1) {
962 IF_DEQUEUE(&ipintrq, m);
963 if (m == 0)
964 return;
965 ip_input(m);
966 }
967}
968
969/*
970 * Take incoming datagram fragment and try to reassemble it into
971 * whole datagram. If a chain for reassembly of this datagram already
972 * exists, then it is given as fp; otherwise have to make a chain.
973 *
974 * When IPDIVERT enabled, keep additional state with each packet that
975 * tells us if we need to divert or tee the packet we're building.
976 * In particular, *divinfo includes the port and TEE flag,
977 * *divert_rule is the number of the matching rule.

--- 1222 unchanged lines hidden ---
951 * Take incoming datagram fragment and try to reassemble it into
952 * whole datagram. If a chain for reassembly of this datagram already
953 * exists, then it is given as fp; otherwise have to make a chain.
954 *
955 * When IPDIVERT enabled, keep additional state with each packet that
956 * tells us if we need to divert or tee the packet we're building.
957 * In particular, *divinfo includes the port and TEE flag,
958 * *divert_rule is the number of the matching rule.

--- 1222 unchanged lines hidden ---