]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/srcdest_table.c
Merge pull request #5280 from qlyoung/doc-clean-topotest-json
[mirror_frr.git] / lib / srcdest_table.c
index e49735192d13f378d98f2c62ab602cec0642290d..ee87d730770e35094ca9cb02e89e1af8955ddc48 100644 (file)
@@ -28,6 +28,7 @@
 #include "memory.h"
 #include "prefix.h"
 #include "table.h"
+#include "printfrr.h"
 
 DEFINE_MTYPE_STATIC(LIB, ROUTE_SRC_NODE, "Route source node")
 
@@ -103,7 +104,7 @@ static void srcdest_srcnode_destroy(route_table_delegate_t *delegate,
 
        XFREE(MTYPE_ROUTE_SRC_NODE, rn);
 
-       srn = table->info;
+       srn = route_table_get_info(table);
        if (srn->src_table && route_table_count(srn->src_table) == 0) {
                /* deleting the route_table from inside destroy_node is ONLY
                 * permitted IF table->count is 0!  see lib/table.c
@@ -140,7 +141,7 @@ static struct route_node *srcdest_srcnode_get(struct route_node *rn,
                 * here */
                srn->src_table = route_table_init_with_delegate(
                        &_srcdest_srcnode_delegate);
-               srn->src_table->info = srn;
+               route_table_set_info(srn->src_table, srn);
 
                /* there is no route_unlock_node on the original rn here.
                 * The reference is kept for the src_table. */
@@ -220,7 +221,7 @@ struct route_node *srcdest_route_next(struct route_node *rn)
        }
 
        /* This part handles the case of iterating source nodes. */
-       parent = route_lock_node(rn->table->info);
+       parent = route_lock_node(route_table_get_info(rn->table));
        next = route_next(rn);
 
        if (next) {
@@ -264,11 +265,12 @@ struct route_node *srcdest_rnode_lookup(struct route_table *table,
        return srn;
 }
 
-void srcdest_rnode_prefixes(struct route_node *rn, const struct prefix **p,
+void srcdest_rnode_prefixes(const struct route_node *rn,
+                           const struct prefix **p,
                            const struct prefix **src_p)
 {
        if (rnode_is_srcnode(rn)) {
-               struct route_node *dst_rn = rn->table->info;
+               struct route_node *dst_rn = route_table_get_info(rn->table);
                if (p)
                        *p = &dst_rn->p;
                if (src_p)
@@ -296,10 +298,22 @@ const char *srcdest2str(const struct prefix *dst_p,
        return str;
 }
 
-const char *srcdest_rnode2str(struct route_node *rn, char *str, int size)
+const char *srcdest_rnode2str(const struct route_node *rn, char *str, int size)
 {
        const struct prefix *dst_p, *src_p;
 
        srcdest_rnode_prefixes(rn, &dst_p, &src_p);
        return srcdest2str(dst_p, (const struct prefix_ipv6 *)src_p, str, size);
 }
+
+printfrr_ext_autoreg_p("RN", printfrr_rn)
+static ssize_t printfrr_rn(char *buf, size_t bsz, const char *fmt,
+                          int prec, const void *ptr)
+{
+       const struct route_node *rn = ptr;
+       const struct prefix *dst_p, *src_p;
+
+       srcdest_rnode_prefixes(rn, &dst_p, &src_p);
+       srcdest2str(dst_p, (const struct prefix_ipv6 *)src_p, buf, bsz);
+       return 2;
+}