diff options
author | Ondrej Filip <feela@network.cz> | 2000-06-01 17:53:06 +0200 |
---|---|---|
committer | Ondrej Filip <feela@network.cz> | 2000-06-01 17:53:06 +0200 |
commit | a783e259d8d710208280126177487cc790418515 (patch) | |
tree | 961bb067c8e7e9c608b839f7abc1128eedec89a3 /proto | |
parent | b594ad238692738352cd8827d71038a356b0d5a5 (diff) | |
download | bird-a783e259d8d710208280126177487cc790418515.tar bird-a783e259d8d710208280126177487cc790418515.zip |
Cisco-like "show ospf neighbors" implemented.
Diffstat (limited to 'proto')
-rw-r--r-- | proto/ospf/config.Y | 4 | ||||
-rw-r--r-- | proto/ospf/neighbor.c | 38 | ||||
-rw-r--r-- | proto/ospf/neighbor.h | 1 | ||||
-rw-r--r-- | proto/ospf/ospf.c | 16 | ||||
-rw-r--r-- | proto/ospf/ospf.h | 2 |
5 files changed, 59 insertions, 2 deletions
diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y index 9574141..9019759 100644 --- a/proto/ospf/config.Y +++ b/proto/ospf/config.Y @@ -13,6 +13,7 @@ CF_HDR CF_DECLS CF_KEYWORDS(OSPF, AREA, OSPF_METRIC1, OSPF_METRIC2, OSPF_TAG) +CF_KEYWORDS(NEIGHBORS) CF_GRAMMAR @@ -39,6 +40,9 @@ CF_ADDTO(dynamic_attr, OSPF_METRIC1 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF CF_ADDTO(dynamic_attr, OSPF_METRIC2 { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_METRIC2); }) CF_ADDTO(dynamic_attr, OSPF_TAG { $$ = f_new_dynamic_attr(EAF_TYPE_INT | EAF_TEMP, T_INT, EA_OSPF_TAG); }) +CF_CLI(SHOW OSPF NEIGHBORS, optsym, [<name>], [[Show information about ospf neighbors]]) +{ ospf_sh_neigh(proto_get_named($4, &proto_ospf)); } ; + CF_CODE CF_END diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c index c4f457a..7faa8ae 100644 --- a/proto/ospf/neighbor.c +++ b/proto/ospf/neighbor.c @@ -8,8 +8,14 @@ #include "ospf.h" -char *ospf_ns[]={"down", "attempt", "init", "2way", "exstart", "exchange", - "loading", "full"}; +char *ospf_ns[]={" down", + " attempt", + " init", + " 2way", + " exstart", + "exchange", + " loading", + " full"}; const char *ospf_inm[]={ "hello received", "neighbor start", "2-way received", "negotiation done", "exstart done", "bad ls request", "load done", @@ -480,3 +486,31 @@ ospf_neigh_remove(struct ospf_neighbor *n) mb_free(n); debug("%s: Deleting neigbor.\n", p->name); } + +void +ospf_sh_neigh_info(struct ospf_neighbor *n) +{ + struct ospf_iface *ifa=n->ifa; + char *pos="other"; + char etime[6]; + int exp,sec,min; + + exp=n->inactim->expires-now; + sec=exp-(exp/60); + min=(exp-sec)/60; + if(min>59) + { + sprintf(etime,"-Inf-"); + } + else + { + sprintf(etime,"%02u:%02u", min, sec); + } + + if(n->rid==ifa->drid) pos="dr "; + if(n->rid==ifa->bdrid) pos="bdr "; + + + cli_msg(-1013,"%-18I\t%3u\t%s/%s\t%-5s\t%-18I\t%-10s",n->rid, n->priority, + ospf_ns[n->state], pos, etime, n->ip,ifa->iface->name); +} diff --git a/proto/ospf/neighbor.h b/proto/ospf/neighbor.h index 98761fe..4f2a4c9 100644 --- a/proto/ospf/neighbor.h +++ b/proto/ospf/neighbor.h @@ -22,5 +22,6 @@ struct ospf_neighbor *find_neigh_noifa(struct proto_ospf *po, u32 rid); struct ospf_area *ospf_find_area(struct proto_ospf *po, u32 aid); void neighbor_timer_hook(timer *timer); void ospf_neigh_remove(struct ospf_neighbor *n); +void ospf_sh_neigh_info(struct ospf_neighbor *n); #endif /* _BIRD_OSPF_NEIGHBOR_H_ */ diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c index 92bb670..b8f7b98 100644 --- a/proto/ospf/ospf.c +++ b/proto/ospf/ospf.c @@ -316,3 +316,19 @@ struct protocol proto_ospf = { get_attr: ospf_get_attr, get_status: ospf_get_status }; + +void +ospf_sh_neigh(struct proto *p) +{ + struct ospf_iface *ifa; + struct ospf_neighbor *n; + struct proto_ospf *po=(struct proto_ospf *)p; + + 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,""); +} diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 087e6e7..0d7da5e 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -24,6 +24,7 @@ #include "nest/protocol.h" #include "nest/iface.h" #include "nest/route.h" +#include "nest/cli.h" #include "conf/conf.h" #include "lib/string.h" @@ -361,6 +362,7 @@ 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); #define EA_OSPF_METRIC1 EA_CODE(EAP_OSPF, 0) #define EA_OSPF_METRIC2 EA_CODE(EAP_OSPF, 1) |