XFREE(MTYPE_TMP, p);
}
+
+void vty_out_timestr(struct vty *vty, time_t uptime)
+{
+ struct tm *tm;
+ time_t difftime = time(NULL);
+ difftime -= uptime;
+ tm = gmtime(&difftime);
+
+#define ONE_DAY_SECOND 60*60*24
+#define ONE_WEEK_SECOND 60*60*24*7
+ if (difftime < ONE_DAY_SECOND)
+ vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
+ tm->tm_sec);
+ else if (difftime < ONE_WEEK_SECOND)
+ vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
+ tm->tm_min);
+ else
+ vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
+ tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour);
+ vty_out(vty, " ago");
+}
struct vty;
void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
PRINTF_ATTRIBUTE(3, 4);
+void vty_out_timestr(struct vty *vty, time_t uptime);
#endif
DEFINE_MTYPE_STATIC(ISISD, ISIS_SPF_RUN, "ISIS SPF Run Info");
+enum vertextype {
+ VTYPE_PSEUDO_IS = 1,
+ VTYPE_PSEUDO_TE_IS,
+ VTYPE_NONPSEUDO_IS,
+ VTYPE_NONPSEUDO_TE_IS,
+ VTYPE_ES,
+ VTYPE_IPREACH_INTERNAL,
+ VTYPE_IPREACH_EXTERNAL,
+ VTYPE_IPREACH_TE,
+ VTYPE_IP6REACH_INTERNAL,
+ VTYPE_IP6REACH_EXTERNAL
+};
+
+#define VTYPE_IS(t) ((t) >= VTYPE_PSEUDO_IS && (t) <= VTYPE_NONPSEUDO_TE_IS)
+#define VTYPE_ES(t) ((t) == VTYPE_ES)
+#define VTYPE_IP(t) ((t) >= VTYPE_IPREACH_INTERNAL && (t) <= VTYPE_IP6REACH_EXTERNAL)
+
+/*
+ * Triple <N, d(N), {Adj(N)}>
+ */
+struct isis_vertex {
+ enum vertextype type;
+
+ union {
+ u_char id[ISIS_SYS_ID_LEN + 1];
+ struct prefix prefix;
+ } N;
+
+ u_int32_t d_N; /* d(N) Distance from this IS */
+ u_int16_t depth; /* The depth in the imaginary tree */
+ struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */
+ struct list *parents; /* list of parents for ECMP */
+ struct list *children; /* list of children used for tree dump */
+};
+
+struct isis_spftree {
+ struct list *paths; /* the SPT */
+ struct list *tents; /* TENT */
+ struct isis_area *area; /* back pointer to area */
+ unsigned int runcount; /* number of runs since uptime */
+ time_t last_run_timestamp; /* last run timestamp for scheduling */
+ time_t last_run_duration; /* last run duration in msec */
+
+ uint16_t mtid;
+ int family;
+ int level;
+};
+
+
/*
* supports the given af ?
*/
{
install_element(VIEW_NODE, &show_isis_topology_cmd);
}
+
+void isis_spf_print(struct isis_spftree *spftree, struct vty *vty)
+{
+ vty_out(vty, " last run elapsed : ");
+ vty_out_timestr(vty, spftree->last_run_timestamp);
+ vty_out(vty, "\n");
+
+ vty_out(vty, " last run duration : %u usec\n",
+ (u_int32_t)spftree->last_run_duration);
+
+ vty_out(vty, " run count : %u\n",
+ spftree->runcount);
+}
#ifndef _ZEBRA_ISIS_SPF_H
#define _ZEBRA_ISIS_SPF_H
-enum vertextype {
- VTYPE_PSEUDO_IS = 1,
- VTYPE_PSEUDO_TE_IS,
- VTYPE_NONPSEUDO_IS,
- VTYPE_NONPSEUDO_TE_IS,
- VTYPE_ES,
- VTYPE_IPREACH_INTERNAL,
- VTYPE_IPREACH_EXTERNAL,
- VTYPE_IPREACH_TE,
- VTYPE_IP6REACH_INTERNAL,
- VTYPE_IP6REACH_EXTERNAL
-};
-
-#define VTYPE_IS(t) ((t) >= VTYPE_PSEUDO_IS && (t) <= VTYPE_NONPSEUDO_TE_IS)
-#define VTYPE_ES(t) ((t) == VTYPE_ES)
-#define VTYPE_IP(t) ((t) >= VTYPE_IPREACH_INTERNAL && (t) <= VTYPE_IP6REACH_EXTERNAL)
-
-/*
- * Triple <N, d(N), {Adj(N)}>
- */
-struct isis_vertex {
- enum vertextype type;
-
- union {
- u_char id[ISIS_SYS_ID_LEN + 1];
- struct prefix prefix;
- } N;
-
- u_int32_t d_N; /* d(N) Distance from this IS */
- u_int16_t depth; /* The depth in the imaginary tree */
- struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */
- struct list *parents; /* list of parents for ECMP */
- struct list *children; /* list of children used for tree dump */
-};
-
-struct isis_spftree {
- struct list *paths; /* the SPT */
- struct list *tents; /* TENT */
- struct isis_area *area; /* back pointer to area */
- unsigned int runcount; /* number of runs since uptime */
- time_t last_run_timestamp; /* last run timestamp for scheduling */
- time_t last_run_duration; /* last run duration in msec */
-
- uint16_t mtid;
- int family;
- int level;
-};
+struct isis_spftree;
struct isis_spftree *isis_spftree_new(struct isis_area *area);
void isis_spftree_del(struct isis_spftree *spftree);
void spftree_area_adj_del(struct isis_area *area, struct isis_adjacency *adj);
int isis_spf_schedule(struct isis_area *area, int level);
void isis_spf_cmds_init(void);
+void isis_spf_print(struct isis_spftree *spftree, struct vty *vty);
#endif /* _ZEBRA_ISIS_SPF_H */
return CMD_SUCCESS;
}
-static void vty_out_timestr(struct vty *vty, time_t uptime)
-{
- struct tm *tm;
- time_t difftime = time(NULL);
- difftime -= uptime;
- tm = gmtime(&difftime);
-
-#define ONE_DAY_SECOND 60*60*24
-#define ONE_WEEK_SECOND 60*60*24*7
- if (difftime < ONE_DAY_SECOND)
- vty_out(vty, "%02d:%02d:%02d", tm->tm_hour, tm->tm_min,
- tm->tm_sec);
- else if (difftime < ONE_WEEK_SECOND)
- vty_out(vty, "%dd%02dh%02dm", tm->tm_yday, tm->tm_hour,
- tm->tm_min);
- else
- vty_out(vty, "%02dw%dd%02dh", tm->tm_yday / 7,
- tm->tm_yday - ((tm->tm_yday / 7) * 7), tm->tm_hour);
- vty_out(vty, " ago");
-}
-
DEFUN (show_isis_spf_ietf,
show_isis_spf_ietf_cmd,
"show isis spf-delay-ietf",
{
struct listnode *node, *node2;
struct isis_area *area;
- struct isis_spftree *spftree;
int level;
if (isis == NULL) {
continue;
vty_out(vty, " Level-%d:\n", level);
- spftree = area->spftree[level - 1];
if (area->spf_timer[level - 1])
vty_out(vty, " SPF: (pending)\n");
else
vty_out(vty, "\n");
vty_out(vty, " IPv4 route computation:\n");
- vty_out(vty, " last run elapsed : ");
- vty_out_timestr(vty, spftree->last_run_timestamp);
- vty_out(vty, "\n");
-
- vty_out(vty, " last run duration : %u usec\n",
- (u_int32_t)spftree->last_run_duration);
+ isis_spf_print(area->spftree[level - 1], vty);
- vty_out(vty, " run count : %d\n",
- spftree->runcount);
-
- spftree = area->spftree6[level - 1];
vty_out(vty, " IPv6 route computation:\n");
-
- vty_out(vty, " last run elapsed : ");
- vty_out_timestr(vty, spftree->last_run_timestamp);
- vty_out(vty, "\n");
-
- vty_out(vty, " last run duration : %llu msec\n",
- (unsigned long long)spftree->last_run_duration);
-
- vty_out(vty, " run count : %d\n",
- spftree->runcount);
+ isis_spf_print(area->spftree6[level - 1], vty);
}
}
vty_out(vty, "\n");