summaryrefslogtreecommitdiff
path: root/proto/ospf
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/config.Y16
-rw-r--r--proto/ospf/iface.c21
-rw-r--r--proto/ospf/iface.h1
-rw-r--r--proto/ospf/ospf.c64
-rw-r--r--proto/ospf/ospf.h3
5 files changed, 95 insertions, 10 deletions
diff --git a/proto/ospf/config.Y b/proto/ospf/config.Y
index 0ee644c6..0951572f 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 eb6d4641..011fd4b4 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 d46cf5d0..b18f546e 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 7e7896a1..70d89850 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 a952640f..52c56e95 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)