summaryrefslogtreecommitdiffstats
path: root/contrib/ipfilter/tools/ippool_y.y
diff options
context:
space:
mode:
authordarrenr <darrenr@FreeBSD.org>2007-06-04 02:50:28 +0000
committerdarrenr <darrenr@FreeBSD.org>2007-06-04 02:50:28 +0000
commite2e28d4361fc9bdb67694eedaf349bdc7ca088a3 (patch)
treef9efeb29d9992430924bdce513e7199c9397ac36 /contrib/ipfilter/tools/ippool_y.y
parent092f5d1218f4867a87b382d75613b9d2b3e56c18 (diff)
downloadFreeBSD-src-e2e28d4361fc9bdb67694eedaf349bdc7ca088a3.zip
FreeBSD-src-e2e28d4361fc9bdb67694eedaf349bdc7ca088a3.tar.gz
Import IPFilter 4.1.23 to vendor branch.
See src/contrib/ipfilter/HISTORY for details of changes since 4.1.13
Diffstat (limited to 'contrib/ipfilter/tools/ippool_y.y')
-rw-r--r--contrib/ipfilter/tools/ippool_y.y113
1 files changed, 110 insertions, 3 deletions
diff --git a/contrib/ipfilter/tools/ippool_y.y b/contrib/ipfilter/tools/ippool_y.y
index a508268..4aa5108 100644
--- a/contrib/ipfilter/tools/ippool_y.y
+++ b/contrib/ipfilter/tools/ippool_y.y
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) 2001-2006 by Darren Reed.
+ *
+ * See the IPFILTER.LICENCE file for details on licencing.
+ */
%{
#include <sys/types.h>
#include <sys/time.h>
@@ -32,6 +37,7 @@
#include "kmem.h"
#define YYDEBUG 1
+#define YYSTACKSIZE 0x00ffffff
extern int yyparse __P((void));
extern int yydebug;
@@ -43,6 +49,9 @@ static ip_pool_t iplo;
static ioctlfunc_t poolioctl = NULL;
static char poolname[FR_GROUPLEN];
+static iphtent_t *add_htablehosts __P((char *));
+static ip_pool_node_t *add_poolhosts __P((char *));
+
%}
%union {
@@ -110,6 +119,7 @@ assign: YY_STR assigning YY_STR ';' { set_variable($1, $3);
resetlexer();
free($1);
free($3);
+ yyvarnext = 0;
}
;
@@ -246,6 +256,7 @@ groupentry:
FR_GROUPLEN);
free($3);
}
+ | YY_STR { $$ = add_htablehosts($1); }
;
range: addrmask { $$ = calloc(1, sizeof(*$$));
@@ -262,6 +273,7 @@ range: addrmask { $$ = calloc(1, sizeof(*$$));
$$->ipn_mask.adf_len = sizeof($$->ipn_mask);
$$->ipn_mask.adf_addr.in4.s_addr = $2[1].s_addr;
}
+ | YY_STR { $$ = add_poolhosts($1); }
hashlist:
next { $$ = NULL; }
@@ -278,6 +290,7 @@ hashentry:
(char *)&($$->ipe_mask),
sizeof($$->ipe_mask));
}
+ | YY_STR { $$ = add_htablehosts($1); }
;
addrmask:
@@ -291,9 +304,6 @@ addrmask:
ipaddr: ipv4 { $$ = $1; }
| YY_NUMBER { $$.s_addr = htonl($1); }
- | YY_STR { if (gethost($1, &($$.s_addr)) == -1)
- yyerror("Unknown hostname");
- }
;
mask: YY_NUMBER { ntomask(4, $1, (u_32_t *)&$$.s_addr); }
@@ -411,3 +421,100 @@ ioctlfunc_t iocfunc;
yyparse();
return 1;
}
+
+
+static iphtent_t *
+add_htablehosts(url)
+char *url;
+{
+ iphtent_t *htop, *hbot, *h;
+ alist_t *a, *hlist;
+
+ if (!strncmp(url, "file://", 7) || !strncmp(url, "http://", 7)) {
+ hlist = load_url(url);
+ } else {
+ use_inet6 = 0;
+
+ hlist = calloc(1, sizeof(*hlist));
+ if (hlist == NULL)
+ return NULL;
+
+ if (gethost(url, &hlist->al_addr) == -1)
+ yyerror("Unknown hostname");
+ }
+
+ hbot = NULL;
+ htop = NULL;
+
+ for (a = hlist; a != NULL; a = a->al_next) {
+ h = calloc(1, sizeof(*h));
+ if (h == NULL)
+ break;
+
+ bcopy((char *)&a->al_addr, (char *)&h->ipe_addr,
+ sizeof(h->ipe_addr));
+ bcopy((char *)&a->al_mask, (char *)&h->ipe_mask,
+ sizeof(h->ipe_mask));
+
+ if (hbot != NULL)
+ hbot->ipe_next = h;
+ else
+ htop = h;
+ hbot = h;
+ }
+
+ alist_free(hlist);
+
+ return htop;
+}
+
+
+static ip_pool_node_t *
+add_poolhosts(url)
+char *url;
+{
+ ip_pool_node_t *ptop, *pbot, *p;
+ alist_t *a, *hlist;
+
+ if (!strncmp(url, "file://", 7) || !strncmp(url, "http://", 7)) {
+ hlist = load_url(url);
+ } else {
+ use_inet6 = 0;
+
+ hlist = calloc(1, sizeof(*hlist));
+ if (hlist == NULL)
+ return NULL;
+
+ if (gethost(url, &hlist->al_addr) == -1)
+ yyerror("Unknown hostname");
+ }
+
+ pbot = NULL;
+ ptop = NULL;
+
+ for (a = hlist; a != NULL; a = a->al_next) {
+ p = calloc(1, sizeof(*p));
+ if (p == NULL)
+ break;
+
+ p->ipn_addr.adf_len = 8;
+ p->ipn_mask.adf_len = 8;
+
+ p->ipn_info = a->al_not;
+
+ bcopy((char *)&a->al_addr, (char *)&p->ipn_addr.adf_addr,
+ sizeof(p->ipn_addr.adf_addr));
+ bcopy((char *)&a->al_mask, (char *)&p->ipn_mask.adf_addr,
+ sizeof(p->ipn_mask.adf_addr));
+
+ if (pbot != NULL)
+ pbot->ipn_next = p;
+ else
+ ptop = p;
+ pbot = p;
+ }
+
+ alist_free(hlist);
+
+ return ptop;
+}
OpenPOWER on IntegriCloud