forked from Mirror/frr

Each BGP prefix may have an as-path list attached. A forged string is stored in the BGP attribute and shows the as-path list output. Before this commit, the as-path list output was expressed as a list of AS values in plain format. Now, if a given BGP instance uses a specific asnotation, then the output is changed: new output: router bgp 1.1 asnotation dot ! address-family ipv4 unicast network 10.200.0.0/24 route-map rmap network 10.201.0.0/24 route-map rmap redistribute connected route-map rmap exit-address-family exit ! route-map rmap permit 1 set as-path prepend 1.1 5433.55 264564564 exit ubuntu2004# do show bgp ipv4 BGP table version is 2, local router ID is 10.0.2.15, vrf id 0 Default local pref 100, local AS 1.1 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 4.4.4.4/32 0.0.0.0 0 32768 1.1 5433.55 4036.61268 ? *> 10.0.2.0/24 0.0.0.0 0 32768 1.1 5433.55 4036.61268 ? 10.200.0.0/24 0.0.0.0 0 32768 1.1 5433.55 4036.61268 i 10.201.0.0/24 0.0.0.0 0 32768 1.1 5433.55 4036.61268 i The changes include: - the aspath structure has a new field: asnotation type The ashash list will differentiate 2 aspaths using a different asnotation. - 3 new printf extensions display the as number in the wished format: pASP, pASD, pASE for plain, dot, or dot+ format (extended). Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
74 lines
2 KiB
C
74 lines
2 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);
|
|
/* 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"))
|
|
|
|
/* for test */
|
|
extern void asn_relax_as_zero(bool relax);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _FRR_ASN_H */
|