diff --git a/bgpq3_printer.c b/bgpq3_printer.c index 930200a..34a63b5 100644 --- a/bgpq3_printer.c +++ b/bgpq3_printer.c @@ -126,7 +126,7 @@ bgpq3_print_juniper_aspath(FILE* f, struct bgpq_expander* b) int 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", b->name?b->name:"NN"); @@ -135,21 +135,34 @@ bgpq3_print_juniper_oaspath(FILE* f, struct bgpq_expander* b) b->asnumber); lineNo++; }; - for(i=0;i<8192;i++) { - for(j=0;j<8;j++) { - if(b->asn32s[0][i]&(0x80>>j)) { - if(i*8+j==b->asnumber) continue; - if(!nc) { - fprintf(f," as-path a%i \"^(.)*(%i", - lineNo,i*8+j); - } else { - fprintf(f,"|%i",i*8+j); - } - nc++; - if(nc==b->aswidth) { - fprintf(f,")$\";\n"); - nc=0; - lineNo++; + 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(i*8+j==b->asnumber) continue; + if(!nc) { + if(!k) { + fprintf(f," as-path a%i \"^(.)*(%u", + lineNo,i*8+j); + } else { + 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++; + if(nc==b->aswidth) { + fprintf(f,")$\";\n"); + nc=0; + lineNo++; + }; }; }; }; diff --git a/bgpq_expander.c b/bgpq_expander.c index e98c1e7..a842576 100644 --- a/bgpq_expander.c +++ b/bgpq_expander.c @@ -92,7 +92,7 @@ bgpq_expander_add_as(struct bgpq_expander* b, char* as) if(!b->asn32s[asno]) { b->asn32s[asno]=malloc(8192); 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", strerror(errno), as); return 0; diff --git a/sx_report.c b/sx_report.c index 7a32438..e607fd7 100644 --- a/sx_report.c +++ b/sx_report.c @@ -15,7 +15,7 @@ static int reportStderr=1; -static char const* const +static char const* sx_report_name(sx_report_t t) { switch(t) {