diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-05-27 15:37:30 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-05-27 15:37:30 +0000 |
commit | c23f38a450e0aa79f5c2b009a2d84e68d744afd5 (patch) | |
tree | b60032b8e921aa370420d4e2241445b2ab12b4b4 /usr.sbin/bgpd | |
parent | 2ce4c8aaf0d6203ec4b881d046ca01918bd47e52 (diff) |
Move prinitng of communities into own function so that special communities
like "*" or "neighbor-as" is printed correctly. Issue noticed by Leen Besselink.
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/printconf.c | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/usr.sbin/bgpd/printconf.c b/usr.sbin/bgpd/printconf.c index ddb41175e6f..a662f9be0a5 100644 --- a/usr.sbin/bgpd/printconf.c +++ b/usr.sbin/bgpd/printconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: printconf.c,v 1.55 2006/04/04 12:03:26 henning Exp $ */ +/* $OpenBSD: printconf.c,v 1.56 2006/05/27 15:37:29 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -25,6 +25,7 @@ #include "session.h" void print_op(enum comp_ops); +void print_community(int, int); void print_set(struct filter_set_head *); void print_mainconf(struct bgpd_config *); void print_network(struct network_config *); @@ -74,6 +75,24 @@ print_op(enum comp_ops op) } void +print_community(int as, int type) +{ + if (as == COMMUNITY_ANY) + printf("*:"); + else if (as == COMMUNITY_NEIGHBOR_AS) + printf("neighbor-as:"); + else + printf("%d:", as); + + if (type == COMMUNITY_ANY) + printf("* "); + else if (type == COMMUNITY_NEIGHBOR_AS) + printf("neighbor-as "); + else + printf("%d ", type); +} + +void print_set(struct filter_set_head *set) { struct filter_set *s; @@ -124,12 +143,16 @@ print_set(struct filter_set_head *set) printf("prepend-neighbor %u ", s->action.prepend); break; case ACTION_DEL_COMMUNITY: - printf("community delete %u:%u ", - s->action.community.as, s->action.community.type); + printf("community delete "); + print_community(s->action.community.as, + s->action.community.type); + printf(" "); break; case ACTION_SET_COMMUNITY: - printf("community %u:%u ", s->action.community.as, + printf("community "); + print_community(s->action.community.as, s->action.community.type); + printf(" "); break; case ACTION_PFTABLE: printf("pftable %s ", s->action.pftable); @@ -441,19 +464,8 @@ print_rule(struct peer *peer_l, struct filter_rule *r) if (r->match.community.as != 0) { printf("community "); - if (r->match.community.as == COMMUNITY_ANY) - printf("*:"); - else if (r->match.community.as == COMMUNITY_NEIGHBOR_AS) - printf("neighbor-as:"); - else - printf("%d:", r->match.community.as); - - if (r->match.community.type == COMMUNITY_ANY) - printf("* "); - else if (r->match.community.type == COMMUNITY_NEIGHBOR_AS) - printf("neighbor-as "); - else - printf("%d ", r->match.community.type); + print_community(r->match.community.as, + r->match.community.type); } print_set(&r->set); |