void ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on) { char router_id[16]; char drouter[16], bdrouter[16]; char duration[16]; struct timeval now, res; /* vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", "RouterID", "State", "Duration", "DR", "BDR", "I/F", "State", VNL); */ inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id)); inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter)); inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter)); gettimeofday (&now, NULL); timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", router_id, ospf6_neighbor_state_str[on->state], duration, drouter, bdrouter, on->ospf6_if->interface->name, ospf6_interface_state_str[on->ospf6_if->state], VNL); }
/* show neighbor structure */ void ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) { char router_id[16]; char duration[16]; struct timeval now, res; char nstate[16]; char deadtime[16]; long h, m, s; /* Router-ID (Name) */ inet_ntop (AF_INET, &on->router_id, router_id, sizeof (router_id)); #ifdef HAVE_GETNAMEINFO { } #endif /*HAVE_GETNAMEINFO*/ gettimeofday (&now, NULL); /* Dead time */ h = m = s = 0; if (on->inactivity_timer) { s = on->inactivity_timer->u.sands.tv_sec - now.tv_sec; h = s / 3600; s -= h * 3600; m = s / 60; s -= m * 60; } snprintf (deadtime, sizeof (deadtime), "%02ld:%02ld:%02ld", h, m, s); /* Neighbor State */ if (if_is_pointopoint (on->ospf6_if->interface)) snprintf (nstate, sizeof (nstate), "PointToPoint"); else { if (on->router_id == on->drouter) snprintf (nstate, sizeof (nstate), "DR"); else if (on->router_id == on->bdrouter) snprintf (nstate, sizeof (nstate), "BDR"); else snprintf (nstate, sizeof (nstate), "DROther"); } /* Duration */ timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); /* vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s", "Neighbor ID", "Pri", "DeadTime", "State", "", "Duration", "I/F", "State", VNL); */ vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s", router_id, on->priority, deadtime, ospf6_neighbor_state_str[on->state], nstate, duration, on->ospf6_if->interface->name, ospf6_interface_state_str[on->ospf6_if->state], VNL); }
/* show specified interface structure */ static int ospf6_interface_show (struct vty *vty, struct interface *ifp) { struct ospf6_interface *oi; struct connected *c; struct prefix *p; struct listnode *i; char strbuf[64], drouter[32], bdrouter[32]; const char *updown[3] = {"down", "up", NULL}; const char *type; struct timeval res, now; char duration[32]; struct ospf6_lsa *lsa; /* check physical interface type */ if (if_is_loopback (ifp)) type = "LOOPBACK"; else if (if_is_broadcast (ifp)) type = "BROADCAST"; else if (if_is_pointopoint (ifp)) type = "POINTOPOINT"; else type = "UNKNOWN"; vty_out (vty, "%s is %s, type %s%s", ifp->name, updown[if_is_up (ifp)], type, VNL); vty_out (vty, " Interface ID: %d%s", ifp->ifindex, VNL); if (ifp->info == NULL) { vty_out (vty, " OSPF not enabled on this interface%s", VNL); return 0; } else oi = (struct ospf6_interface *) ifp->info; vty_out (vty, " Internet Address:%s", VNL); for (ALL_LIST_ELEMENTS_RO (ifp->connected, i, c)) { p = c->address; prefix2str (p, strbuf, sizeof (strbuf)); switch (p->family) { case AF_INET: vty_out (vty, " inet : %s%s", strbuf, VNL); break; case AF_INET6: vty_out (vty, " inet6: %s%s", strbuf, VNL); break; default: vty_out (vty, " ??? : %s%s", strbuf, VNL); break; } } if (oi->area) { vty_out (vty, " Instance ID %d, Interface MTU %d (autodetect: %d)%s", oi->instance_id, oi->ifmtu, ifp->mtu6, VNL); vty_out (vty, " MTU mismatch detection: %s%s", oi->mtu_ignore ? "disabled" : "enabled", VNL); inet_ntop (AF_INET, &oi->area->area_id, strbuf, sizeof (strbuf)); vty_out (vty, " Area ID %s, Cost %hu%s", strbuf, oi->cost, VNL); } else vty_out (vty, " Not Attached to Area%s", VNL); vty_out (vty, " State %s, Transmit Delay %d sec, Priority %d%s", ospf6_interface_state_str[oi->state], oi->transdelay, oi->priority, VNL); vty_out (vty, " Timer intervals configured:%s", VNL); vty_out (vty, " Hello %d, Dead %d, Retransmit %d%s", oi->hello_interval, oi->dead_interval, oi->rxmt_interval, VNL); inet_ntop (AF_INET, &oi->drouter, drouter, sizeof (drouter)); inet_ntop (AF_INET, &oi->bdrouter, bdrouter, sizeof (bdrouter)); vty_out (vty, " DR: %s BDR: %s%s", drouter, bdrouter, VNL); vty_out (vty, " Number of I/F scoped LSAs is %u%s", oi->lsdb->count, VNL); bane_gettime (BANE_CLK_MONOTONIC, &now); timerclear (&res); if (oi->thread_send_lsupdate) timersub (&oi->thread_send_lsupdate->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", oi->lsupdate_list->count, duration, (oi->thread_send_lsupdate ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (oi->lsupdate_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); timerclear (&res); if (oi->thread_send_lsack) timersub (&oi->thread_send_lsack->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", oi->lsack_list->count, duration, (oi->thread_send_lsack ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (oi->lsack_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); return 0; }
void ospf6_neighbor_show_detail (struct vty *vty, struct ospf6_neighbor *on) { char drouter[16], bdrouter[16]; char linklocal_addr[64], duration[32]; struct timeval now, res; struct ospf6_lsa *lsa; inet_ntop (AF_INET6, &on->linklocal_addr, linklocal_addr, sizeof (linklocal_addr)); inet_ntop (AF_INET, &on->drouter, drouter, sizeof (drouter)); inet_ntop (AF_INET, &on->bdrouter, bdrouter, sizeof (bdrouter)); gettimeofday (&now, NULL); timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " Neighbor %s%s", on->name, VNL); vty_out (vty, " Area %s via interface %s (ifindex %d)%s", on->ospf6_if->area->name, on->ospf6_if->interface->name, on->ospf6_if->interface->ifindex, VNL); vty_out (vty, " His IfIndex: %d Link-local address: %s%s", on->ifindex, linklocal_addr, VNL); vty_out (vty, " State %s for a duration of %s%s", ospf6_neighbor_state_str[on->state], duration, VNL); vty_out (vty, " His choice of DR/BDR %s/%s, Priority %d%s", drouter, bdrouter, on->priority, VNL); vty_out (vty, " DbDesc status: %s%s%s SeqNum: %#lx%s", (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_IBIT) ? "Initial " : ""), (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MBIT) ? "More " : ""), (CHECK_FLAG (on->dbdesc_bits, OSPF6_DBDESC_MSBIT) ? "Master" : "Slave"), (u_long) ntohl (on->dbdesc_seqnum), VNL); vty_out (vty, " Summary-List: %d LSAs%s", on->summary_list->count, VNL); for (lsa = ospf6_lsdb_head (on->summary_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " Request-List: %d LSAs%s", on->request_list->count, VNL); for (lsa = ospf6_lsdb_head (on->request_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); vty_out (vty, " Retrans-List: %d LSAs%s", on->retrans_list->count, VNL); for (lsa = ospf6_lsdb_head (on->retrans_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); timerclear (&res); if (on->thread_send_dbdesc) timersub (&on->thread_send_dbdesc->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for DbDesc in Time %s [thread %s]%s", on->dbdesc_list->count, duration, (on->thread_send_dbdesc ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->dbdesc_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); timerclear (&res); if (on->thread_send_lsreq) timersub (&on->thread_send_lsreq->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSReq in Time %s [thread %s]%s", on->lsreq_list->count, duration, (on->thread_send_lsreq ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->lsreq_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); timerclear (&res); if (on->thread_send_lsupdate) timersub (&on->thread_send_lsupdate->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSUpdate in Time %s [thread %s]%s", on->lsupdate_list->count, duration, (on->thread_send_lsupdate ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->lsupdate_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); timerclear (&res); if (on->thread_send_lsack) timersub (&on->thread_send_lsack->u.sands, &now, &res); timerstring (&res, duration, sizeof (duration)); vty_out (vty, " %d Pending LSAs for LSAck in Time %s [thread %s]%s", on->lsack_list->count, duration, (on->thread_send_lsack ? "on" : "off"), VNL); for (lsa = ospf6_lsdb_head (on->lsack_list); lsa; lsa = ospf6_lsdb_next (lsa)) vty_out (vty, " %s%s", lsa->name, VNL); }