From 2148e07ae93d0aa4b2092b618b760504a72bb447 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Sat, 26 Mar 2005 13:35:17 +0000 Subject: Implement the IMSG_CTL_IFINFO bits correctly. This is needed for "ospfctl show fib interface". OK henning@ norby@ --- usr.sbin/ospfd/control.c | 3 ++- usr.sbin/ospfd/kroute.c | 13 +++++++------ usr.sbin/ospfd/ospfd.c | 10 ++++++---- usr.sbin/ospfd/ospfd.h | 4 ++-- 4 files changed, 17 insertions(+), 13 deletions(-) (limited to 'usr.sbin') diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c index a217b9600af..bbd8231e6e0 100644 --- a/usr.sbin/ospfd/control.c +++ b/usr.sbin/ospfd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.9 2005/03/22 22:13:48 norby Exp $ */ +/* $OpenBSD: control.c,v 1.10 2005/03/26 13:35:16 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -228,6 +228,7 @@ control_dispatch_imsg(int fd, short event, void *bula) break; case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: + case IMSG_CTL_IFINFO: c->ibuf.pid = imsg.hdr.pid; ospfe_imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, imsg.data, diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c index 42aaf54c664..480abc83687 100644 --- a/usr.sbin/ospfd/kroute.c +++ b/usr.sbin/ospfd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.11 2005/03/26 11:06:49 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.12 2005/03/26 13:35:16 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby @@ -311,16 +311,17 @@ kr_show_route(struct imsg *imsg) } void -kr_ifinfo(char *ifname) +kr_ifinfo(char *ifname, pid_t pid) { struct kif_node *kif; RB_FOREACH(kif, kif_tree, &kit) - if (!strcmp(ifname, kif->k.ifname)) { - main_imsg_compose_ospfe(IMSG_CTL_IFINFO, 0, - &kif->k, sizeof(kif->k)); - return; + if (ifname == NULL || !strcmp(ifname, kif->k.ifname)) { + main_imsg_compose_ospfe(IMSG_CTL_IFINFO, + pid, &kif->k, sizeof(kif->k)); } + + main_imsg_compose_ospfe(IMSG_CTL_END, pid, NULL, 0); } /* rb-tree compare */ diff --git a/usr.sbin/ospfd/ospfd.c b/usr.sbin/ospfd/ospfd.c index dc6ca68b070..c8967e66913 100644 --- a/usr.sbin/ospfd/ospfd.c +++ b/usr.sbin/ospfd/ospfd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.c,v 1.12 2005/03/26 11:04:28 henning Exp $ */ +/* $OpenBSD: ospfd.c,v 1.13 2005/03/26 13:35:16 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -338,10 +338,12 @@ main_dispatch_ospfe(int fd, short event, void *bula) kr_show_route(&imsg); break; case IMSG_CTL_IFINFO: - if (imsg.hdr.len != IMSG_HEADER_SIZE + IFNAMSIZ) - log_warnx("IFINFO request with wrong len"); + if (imsg.hdr.len == IMSG_HEADER_SIZE) + kr_ifinfo(NULL, imsg.hdr.pid); + else if (imsg.hdr.len == IMSG_HEADER_SIZE + IFNAMSIZ) + kr_ifinfo(imsg.data, imsg.hdr.pid); else - kr_ifinfo(imsg.data); + log_warnx("IFINFO request with wrong len"); break; default: log_debug("main_dispatch_ospfe: error handling imsg %d", diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 517d3d14aaf..ccafbb988ce 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.21 2005/03/26 11:06:49 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.22 2005/03/26 13:35:16 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby @@ -482,7 +482,7 @@ void kr_dispatch_msg(int, short, void *); int kr_nexthop_add(struct in_addr); void kr_nexthop_delete(struct in_addr); void kr_show_route(struct imsg *); -void kr_ifinfo(char *); +void kr_ifinfo(char *, pid_t); struct kif *kif_findname(char *); u_int8_t mask2prefixlen(in_addr_t); -- cgit v1.2.3