]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib/clippy: expose JOIN_TKN's fork node
authorDavid Lamparter <equinox@opensourcerouting.org>
Sun, 21 Jul 2024 01:29:11 +0000 (18:29 -0700)
committerDonald Sharp <sharpd@nvidia.com>
Wed, 31 Jul 2024 12:08:53 +0000 (08:08 -0400)
FORK_TKN's join node is already exposed, mirror to expose JOIN_TKN's
fork node.

(contains minor cleanup to make checkpatch.pl shut up)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/command_py.c

index 411caa52d6687ea443cc932681e18e6af63253ac..99438d4f5aac8f34be2e21947993ddcbc274012f 100644 (file)
@@ -138,22 +138,40 @@ static PyObject *graph_node_prev(PyObject *self, PyObject *args)
 static PyObject *graph_node_join(PyObject *self, PyObject *args)
 {
        struct wrap_graph_node *wrap = (struct wrap_graph_node *)self;
+       struct cmd_token *tok;
 
        if (!wrap->node->data
            || ((struct cmd_token *)wrap->node->data)->type == END_TKN)
                Py_RETURN_NONE;
 
-       struct cmd_token *tok = wrap->node->data;
+       tok = wrap->node->data;
        if (tok->type != FORK_TKN)
                Py_RETURN_NONE;
 
        return graph_to_pyobj(wrap->wgraph, tok->forkjoin);
 };
 
+static PyObject *graph_node_fork(PyObject *self, PyObject *args)
+{
+       struct wrap_graph_node *wrap = (struct wrap_graph_node *)self;
+       struct cmd_token *tok;
+
+       if (!wrap->node->data ||
+           ((struct cmd_token *)wrap->node->data)->type == END_TKN)
+               Py_RETURN_NONE;
+
+       tok = wrap->node->data;
+       if (tok->type != JOIN_TKN)
+               Py_RETURN_NONE;
+
+       return graph_to_pyobj(wrap->wgraph, tok->forkjoin);
+};
+
 static PyMethodDef methods_graph_node[] = {
        { "next", graph_node_next, METH_NOARGS, "outbound graph edge list" },
        { "prev", graph_node_prev, METH_NOARGS, "inbound graph edge list" },
        { "join", graph_node_join, METH_NOARGS, "outbound join node" },
+       { "fork", graph_node_fork, METH_NOARGS, "inbound fork node" },
        {}
 };