Add AS-List Feature for JunOS (#57)

Co-authored-by: Fiona Weber <fiona.weber@wobcom.de>
This commit is contained in:
Fiona Weber
2022-07-07 09:07:24 +02:00
committed by GitHub
parent 96079b8901
commit c2126343cf
4 changed files with 86 additions and 7 deletions

View File

@@ -274,6 +274,45 @@ bgpq4_print_juniper_oaspath(FILE *f, struct bgpq_expander *b)
fprintf(f, " }\n}\n");
}
static void
bgpq4_print_juniper_aslist(FILE *f, struct bgpq_expander *b)
{
int nc = 0, lineNo = 0;
struct asn_entry *asne, find, *res;
fprintf(f,"policy-options {\nreplace:\n as-list-group %s {\n",
b->name);
find.asn = b->asnumber;
if ((res = RB_FIND(asn_tree, &b->asnlist, &find)) != NULL) {
fprintf(f, " as-list a0 members %u;\n", res->asn);
RB_REMOVE(asn_tree, &b->asnlist, res);
lineNo++;
}
RB_FOREACH(asne, asn_tree, &b->asnlist) {
if (!nc) {
fprintf(f, " as-list a%u members [ %u",
lineNo, asne->asn);
} else {
fprintf(f," %u", asne->asn);
}
nc++;
if (nc == b->aswidth) {
fprintf(f, " ];\n");
nc = 0;
lineNo++;
}
}
if (nc)
fprintf(f, " ];\n");
fprintf(f, " }\n}\n");
}
static void
bgpq4_print_openbgpd_oaspath(FILE *f, struct bgpq_expander *b)
{
@@ -878,6 +917,18 @@ bgpq4_print_oaspath(FILE *f, struct bgpq_expander *b)
}
}
void
bgpq4_print_aslist(FILE *f, struct bgpq_expander *b)
{
switch (b->vendor) {
case V_JUNIPER:
bgpq4_print_juniper_aslist(f, b);
break;
default:
sx_report(SX_FATAL,"Unknown vendor %i\n", b->vendor);
}
}
void
bgpq4_print_asset(FILE *f, struct bgpq_expander *b)
{