Commit Graph

22 Commits

Author SHA1 Message Date
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
8005767b2e lib: assign CLI varnames while parsing
... rather than running a costly extra pass across the finished tree.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-18 19:48:11 +02:00
ewlumpkin
81eb8fc749 lib: fix spelling nits in command.h
Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
2021-10-05 03:21:50 +00: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
bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet.  Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition.  And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...

With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.

Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01:00
David Lamparter
5e085e529d lib: get rid of padding in struct cmd_element
This makes the Python code looking at xrefs much easier.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-23 16:56:58 +01:00
David Lamparter
feb06e7a93 lib/xref: add xrefs for DEFUNs
This allows grabbing a list of all DEFUNs and their help texts through
the xref extraction mechanics.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-02-01 17:28:11 +01:00
Renato Westphal
ca77b518bd *: introduce DEFPY_YANG & friends
DEFPY_YANG will allow the CLI to identify which commands are
YANG-modeled or not before executing them. This is going to be
useful for the upcoming configuration back-off timer work that
needs to commit pending configuration changes before executing a
command that isn't YANG-modeled.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-08-03 15:17:03 -03:00
David Lamparter
154e9ca142 lib: make cmd_element & qobj_type const
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-30 00:38:32 +01:00
Renato Westphal
7f04943d6b lib: a few more trivial changes for C++ compatibility
* command_graph.h: stop using "new" as a parameter name as that's a
  reserved C++ keyword.

* module.h: avoid using C99 designated initializers since C++ doesn't
  support them. This change hurts code readability quite considerably,
  so we should try to find a better solution later.

* pw.h: remove unneeded empty structure to silence a C++ warning.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-11 22:34:12 -02:00
Renato Westphal
5e2444690b lib: add extern "C" {} blocks to all libfrr headers
These are necessary to use functions defined in these headers from C++.

Signed-off-by: David Lamparter <equinox@diac24.net>
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-02-11 22:34:12 -02:00
Quentin Young
26fbe47294 lib: add ability to dump cli mode graph
The grammar sandbox has had the ability to dump individual commands as
DOT graphs, but now that generalized DOT support is present it's trivial
to extend this to entire submodes. This is quite useful for visualizing
the CLI space when debugging CLI errors.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22 17:14:55 -04:00
Quentin Young
9779e3f193
lib: add CLI token for 48-bit mac addresses
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-11 12:42:01 -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
896014f4bc *: make consistent & update GPLv2 file headers
The FSF's address changed, and we had a mixture of comment styles for
the GPL file header.  (The style with * at the beginning won out with
580 to 141 in existing files.)

Note: I've intentionally left intact other "variations" of the copyright
header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 16:37:41 +02:00
David Lamparter
70d44c5cd4 lib: cli: autocomplete variables
Shows known values in the appropriate naming domain when the user hits
<?> or <Tab>.  This patch only works in the telnet CLI, the next patch
adds vtysh support.

Included completions:
- interface names
- route-map names
- prefix-list names

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 10:27:43 -04:00
David Lamparter
c09c46ae3c lib: parser: add pre-merge varname propagation step
Fills token->varname based on context.  WORD tokens use the WORD - if it
isn't actually "WORD".  Other than that, a preceding constant token is
used as name.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 10:27:43 -04:00
David Lamparter
5894e76da7 lib: parser: split off & rename graph handling
Put core CLI graph stuff in lib/command_graph.[ch] and consistently
prefix all function names with "cmd_".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15 10:27:43 -04:00