ippool_y.y revision 19adb7fecd1f9ffffd2ce52f537c83478ff97cf4
%{
/*
* Copyright (C) 2003 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#endif
#if __FreeBSD_version >= 300000
#endif
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <ctype.h>
#include <unistd.h>
#include "ipf.h"
#if SOLARIS2 >= 10
#include "ip_lookup.h"
#include "ip_pool.h"
#include "ip_htable.h"
#else
#include "netinet/ip_lookup.h"
#include "netinet/ip_htable.h"
#endif
#include "ippool_l.h"
#include "kmem.h"
#define YYDEBUG 1
extern int yydebug;
static iphtable_t ipht;
static char poolname[FR_GROUPLEN];
static int set_ipv6_addr = 0;
%}
%union {
char *str;
}
%%
| assign
;
resetlexer();
}
resetlexer();
}
resetlexer();
}
;
eol: ';'
;
resetlexer();
free($1);
free($3);
}
;
;
}
;
}
;
;
role:
;
addrlist '}'
$$ = $7;
}
;
hashlist '}'
$$ = $8;
}
;
{ iphtent_t *e;
for (e = $4; e != NULL;
e = e->ipe_next)
if (e->ipe_group[0] == '\0')
$1,
$$ = $4;
}
;
$$ = poolname;
}
| { $$ = ""; }
;
}
}
;
| size
| seed
;
| range { $$ = $1; }
;
if (set_ipv6_addr)
$$->ipe_family = AF_INET6;
else
$$->ipe_family = AF_INET;
bcopy((char *)&($1[0]),
(char *)&($$->ipe_addr),
sizeof($$->ipe_addr));
(char *)&($$->ipe_mask),
sizeof($$->ipe_mask));
set_ipv6_addr = 0;
$$->ipe_next = $3; }
if (set_ipv6_addr)
$$->ipe_family = AF_INET6;
else
$$->ipe_family = AF_INET;
bcopy((char *)&($1[0]),
(char *)&($$->ipe_addr),
sizeof($$->ipe_addr));
(char *)&($$->ipe_mask),
sizeof($$->ipe_mask));
set_ipv6_addr = 0;
}
;
;
if (set_ipv6_addr)
$$->ipe_family = AF_INET6;
else
$$->ipe_family = AF_INET;
bcopy((char *)&($1[0]),
(char *)&($$->ipe_addr),
sizeof($$->ipe_addr));
(char *)&($$->ipe_mask),
sizeof($$->ipe_mask));
set_ipv6_addr = 0;
free($3); }
;
$$->ipn_info = 0;
if (set_ipv6_addr) {
} else {
}
set_ipv6_addr = 0;
}
$$->ipn_info = 1;
if (set_ipv6_addr) {
} else {
}
set_ipv6_addr = 0;
}
;
if (set_ipv6_addr)
$$->ipe_family = AF_INET6;
else
$$->ipe_family = AF_INET;
bcopy((char *)&($1[0]),
(char *)&($$->ipe_addr),
sizeof($$->ipe_addr));
(char *)&($$->ipe_mask),
sizeof($$->ipe_mask));
set_ipv6_addr = 0;
}
;
| ipaddr { $$[0] = $1;
if (set_ipv6_addr)
else
;
bcopy(&$1, &$$, sizeof($$));
yyexpectaddr = 0; }
;
else
}
| ipv4 { $$ = $1; }
;
;
;
{ if ($1 > 255 || $3 > 255 || $5 > 255 || $7 > 255) {
yyerror("Invalid octet string for IP address");
return 0;
}
}
;
;
%%
{ "auth", IPT_AUTH },
{ "count", IPT_COUNT },
{ "group", IPT_GROUP },
{ "group-map", IPT_GROUPMAP },
{ "hash", IPT_HASH },
{ "in", IPT_IN },
{ "ipf", IPT_IPF },
{ "name", IPT_NAME },
{ "nat", IPT_NAT },
{ "number", IPT_NUM },
{ "out", IPT_OUT },
{ "role", IPT_ROLE },
{ "seed", IPT_SEED },
{ "size", IPT_SIZE },
{ "table", IPT_TABLE },
{ "tree", IPT_TREE },
{ "type", IPT_TYPE },
{ NULL, 0 }
};
int fd;
char *filename;
{
char *s;
yylineNum = 1;
s = getenv("YYDEBUG");
if (s)
else
yydebug = 0;
if (!fp) {
return -1;
}
} else
;
return 0;
}
int fd;
{
char *s;
int i;
return 0;
if (i == EOF)
return 0;
return 0;
return 0;
s = getenv("YYDEBUG");
if (s)
else
yydebug = 0;
yyparse();
return 1;
}