Commit graph

36 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 47a3a82770 *: manual SPDX License ID conversions
The files converted in this commit either had some random misspelling or
formatting weirdness that made them escape automated replacement, or
have a particularly "weird" licensing setup (e.g. dual-licensed.)

This also marks a bunch of "public domain" files as SPDX License "NONE".

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:07 +01: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 09781197b6 build: make builddir include path consistent
... by referencing all autogenerated headers relative to the root
directory.  (90% of the changes here is `version.h`.)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-04-21 15:42:33 +02:00
David Lamparter 1b3e9a21dd lib: make some variables static
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-13 06:22:34 +01:00
Quentin Young 6163c6cca1 lib: change M:A:C to X:X:X:X:X:X
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-10-24 21:44:33 +00:00
David Lamparter 7b34167d7d lib: early-include "config.h" in flex lexers
This is neccessary to get _FILE_OFFSET_BITS right.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-09 01:16:25 +02:00
Quentin Young 1ec890a76b lib: ignore cli lexer in clang-analyze
Lexer code is generated by Flex and we don't care about false positives
in it.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-04-13 17:17:42 -04:00
Renato Westphal a37bd5e070 lib: fix more warnings on *BSD
* zebra/kernel_socket.c: include "rt.h" to provide the prototypes of
  kernel_init() and kernel_terminate();

* lib/prefix.h: remove the deprecation warning whenever ETHER_ADDR_LEN
  is used. isisd uses the ETHER_HDR_LEN constant which is defined in
  terms of ETHER_ADDR_LEN in the *BSD system headers. So, when building
  FRR on *BSD, we were getting several warnings because we were using
  ETHER_ADDR_LEN indirectly;

* lib/command_lex.l, lib/defun_lex.l: ignore other harmless warnings;

* lib/spf_backoff.c: cast 'tv->tv_usec' to 'long int' before printing.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-02-02 16:31:20 -02:00
Daniel Walton d114b977e9 *: support keywords that begin with uppercase letter
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>

VARIABLE tokens must be all uppercase, this allows us to support WORD
tokens that begin with an uppercase letter.  The "Null0" keyword is an
example of where this is needed.

The only VARIABLE we had that wasn't already all uppercase was
ASN:nn_or_IP-address:nn
2017-09-14 18:07:30 +00: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
David Lamparter 4a121f99f7 build: convert lib/ to non-recursive build
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-31 23:03:27 +02:00
Quentin Young 073845da5e lib: add #pragma's to ignore flex sign cmp error
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-04-07 19:18:57 +00:00
David Lamparter 55b7f20fda lib: parser: fix allocation counting
command_lex.l was allocating as MTYPE_TMP, while command_parse.y would
just call free().  Make both use MTYPE_LEX.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-31 15:28:19 +01:00
David Lamparter 14152706b4 lib: parser: guard yylloc
yylloc seems to be NULL on parser init for some flex+bison
combinations...

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-24 02:52:07 +01:00
David Lamparter 8bb647a830 lib: parser: add error location reporting
flex+bison have nice capabilities to track the location that is
currently being processed; let's enable these and get better warnings
for broken CLI specs.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-23 21:52:44 +01:00
David Lamparter 61617d382e lib: parser: free Mr. T
Mr. T was abducted by the parser and held hostage for ransom.
Murdock was called, flew in and replaced him with a Tab character.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-01-23 21:49:57 +01:00
David Lamparter bca1a301ba lib: parser: accept number-only word tokens
There seems to be no reason why numbers don't work as plain word tokens;
this is useful to have "number choices" or constants, e.g. <128|192|256>
for bit encryption lengths.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-16 20:48:31 +01:00
David Lamparter afc3a6ceb6 lib: parser: reorder bison incarnations
This shuffles the code blocks in command_parser.y to match file output
order, then adjusts things to make the include handling less messy.

(also dropped unused DECIMAL_STRLEN_MAX define.)

This should hopefully fix the build on NetBSD 6.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-16 20:42:01 +01:00
David Lamparter e9484f70b2 lib: parser: use reentrant mode on flex & bison
This removes remaining global variables from the lexer, pushing the
lexer state into struct parser_ctx too.  At the same time, "cmd_yy" is
used as prefix for all parser & lexer routines.

The result is that (a) there is no collision anymore if a program uses
flex/bison and links libzebra, and (b) the parser is fully encapsulated
and could be called in parallel from multiple threads.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2016-12-01 18:45:27 +01:00
Quentin Young 8c9474817e Revert "lib: Allow '_' in arguments to VARIABLE_TKN"
This reverts commit e0a467872b.
2016-10-20 19:21:37 +00:00
Quentin Young e0a467872b lib: Allow '_' in arguments to VARIABLE_TKN
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-10-20 19:17:36 +00:00
Quentin Young 9286efabb9 lib: Allow nesting options in selectors
Options may now be nested in selectors as long
as they are not the first token in sequence.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-09-18 20:32:21 +00:00
Quentin Young fe3936ecf5 lib: Remove unnecessary XSTRDUP
yy_scan_string duplicates its input

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-09 21:02:11 +00:00
Quentin Young 4427e9b3ee lib: Fix various minor bugs
- cmd_make_strvec returns null pointer if str
  begins with a '#'
- disallow options nested options
- NULL out state variable in parser
- flip backwards comparison
- fix memory leak in lexer

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-09 17:37:01 +00:00
Quentin Young 1ab84bf32f lib: Code cleanup, formatting, & headers
Gnu-style code, add copyright headers, cleanup some
random style issues, shuffle around code into
relevant units, add docs.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-08 21:11:14 +00:00
Quentin Young 51fc9379a9 lib: Major parser refactor
Lots of cleanup, code consolidation, organizational
improvements.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-05 20:50:42 +00:00
Quentin Young b389976966 lib: Unrefactor to signed long long for ranges
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 18:16:26 +00:00
Quentin Young ef955a80a6 lib: Allow optional whitespace in ranges
Makes ranges where both endpoints are negative
somewhat more readable. Also validate ranges.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 16:39:15 +00:00
Quentin Young 5a8bbed0b1 lib: Add support for negative ranges
And convert range delimiters to signed int

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-04 16:18:31 +00:00
Quentin Young e648e61a74 lib: Fix OOB range parses, variable matches
Variables now allow strings beginning with numbers
to match, ranges and numbers are now long long to
fix OOB parses resulting in integer wraparounds.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-01 18:36:30 +00:00
Quentin Young 1a8c390d4a lib: Fixed bad node copy, modified token regex
When building argv for matched command, only the
last node was being copied to argv; the rest were
added by reference. Additionally the regex for
certain tokens was too restrictive and disallowed
characters allowed by the old parser; these have
been reinstated.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-01 17:03:39 +00:00
Quentin Young 6d53a10e4c lib: Add partial matching support
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-08-01 13:18:25 +00:00
Quentin Young de9d7e4f3c lib: Cleanup some memory issues in CLI
Various memory leaks have been fixed and the quagga
memory macros are in use. Also consolidated the argv
and matching code into one graph traversal.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-29 15:54:03 +00:00
Quentin Young 2a23ca6e52 lib: Change some includes
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2016-07-12 15:05:06 +00:00
Renamed from lib/command.lex (Browse further)