1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Cleaned up handling of interface patterns:

o  Parsing of interface patterns moved to generic code,
      introduced this_ipatt which works similarly to this_iface.
   o  Interface patterns now support selection by both interface
      names and primary IP addresses.
   o  Proto `direct' updated.
   o  RIP updated as well, it also seems the memory corruption
      bug there is gone.
This commit is contained in:
Martin Mares
1999-08-03 19:30:49 +00:00
parent 9273035403
commit 8edf2361f9
5 changed files with 66 additions and 68 deletions

View File

@@ -9,12 +9,11 @@
CF_HDR
static struct proto_config *this_proto;
static struct iface_patt *this_ipatt;
#include "nest/rt-dev.h"
#include "nest/password.h"
void rt_dev_add_iface(char *);
CF_DECLS
CF_KEYWORDS(ROUTER, ID, PROTOCOL, PREFERENCE, DISABLED, DEBUG, ALL, OFF, DIRECT)
@@ -102,18 +101,23 @@ rtable:
}
;
/* Interface patterns */
iface_patt:
TEXT { this_ipatt->pattern = $1; this_ipatt->prefix = IPA_NONE; this_ipatt->pxlen = 0; }
| IPA pxlen { this_ipatt->pattern = NULL; this_ipatt->prefix = $1; this_ipatt->pxlen = $2; }
| TEXT IPA pxlen { this_ipatt->pattern = $1; this_ipatt->prefix = $2; this_ipatt->pxlen = $3; }
;
/* Direct device route protocol */
CF_ADDTO(proto, dev_proto '}')
dev_proto_start: proto_start DIRECT {
struct rt_dev_config *p = proto_config_new(&proto_device, sizeof(struct rt_dev_config));
struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));
this_proto = &p->c;
p->c.preference = DEF_PREF_DIRECT;
init_list(&p->iface_list);
k->pattern = "*";
add_tail(&p->iface_list, &k->n);
}
;
@@ -123,15 +127,26 @@ dev_proto:
| dev_proto dev_iface_list ';'
;
dev_iface_list:
INTERFACE TEXT {
/* FIXME: Beware of obscure semantics. */
init_list(&((struct rt_dev_config *) this_proto)->iface_list);
rt_dev_add_iface($2);
dev_iface_entry_init:
/* EMPTY */ {
struct rt_dev_config *p = (void *) this_proto;
struct iface_patt *k = cfg_allocz(sizeof(struct iface_patt));
add_tail(&p->iface_list, &k->n);
this_ipatt = k;
}
| dev_iface_list ',' TEXT { rt_dev_add_iface($3); }
;
dev_iface_entry:
dev_iface_entry_init iface_patt
;
dev_iface_list:
INTERFACE dev_iface_entry
| dev_iface_list ',' dev_iface_entry
;
/* Password lists */
password_begin:
PASSWORD TEXT {
last_password_item = cfg_alloc(sizeof (struct password_item));
@@ -162,14 +177,4 @@ password_list:
CF_CODE
void
rt_dev_add_iface(char *n)
{
struct rt_dev_config *p = (void *) this_proto;
struct iface_patt *k = cfg_alloc(sizeof(struct iface_patt));
k->pattern = cfg_strdup(n);
add_tail(&p->iface_list, &k->n);
}
CF_END