Deleted Added
full compact
ip_input.c (82445) ip_input.c (82884)
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 82445 2001-08-27 22:10:07Z jesper $
34 * $FreeBSD: head/sys/netinet/ip_input.c 82884 2001-09-03 20:03:55Z julian $
35 */
36
37#define _IP_VHL
38
39#include "opt_bootp.h"
40#include "opt_ipfw.h"
41#include "opt_ipdn.h"
42#include "opt_ipdivert.h"

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

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>
76#include <machine/in_cksum.h>
77
35 */
36
37#define _IP_VHL
38
39#include "opt_bootp.h"
40#include "opt_ipfw.h"
41#include "opt_ipdn.h"
42#include "opt_ipdivert.h"

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

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>
76#include <machine/in_cksum.h>
77
78#include <netinet/ipprotosw.h>
79
80#include <sys/socketvar.h>
81
82#include <netinet/ip_fw.h>
83
84#ifdef IPSEC
85#include <netinet6/ipsec.h>
86#include <netkey/key.h>
87#endif

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

148SYSCTL_INT(_net_inet_ip, OID_AUTO, check_interface, CTLFLAG_RW,
149 &ip_checkinterface, 0, "Verify packet arrives on correct interface");
150
151#ifdef DIAGNOSTIC
152static int ipprintfs = 0;
153#endif
154
155extern struct domain inetdomain;
78#include <sys/socketvar.h>
79
80#include <netinet/ip_fw.h>
81
82#ifdef IPSEC
83#include <netinet6/ipsec.h>
84#include <netkey/key.h>
85#endif

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

146SYSCTL_INT(_net_inet_ip, OID_AUTO, check_interface, CTLFLAG_RW,
147 &ip_checkinterface, 0, "Verify packet arrives on correct interface");
148
149#ifdef DIAGNOSTIC
150static int ipprintfs = 0;
151#endif
152
153extern struct domain inetdomain;
156extern struct ipprotosw inetsw[];
154extern struct protosw inetsw[];
157u_char ip_protox[IPPROTO_MAX];
158static int ipqmaxlen = IFQ_MAXLEN;
159struct in_ifaddrhead in_ifaddrhead; /* first inet address */
160SYSCTL_INT(_net_inet_ip, IPCTL_INTRQMAXLEN, intr_queue_maxlen, CTLFLAG_RW,
161 &ipintrq.ifq_maxlen, 0, "Maximum size of the IP input queue");
162SYSCTL_INT(_net_inet_ip, IPCTL_INTRQDROPS, intr_queue_drops, CTLFLAG_RD,
163 &ipintrq.ifq_drops, 0, "Number of packets dropped from the IP input queue");
164

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

231
232/*
233 * IP initialization: fill in IP protocol switch table.
234 * All protocols not implemented in kernel go to raw IP protocol handler.
235 */
236void
237ip_init()
238{
155u_char ip_protox[IPPROTO_MAX];
156static int ipqmaxlen = IFQ_MAXLEN;
157struct in_ifaddrhead in_ifaddrhead; /* first inet address */
158SYSCTL_INT(_net_inet_ip, IPCTL_INTRQMAXLEN, intr_queue_maxlen, CTLFLAG_RW,
159 &ipintrq.ifq_maxlen, 0, "Maximum size of the IP input queue");
160SYSCTL_INT(_net_inet_ip, IPCTL_INTRQDROPS, intr_queue_drops, CTLFLAG_RD,
161 &ipintrq.ifq_drops, 0, "Number of packets dropped from the IP input queue");
162

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

229
230/*
231 * IP initialization: fill in IP protocol switch table.
232 * All protocols not implemented in kernel go to raw IP protocol handler.
233 */
234void
235ip_init()
236{
239 register struct ipprotosw *pr;
237 register struct protosw *pr;
240 register int i;
241
242 TAILQ_INIT(&in_ifaddrhead);
238 register int i;
239
240 TAILQ_INIT(&in_ifaddrhead);
243 pr = (struct ipprotosw *)pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
241 pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW);
244 if (pr == 0)
245 panic("ip_init");
246 for (i = 0; i < IPPROTO_MAX; i++)
247 ip_protox[i] = pr - inetsw;
242 if (pr == 0)
243 panic("ip_init");
244 for (i = 0; i < IPPROTO_MAX; i++)
245 ip_protox[i] = pr - inetsw;
248 for (pr = (struct ipprotosw *)inetdomain.dom_protosw;
249 pr < (struct ipprotosw *)inetdomain.dom_protoswNPROTOSW; pr++)
246 for (pr = inetdomain.dom_protosw;
247 pr < inetdomain.dom_protoswNPROTOSW; pr++)
250 if (pr->pr_domain->dom_family == PF_INET &&
251 pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
252 ip_protox[pr->pr_protocol] = pr - inetsw;
253
254 for (i = 0; i < IPREASS_NHASH; i++)
255 TAILQ_INIT(&ipq[i]);
256
257 maxnipq = nmbclusters / 4;

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

814 }
815#endif
816
817 /*
818 * Switch out to protocol's input routine.
819 */
820 ipstat.ips_delivered++;
821 {
248 if (pr->pr_domain->dom_family == PF_INET &&
249 pr->pr_protocol && pr->pr_protocol != IPPROTO_RAW)
250 ip_protox[pr->pr_protocol] = pr - inetsw;
251
252 for (i = 0; i < IPREASS_NHASH; i++)
253 TAILQ_INIT(&ipq[i]);
254
255 maxnipq = nmbclusters / 4;

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

812 }
813#endif
814
815 /*
816 * Switch out to protocol's input routine.
817 */
818 ipstat.ips_delivered++;
819 {
822 int off = hlen, nh = ip->ip_p;
820 int off = hlen;
823
821
824 (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off, nh);
822 (*inetsw[ip_protox[ip->ip_p]].pr_input)(m, off);
825#ifdef IPFIREWALL_FORWARD
826 ip_fw_fwd_addr = NULL; /* tcp needed it */
827#endif
828 return;
829 }
830bad:
831#ifdef IPFIREWALL_FORWARD
832 ip_fw_fwd_addr = NULL;

--- 1076 unchanged lines hidden ---
823#ifdef IPFIREWALL_FORWARD
824 ip_fw_fwd_addr = NULL; /* tcp needed it */
825#endif
826 return;
827 }
828bad:
829#ifdef IPFIREWALL_FORWARD
830 ip_fw_fwd_addr = NULL;

--- 1076 unchanged lines hidden ---