From 838adbb0eefc2fe591f8ac001458106723faa765 Mon Sep 17 00:00:00 2001 From: snar Date: Fri, 27 Mar 2009 13:57:18 +0000 Subject: [PATCH] ripe/radb asplain/asdot notation changes... --- bgpq3.c | 6 +++--- bgpq3.h | 3 ++- bgpq_expander.c | 10 ++++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bgpq3.c b/bgpq3.c index efc8ac7..509688b 100644 --- a/bgpq3.c +++ b/bgpq3.c @@ -65,7 +65,7 @@ parseasnumber(struct bgpq_expander* expander, char* optarg) { char* eon=NULL; expander->asnumber=strtoul(optarg,&eon,10); - if(expander->asnumber<0 || expander->asnumber>(65535ul*65535)) { + if(expander->asnumber<1 || expander->asnumber>(65535ul*65535)) { sx_report(SX_FATAL,"Invalid AS number: %s\n", optarg); exit(1); }; @@ -77,7 +77,7 @@ parseasnumber(struct bgpq_expander* expander, char* optarg) sx_report(SX_FATAL,"Invalid AS number: %s\n", optarg); exit(1); }; - if(loas<0 || loas>65536) { + if(loas<1 || loas>65535) { sx_report(SX_FATAL,"Invalid AS number: %s\n", optarg); exit(1); }; @@ -231,7 +231,7 @@ main(int argc, char* argv[]) sx_report(SX_FATAL,"asdot notation supported only for Cisco\n"); }; - if(!expander.asn32 && expander.asnumber>=65536) { + if(!expander.asn32 && expander.asnumber>65535) { expander.asnumber=23456; }; diff --git a/bgpq3.h b/bgpq3.h index f2ee0a4..26254e7 100644 --- a/bgpq3.h +++ b/bgpq3.h @@ -30,7 +30,8 @@ struct bgpq_expander { struct sx_slentry* rsets; int family; char* sources; - int asnumber, aswidth, asdot; + uint32_t asnumber; + int aswidth, asdot; char* name; bgpq_vendor_t vendor; bgpq_gen_t generation; diff --git a/bgpq_expander.c b/bgpq_expander.c index 641e885..d48b5e8 100644 --- a/bgpq_expander.c +++ b/bgpq_expander.c @@ -104,9 +104,15 @@ bgpq_expander_add_as(struct bgpq_expander* b, char* as) return 0; }; - if(*eoa=='.') { + if(*eoa=='.' || asno>65535) { if(b->asn32 || b->generation>=T_PREFIXLIST) { - uint32_t asn1=strtoul(eoa+1,&eoa,10); + uint32_t asn1; + if(asno>65535) { + asn1=asno%65536; + asno/=65536; + } else + asn1=strtoul(eoa+1,&eoa,10); + if(eoa && *eoa!=0) { sx_report(SX_ERROR,"Invalid symbol in AS number: '%c' in %s\n", *eoa, as);