diff options
author | Ondrej Filip <feela@network.cz> | 2000-06-01 19:52:21 +0200 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2000-06-01 19:52:21 +0200 |
commit | c4f0f0140863c743b1d63c3bc94cb8e85417a4ad (patch) | |
tree | 8251605b5d619bc89e85042c69379f11633823be /proto | |
parent | 58740ed4c587a230bf1406eca52cbc84bcb1c5c3 (diff) | |
download | bird-c4f0f0140863c743b1d63c3bc94cb8e85417a4ad.tar bird-c4f0f0140863c743b1d63c3bc94cb8e85417a4ad.zip |
Added show ospf interface.
show ospf neighbors now knows "<interface>".
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/config.Y | 16 | ||||
-rw-r--r-- | proto/ospf/iface.c | 21 | ||||
-rw-r--r-- | proto/ospf/iface.h | 1 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 64 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 3 |
5 files changed, 95 insertions, 10 deletions
diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index 0ee644c..0951572 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -15,6 +15,8 @@ CF_DECLS CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG) CF_KEYWORDS(NEIGHBORS) +%type <t> opttext + CF_GRAMMAR CF_ADDTO(proto, ospf_proto '}') @@ -34,7 +36,12 @@ ospf_proto: ospf_area: AREA idval { ((struct ospf_config *)this_proto)->area = $2; } - ; +; + +opttext: + TEXT +| /* empty */ { $$ = NULL; } +; CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC1); }) CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); }) @@ -43,8 +50,11 @@ CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEM CF_CLI(SHOW OSPF, optsym, [<name>], [[Show information about ospf protocol]]) { ospf_sh(proto_get_named($3, &proto_ospf)); } ; -CF_CLI(SHOW OSPF NEIGHBORS, optsym, [<name>], [[Show information about ospf neighbors]]) -{ ospf_sh_neigh(proto_get_named($4, &proto_ospf)); } ; +CF_CLI(SHOW OSPF NEIGHBORS, optsym opttext, [<name>] [\"<interface>\"], [[Show information about ospf neighbors]]) +{ ospf_sh_neigh(proto_get_named($4, &proto_ospf), $5); } ; + +CF_CLI(SHOW OSPF INTERFACE, optsym opttext, [<name>] [\"<interface>\"], [[Show infomation about interface]]) +{ ospf_sh_iface(proto_get_named($4, &proto_ospf), $5); }; CF_CODE diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c index eb6d464..011fd4b 100644 --- a/proto/ospf/iface.c +++ b/proto/ospf/iface.c @@ -14,6 +14,8 @@ char *ospf_is[]={ "down", "loop", "waiting", "point-to-point", "drother", char *ospf_ism[]={ "interface up", "wait timer fired", "backup seen", "neighbor change", "loop indicated", "unloop indicated", "interface down"}; +char *ospf_it[]={ "broadcast", "nbma", "point-to-point", "virtual link" }; + void iface_chstate(struct ospf_iface *ifa, u8 state) { @@ -406,3 +408,22 @@ ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface) } } +void +ospf_iface_info(struct ospf_iface *ifa) +{ + int x; + cli_msg(-1015,"Interface \"%s\":", ifa->iface->name); + cli_msg(-1015,"\tArea: %I (%u)", ifa->oa->areaid, ifa->oa->areaid); + cli_msg(-1015,"\tType: %s", ospf_it[ifa->type]); + cli_msg(-1015,"\tState: %s", ospf_is[ifa->state]); + cli_msg(-1015,"\tPriority: %u", ifa->priority); + cli_msg(-1015,"\tCost: %u", ifa->cost); + cli_msg(-1015,"\tHello timer: %u", ifa->helloint); + cli_msg(-1015,"\tWait timer: %u", ifa->waitint); + cli_msg(-1015,"\tDead timer: %u", ifa->deadc*ifa->helloint); + cli_msg(-1015,"\tRetransmit timer: %u", ifa->rxmtint); + cli_msg(-1015,"\tDesigned router (ID): %I", ifa->drid); + cli_msg(-1015,"\tDesigned router (IP): %I", ifa->drip); + cli_msg(-1015,"\tBackup designed router (ID): %I", ifa->bdrid); + cli_msg(-1015,"\tBackup designed router (IP): %I", ifa->bdrip); +} diff --git a/proto/ospf/iface.h b/proto/ospf/iface.h index d46cf5d..b18f546 100644 --- a/proto/ospf/iface.h +++ b/proto/ospf/iface.h @@ -21,5 +21,6 @@ void ospf_add_timers(struct ospf_iface *ifa, pool *pool); void ospf_iface_default(struct ospf_iface *ifa); struct ospf_iface *find_iface(struct proto_ospf *p, struct iface *what); void ospf_if_notify(struct proto *p, unsigned flags, struct iface *iface); +void ospf_iface_info(struct ospf_iface *ifa); #endif /* _BIRD_OSPF_IFACE_H_ */ diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 7e7896a..70d8985 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -318,19 +318,38 @@ struct protocol proto_ospf = { }; void -ospf_sh_neigh(struct proto *p) +ospf_sh_neigh(struct proto *p, char *iff) { - struct ospf_iface *ifa; + struct ospf_iface *ifa=NULL,*f; struct ospf_neighbor *n; struct proto_ospf *po=(struct proto_ospf *)p; - + + if(iff!=NULL) + { + WALK_LIST(f, po->iface_list) + { + if(strcmp(iff,f->iface->name)==0) ifa=f; + break; + } + if(ifa==NULL) + { + cli_msg(0,""); + return; + } cli_msg(-1013,"%s:", p->name); cli_msg(-1013,"%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s","Router ID","Pri", " State", "DTime", "Router IP", "Interface"); - WALK_LIST(ifa,po->iface_list) - WALK_LIST(n, ifa->neigh_list) - ospf_sh_neigh_info(n); + WALK_LIST(n, ifa->neigh_list) ospf_sh_neigh_info(n); cli_msg(0,""); + } + + cli_msg(-1013,"%s:", p->name); + cli_msg(-1013,"%-12s\t%3s\t%-15s\t%-5s\t%-12s\t%-10s","Router ID","Pri", + " State", "DTime", "Router IP", "Interface"); + WALK_LIST(ifa,po->iface_list) + WALK_LIST(n, ifa->neigh_list) + ospf_sh_neigh_info(n); + cli_msg(0,""); } void @@ -371,3 +390,36 @@ ospf_sh(struct proto *p) cli_msg(0,""); } +void +ospf_sh_iface(struct proto *p, char *iff) +{ + struct ospf_area *oa; + struct proto_ospf *po=(struct proto_ospf *)p; + struct ospf_iface *ifa=NULL,*f; + struct ospf_neighbor *n; + int ifano; + int nno; + int adjno; + + if(iff!=NULL) + { + WALK_LIST(f, po->iface_list) + { + if(strcmp(iff,f->iface->name)==0) ifa=f; + break; + } + if(ifa==NULL) + { + cli_msg(0,""); + return; + } + cli_msg(-1015,"%s:", p->name); + ospf_iface_info(ifa); + cli_msg(0,""); + return; + } + cli_msg(-1015,"%s:", p->name); + WALK_LIST(ifa, po->iface_list) ospf_iface_info(ifa); + cli_msg(0,""); +} + diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index a952640..52c56e9 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -362,8 +362,9 @@ void ospf_rt_notify(struct proto *p, net *n, rte *new, rte *old,ea_list *attrs); void area_disp(timer *timer); void schedule_rt_lsa(struct ospf_area *oa); void schedule_rtcalc(struct ospf_area *oa); -void ospf_sh_neigh(struct proto *p); +void ospf_sh_neigh(struct proto *p, char *iff); void ospf_sh(struct proto *p); +void ospf_sh_iface(struct proto *p, char *iff); #define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0) #define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1) |