summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/lib/load_hash.c
diff options
context:
space:
mode:
authorcy <cy@FreeBSD.org>2013-07-19 05:41:57 +0000
committercy <cy@FreeBSD.org>2013-07-19 05:41:57 +0000
commit672af8808c0e7c15f330b401482f9271c2eb3fa6 (patch)
tree225b5acf68c01bc6a260b386c2b2dbf4fa2839e3 /contrib/ipfilter/lib/load_hash.c
parent71e82d94e82560b20789833f60056506de34de8b (diff)
downloadFreeBSD-src-672af8808c0e7c15f330b401482f9271c2eb3fa6.zip
FreeBSD-src-672af8808c0e7c15f330b401482f9271c2eb3fa6.tar.gz
As per the developers handbook (5.3.1 step 1), prepare the vendor trees for
import of new ipfilter vendor sources by flattening them. To keep the tags consistent with dist, the tags are also flattened. Approved by: glebius (Mentor)
Diffstat (limited to 'contrib/ipfilter/lib/load_hash.c')
-rw-r--r--contrib/ipfilter/lib/load_hash.c112
1 files changed, 0 insertions, 112 deletions
diff --git a/contrib/ipfilter/lib/load_hash.c b/contrib/ipfilter/lib/load_hash.c
deleted file mode 100644
index 84abca0..0000000
--- a/contrib/ipfilter/lib/load_hash.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2002-2005 by Darren Reed.
- *
- * See the IPFILTER.LICENCE file for details on licencing.
- *
- * $Id: load_hash.c,v 1.11.2.5 2006/07/14 06:12:25 darrenr Exp $
- */
-
-#include <fcntl.h>
-#include <sys/ioctl.h>
-#include "ipf.h"
-#include "netinet/ip_lookup.h"
-#include "netinet/ip_htable.h"
-
-static int hashfd = -1;
-
-
-int load_hash(iphp, list, iocfunc)
-iphtable_t *iphp;
-iphtent_t *list;
-ioctlfunc_t iocfunc;
-{
- iplookupop_t op;
- iphtable_t iph;
- iphtent_t *a;
- size_t size;
- int n;
-
- if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
- hashfd = open(IPLOOKUP_NAME, O_RDWR);
- if ((hashfd == -1) && ((opts & OPT_DONOTHING) == 0))
- return -1;
-
- for (n = 0, a = list; a != NULL; a = a->ipe_next)
- n++;
-
- op.iplo_arg = 0;
- op.iplo_type = IPLT_HASH;
- op.iplo_unit = iphp->iph_unit;
- strncpy(op.iplo_name, iphp->iph_name, sizeof(op.iplo_name));
- if (*op.iplo_name == '\0')
- op.iplo_arg = IPHASH_ANON;
- op.iplo_size = sizeof(iph);
- op.iplo_struct = &iph;
- iph.iph_unit = iphp->iph_unit;
- iph.iph_type = iphp->iph_type;
- strncpy(iph.iph_name, iphp->iph_name, sizeof(iph.iph_name));
- iph.iph_flags = iphp->iph_flags;
- if (n <= 0)
- n = 1;
- if (iphp->iph_size == 0)
- size = n * 2 - 1;
- else
- size = iphp->iph_size;
- if ((list == NULL) && (size == 1)) {
- fprintf(stderr,
- "WARNING: empty hash table %s, recommend setting %s\n",
- iphp->iph_name, "size to match expected use");
- }
- iph.iph_size = size;
- iph.iph_seed = iphp->iph_seed;
- iph.iph_table = NULL;
- iph.iph_list = NULL;
- iph.iph_ref = 0;
-
- if ((opts & OPT_REMOVE) == 0) {
- if ((*iocfunc)(hashfd, SIOCLOOKUPADDTABLE, &op))
- if ((opts & OPT_DONOTHING) == 0) {
- perror("load_hash:SIOCLOOKUPADDTABLE");
- return -1;
- }
- }
-
- strncpy(iph.iph_name, op.iplo_name, sizeof(op.iplo_name));
- strncpy(iphp->iph_name, op.iplo_name, sizeof(op.iplo_name));
-
- if (opts & OPT_VERBOSE) {
- for (a = list; a != NULL; a = a->ipe_next) {
- a->ipe_addr.in4_addr = ntohl(a->ipe_addr.in4_addr);
- a->ipe_mask.in4_addr = ntohl(a->ipe_mask.in4_addr);
- }
- iph.iph_table = calloc(size, sizeof(*iph.iph_table));
- if (iph.iph_table == NULL) {
- perror("calloc(size, sizeof(*iph.iph_table))");
- return -1;
- }
- iph.iph_list = list;
- printhash(&iph, bcopywrap, iph.iph_name, opts);
- free(iph.iph_table);
- iph.iph_list = NULL;
-
- for (a = list; a != NULL; a = a->ipe_next) {
- a->ipe_addr.in4_addr = htonl(a->ipe_addr.in4_addr);
- a->ipe_mask.in4_addr = htonl(a->ipe_mask.in4_addr);
- }
- }
-
- if (opts & OPT_DEBUG)
- printf("Hash %s:\n", iph.iph_name);
-
- for (a = list; a != NULL; a = a->ipe_next)
- load_hashnode(iphp->iph_unit, iph.iph_name, a, iocfunc);
-
- if ((opts & OPT_REMOVE) != 0) {
- if ((*iocfunc)(hashfd, SIOCLOOKUPDELTABLE, &op))
- if ((opts & OPT_DONOTHING) == 0) {
- perror("load_hash:SIOCLOOKUPDELTABLE");
- return -1;
- }
- }
- return 0;
-}
OpenPOWER on IntegriCloud