struct list_head rules;
};
+extern const char *chain_type_name_lookup(const char *name);
extern const char *chain_hookname_lookup(const char *name);
extern struct chain *chain_alloc(const char *name);
extern void chain_free(struct chain *chain);
hook_spec : TYPE STRING HOOK STRING PRIORITY NUM
{
- $<chain>0->type = $2;
+ $<chain>0->type = chain_type_name_lookup($2);
+ if ($<chain>0->type == NULL) {
+ erec_queue(error(&@2, "unknown chain type %s", $2),
+ state->msgs);
+ YYERROR;
+ }
$<chain>0->hookstr = chain_hookname_lookup($4);
if ($<chain>0->hookstr == NULL) {
- erec_queue(error(&@4, "unknown hook name %s", $4),
+ erec_queue(error(&@4, "unknown chain type %s", $4),
state->msgs);
YYERROR;
}
}
| TYPE STRING HOOK STRING PRIORITY DASH NUM
{
- $<chain>0->type = $2;
+ $<chain>0->type = chain_type_name_lookup($2);
+ if ($<chain>0->type == NULL) {
+ erec_queue(error(&@2, "unknown type name %s", $2),
+ state->msgs);
+ YYERROR;
+ }
$<chain>0->hookstr = chain_hookname_lookup($4);
if ($<chain>0->hookstr == NULL) {
erec_queue(error(&@4, "unknown hook name %s", $4),
return NULL;
}
+static const char *chain_type_str_array[] = {
+ "filter",
+ "nat",
+ "route",
+ NULL,
+};
+
+const char *chain_type_name_lookup(const char *name)
+{
+ int i;
+
+ for (i = 0; chain_type_str_array[i]; i++) {
+ if (!strcmp(name, chain_type_str_array[i]))
+ return chain_type_str_array[i];
+ }
+
+ return NULL;
+}
+
static const char *chain_hookname_str_array[] = {
"prerouting",
"input",