diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2017-01-23 12:25:20 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2017-01-23 12:25:20 +0000 |
commit | 66adc2abc0af8b82547d7f8a029585d963bf9fb0 (patch) | |
tree | 291b68a7cb067f410635f735796ec5f32f004657 /usr.sbin/bgpd/rde_rib.c | |
parent | 7b034d5cbc45473d52acea4a005c72af11623036 (diff) |
More rototilling, make rib_new and rib_find return a point to struct rib_desc
Diffstat (limited to 'usr.sbin/bgpd/rde_rib.c')
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 16b45cca947..ac67d18fe72 100644 --- a/usr.sbin/bgpd/rde_rib.c +++ b/usr.sbin/bgpd/rde_rib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_rib.c,v 1.145 2017/01/23 11:46:02 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.146 2017/01/23 12:25:19 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -50,7 +50,7 @@ RB_GENERATE(rib, rib_entry, rib_e, rib_compare); /* RIB specific functions */ -u_int16_t +struct rib_desc * rib_new(char *name, u_int rtableid, u_int16_t flags) { struct rib_desc *xribs; @@ -61,9 +61,6 @@ rib_new(char *name, u_int rtableid, u_int16_t flags) break; } - if (id == RIB_FAILED) - fatalx("rib_new: trying to use reserved id"); - if (id >= rib_size) { if ((xribs = reallocarray(ribs, id + 1, sizeof(struct rib_desc))) == NULL) { @@ -87,23 +84,23 @@ rib_new(char *name, u_int rtableid, u_int16_t flags) fatal(NULL); TAILQ_INIT(ribs[id].in_rules); - return (id); + return (&ribs[id]); } -u_int16_t +struct rib_desc * rib_find(char *name) { u_int16_t id; if (name == NULL || *name == '\0') - return (1); /* no name returns the Loc-RIB */ + return (&ribs[1]); /* no name returns the Loc-RIB */ for (id = 0; id < rib_size; id++) { if (!strcmp(ribs[id].name, name)) - return (id); + return (&ribs[id]); } - return (RIB_FAILED); + return (NULL); } void |