diff options
Diffstat (limited to 'lanbrowsing/lisa/addressvalidator.cpp')
-rw-r--r-- | lanbrowsing/lisa/addressvalidator.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lanbrowsing/lisa/addressvalidator.cpp b/lanbrowsing/lisa/addressvalidator.cpp index 70207ece..aa292806 100644 --- a/lanbrowsing/lisa/addressvalidator.cpp +++ b/lanbrowsing/lisa/addressvalidator.cpp @@ -33,7 +33,7 @@ using namespace std; AddressValidator::AddressValidator(const MyString& addressSpecs) //this is 127.0.0.0 :localhostNet(htonl(0x7f000000)) -//with tqmask 255.255.255.0 +//with mask 255.255.255.0 ,localhostMask(htonl(0xffffff00)) { clearSpecs(); @@ -44,7 +44,7 @@ AddressValidator::AddressValidator(const MyString& addressSpecs) AddressValidator::AddressValidator() //this is 127.0.0.0 :localhostNet(htonl(0x7f000000)) - //with tqmask 255.255.255.0 + //with mask 255.255.255.0 ,localhostMask(htonl(0xffffff00)) { clearSpecs(); @@ -115,11 +115,11 @@ void AddressValidator::setValidAddresses(MyString addressSpecs) pos=nextPart.find('/'); MyString netStr=nextPart.left(pos); MyString maskStr=nextPart.mid(pos+1); - int tqmask=inet_addr(maskStr.data()); - int net= (inet_addr(netStr.data()) & tqmask); - dcerr<<"setValidAddresses: net/tqmask: " - <<std::ios::hex<<net<<"/"<<tqmask<<std::ios::dec<<std::endl; - addSpec(NETMASK_SPEC,net,tqmask); + int mask=inet_addr(maskStr.data()); + int net= (inet_addr(netStr.data()) & mask); + dcerr<<"setValidAddresses: net/mask: " + <<std::ios::hex<<net<<"/"<<mask<<std::ios::dec<<std::endl; + addSpec(NETMASK_SPEC,net,mask); } } } @@ -130,19 +130,19 @@ void AddressValidator::clearSpecs() for (int i=0; i<MAX_SPECS; i++) { specs[i].address=0; - specs[i].tqmask=0; + specs[i].mask=0; specs[i].typeOfSpec=NO_SPEC; } } -void AddressValidator::addSpec(int type, int address, int tqmask) +void AddressValidator::addSpec(int type, int address, int mask) { for (int i=0; i<MAX_SPECS; i++) { if (specs[i].typeOfSpec==NO_SPEC) { specs[i].address=address; - specs[i].tqmask=tqmask; + specs[i].mask=mask; specs[i].typeOfSpec=type; return; } @@ -155,7 +155,7 @@ int AddressValidator::isValid(int addressNBO) <<std::ios::hex<<addressNBO<<std::ios::dec<<std::endl; //localhost is always allowed dcerr<<"isValid() local net: "<< - std::ios::hex<<localhostNet<<" tqmask: "<<localhostMask<<" AND: "<<(addressNBO & + std::ios::hex<<localhostNet<<" mask: "<<localhostMask<<" AND: "<<(addressNBO & localhostMask)<<std::ios::dec<<std::endl; if ((addressNBO & localhostMask) == localhostNet) return 1; @@ -183,17 +183,17 @@ int AddressValidator::isValid(int addressNBO) else if (specs[i].typeOfSpec==NETMASK_SPEC) { dcerr<<"isValid: ANDing "<< - std::ios::hex<<(addressNBO & specs[i].tqmask)<<" "<< + std::ios::hex<<(addressNBO & specs[i].mask)<<" "<< specs[i].address<<std::ios::dec<<std::endl; - if ((addressNBO & specs[i].tqmask) == specs[i].address) + if ((addressNBO & specs[i].mask) == specs[i].address) { - dcerr<<"isValid: net/tqmask"<<std::endl; + dcerr<<"isValid: net/mask"<<std::endl; return 1; } } else if (specs[i].typeOfSpec==RANGE_SPEC) { - if ((ntohl(addressNBO)>=specs[i].address) && (ntohl(addressNBO)<=specs[i].tqmask)) + if ((ntohl(addressNBO)>=specs[i].address) && (ntohl(addressNBO)<=specs[i].mask)) { dcerr<<"isValid: range"<<std::endl; return 1; @@ -202,19 +202,19 @@ int AddressValidator::isValid(int addressNBO) else if (specs[i].typeOfSpec==MULTIRANGE_SPEC) { unsigned int addr=ntohl(addressNBO); - dcerr<<"isValid ntohl="<<hex<<addr<<" addr: "<<specs[i].address<<" ma: "<<specs[i].tqmask<<dec<<std::endl; - unsigned int tqmask=0x000000ff; + dcerr<<"isValid ntohl="<<hex<<addr<<" addr: "<<specs[i].address<<" ma: "<<specs[i].mask<<dec<<std::endl; + unsigned int mask=0x000000ff; int failure=0; for (int j=0; j<4; j++) { - dcerr<<"isValid "<<hex<<"tqmask="<<tqmask<<" addr="<<(addr&tqmask)<<" addr="<<(specs[i].address & tqmask)<<" ma="<<(specs[i].tqmask&tqmask)<<std::endl; - if (((addr & tqmask) < (specs[i].address & tqmask)) - || ((addr & tqmask) > (specs[i].tqmask & tqmask))) + dcerr<<"isValid "<<hex<<"mask="<<mask<<" addr="<<(addr&mask)<<" addr="<<(specs[i].address & mask)<<" ma="<<(specs[i].mask&mask)<<std::endl; + if (((addr & mask) < (specs[i].address & mask)) + || ((addr & mask) > (specs[i].mask & mask))) { failure=1; break; } - tqmask=tqmask<<8; + mask=mask<<8; } dcerr<<"isValid: multirange"<<std::endl; if (!failure) |