Deleted Added
full compact
ip6_input.c (126489) ip6_input.c (126508)
1/* $FreeBSD: head/sys/netinet6/ip6_input.c 126489 2004-03-02 16:01:27Z ume $ */
1/* $FreeBSD: head/sys/netinet6/ip6_input.c 126508 2004-03-02 20:29:55Z mlaier $ */
2/* $KAME: ip6_input.c,v 1.259 2002/01/21 04:58:09 jinmei Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

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

338 ip6 = mtod(m, struct ip6_hdr *);
339
340 if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
341 ip6stat.ip6s_badvers++;
342 in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
343 goto bad;
344 }
345
2/* $KAME: ip6_input.c,v 1.259 2002/01/21 04:58:09 jinmei Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions

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

338 ip6 = mtod(m, struct ip6_hdr *);
339
340 if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) {
341 ip6stat.ip6s_badvers++;
342 in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr);
343 goto bad;
344 }
345
346#ifdef PFIL_HOOKS
347 /*
348 * Run through list of hooks for input packets.
349 *
350 * NB: Beware of the destination address changing
351 * (e.g. by NAT rewriting). When this happens,
352 * tell ip6_forward to do the right thing.
353 */
354 odst = ip6->ip6_dst;
355 if (pfil_run_hooks(&inet6_pfil_hook, &m, m->m_pkthdr.rcvif, PFIL_IN))
356 return;
357 if (m == NULL) /* consumed by filter */
358 return;
359 ip6 = mtod(m, struct ip6_hdr *);
360 srcrt = !IN6_ARE_ADDR_EQUAL(&odst, &ip6->ip6_dst);
361#endif /* PFIL_HOOKS */
362
363 ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
364
365 /*
346 ip6stat.ip6s_nxthist[ip6->ip6_nxt]++;
347
348 /*
366 * Check with the firewall...
367 */
368 if (ip6_fw_enable && ip6_fw_chk_ptr) {
369 u_short port = 0;
370 /* If ipfw says divert, we have to just drop packet */
371 /* use port as a dummy argument */
372 if ((*ip6_fw_chk_ptr)(&ip6, NULL, &port, &m)) {
373 m_freem(m);
374 m = NULL;
375 }
376 if (!m)
377 return;
378 }
379
380 /*
381 * Check against address spoofing/corruption.
382 */
383 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src) ||
384 IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst)) {
385 /*
386 * XXX: "badscope" is not very suitable for a multicast source.
387 */
388 ip6stat.ip6s_badscope++;

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

451 if ((IN6_IS_ADDR_MC_INTFACELOCAL(&ip6->ip6_dst) ||
452 IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_dst)) &&
453 ip6->ip6_dst.s6_addr16[1]) {
454 ip6stat.ip6s_badscope++;
455 goto bad;
456 }
457 }
458
349 * Check against address spoofing/corruption.
350 */
351 if (IN6_IS_ADDR_MULTICAST(&ip6->ip6_src) ||
352 IN6_IS_ADDR_UNSPECIFIED(&ip6->ip6_dst)) {
353 /*
354 * XXX: "badscope" is not very suitable for a multicast source.
355 */
356 ip6stat.ip6s_badscope++;

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

419 if ((IN6_IS_ADDR_MC_INTFACELOCAL(&ip6->ip6_dst) ||
420 IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_dst)) &&
421 ip6->ip6_dst.s6_addr16[1]) {
422 ip6stat.ip6s_badscope++;
423 goto bad;
424 }
425 }
426
427#ifdef PFIL_HOOKS
459 /*
428 /*
429 * Run through list of hooks for input packets.
430 *
431 * NB: Beware of the destination address changing
432 * (e.g. by NAT rewriting). When this happens,
433 * tell ip6_forward to do the right thing.
434 */
435 odst = ip6->ip6_dst;
436 if (pfil_run_hooks(&inet6_pfil_hook, &m, m->m_pkthdr.rcvif, PFIL_IN))
437 return;
438 if (m == NULL) /* consumed by filter */
439 return;
440 ip6 = mtod(m, struct ip6_hdr *);
441 srcrt = !IN6_ARE_ADDR_EQUAL(&odst, &ip6->ip6_dst);
442#endif /* PFIL_HOOKS */
443
444 /*
445 * Check with the firewall...
446 */
447 if (ip6_fw_enable && ip6_fw_chk_ptr) {
448 u_short port = 0;
449 /* If ipfw says divert, we have to just drop packet */
450 /* use port as a dummy argument */
451 if ((*ip6_fw_chk_ptr)(&ip6, NULL, &port, &m)) {
452 m_freem(m);
453 m = NULL;
454 }
455 if (!m)
456 return;
457 }
458
459 /*
460 * construct source and destination address structures with
461 * disambiguating their scope zones (if there is ambiguity).
462 * XXX: sin6_family and sin6_len will NOT be referred to, but we fill
463 * in these fields just in case.
464 */
465 if (in6_addr2zoneid(m->m_pkthdr.rcvif, &ip6->ip6_src, &srczone) ||
466 in6_addr2zoneid(m->m_pkthdr.rcvif, &ip6->ip6_dst, &dstzone)) {
467 /*

--- 1196 unchanged lines hidden ---
460 * construct source and destination address structures with
461 * disambiguating their scope zones (if there is ambiguity).
462 * XXX: sin6_family and sin6_len will NOT be referred to, but we fill
463 * in these fields just in case.
464 */
465 if (in6_addr2zoneid(m->m_pkthdr.rcvif, &ip6->ip6_src, &srczone) ||
466 in6_addr2zoneid(m->m_pkthdr.rcvif, &ip6->ip6_dst, &dstzone)) {
467 /*

--- 1196 unchanged lines hidden ---