Example #1
0
/* Add rip route map rule. */
static int
rip_route_set_add (struct vty *vty, struct route_map_index *index,
		   const char *command, const char *arg)
{
  int ret;

  ret = route_map_add_set (index, command, arg);
  if (ret)
    {
      switch (ret)
	{
	case RMAP_RULE_MISSING:
	  vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
	  return CMD_WARNING;
	case RMAP_COMPILE_ERROR:
	  /* rip, ripng and other protocols share the set metric command
	     but only values from 0 to 16 are valid for rip and ripng
	     if metric is out of range for rip and ripng, it is not for
	     other protocols. Do not return an error */
	  if (strcmp(command, "metric")) {
	     vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
	     return CMD_WARNING;
	  }
	}
    }
  return CMD_SUCCESS;
}
/**
 * Executes the qos_cos_port_command for the given port_name.
 */
static int
qos_cos_port_command(const char *port_name,
        const char *cos_map_index)
{
    if (port_name == NULL) {
        vty_out(vty, "port_name cannot be NULL.%s", VTY_NEWLINE);
        return CMD_OVSDB_FAILURE;
    }

    if (is_member_of_lag(port_name)) {
        vty_out(vty, "QoS COS cannot be configured on a member of a LAG.%s",
                VTY_NEWLINE);
        return CMD_OVSDB_FAILURE;
    }

    struct ovsrec_port *port_row = port_row_for_name(port_name);
    if (port_row == NULL) {
        vty_out(vty, "Port %s does not exist.%s", port_name, VTY_NEWLINE);
        return CMD_OVSDB_FAILURE;
    }

    const char *qos_trust_name = qos_trust_port_get_value(port_row);
    if (qos_trust_name == NULL || strncmp(qos_trust_name,
            QOS_TRUST_NONE_STRING, QOS_CLI_STRING_BUFFER_SIZE) != 0) {
        vty_out(vty, "QoS COS override is only allowed\
 if the trust mode is 'none'.%s",
                VTY_NEWLINE);
        return CMD_OVSDB_FAILURE;
    }
Example #3
0
/* Printout flag information into vty */
void
if_flag_dump_vty (struct vty *vty, unsigned long flag)
{
  int separator = 0;

#define IFF_OUT_VTY(X, Y) \
  if ((X) && (flag & (X))) \
    { \
      if (separator) \
	vty_out (vty, ","); \
      else \
	separator = 1; \
      vty_out (vty, Y); \
    }

  vty_out (vty, "<");
  IFF_OUT_VTY (IFF_UP, "UP");
  IFF_OUT_VTY (IFF_BROADCAST, "BROADCAST");
  IFF_OUT_VTY (IFF_DEBUG, "DEBUG");
  IFF_OUT_VTY (IFF_LOOPBACK, "LOOPBACK");
  IFF_OUT_VTY (IFF_POINTOPOINT, "POINTOPOINT");
  IFF_OUT_VTY (IFF_NOTRAILERS, "NOTRAILERS");
  IFF_OUT_VTY (IFF_RUNNING, "RUNNING");
  IFF_OUT_VTY (IFF_NOARP, "NOARP");
  IFF_OUT_VTY (IFF_PROMISC, "PROMISC");
  IFF_OUT_VTY (IFF_ALLMULTI, "ALLMULTI");
  IFF_OUT_VTY (IFF_OACTIVE, "OACTIVE");
  IFF_OUT_VTY (IFF_SIMPLEX, "SIMPLEX");
  IFF_OUT_VTY (IFF_LINK0, "LINK0");
  IFF_OUT_VTY (IFF_LINK1, "LINK1");
  IFF_OUT_VTY (IFF_LINK2, "LINK2");
  IFF_OUT_VTY (IFF_MULTICAST, "MULTICAST");
  vty_out (vty, ">");
}
Example #4
0
/* Add eigrp route map rule. */
static int eigrp_route_set_add(struct vty *vty, struct route_map_index *index,
			       const char *command, const char *arg)
{
	int ret;

	ret = route_map_add_set(index, command, arg);
	switch (ret) {
	case RMAP_RULE_MISSING:
		vty_out(vty, "%% Can't find rule.\n");
		return CMD_WARNING_CONFIG_FAILED;
		break;
	case RMAP_COMPILE_ERROR:
		/*
		 * rip, ripng and other protocols share the set metric command
		 * but only values from 0 to 16 are valid for rip and ripng
		 * if metric is out of range for rip and ripng, it is
		 * not for other protocols. Do not return an error
		 */
		if (strcmp(command, "metric")) {
			vty_out(vty, "%% Argument is malformed.\n");
			return CMD_WARNING_CONFIG_FAILED;
		}
		break;
	case RMAP_COMPILE_SUCCESS:
		break;
	}

	return CMD_SUCCESS;
}
Example #5
0
void
ospf6_spf_display_subtree (struct vty *vty, const char *prefix, int rest,
                           struct ospf6_vertex *v)
{
  struct listnode *node, *nnode;
  struct ospf6_vertex *c;
  char *next_prefix;
  int len;
  int restnum;

  /* "prefix" is the space prefix of the display line */
  vty_out (vty, "%s+-%s [%d]%s", prefix, v->name, v->cost, VNL);

  len = strlen (prefix) + 4;
  next_prefix = (char *) malloc (len);
  if (next_prefix == NULL)
    {
      vty_out (vty, "malloc failed%s", VNL);
      return;
    }
  snprintf (next_prefix, len, "%s%s", prefix, (rest ? "|  " : "   "));

  restnum = listcount (v->child_list);
  for (ALL_LIST_ELEMENTS (v->child_list, node, nnode, c))
    {
      restnum--;
      ospf6_spf_display_subtree (vty, next_prefix, restnum, c);
    }

  free (next_prefix);
}
Example #6
0
/* Say hello to vty interface. */
void
vty_hello (vty_t *vty)
{
	if (host.motdfile) {
		FILE *f;
		char buf[4096];

		f = fopen(host.motdfile, "r");
		if (f) {
			while (fgets(buf, sizeof(buf), f)) {
				char *s;
				/* work backwards to ignore trailling isspace() */
				for (s = buf + strlen(buf); (s > buf) && isspace((int)*(s - 1));
				     s--);
					*s = '\0';
				vty_out(vty, "%s%s", buf, VTY_NEWLINE);
			}
			fclose (f);
		} else {
			vty_out(vty, "MOTD file not found%s", VTY_NEWLINE);
		}
	} else if (host.motd) {
		vty_out(vty, "%s", host.motd);
	}
}
Example #7
0
static void dump_trunk(struct vty *vty, struct mgcp_trunk_config *cfg, int verbose)
{
	int i;

	vty_out(vty, "%s trunk nr %d with %d endpoints:%s",
		cfg->trunk_type == MGCP_TRUNK_VIRTUAL ? "Virtual" : "E1",
		cfg->trunk_nr, cfg->number_endpoints - 1, VTY_NEWLINE);

	if (!cfg->endpoints) {
		vty_out(vty, "No endpoints allocated yet.%s", VTY_NEWLINE);
		return;
	}

	for (i = 1; i < cfg->number_endpoints; ++i) {
		struct mgcp_endpoint *endp = &cfg->endpoints[i];
		vty_out(vty,
			" Endpoint 0x%.2x: CI: %d net: %u/%u bts: %u/%u on %s "
			"traffic received bts: %u  remote: %u transcoder: %u/%u%s",
			i, endp->ci,
			ntohs(endp->net_end.rtp_port), ntohs(endp->net_end.rtcp_port),
			ntohs(endp->bts_end.rtp_port), ntohs(endp->bts_end.rtcp_port),
			inet_ntoa(endp->bts_end.addr),
			endp->bts_end.packets, endp->net_end.packets,
			endp->trans_net.packets, endp->trans_bts.packets,
			VTY_NEWLINE);

		if (verbose && endp->allocated) {
			dump_rtp_end("Net->BTS", vty, &endp->bts_state, &endp->bts_end);
			dump_rtp_end("BTS->Net", vty, &endp->net_state, &endp->net_end);
		}
	}
}
Example #8
0
void
bgp_damp_info_vty (struct vty *vty, struct bgp_info *binfo)  
{
  struct bgp_damp_info *bdi;
  time_t t_now, t_diff;
  char timebuf[BGP_UPTIME_LEN];
  int penalty;

  if (!binfo->extra)
    return;
  
  /* BGP dampening information.  */
  bdi = binfo->extra->damp_info;

  /* If dampening is not enabled or there is no dampening information,
     return immediately.  */
  if (! damp || ! bdi)
    return;

  /* Calculate new penalty.  */
  t_now = bgp_clock ();
  t_diff = t_now - bdi->t_updated;
  penalty = bgp_damp_decay (t_diff, bdi->penalty);

  vty_out (vty, "      Dampinfo: penalty %d, flapped %d times in %s",
           penalty, bdi->flap,
	   peer_uptime (bdi->start_time, timebuf, BGP_UPTIME_LEN));

  if (CHECK_FLAG (binfo->flags, BGP_INFO_DAMPED)
      && ! CHECK_FLAG (binfo->flags, BGP_INFO_HISTORY))
    vty_out (vty, ", reuse in %s",
	     bgp_get_reuse_time (penalty, timebuf, BGP_UPTIME_LEN));

  vty_out (vty, "%s", VTY_NEWLINE);
}
Example #9
0
void
ospf6_area_show (struct vty *vty, struct ospf6_area *o6a)
{
  listnode i;
  struct ospf6_interface *o6i;

  vty_out (vty, " Area %s%s", o6a->str, VTY_NEWLINE);
  vty_out (vty, "     Number of Area scoped LSAs is %u%s",
           o6a->lsdb->count, VTY_NEWLINE);

  ospf6_spf_statistics_show (vty, o6a->spf_tree);

  vty_out (vty, "     Interface attached to this area:");
  for (i = listhead (o6a->if_list); i; nextnode (i))
    {
      o6i = (struct ospf6_interface *) getdata (i);
      vty_out (vty, " %s", o6i->interface->name);
    }
  vty_out (vty, "%s", VTY_NEWLINE);

  for (i = listhead (o6a->if_list); i; nextnode (i))
    {
      o6i = (struct ospf6_interface *) getdata (i);
      if (listcount (o6i->neighbor_list) != 0)
        ospf6_interface_statistics_show (vty, o6i);
    }
}
Example #10
0
/*********************** MSDP feature APIs *********************************/
int pim_msdp_config_write(struct pim_instance *pim, struct vty *vty,
			  const char *spaces)
{
	struct listnode *mbrnode;
	struct pim_msdp_mg_mbr *mbr;
	struct pim_msdp_mg *mg = pim->msdp.mg;
	char mbr_str[INET_ADDRSTRLEN];
	char src_str[INET_ADDRSTRLEN];
	int count = 0;

	if (!mg) {
		return count;
	}

	if (mg->src_ip.s_addr != INADDR_ANY) {
		pim_inet4_dump("<src?>", mg->src_ip, src_str, sizeof(src_str));
		vty_out(vty, "%sip msdp mesh-group %s source %s\n", spaces,
			mg->mesh_group_name, src_str);
		++count;
	}

	for (ALL_LIST_ELEMENTS_RO(mg->mbr_list, mbrnode, mbr)) {
		pim_inet4_dump("<mbr?>", mbr->mbr_ip, mbr_str, sizeof(mbr_str));
		vty_out(vty, "%sip msdp mesh-group %s member %s\n", spaces,
			mg->mesh_group_name, mbr_str);
		++count;
	}
	return count;
}
static void vty_dump_sne(struct vty *vty, struct gprs_sndcp_entity *sne)
{
	vty_out(vty, " TLLI %08x SAPI=%u NSAPI=%u:%s",
		sne->lle->llme->tlli, sne->lle->sapi, sne->nsapi, VTY_NEWLINE);
	vty_out(vty, "  Defrag: npdu=%u highest_seg=%u seg_have=0x%08x tot_len=%u%s",
		sne->defrag.npdu, sne->defrag.highest_seg, sne->defrag.seg_have,
		sne->defrag.tot_len, VTY_NEWLINE);
}
Example #12
0
/* ----- wrong usage ----- */
void
usage (struct vty *vty) {
  vty_out (vty,"usage: X Y seed [-ll#i -lm#i -cl#i -p -pl#i -pm#i ...]%s",VTY_NEWLINE);
  vty_out (vty,"help: -h or -hh%s",VTY_NEWLINE);

  if ( np > 0 )
    zlog_err ("error in parameter # %d\n\n", np );
}
Example #13
0
static void _vty_output(struct log_target *tgt,
			unsigned int level, const char *line)
{
	struct vty *vty = tgt->tgt_vty.vty;
	vty_out(vty, "%s", line);
	/* This is an ugly hack, but there is no easy way... */
	if (strchr(line, '\n'))
		vty_out(vty, "\r");
}
Example #14
0
void
show_memory_vty (struct vty *vty, struct memory_list *list)
{
  struct memory_list *m;

  for (m = list; m->index >= 0; m++)
    if (m->index == 0)
      vty_out (vty, "-----------------------------\r\n");
    else
      vty_out (vty, "%-22s: %5ld\r\n", m->format, mstat[m->index].alloc);
}
Example #15
0
u_int32_t cfc_cf_show_status(struct vty *vty, cfc_show_status_info_t* stat_info)
{
    if(CFC_MODULE_INACTIVE == stat_info->module_stat)
    {
        vty_out(vty, "performance status              off%s", VTY_NEWLINE);
    }
    else
    {
        vty_out(vty, "performance status              on%s", VTY_NEWLINE);
        vty_out(vty, "performance para                %dM%s", stat_info->tot_flux, VTY_NEWLINE);
    }
    return ERROR_SUCCESS;    
}
Example #16
0
static void vty_dump_lle(struct vty *vty, struct gprs_llc_lle *lle)
{
	struct gprs_llc_params *par = &lle->params;
	vty_out(vty, " SAPI %2u State %s VUsend=%u, VUrecv=%u", lle->sapi, 
		get_value_string(gprs_llc_state_strs, lle->state),
		lle->vu_send, lle->vu_recv);
	vty_out(vty, " Vsent=%u Vack=%u Vrecv=%u, RetransCtr=%u%s",
		lle->v_sent, lle->v_ack, lle->v_recv,
		lle->retrans_ctr, VTY_NEWLINE);
	vty_out(vty, "  T200=%u, N200=%u, N201-U=%u, N201-I=%u, mD=%u, "
		"mU=%u, kD=%u, kU=%u%s", par->t200_201, par->n200,
		par->n201_u, par->n201_i, par->mD, par->mU, par->kD,
		par->kU, VTY_NEWLINE);
}
Example #17
0
int
bgp_show_dampening_parameters (struct vty *vty, afi_t afi, safi_t safi)
{
  struct bgp *bgp;
  bgp = bgp_get_default();

  if (bgp == NULL)
    {
      vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
      return CMD_WARNING;
    }

  if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
    {
      vty_out (vty, "Half-life time: %ld min%s",
                    damp->half_life / 60, VTY_NEWLINE);
      vty_out (vty, "Reuse penalty: %d%s",
                    damp->reuse_limit, VTY_NEWLINE);
      vty_out (vty, "Suppress penalty: %d%s",
                    damp->suppress_value, VTY_NEWLINE);
      vty_out (vty, "Max suppress time: %ld min%s",
                    damp->max_suppress_time / 60, VTY_NEWLINE);
      vty_out (vty, "Max supress penalty: %u%s",
                    damp->ceiling, VTY_NEWLINE);
      vty_out (vty, "%s", VTY_NEWLINE);
    }
  else
    vty_out (vty, "dampening not enabled for %s%s",
                  afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE);

  return CMD_SUCCESS;
}
Example #18
0
static void gbprox_vty_print_peer(struct vty *vty, struct gbproxy_peer *peer)
{
	struct gprs_ra_id raid;
	gsm48_parse_ra(&raid, peer->ra);

	vty_out(vty, "NSEI %5u, PTP-BVCI %5u, "
		"RAI %u-%u-%u-%u",
		peer->nsei, peer->bvci,
		raid.mcc, raid.mnc, raid.lac, raid.rac);
	if (peer->blocked)
		vty_out(vty, " [BVC-BLOCKED]");

	vty_out(vty, "%s", VTY_NEWLINE);
}
Example #19
0
static int
bfd_ioctl_peer_info (struct bfd_nl_peerinfo *peer, struct vty *vty)
{
	char buf1[BUFSIZ], buf2[BUFSIZ];

	vty_out (vty, "%s",
	    inet_ntop (peer->dst.sa.sa_family,
		peer->dst.sa.sa_family == AF_INET ?
		(char *) &peer->dst.sin.sin_addr
		: (char *) &peer->dst.sin6.sin6_addr, buf1, BUFSIZ));
	vty_out (vty, "  %u %u  %s %s%s",
	    ntohl (peer->my_disc),
	    ntohl (peer->your_disc),
	    bfd_state_string[peer->state],
	    ifindex2ifname (peer->ifindex), VTY_NEWLINE);

	vty_out (vty, "  SrcIP: %s%s",
	    inet_ntop (peer->src.sa.sa_family,
		peer->src.sa.sa_family == AF_INET ?
		(char *) &peer->src.sin.sin_addr
		: (char *) &peer->src.sin6.sin6_addr, buf2, BUFSIZ),
	    VTY_NEWLINE);

	vty_out (vty, "  Packet Rcvd: %llu%s", peer->pkt_in, VTY_NEWLINE);
	vty_out (vty, "  Packet Send: %llu%s", peer->pkt_out, VTY_NEWLINE);
	vty_out (vty, "  Last UpTime(sysUptime): %u%s", peer->last_up, VTY_NEWLINE);
	vty_out (vty, "  Last DownTime(sysUptime): %u%s",
	    peer->last_down, VTY_NEWLINE);
	vty_out (vty, "  Up Count: %u%s", peer->up_cnt, VTY_NEWLINE);

	return 0;
}
Example #20
0
/* Specific MPLS TE router parameters write function */
void
isis_mpls_te_config_write_router (struct vty *vty)
{

  zlog_debug ("ISIS MPLS-TE: Write ISIS router configuration");

  if (IS_MPLS_TE(isisMplsTE))
    {
      vty_out (vty, "  mpls-te on%s", VTY_NEWLINE);
      vty_out (vty, "  mpls-te router-address %s%s",
               inet_ntoa (isisMplsTE.router_id), VTY_NEWLINE);
    }

  return;
}
Example #21
0
void
ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
{
  struct listnode *i;
  struct ospf6_interface *oi;

  vty_out (vty, " Area %s%s", oa->name, VNL);
  vty_out (vty, "     Number of Area scoped LSAs is %u%s",
           oa->lsdb->count, VNL);

  vty_out (vty, "     Interface attached to this area:");
  for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
    vty_out (vty, " %s", oi->interface->name);
  
  vty_out (vty, "%s", VNL);
}
Example #22
0
static void vty_dump_llme(struct vty *vty, struct gprs_llc_llme *llme)
{
	unsigned int i;
	struct timespec now_tp = {0};
	clock_gettime(CLOCK_MONOTONIC, &now_tp);

	vty_out(vty, "TLLI %08x (Old TLLI %08x) BVCI=%u NSEI=%u %s: "
		"IOV-UI=0x%06x CKSN=%d Age=%d: State %s%s", llme->tlli,
		llme->old_tlli, llme->bvci, llme->nsei,
		get_value_string(gprs_cipher_names, llme->algo), llme->iov_ui,
		llme->cksn, llme->age_timestamp == GPRS_LLME_RESET_AGE ? 0 :
		(int)(now_tp.tv_sec - (time_t)llme->age_timestamp),
		get_value_string(gprs_llc_state_strs, llme->state), VTY_NEWLINE);

	for (i = 0; i < ARRAY_SIZE(valid_sapis); i++) {
		struct gprs_llc_lle *lle;
		uint8_t sapi = valid_sapis[i];

		if (sapi >= ARRAY_SIZE(llme->lle))
			continue;

		lle = &llme->lle[sapi];
		vty_dump_lle(vty, lle);
	}
}
Example #23
0
void
router_id_write (struct vty *vty)
{
  if (rid_user_assigned.u.prefix4.s_addr)
    vty_out (vty, "router-id %s%s", inet_ntoa (rid_user_assigned.u.prefix4),
	     VTY_NEWLINE);
}
static int
ospf6_interface_register_metricfunction (struct ospf6_interface *oi,
					 struct vty *vty)
{
  int err;
  struct ospf6_interface_metricfunction *imf;
  struct ospf6_interface_neighbor_metric_params nbrmetric_params = {
    .name = metricfunction_name,
    .delete = ospf6_interface_delete_metricfunction,
    .config_write = ospf6_interface_config_write_metricfunction,
    .nbrops = {
      .create = ospf6_neighbor_create_metricfunction,
    },
  };

  imf = XCALLOC (MTYPE_OSPF6_IF, sizeof (*imf));

  nbrmetric_params.data = imf;
  err =
    ospf6_interface_register_neighbor_metric (oi, &metricfunction_nbrmetric_id,
					      &nbrmetric_params, vty);
  if (err)
    {
      vty_out (vty, "could not register neighbor metric %s on interface %s%s",
	       nbrmetric_params.name, oi->interface->name, VNL);
      XFREE (MTYPE_OSPF6_IF, imf);
      return -1;
    }

  return 0;
}
Example #25
0
static int
config_write_agentx (struct vty *vty)
{
    if (agentx_enabled)
        vty_out (vty, "agentx%s", VTY_NEWLINE);
    return 0;
}
void
print_acl_horizontal_rule(void)
{
    vty_out(vty, "%s%s",
        "-------------------------------------------------------------------------------",
        VTY_NEWLINE);
}
Example #27
0
/**
 * @fn eigrp_nbr_hard_restart
 *
 * @param[in]		nbr	Neighbor who would receive hard restart
 * @param[in]		vty Virtual terminal for log output
 * @return void
 *
 * @par
 * Function used for executing hard restart for neighbor:
 * Send Hello packet with Peer Termination TLV with
 * neighbor's address, set it's state to DOWN and delete the neighbor
 */
void eigrp_nbr_hard_restart(struct eigrp_neighbor *nbr, struct vty *vty)
{
	if(nbr == NULL)
	{
		zlog_err("Nbr Hard restart: Neighbor not specified.");
		return;
	}

	zlog_debug ("Neighbor %s (%s) is down: manually cleared",
			inet_ntoa (nbr->src),
			ifindex2ifname (nbr->ei->ifp->ifindex));
	if(vty != NULL)
	{
		vty_time_print (vty, 0);
		vty_out (vty, "Neighbor %s (%s) is down: manually cleared%s",
				inet_ntoa (nbr->src),
				ifindex2ifname (nbr->ei->ifp->ifindex),
				VTY_NEWLINE);
	}

	/* send Hello with Peer Termination TLV */
	eigrp_hello_send(nbr->ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN_NBR, &(nbr->src));
	/* set neighbor to DOWN */
	nbr->state = EIGRP_NEIGHBOR_DOWN;
	/* delete neighbor */
	eigrp_nbr_delete (nbr);
}
Example #28
0
static void
fab_dump_per_route_elem(void *rt_arg, void *vty)
{
    rt_path_elem_t *rt_elem = rt_arg;

    vty_out(vty, "Node(%d):Link(%hu)->", rt_elem->sw_alias, rt_elem->link.la); 
}
Example #29
0
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);
}
Example #30
0
/* 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);
}