Commit graph

28 commits

Author SHA1 Message Date
David Lamparter ece3132471 lib/clippy: add CMD_ELEMENT_TKN
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-31 08:08:53 -04:00
David Lamparter cb9d20b712 lib/clippy: improve graph node member access
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-31 08:08:53 -04:00
David Lamparter e2344206ca lib/clippy: expose JOIN_TKN's fork node
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-31 08:08:53 -04:00
David Lamparter 3c1556f386 lib/clippy: expose graph nodes' back pointers
There's a wrapper for nodes' outgoing pointers, but not incoming yet.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter 8511f39987 lib/clippy: allow accessing graph nodes by index
Add len(graph) and graph[i] wrappers to access arbitrary nodes in a
graph.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter f85e58af12 lib/clippy: add a __repr__ for graph nodes
Make it a little easier to work on python code using this wrapper.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter 34a4f858b7 lib/clippy: wrap cmd_graph_merge via Graph.merge()
Export cmd_graph_merge() to python code via graph1.merge(graph2).

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter 7fb8729a32 lib/clippy: allow creating empty graph
When merging graphs, it makes sense to allow starting with an empty one.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-07-31 08:08:53 -04:00
David Lamparter cf37c79f31 lib/clippy: dynamically wrap graph nodes
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>
2024-07-31 08:08:53 -04:00
Russ White ba755d35e5
Merge pull request #12248 from pguibert6WIND/bgpasdot
lib, bgp: add initial support for asdot format
2023-02-21 08:01:03 -05:00
Philippe Guibert 8079a4138d lib, bgp: add initial support for asdot format
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-10 10:27:17 +01:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
David Lamparter 3df5764499 lib: add CMD_ATTR_NOSH
To propagate into .xref so extract.pl can be handled there.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-10-06 15:34:32 +02:00
David Lamparter 9eebf97e3d lib: make cmd_element->attr a bitmask & clarify
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-10-06 15:34:32 +02:00
David Lamparter 5b4f4e626f build: first header *must* be zebra.h or config.h
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>
2022-04-04 18:33:10 +02:00
David Lamparter 3be280bb8c lib: fix indentation trainwreck in command_py
Hooooo boooooyyyy... that `default` sure was in an "interesting" place.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-08-26 21:08:51 +02:00
David Lamparter 90c8406c20 lib: add ![...] syntax for easy "no" forms
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-08-26 21:03:44 +02:00
David Lamparter 5609b3af49 lib/clippy: add libelf wrapper
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>
2021-02-23 16:56:58 +01:00
David Lamparter 2618a52ed3 *: config.h or zebra.h is the first #include
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-13 13:35:33 +02:00
David Lamparter f54dd468ec lib/clippy: ignore -Wstrict-aliasing
This warning is both meaningless and unfixable, just ignore it.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 00:05:03 +02:00
David Lamparter 3e30070331 Revert "isisd lib ospfd pbrd python: fix empty init"
This reverts commit 48944eb65e.

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-12-01 16:49:45 +01:00
F. Aragon 48944eb65e
isisd lib ospfd pbrd python: fix empty init
ISO C forbids empty initializer braces. Empty initializers have been
replaced with {0}

Signed-off-by: F. Aragon <paco@voltanet.io>
2018-11-21 14:45:42 +01:00
Donald Sharp e871b669e1 lib: Fix small memory leak when using command_py.c
When free'ing memory associated with the wgraph, also
free memory malloced during the initialization.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-10-17 09:22:41 -04:00
Quentin Young 473196f613
lib, python: add M:A:C support for clippy
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-14 11:30:08 -04:00
David Lamparter 9d303b37d7 Revert "*: reindent pt. 2"
This reverts commit c14777c6bf.

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-22 14:52:33 +02:00
whitespace / reindent c14777c6bf
*: reindent pt. 2
w/ clang 5

* reflow comments
* struct members go 1 per line
* binpack algo was adjusted
2017-07-17 15:26:02 -04:00
whitespace / reindent d62a17aede *: reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'`

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-17 14:04:07 +02:00
David Lamparter 29ad6f6882 lib: clippy the assistant
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>
2017-06-14 19:29:23 +02:00