mirror of
https://github.com/bgp/bgpq4.git
synced 2024-05-11 05:55:05 +00:00
IOS XR as-path-sets
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -1,4 +1,7 @@
|
||||
untagged yet (2015-09-23)
|
||||
untagged yet (2016-05-10)
|
||||
- feature: IOS XR mode now supports as-paths (ios-regexs). Thanks
|
||||
to Tassos Chatzithomaoglou for examples and proofreading.
|
||||
(additions from 2015-09-23)
|
||||
- bugfix: stoplist shall be able to catch AS numbers as promised.
|
||||
- bugfix: bgpq3 shall not hang at unknown escapes in -M..
|
||||
- gotcha: "ANY" object in recursive mode ignored: shut complaints on
|
||||
|
12
bgpq3.c
12
bgpq3.c
@@ -305,6 +305,8 @@ main(int argc, char* argv[])
|
||||
if(expander.generation==T_ASPATH) {
|
||||
if(expander.vendor==V_CISCO) {
|
||||
expander.aswidth=4;
|
||||
} else if(expander.vendor==V_CISCO_XR) {
|
||||
expander.aswidth=6;
|
||||
} else if(expander.vendor==V_JUNIPER) {
|
||||
expander.aswidth=8;
|
||||
} else if(expander.vendor==V_BIRD) {
|
||||
@@ -313,6 +315,8 @@ main(int argc, char* argv[])
|
||||
} else if(expander.generation==T_OASPATH) {
|
||||
if(expander.vendor==V_CISCO) {
|
||||
expander.aswidth=5;
|
||||
} else if(expander.vendor==V_CISCO_XR) {
|
||||
expander.aswidth=7;
|
||||
} else if(expander.vendor==V_JUNIPER) {
|
||||
expander.aswidth=8;
|
||||
};
|
||||
@@ -323,8 +327,10 @@ main(int argc, char* argv[])
|
||||
expander.generation=T_PREFIXLIST;
|
||||
};
|
||||
|
||||
if(expander.vendor==V_CISCO_XR && expander.generation!=T_PREFIXLIST) {
|
||||
sx_report(SX_FATAL, "Sorry, only prefix-sets supported for IOS XR\n");
|
||||
if(expander.vendor==V_CISCO_XR && expander.generation!=T_PREFIXLIST &&
|
||||
expander.generation!=T_ASPATH && expander.generation!=T_OASPATH) {
|
||||
sx_report(SX_FATAL, "Sorry, only prefix-sets and as-paths "
|
||||
"supported for IOS XR\n");
|
||||
};
|
||||
if(expander.vendor==V_BIRD && expander.generation!=T_PREFIXLIST &&
|
||||
expander.generation!=T_ASPATH) {
|
||||
@@ -536,4 +542,4 @@ main(int argc, char* argv[])
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -80,6 +80,45 @@ bgpq3_print_cisco_aspath(FILE* f, struct bgpq_expander* b)
|
||||
fprintf(f,"ip as-path access-list %s deny .*\n", b->name?b->name:"NN");
|
||||
return 0;
|
||||
};
|
||||
|
||||
int
|
||||
bgpq3_print_cisco_xr_aspath(FILE* f, struct bgpq_expander* b)
|
||||
{
|
||||
int nc=0, i, j, k, comma=0;
|
||||
fprintf(f, "as-path-set %s", b->name?b->name:"NN");
|
||||
if(b->asn32s[b->asnumber/65536] &&
|
||||
b->asn32s[b->asnumber/65536][(b->asnumber%65536)/8]&
|
||||
(0x80>>(b->asnumber%8))) {
|
||||
fprintf(f,"\n ios-regex '^%u(_%u)*$'", b->asnumber,b->asnumber);
|
||||
comma=1;
|
||||
};
|
||||
for(k=0;k<65536;k++) {
|
||||
if(!b->asn32s[k]) continue;
|
||||
|
||||
for(i=0;i<8192;i++) {
|
||||
for(j=0;j<8;j++) {
|
||||
if(b->asn32s[k][i]&(0x80>>j)) {
|
||||
if(k*65536+i*8+j==b->asnumber) continue;
|
||||
if(!nc) {
|
||||
fprintf(f,"%s\n ios-regex '^%u(_[0-9]+)*_(%u",
|
||||
comma?",":"", b->asnumber,k*65536+i*8+j);
|
||||
comma=1;
|
||||
} else {
|
||||
fprintf(f,"|%u",k*65536+i*8+j);
|
||||
}
|
||||
nc++;
|
||||
if(nc==b->aswidth) {
|
||||
fprintf(f,")$'");
|
||||
nc=0;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
if(nc) fprintf(f,")$'");
|
||||
fprintf(f,"\nend-set\n");
|
||||
return 0;
|
||||
};
|
||||
int
|
||||
bgpq3_print_cisco_oaspath(FILE* f, struct bgpq_expander* b)
|
||||
{
|
||||
@@ -138,6 +177,44 @@ bgpq3_print_cisco_oaspath(FILE* f, struct bgpq_expander* b)
|
||||
fprintf(f,"ip as-path access-list %s deny .*\n", b->name?b->name:"NN");
|
||||
return 0;
|
||||
};
|
||||
|
||||
int
|
||||
bgpq3_print_cisco_xr_oaspath(FILE* f, struct bgpq_expander* b)
|
||||
{
|
||||
int nc=0, i, j, k, comma=0;
|
||||
fprintf(f, "as-path-set %s", b->name?b->name:"NN");
|
||||
if(b->asn32s[b->asnumber/65536] &&
|
||||
b->asn32s[b->asnumber/65536][(b->asnumber%65536)/8]&
|
||||
(0x80>>(b->asnumber%8))) {
|
||||
fprintf(f,"\n ios-regex '^(_%u)*$'",b->asnumber);
|
||||
comma=1;
|
||||
};
|
||||
for(k=0;k<65536;k++) {
|
||||
if(!b->asn32s[k]) continue;
|
||||
for(i=0;i<8192;i++) {
|
||||
for(j=0;j<8;j++) {
|
||||
if(b->asn32s[k][i]&(0x80>>j)) {
|
||||
if(k*65536+i*8+j==b->asnumber) continue;
|
||||
if(!nc) {
|
||||
fprintf(f,"%s\n ios-regex '^(_[0-9]+)*_(%u",
|
||||
comma?",":"", k*65536+i*8+j);
|
||||
comma=1;
|
||||
} else {
|
||||
fprintf(f,"|%u",k*65536+i*8+j);
|
||||
}
|
||||
nc++;
|
||||
if(nc==b->aswidth) {
|
||||
fprintf(f,")$'");
|
||||
nc=0;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
if(nc) fprintf(f,")$'");
|
||||
fprintf(f,"\nend-set\n");
|
||||
return 0;
|
||||
};
|
||||
|
||||
int
|
||||
bgpq3_print_juniper_aspath(FILE* f, struct bgpq_expander* b)
|
||||
@@ -233,6 +310,8 @@ bgpq3_print_aspath(FILE* f, struct bgpq_expander* b)
|
||||
return bgpq3_print_juniper_aspath(f,b);
|
||||
} else if(b->vendor==V_CISCO) {
|
||||
return bgpq3_print_cisco_aspath(f,b);
|
||||
} else if(b->vendor==V_CISCO_XR) {
|
||||
return bgpq3_print_cisco_xr_aspath(f,b);
|
||||
} else if(b->vendor==V_JSON) {
|
||||
return bgpq3_print_json_aspath(f,b);
|
||||
} else if(b->vendor==V_BIRD) {
|
||||
@@ -250,6 +329,8 @@ bgpq3_print_oaspath(FILE* f, struct bgpq_expander* b)
|
||||
return bgpq3_print_juniper_oaspath(f,b);
|
||||
} else if(b->vendor==V_CISCO) {
|
||||
return bgpq3_print_cisco_oaspath(f,b);
|
||||
} else if(b->vendor==V_CISCO_XR) {
|
||||
return bgpq3_print_cisco_xr_oaspath(f,b);
|
||||
} else {
|
||||
sx_report(SX_FATAL,"Unknown vendor %i\n", b->vendor);
|
||||
};
|
||||
|
Reference in New Issue
Block a user