diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-04 21:53:44 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-04 21:53:44 +0000 |
commit | 4dff0e232fcda1034a9a3f39a150fe2c9d57abd9 (patch) | |
tree | 18d47e0b482ea4960e23f1d249632d1510d087a4 | |
parent | 3e713af5ad1646bd731a6ffc05cef3885c4f46e8 (diff) |
Implement rib_find and add a rib id to struct rde_peer.
-rw-r--r-- | usr.sbin/bgpd/rde.h | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 21 |
2 files changed, 24 insertions, 2 deletions
diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 00ea19504ad..0b8db538f5c 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.116 2009/06/04 04:46:42 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.117 2009/06/04 21:53:43 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -73,6 +73,7 @@ struct rde_peer { u_int32_t up_nlricnt; u_int32_t up_wcnt; enum peer_state state; + u_int16_t ribid; u_int16_t short_as; u_int8_t reconf_in; /* in filter changed */ u_int8_t reconf_out; /* out filter changed */ @@ -277,6 +278,7 @@ struct rib { #define F_RIB_ENTRYLOCK 0x0001 #define F_RIB_NOEVALUATE 0x0002 +#define RIB_FAILED 0xffff struct prefix { LIST_ENTRY(prefix) rib_l, path_l; @@ -347,6 +349,7 @@ extern u_int16_t rib_size; extern struct rib *ribs; u_int16_t rib_new(int, char *, u_int16_t); +u_int16_t rib_find(char *); void rib_free(struct rib *); struct rib_entry *rib_get(struct rib *, struct bgpd_addr *, int); struct rib_entry *rib_lookup(struct rib *, struct bgpd_addr *); diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 761db5db985..b3b6bdab6dd 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.113 2009/06/04 04:46:42 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.114 2009/06/04 21:53:43 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -62,6 +62,9 @@ rib_new(int id, char *name, u_int16_t flags) } } + if (id == RIB_FAILED) + fatalx("rib_new: trying to use reserved id"); + if (id >= rib_size) { newsize = sizeof(struct rib) * (id + 1); if ((xribs = realloc(ribs, newsize)) == NULL) { @@ -82,6 +85,22 @@ rib_new(int id, char *name, u_int16_t flags) return (id); } +u_int16_t +rib_find(char *name) +{ + u_int16_t id; + + if (name == NULL || *name == '\0') + return (1); /* XXX */ + + for (id = 0; id < rib_size; id++) { + if (!strcmp(ribs[id].name, name)) + return (id); + } + + return (RIB_FAILED); +} + void rib_free(struct rib *rib) { |