📄 ospf_te.c
字号:
int i; vty_out (vty, " mpls-te link metric %u%s", (u_int32_t) ntohl (lp->te_metric.value), VTY_NEWLINE); ntohf (&lp->max_bw.value, &fval); if (fval >= MPLS_TE_MINIMUM_BANDWIDTH) vty_out (vty, " mpls-te link max-bw %g%s", fval, VTY_NEWLINE); ntohf (&lp->max_rsv_bw.value, &fval); if (fval >= MPLS_TE_MINIMUM_BANDWIDTH) vty_out (vty, " mpls-te link max-rsv-bw %g%s", fval, VTY_NEWLINE); for (i = 0; i < 8; i++) { ntohf (&lp->unrsv_bw.value[i], &fval); if (fval >= MPLS_TE_MINIMUM_BANDWIDTH) vty_out (vty, " mpls-te link unrsv-bw %d %g%s", i, fval, VTY_NEWLINE); } vty_out (vty, " mpls-te link rsc-clsclr 0x%x%s", (u_int32_t) ntohl (lp->rsc_clsclr.value), VTY_NEWLINE); } return;}/*------------------------------------------------------------------------* * Followings are vty command functions. *------------------------------------------------------------------------*/DEFUN (mpls_te, mpls_te_cmd, "mpls-te", "Configure MPLS-TE parameters\n" "Enable the MPLS-TE functionality\n"){ listnode node; struct mpls_te_link *lp; if (OspfMplsTE.status == enabled) return CMD_SUCCESS; if (IS_DEBUG_OSPF_EVENT) zlog_info ("MPLS-TE: OFF -> ON"); OspfMplsTE.status = enabled; /* * Following code is intended to handle two cases; * * 1) MPLS-TE was disabled at startup time, but now become enabled. * 2) MPLS-TE was once enabled then disabled, and now enabled again. */ for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) if ((lp = getdata (node)) != NULL) initialize_linkparams (lp); ospf_mpls_te_foreach_area (ospf_mpls_te_lsa_schedule, REORIGINATE_PER_AREA); return CMD_SUCCESS;}ALIAS (mpls_te, mpls_te_on_cmd, "mpls-te on", "Configure MPLS-TE parameters\n" "Enable the MPLS-TE functionality\n");DEFUN (no_mpls_te, no_mpls_te_cmd, "no mpls-te", NO_STR "Configure MPLS-TE parameters\n" "Disable the MPLS-TE functionality\n"){ listnode node; struct mpls_te_link *lp; if (OspfMplsTE.status == disabled) return CMD_SUCCESS; if (IS_DEBUG_OSPF_EVENT) zlog_info ("MPLS-TE: ON -> OFF"); OspfMplsTE.status = disabled; for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) if ((lp = getdata (node)) != NULL) if (lp->area != NULL) if (lp->flags & LPFLG_LSA_ENGAGED) ospf_mpls_te_lsa_schedule (lp, FLUSH_THIS_LSA); return CMD_SUCCESS;}DEFUN (mpls_te_router_addr, mpls_te_router_addr_cmd, "mpls-te router-address A.B.C.D", "MPLS-TE specific commands\n" "Stable IP address of the advertising router\n" "MPLS-TE router address in IPv4 address format\n"){ struct te_tlv_router_addr *ra = &OspfMplsTE.router_addr; struct in_addr value; if (! inet_aton (argv[0], &value)) { vty_out (vty, "Please specify Router-Addr by A.B.C.D%s", VTY_NEWLINE); return CMD_WARNING; } if (ntohs (ra->header.type) == 0 || ntohl (ra->value.s_addr) != ntohl (value.s_addr)) { listnode node; struct mpls_te_link *lp; int need_to_reoriginate = 0; set_mpls_te_router_addr (value); if (OspfMplsTE.status == disabled) goto out; for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) { if ((lp = getdata (node)) == NULL) continue; if (lp->area == NULL) continue; if ((lp->flags & LPFLG_LSA_ENGAGED) == 0) { need_to_reoriginate = 1; break; } } for (node = listhead (OspfMplsTE.iflist); node; nextnode (node)) { if ((lp = getdata (node)) == NULL) continue; if (lp->area == NULL) continue; if (need_to_reoriginate) lp->flags |= LPFLG_LSA_FORCED_REFRESH; else ospf_mpls_te_lsa_schedule (lp, REFRESH_THIS_LSA); } if (need_to_reoriginate) ospf_mpls_te_foreach_area ( ospf_mpls_te_lsa_schedule, REORIGINATE_PER_AREA); }out: return CMD_SUCCESS;}DEFUN (mpls_te_link_metric, mpls_te_link_metric_cmd, "mpls-te link metric <0-4294967295>", "MPLS-TE specific commands\n" "Configure MPLS-TE link parameters\n" "Link metric for MPLS-TE purpose\n" "Metric\n"){ struct interface *ifp = (struct interface *) vty->index; struct mpls_te_link *lp; u_int32_t value; if ((lp = lookup_linkparams_by_ifp (ifp)) == NULL) { vty_out (vty, "mpls_te_link_metric: Something wrong!%s", VTY_NEWLINE); return CMD_WARNING; } value = strtoul (argv[0], NULL, 10); if (ntohs (lp->te_metric.header.type) == 0 || ntohl (lp->te_metric.value) != value) { set_linkparams_te_metric (lp, value); if (OspfMplsTE.status == enabled) if (lp->area != NULL) { if (lp->flags & LPFLG_LSA_ENGAGED) ospf_mpls_te_lsa_schedule (lp, REFRESH_THIS_LSA); else ospf_mpls_te_lsa_schedule (lp, REORIGINATE_PER_AREA); } } return CMD_SUCCESS;}DEFUN (mpls_te_link_maxbw, mpls_te_link_maxbw_cmd, "mpls-te link max-bw BANDWIDTH", "MPLS-TE specific commands\n" "Configure MPLS-TE link parameters\n" "Maximum bandwidth that can be used\n" "Bytes/second (IEEE floating point format)\n"){ struct interface *ifp = (struct interface *) vty->index; struct mpls_te_link *lp; float f1, f2; if ((lp = lookup_linkparams_by_ifp (ifp)) == NULL) { vty_out (vty, "mpls_te_link_maxbw: Something wrong!%s", VTY_NEWLINE); return CMD_WARNING; } ntohf (&lp->max_bw.value, &f1); if (sscanf (argv[0], "%g", &f2) != 1) { vty_out (vty, "mpls_te_link_maxbw: fscanf: %s%s", strerror (errno), VTY_NEWLINE); return CMD_WARNING; } if (ntohs (lp->max_bw.header.type) == 0 || f1 != f2) { set_linkparams_max_bw (lp, &f2); if (OspfMplsTE.status == enabled) if (lp->area != NULL) { if (lp->flags & LPFLG_LSA_ENGAGED) ospf_mpls_te_lsa_schedule (lp, REFRESH_THIS_LSA); else ospf_mpls_te_lsa_schedule (lp, REORIGINATE_PER_AREA); } } return CMD_SUCCESS;}DEFUN (mpls_te_link_max_rsv_bw, mpls_te_link_max_rsv_bw_cmd, "mpls-te link max-rsv-bw BANDWIDTH", "MPLS-TE specific commands\n" "Configure MPLS-TE link parameters\n" "Maximum bandwidth that may be reserved\n" "Bytes/second (IEEE floating point format)\n"){ struct interface *ifp = (struct interface *) vty->index; struct mpls_te_link *lp; float f1, f2; if ((lp = lookup_linkparams_by_ifp (ifp)) == NULL) { vty_out (vty, "mpls_te_link_max_rsv_bw: Something wrong!%s", VTY_NEWLINE); return CMD_WARNING; } ntohf (&lp->max_rsv_bw.value, &f1); if (sscanf (argv[0], "%g", &f2) != 1) { vty_out (vty, "mpls_te_link_max_rsv_bw: fscanf: %s%s", strerror (errno), VTY_NEWLINE); return CMD_WARNING; } if (ntohs (lp->max_rsv_bw.header.type) == 0 || f1 != f2) { set_linkparams_max_rsv_bw (lp, &f2); if (OspfMplsTE.status == enabled) if (lp->area != NULL) { if (lp->flags & LPFLG_LSA_ENGAGED) ospf_mpls_te_lsa_schedule (lp, REFRESH_THIS_LSA); else ospf_mpls_te_lsa_schedule (lp, REORIGINATE_PER_AREA); } } return CMD_SUCCESS;}DEFUN (mpls_te_link_unrsv_bw, mpls_te_link_unrsv_bw_cmd, "mpls-te link unrsv-bw <0-7> BANDWIDTH", "MPLS-TE specific commands\n" "Configure MPLS-TE link parameters\n" "Unreserved bandwidth at each priority level\n" "Priority\n" "Bytes/second (IEEE floating point format)\n"){ struct interface *ifp = (struct interface *) vty->index; struct mpls_te_link *lp; int priority; float f1, f2; if ((lp = lookup_linkparams_by_ifp (ifp)) == NULL) { vty_out (vty, "mpls_te_link_unrsv_bw: Something wrong!%s", VTY_NEWLINE); return CMD_WARNING; } /* We don't have to consider about range check here. */ if (sscanf (argv[0], "%d", &priority) != 1) { vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", strerror (errno), VTY_NEWLINE); return CMD_WARNING; } ntohf (&lp->unrsv_bw.value [priority], &f1); if (sscanf (argv[1], "%g", &f2) != 1) { vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", strerror (errno), VTY_NEWLINE); return CMD_WARNING; } if (ntohs (lp->unrsv_bw.header.type) == 0 || f1 != f2) { set_linkparams_unrsv_bw (lp, priority, &f2); if (OspfMplsTE.status == enabled) if (lp->area != NULL) { if (lp->flags & LPFLG_LSA_ENGAGED) ospf_mpls_te_lsa_schedule (lp, REFRESH_THIS_LSA); else ospf_mpls_te_lsa_schedule (lp, REORIGINATE_PER_AREA); } } return CMD_SUCCESS;}DEFUN (mpls_te_link_rsc_clsclr, mpls_te_link_rsc_clsclr_cmd, "mpls-te link rsc-clsclr BITPATTERN", "MPLS-TE specific commands\n" "Configure MPLS-TE link parameters\n" "Administrative group membership\n" "32-bit Hexadecimal value (ex. 0xa1)\n"){ struct interface *ifp = (struct interface *) vty->index; struct mpls_te_link *lp; unsigned long value; if ((lp = lookup_linkparams_by_ifp (ifp)) == NULL) { vty_out (vty, "mpls_te_link_rsc_clsclr: Something wrong!%s", VTY_NEWLINE); return CMD_WARNING; } if (sscanf (argv[0], "0x%lx", &value) != 1) { vty_out (vty, "mpls_te_link_rsc_clsclr: fscanf: %s%s", strerror (errno), VTY_NEWLINE); return CMD_WARNING; } if (ntohs (lp->rsc_clsclr.header.type) == 0 || ntohl (lp->rsc_clsclr.value) != value) { set_linkparams_rsc_clsclr (lp, value); if (OspfMplsTE.status == enabled) if (lp->area != NULL) { if (lp->flags & LPFLG_LSA_ENGAGED) ospf_mpls_te_lsa_schedule (lp, REFRESH_THIS_LSA); else ospf_mpls_te_lsa_schedule (lp, REORIGINATE_PER_AREA); } } return CMD_SUCCESS;}DEFUN (show_mpls_te_router, show_mpls_te_router_cmd, "show mpls-te router", SHOW_STR "MPLS-TE information\n" "Router information\n"){ if (OspfMplsTE.status == enabled) { vty_out (vty, "--- MPLS-TE router parameters ---%s", VTY_NEWLINE); if (ntohs (OspfMplsTE.router_addr.header.type) != 0) show_vty_router_addr (vty, &OspfMplsTE.router_addr.header); else if (vty != NULL) vty_out (vty, " N/A%s", VTY_NEWLINE); } return CMD_SUCCESS;}static voidshow_mpls_te_link_sub (struct vty *vty, struct interface *ifp){ struct mpls_te_link *lp; struct te_tlv_header *tlvh; if ((OspfMplsTE.status == enabled) && (! if_is_loopback (ifp) && if_is_up (ifp) && ospf_oi_count (ifp) > 0) && ((lp = lookup_linkparams_by_ifp (ifp)) != NULL)) { vty_out (vty, "-- MPLS-TE link parameters for %s --%s", ifp->name, VTY_NEWLINE); show_vty_link_subtlv_link_type (vty, &lp->link_type.header); show_vty_link_subtlv_link_id (vty, &lp->link_id.header); if ((tlvh = (struct te_tlv_header *) lp->lclif_ipaddr) != NULL) show_vty_link_subtlv_lclif_ipaddr (vty, tlvh); if ((tlvh = (struct te_tlv_header *) lp->rmtif_ipaddr) != NULL) show_vty_link_subtlv_rmtif_ipaddr (vty, tlvh); show_vty_link_subtlv_te_metric (vty, &lp->te_metric.header); show_vty_link_subtlv_max_bw (vty, &lp->max_bw.header); show_vty_link_subtlv_max_rsv_bw (vty, &lp->max_rsv_bw.header); show_vty_link_subtlv_unrsv_bw (vty, &lp->unrsv_bw.header); show_vty_link_subtlv_rsc_clsclr (vty, &lp->rsc_clsclr.header); } else { vty_out (vty, " %s: MPLS-TE is disabled on this interface%s", ifp->name, VTY_NEWLINE); } return;}DEFUN (show_mpls_te_link, show_mpls_te_link_cmd, "show mpls-te interface [INTERFACE]", SHOW_STR "MPLS-TE information\n" "Interface information\n" "Interface name\n"){ struct interface *ifp; listnode node; /* Show All Interfaces. */ if (argc == 0) for (node = listhead (iflist); node; nextnode (node)) show_mpls_te_link_sub (vty, node->data); /* Interface name is specified. */ else { if ((ifp = if_lookup_by_name (argv[0])) == NULL) vty_out (vty, "No such interface name%s", VTY_NEWLINE); else show_mpls_te_link_sub (vty, ifp); } return CMD_SUCCESS;}static voidospf_mpls_te_register_vty (void){ install_element (VIEW_NODE, &show_mpls_te_router_cmd); install_element (VIEW_NODE, &show_mpls_te_link_cmd); install_element (ENABLE_NODE, &show_mpls_te_router_cmd); install_element (ENABLE_NODE, &show_mpls_te_link_cmd); install_element (OSPF_NODE, &mpls_te_cmd); install_element (OSPF_NODE, &no_mpls_te_cmd); install_element (OSPF_NODE, &mpls_te_on_cmd); install_element (OSPF_NODE, &mpls_te_router_addr_cmd); install_element (INTERFACE_NODE, &mpls_te_link_metric_cmd); install_element (INTERFACE_NODE, &mpls_te_link_maxbw_cmd); install_element (INTERFACE_NODE, &mpls_te_link_max_rsv_bw_cmd); install_element (INTERFACE_NODE, &mpls_te_link_unrsv_bw_cmd); install_element (INTERFACE_NODE, &mpls_te_link_rsc_clsclr_cmd); return;}#endif /* HAVE_OSPF_TE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -