]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Cisco-like "show ospf neighbors" implemented.
authorOndrej Filip <feela@network.cz>
Thu, 1 Jun 2000 15:53:06 +0000 (15:53 +0000)
committerOndrej Filip <feela@network.cz>
Thu, 1 Jun 2000 15:53:06 +0000 (15:53 +0000)
doc/reply_codes
proto/ospf/config.Y
proto/ospf/neighbor.c
proto/ospf/neighbor.h
proto/ospf/ospf.c
proto/ospf/ospf.h

index 1a547913f40ae59e972db45d225959302161572a..cad367848797730a6ba060a18f9af1ab20970c6b 100644 (file)
@@ -37,6 +37,7 @@ Reply codes of BIRD command-line interface
 1010   Symbol list
 1011   Uptime
 1012   Route extended attribute list
+1013   Show ospf neighbors
 
 8000   Reply too long
 8001   Route not found
index 95741410f0731378ed4b77e3f97fe13578029398..901975979599a257ff2e464b4a90adf88ec38129 100644 (file)
@@ -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
index c4f457a01e9daeb29ea8c81dca23699e0da1f078..7faa8ae9001f94d5d7d932607e68be5b18c27299 100644 (file)
@@ -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);
+}
index 98761fe0c51539f710b920b99212f9c2190c2f12..4f2a4c91e5eea0e167784c1f778cc10e67c5f7e3 100644 (file)
@@ -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_ */
index 92bb670db8962f16aee119023b0cf8612629b387..b8f7b9841ea5dac7ba3c1d35806a85e55cbb9f75 100644 (file)
@@ -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,"");
+}
index 087e6e79c50da9f4fcd42d2284b12f605c6e8e97..0d7da5ed601f9873d135ad1b186f1e741a693174 100644 (file)
@@ -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)