mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-28 19:35:13 +00:00

RD may be built based on an AS number. Like for the AS, the RD may use the AS notation. The two below examples can illustrate: RD 1.1:20 stands for an AS4B:NN RD with AS4B=65536 in dot format. RD 0.1:20 stands for an AS2B:NNNN RD with AS2B=0.1 in dot+ format. This commit adds the asnotation mode to prefix_rd2str() API so as to pick up the relevant display. Two new printfrr extensions are available to display the RD with the two above display methods. - The pRDD extension stands for dot asnotation format - The pRDE extension stands for dot+ asnotation format. - The pRD extension has been renamed to pRDP extension The code is changed each time '%pRD' printf extension is called. Possibly, the asnotation may change the output, then a macro defines the asnotation mode to use. A side effect of forging the mode to use is that the string could not be concatenated with other strings in vty_out and snprintfrr. Those functions have been called multiple times. When zlog_debug needs to display the RD with some other string, the prefix_rd2str() old API is used instead of the printf extension. Some code has been kept untouched: - code related to running-config. Actually, wherever an RD is displayed, its configured name should be dumped. - bgp rfapi code - bgp evpn multihoming code (partially done), since the logic is missing to get the asnotation of 'struct bgp_evpn_es'. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
82 lines
2.4 KiB
C
82 lines
2.4 KiB
C
/*
|
|
* AS number structure
|
|
* Copyright 2022 6WIND
|
|
*
|
|
* This file is part of GNU Zebra.
|
|
*
|
|
* GNU Zebra is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published
|
|
* by the Free Software Foundation; either version 2, or (at your
|
|
* option) any later version.
|
|
*
|
|
* GNU Zebra is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along
|
|
* with this program; see the file COPYING; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _FRR_ASN_H
|
|
#define _FRR_ASN_H
|
|
|
|
#include "zebra.h"
|
|
#include "command_match.h"
|
|
#include "json.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define ASN_STRING_MAX_SIZE 12
|
|
|
|
enum asnotation_mode {
|
|
ASNOTATION_PLAIN = 0,
|
|
ASNOTATION_DOT,
|
|
ASNOTATION_DOTPLUS,
|
|
ASNOTATION_UNDEFINED,
|
|
};
|
|
|
|
typedef uint32_t as_t;
|
|
|
|
extern bool asn_str2asn(const char *asstring, as_t *asn);
|
|
extern const char *asn_asn2asplain(as_t asn);
|
|
extern const char *asn_str2asn_parse(const char *asstring, as_t *asn,
|
|
bool *found_ptr);
|
|
extern enum match_type asn_str2asn_match(const char *str);
|
|
extern bool asn_str2asn_notation(const char *asstring, as_t *asn,
|
|
enum asnotation_mode *asnotation);
|
|
extern const char *asn_mode2str(enum asnotation_mode asnotation);
|
|
void asn_asn2json_array(json_object *jseg_list, as_t asn,
|
|
enum asnotation_mode asnotation);
|
|
void asn_asn2json(json_object *jseg_list, const char *attr,
|
|
as_t asn, enum asnotation_mode asnotation);
|
|
extern char *asn_asn2string(const as_t *as, char *buf, size_t len,
|
|
enum asnotation_mode asnotation);
|
|
/* display AS in appropriate format */
|
|
#ifdef _FRR_ATTRIBUTE_PRINTFRR
|
|
#pragma FRR printfrr_ext "%pASP" (as_t *)
|
|
#pragma FRR printfrr_ext "%pASD" (as_t *)
|
|
#pragma FRR printfrr_ext "%pASE" (as_t *)
|
|
#endif
|
|
|
|
#define ASN_FORMAT(mode) \
|
|
((mode == ASNOTATION_DOT) ? "%pASD" : \
|
|
((mode == ASNOTATION_DOTPLUS) ? "%pASE" : \
|
|
"%pASP"))
|
|
#define ASN_FORMAT_SPACE(mode) \
|
|
((mode == ASNOTATION_DOT) ? "%10pASD" : \
|
|
((mode == ASNOTATION_DOTPLUS) ? "%10pASE" : \
|
|
"%10pASP"))
|
|
|
|
/* for test */
|
|
extern void asn_relax_as_zero(bool relax);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _FRR_ASN_H */
|