summaryrefslogtreecommitdiff
path: root/lib/command_graph.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>
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>
2023-01-31lib: Add missing enum's to switch statementDonald Sharp
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
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>
2021-10-18lib: assign CLI varnames while parsingDavid Lamparter
... rather than running a costly extra pass across the finished tree. 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-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
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>
2019-08-06*: fix ctype (isalpha & co.) castsDavid Lamparter
The correct cast for these is (unsigned char), because "char" could be signed and thus have some negative value. isalpha & co. expect an int arg that is positive, i.e. 0-255. So we need to cast to (unsigned char) when calling any of these. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-02-25*: use proper bool initializers & fix comparisonsQuentin Young
- bools should be initialized with true/false - bools do not need to be compared Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-26lib: fix clippy build w/ gcc under certain configsQuentin Young
GCC's linker driver sometimes gets confused when building clippy. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-22lib: add ability to dump cli mode graphQuentin Young
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-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-02-02*: silence '-Wchar-subscripts' warnings on NetBSDRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2017-08-11lib: add CLI token for 48-bit mac addressesQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-07lib: cli: don't run off graph "pre-end"David Lamparter
Behind END_TKN, there is another graph node whose data pointer is actually struct cmd_element instead of struct cmd_token. Don't try to interpret that as cmd_token. This causes very interesting crashes when ASLR decides to give one of the strings of a command definition a lower 32-bit value that is a valid cmd_token_type (e.g. FORK_TKN). Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
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-07-14lib: parser: remove incorrect assertDavid Lamparter
A {foo|bar|baz} graph node will have more than 1/2 incoming links even if no other references are left to it (which is what the assert was previously trying to ensure.) I don't see a good way to "fix" the assert so I'm just removing it. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-14*: fix GCC 7 warnings/issuesDavid Lamparter
The label initializer & nhrpd variable are just to shut up GCC 7, the other two are actual bugs. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-16Merge pull request #532 from opensourcerouting/gpl-headersDonald Sharp
*: make consistent & update GPLv2 file headers
2017-05-15lib: parser: remove forgotten lineDavid Lamparter
MTYPE_CMD_TOKEN_DATA isn't used anymore, I forgot to ditch the line. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
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-15lib: parser: add pre-merge varname propagation stepDavid Lamparter
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-15lib: parser: split off & rename graph handlingDavid Lamparter
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>