]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: make isis_spftree non-public
authorChristian Franke <chris@opensourcerouting.org>
Thu, 3 Aug 2017 09:45:58 +0000 (11:45 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Thu, 3 Aug 2017 09:45:58 +0000 (11:45 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
isisd/isis_misc.c
isisd/isis_misc.h
isisd/isis_spf.c
isisd/isis_spf.h
isisd/isisd.c

index 4d7b4c381af99dbc2d2948a5bc1dec6cb5f07396..c872774da8cca8ce0258548de642b9b752804076 100644 (file)
@@ -601,3 +601,24 @@ void vty_multiline(struct vty *vty, const char *prefix, const char *format, ...)
 
        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");
+}
index 7de534ec7b26047101f146cd91a15151c26a5f8a..5a19a1ffa0debe6bd5d78df4c0e4bd8b3f0da7e9 100644 (file)
@@ -84,4 +84,5 @@ void log_multiline(int priority, const char *prefix, const char *format, ...)
 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
index 740f087ee75de5e1cdaddccfb6b2e3877afbb2d0..413f2898006ffbad0190eeda1e8c1fe64b44529c 100644 (file)
 
 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 ?
  */
@@ -1430,3 +1479,16 @@ void isis_spf_cmds_init()
 {
        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);
+}
index c7a505489f46596fd25a39d3675aa11e8e90d9e6..84e07861d2c351252316efde190b28982f5a1f61 100644 (file)
 #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);
@@ -79,4 +33,5 @@ void spftree_area_del(struct isis_area *area);
 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 */
index 05797fb73add6ee63f49e6e904940b01676f0e69..60b9367da9907baf0cb3dedd82cc19d232e21c63 100644 (file)
@@ -1231,27 +1231,6 @@ DEFUN (show_hostname,
        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",
@@ -1308,7 +1287,6 @@ DEFUN (show_isis_summary,
 {
        struct listnode *node, *node2;
        struct isis_area *area;
-       struct isis_spftree *spftree;
        int level;
 
        if (isis == NULL) {
@@ -1349,7 +1327,6 @@ DEFUN (show_isis_summary,
                                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
@@ -1363,28 +1340,10 @@ DEFUN (show_isis_summary,
                        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");