ip_frag.c (348822) | ip_frag.c (363769) |
---|---|
1/* $FreeBSD: stable/11/sys/contrib/ipfilter/netinet/ip_frag.c 348822 2019-06-08 22:29:51Z cy $ */ | 1/* $FreeBSD: stable/11/sys/contrib/ipfilter/netinet/ip_frag.c 363769 2020-08-02 04:25:36Z cy $ */ |
2 3/* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 */ 8#if defined(KERNEL) || defined(_KERNEL) 9# undef KERNEL --- 60 unchanged lines hidden (view full) --- 70#include "netinet/ip_auth.h" 71#include "netinet/ip_lookup.h" 72#include "netinet/ip_proxy.h" 73#include "netinet/ip_sync.h" 74/* END OF INCLUDES */ 75 76#if !defined(lint) 77static const char sccsid[] = "@(#)ip_frag.c 1.11 3/24/96 (C) 1993-2000 Darren Reed"; | 2 3/* 4 * Copyright (C) 2012 by Darren Reed. 5 * 6 * See the IPFILTER.LICENCE file for details on licencing. 7 */ 8#if defined(KERNEL) || defined(_KERNEL) 9# undef KERNEL --- 60 unchanged lines hidden (view full) --- 70#include "netinet/ip_auth.h" 71#include "netinet/ip_lookup.h" 72#include "netinet/ip_proxy.h" 73#include "netinet/ip_sync.h" 74/* END OF INCLUDES */ 75 76#if !defined(lint) 77static const char sccsid[] = "@(#)ip_frag.c 1.11 3/24/96 (C) 1993-2000 Darren Reed"; |
78static const char rcsid[] = "@(#)$FreeBSD: stable/11/sys/contrib/ipfilter/netinet/ip_frag.c 348822 2019-06-08 22:29:51Z cy $"; | 78static const char rcsid[] = "@(#)$FreeBSD: stable/11/sys/contrib/ipfilter/netinet/ip_frag.c 363769 2020-08-02 04:25:36Z cy $"; |
79/* static const char rcsid[] = "@(#)$Id: ip_frag.c,v 2.77.2.12 2007/09/20 12:51:51 darrenr Exp $"; */ 80#endif 81 82 83#ifdef USE_MUTEXES 84static ipfr_t *ipfr_frag_new __P((ipf_main_softc_t *, ipf_frag_softc_t *, 85 fr_info_t *, u_32_t, ipfr_t **, 86 ipfrwlock_t *)); --- 312 unchanged lines hidden (view full) --- 399 400 if (pass & FR_FRSTRICT) { 401 if (fin->fin_off != 0) { 402 FBUMPD(ifs_newrestrictnot0); 403 return NULL; 404 } 405 } 406 | 79/* static const char rcsid[] = "@(#)$Id: ip_frag.c,v 2.77.2.12 2007/09/20 12:51:51 darrenr Exp $"; */ 80#endif 81 82 83#ifdef USE_MUTEXES 84static ipfr_t *ipfr_frag_new __P((ipf_main_softc_t *, ipf_frag_softc_t *, 85 fr_info_t *, u_32_t, ipfr_t **, 86 ipfrwlock_t *)); --- 312 unchanged lines hidden (view full) --- 399 400 if (pass & FR_FRSTRICT) { 401 if (fin->fin_off != 0) { 402 FBUMPD(ifs_newrestrictnot0); 403 return NULL; 404 } 405 } 406 |
407 memset(&frag, 0, sizeof(frag)); |
|
407 frag.ipfr_v = fin->fin_v; 408 idx = fin->fin_v; 409 frag.ipfr_p = fin->fin_p; 410 idx += fin->fin_p; 411 frag.ipfr_id = fin->fin_id; 412 idx += fin->fin_id; 413 frag.ipfr_source = fin->fin_fi.fi_src; 414 idx += frag.ipfr_src.s_addr; --- 32 unchanged lines hidden (view full) --- 447 * allocate some memory, if possible, if not, just record that we 448 * failed to do so. 449 */ 450 KMALLOC(fran, ipfr_t *); 451 if (fran == NULL) { 452 FBUMPD(ifs_nomem); 453 return NULL; 454 } | 408 frag.ipfr_v = fin->fin_v; 409 idx = fin->fin_v; 410 frag.ipfr_p = fin->fin_p; 411 idx += fin->fin_p; 412 frag.ipfr_id = fin->fin_id; 413 idx += fin->fin_id; 414 frag.ipfr_source = fin->fin_fi.fi_src; 415 idx += frag.ipfr_src.s_addr; --- 32 unchanged lines hidden (view full) --- 448 * allocate some memory, if possible, if not, just record that we 449 * failed to do so. 450 */ 451 KMALLOC(fran, ipfr_t *); 452 if (fran == NULL) { 453 FBUMPD(ifs_nomem); 454 return NULL; 455 } |
456 memset(fran, 0, sizeof(*fran)); |
|
455 456 WRITE_ENTER(lock); 457 458 /* 459 * first, make sure it isn't already there... 460 */ 461 for (fra = table[idx]; (fra != NULL); fra = fra->ipfr_hnext) 462 if (!bcmp((char *)&frag.ipfr_ifp, (char *)&fra->ipfr_ifp, --- 21 unchanged lines hidden (view full) --- 484 */ 485 if ((fra->ipfr_hnext = table[idx]) != NULL) 486 table[idx]->ipfr_hprev = &fra->ipfr_hnext; 487 fra->ipfr_hprev = table + idx; 488 fra->ipfr_data = NULL; 489 table[idx] = fra; 490 bcopy((char *)&frag.ipfr_ifp, (char *)&fra->ipfr_ifp, IPFR_CMPSZ); 491 fra->ipfr_v = fin->fin_v; | 457 458 WRITE_ENTER(lock); 459 460 /* 461 * first, make sure it isn't already there... 462 */ 463 for (fra = table[idx]; (fra != NULL); fra = fra->ipfr_hnext) 464 if (!bcmp((char *)&frag.ipfr_ifp, (char *)&fra->ipfr_ifp, --- 21 unchanged lines hidden (view full) --- 486 */ 487 if ((fra->ipfr_hnext = table[idx]) != NULL) 488 table[idx]->ipfr_hprev = &fra->ipfr_hnext; 489 fra->ipfr_hprev = table + idx; 490 fra->ipfr_data = NULL; 491 table[idx] = fra; 492 bcopy((char *)&frag.ipfr_ifp, (char *)&fra->ipfr_ifp, IPFR_CMPSZ); 493 fra->ipfr_v = fin->fin_v; |
494 fra->ipfr_p = fin->fin_p; |
|
492 fra->ipfr_ttl = softc->ipf_ticks + softf->ipfr_ttl; 493 fra->ipfr_firstend = frag.ipfr_firstend; 494 495 /* 496 * Compute the offset of the expected start of the next packet. 497 */ 498 if (off == 0) 499 fra->ipfr_seen0 = 1; --- 172 unchanged lines hidden (view full) --- 672 } 673 674 /* 675 * For fragments, we record protocol, packet id, TOS and both IP#'s 676 * (these should all be the same for all fragments of a packet). 677 * 678 * build up a hash value to index the table with. 679 */ | 495 fra->ipfr_ttl = softc->ipf_ticks + softf->ipfr_ttl; 496 fra->ipfr_firstend = frag.ipfr_firstend; 497 498 /* 499 * Compute the offset of the expected start of the next packet. 500 */ 501 if (off == 0) 502 fra->ipfr_seen0 = 1; --- 172 unchanged lines hidden (view full) --- 675 } 676 677 /* 678 * For fragments, we record protocol, packet id, TOS and both IP#'s 679 * (these should all be the same for all fragments of a packet). 680 * 681 * build up a hash value to index the table with. 682 */ |
683 memset(&frag, 0, sizeof(frag)); |
|
680 frag.ipfr_v = fin->fin_v; 681 idx = fin->fin_v; 682 frag.ipfr_p = fin->fin_p; 683 idx += fin->fin_p; 684 frag.ipfr_id = fin->fin_id; 685 idx += fin->fin_id; 686 frag.ipfr_source = fin->fin_fi.fi_src; 687 idx += frag.ipfr_src.s_addr; --- 669 unchanged lines hidden --- | 684 frag.ipfr_v = fin->fin_v; 685 idx = fin->fin_v; 686 frag.ipfr_p = fin->fin_p; 687 idx += fin->fin_p; 688 frag.ipfr_id = fin->fin_id; 689 idx += fin->fin_id; 690 frag.ipfr_source = fin->fin_fi.fi_src; 691 idx += frag.ipfr_src.s_addr; --- 669 unchanged lines hidden --- |