summaryrefslogtreecommitdiff
path: root/lib/command_py.c
AgeCommit message (Collapse)Author
2024-07-31lib/clippy: add `CMD_ELEMENT_TKN`David Lamparter
The command graph has its tail end nodes pointing at the `struct cmd_element` rather than a `struct cmd_token`. This is a bit weird to begin with, but becomes very annoying for the python bindings where there is just no `struct cmd_element`. Create a `CMD_ELEMENT_TKN` type for `cmd_token` instead, and replace the tail end token in the python bindings with an instance of that. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: improve graph node member accessDavid Lamparter
Expose all of the struct members of cmd_token, and retrieve them dynamically rather than copying them around. The problem with copying them is that they can change as a result of merge(), and if there is an existing wrapper object around it will not have its copy updated to match. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: expose JOIN_TKN's fork nodeDavid Lamparter
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>
2024-07-31lib/clippy: expose graph nodes' back pointersDavid Lamparter
There's a wrapper for nodes' outgoing pointers, but not incoming yet. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: allow accessing graph nodes by indexDavid Lamparter
Add len(graph) and graph[i] wrappers to access arbitrary nodes in a graph. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: add a __repr__ for graph nodesDavid Lamparter
Make it a little easier to work on python code using this wrapper. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: wrap cmd_graph_merge via Graph.merge()David Lamparter
Export cmd_graph_merge() to python code via graph1.merge(graph2). Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: allow creating empty graphDavid Lamparter
When merging graphs, it makes sense to allow starting with an empty one. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31lib/clippy: dynamically wrap graph nodesDavid Lamparter
The number of nodes in a graph will change as soon as cmd_graph_merge is supported as an operation, therefore size this dynamically. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-21Merge pull request #12248 from pguibert6WIND/bgpasdotRuss White
lib, bgp: add initial support for asdot format
2023-02-10lib, bgp: add initial support for asdot formatPhilippe Guibert
AS number can be defined as an unsigned long number, or two uint16 values separated by a period (.). The possible valus are: - usual 32 bit values : [1;2^32 -1] - <1.65535>.<0.65535> for dot notation - <0.65535>.<0.65535> for dot+ notation. The 0.0 value is forbidden when configuring BGP instances or peer configurations. A new ASN type is added for parsing in the vty. The following commands use that new identifier: - router bgp .. - bgp confederation .. - neighbor <> remote-as <> - neighbor <> local-as <> - clear ip bgp <> - route-map / set as-path <> An asn library is available in lib/ and provides some services: - convert an as string into an as number. - parse an as path list string and extract a number. - convert an as number into a string. Also, the bgp tests forge an as_zero_path, and to do that, an API to relax the possibility to have a 0 as value is specifically called from the tests. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06lib: add CMD_ATTR_NOSHDavid Lamparter
To propagate into .xref so extract.pl can be handled there. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06lib: make cmd_element->attr a bitmask & clarifyDavid Lamparter
It already "looks" like a bitmask, but we currently can't flag a command both YANG and HIDDEN at the same time. It really should be a bitmask. Also clarify DEPRECATED behaviour (or the absence thereof.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-04-04build: first header *must* be zebra.h or config.hDavid Lamparter
This has already been a requirement for Solaris, it is still a requirement for some of the autoconf feature checks to work correctly, and it will be a requirement for `-fms-extensions`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26lib: fix indentation trainwreck in command_pyDavid Lamparter
Hooooo boooooyyyy... that `default` sure was in an "interesting" place. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26lib: add `![...]` syntax for easy "no" formsDavid Lamparter
This allows defining a CLI command like this: `[no] some setting ![VALUE]` with VALUE being optional for the "no" form, but required for the positive form. It's just a `[...]` where the empty branch can only be taken for commands starting with `no`. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-02-23lib/clippy: add libelf wrapperDavid Lamparter
This adds _clippy.ELFFile, which provides a fast wrapper around libelf. The API is similar to / a subset of pyelfutils, which unfortunately is painfully slow (to the tune of minutes instead of seconds.) The idea is that xrefs can be read out of ELF files by reading out the "xref_array" section or "FRRouting/XREF" note. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13*: config.h or zebra.h is the first #includeDavid Lamparter
This is mostly relevant for Solaris, where config.h sets up some #define that affect overall header behaviour, so it needs to be before anything else. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13lib/clippy: ignore -Wstrict-aliasingDavid Lamparter
This warning is both meaningless and unfixable, just ignore it. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-12-01Revert "isisd lib ospfd pbrd python: fix empty init"David Lamparter
This reverts commit 48944eb65e1d1ced03d46121d923d9d613a480d5. We're using GNU C, not ISO C - and this commit triggers new (real) warnings about {0} instead of bogus ones about {}. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-11-21isisd lib ospfd pbrd python: fix empty initF. Aragon
ISO C forbids empty initializer braces. Empty initializers have been replaced with {0} Signed-off-by: F. Aragon <paco@voltanet.io>
2017-10-17lib: Fix small memory leak when using command_py.cDonald Sharp
When free'ing memory associated with the wgraph, also free memory malloced during the initialization. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-14lib, python: add M:A:C support for clippyQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-07-22Revert "*: reindent pt. 2"David Lamparter
This reverts commit c14777c6bfd0a446c85243d3a9835054a259c276. clang 5 is not widely available enough for people to indent with. This is particularly problematic when rebasing/adjusting branches. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17*: reindent pt. 2whitespace / reindent
w/ clang 5 * reflow comments * struct members go 1 per line * binpack algo was adjusted
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-06-14lib: clippy the assistantDavid Lamparter
Wraps the command parsing code for Python, so we can use it to do fancy preprocessing and replace extract.pl. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>