From e47c1496219f0d6a6f27bc322e56b5a8a327f4b4 Mon Sep 17 00:00:00 2001 From: Henning Brauer Date: Thu, 23 Dec 2004 17:24:04 +0000 Subject: introduce getpeerbydesc(), find a peer by its description --- usr.sbin/bgpd/session.c | 14 +++++++++++++- usr.sbin/bgpd/session.h | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 6fab38bfd8e..fe20bd8151c 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.210 2004/12/23 15:15:55 henning Exp $ */ +/* $OpenBSD: session.c,v 1.211 2004/12/23 17:24:03 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -2389,6 +2389,18 @@ getpeerbyaddr(struct bgpd_addr *addr) return (p); } +struct peer * +getpeerbydesc(const char *descr) +{ + struct peer *p; + + for (p = peers; p != NULL && strcmp(p->conf.descr, descr); + p = p->next) + ; /* nothing */ + + return (p); +} + struct peer * getpeerbyip(struct sockaddr *ip) { diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 103dc5fc368..9d45d121ec9 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.74 2004/12/23 15:15:55 henning Exp $ */ +/* $OpenBSD: session.h,v 1.75 2004/12/23 17:24:03 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -184,6 +184,7 @@ pid_t session_main(struct bgpd_config *, struct peer *, struct mrt_head *, int[2], int[2], int[2]); void bgp_fsm(struct peer *, enum session_events); struct peer *getpeerbyaddr(struct bgpd_addr *); +struct peer *getpeerbydesc(const char *); int imsg_compose_parent(int, pid_t, void *, u_int16_t); int imsg_compose_rde(int, pid_t, void *, u_int16_t); -- cgit v1.2.3