ok, second stage of asn32-safety (output as-path access-lists).

This commit is contained in:
snar
2008-05-16 15:36:40 +00:00
parent 49984acc34
commit 829ef80fb1
3 changed files with 31 additions and 18 deletions

View File

@@ -126,7 +126,7 @@ bgpq3_print_juniper_aspath(FILE* f, struct bgpq_expander* b)
int int
bgpq3_print_juniper_oaspath(FILE* f, struct bgpq_expander* b) bgpq3_print_juniper_oaspath(FILE* f, struct bgpq_expander* b)
{ {
int nc=0, lineNo=0, i, j; int nc=0, lineNo=0, i, j, k;
fprintf(f,"policy-options {\nreplace:\n as-path-group %s {\n", fprintf(f,"policy-options {\nreplace:\n as-path-group %s {\n",
b->name?b->name:"NN"); b->name?b->name:"NN");
@@ -135,15 +135,27 @@ bgpq3_print_juniper_oaspath(FILE* f, struct bgpq_expander* b)
b->asnumber); b->asnumber);
lineNo++; lineNo++;
}; };
for(k=0;k<65536;k++) {
if(!b->asn32s[k]) continue;
for(i=0;i<8192;i++) { for(i=0;i<8192;i++) {
for(j=0;j<8;j++) { for(j=0;j<8;j++) {
if(b->asn32s[0][i]&(0x80>>j)) { if(b->asn32s[k][i]&(0x80>>j)) {
if(i*8+j==b->asnumber) continue; if(i*8+j==b->asnumber) continue;
if(!nc) { if(!nc) {
fprintf(f," as-path a%i \"^(.)*(%i", if(!k) {
fprintf(f," as-path a%i \"^(.)*(%u",
lineNo,i*8+j); lineNo,i*8+j);
} else { } else {
fprintf(f,"|%i",i*8+j); fprintf(f," as-path a%i \"^(.)*(%u.%u",
lineNo,k,i*8+j);
};
} else {
if(!k) {
fprintf(f,"|%u",i*8+j);
} else {
fprintf(f,"|%u.%u",k,i*8+j);
};
} }
nc++; nc++;
if(nc==b->aswidth) { if(nc==b->aswidth) {
@@ -154,6 +166,7 @@ bgpq3_print_juniper_oaspath(FILE* f, struct bgpq_expander* b)
}; };
}; };
}; };
};
if(nc) fprintf(f,")$\";\n"); if(nc) fprintf(f,")$\";\n");
fprintf(f," }\n}\n"); fprintf(f," }\n}\n");
return 0; return 0;

View File

@@ -92,7 +92,7 @@ bgpq_expander_add_as(struct bgpq_expander* b, char* as)
if(!b->asn32s[asno]) { if(!b->asn32s[asno]) {
b->asn32s[asno]=malloc(8192); b->asn32s[asno]=malloc(8192);
if(!b->asn32s[asno]) { if(!b->asn32s[asno]) {
sx_report(SX_ERROR, "Unable to allocate 8192 bytes: %s." sx_report(SX_FATAL, "Unable to allocate 8192 bytes: %s."
" Unable to add asn32 %s to future expansion\n", " Unable to add asn32 %s to future expansion\n",
strerror(errno), as); strerror(errno), as);
return 0; return 0;

View File

@@ -15,7 +15,7 @@
static int reportStderr=1; static int reportStderr=1;
static char const* const static char const*
sx_report_name(sx_report_t t) sx_report_name(sx_report_t t)
{ {
switch(t) { switch(t) {