summaryrefslogtreecommitdiffstats
path: root/lanbrowsing/lisa/addressvalidator.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-22 00:30:31 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-22 00:30:31 +0000
commit69cac65817d949cda2672ec4f0aa73d5e66a0ba1 (patch)
tree073fde0496ea90eb5bf5cffe66a8da43a9f55fbc /lanbrowsing/lisa/addressvalidator.cpp
parent3467e6464beac3a162839bf7078e22e3a74d73e7 (diff)
downloadtdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.tar.gz
tdenetwork-69cac65817d949cda2672ec4f0aa73d5e66a0ba1.zip
TQt4 port kdenetwork
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1237912 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'lanbrowsing/lisa/addressvalidator.cpp')
-rw-r--r--lanbrowsing/lisa/addressvalidator.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/lanbrowsing/lisa/addressvalidator.cpp b/lanbrowsing/lisa/addressvalidator.cpp
index aa292806..f4dab083 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 mask 255.255.255.0
+//with tqmask 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 mask 255.255.255.0
+ //with tqmask 255.255.255.0
,localhostMask(htonl(0xffffff00))
{
clearSpecs();
@@ -74,20 +74,20 @@ void AddressValidator::setValidAddresses(MyString addressSpecs)
nextPart=addressSpecs.left(pos);
addressSpecs=addressSpecs.mid(pos+1);
dcerr<<"setValidAddresses: nextPart: "<<nextPart<<std::endl;
- if ((nextPart.contains('.')==3) && (nextPart.contains('-')==0))
+ if ((nextPart.tqcontains('.')==3) && (nextPart.tqcontains('-')==0))
{
addSpec(EXACTADDR_SPEC,inet_addr(nextPart.data()));
dcerr<<"setValidAddresses: exact addr: "
<<std::ios::hex<<inet_addr(nextPart.data())<<std::ios::dec<<std::endl;
}
- else if ((nextPart.contains('-')==1) && (nextPart.contains('.')==6))
+ else if ((nextPart.tqcontains('-')==1) && (nextPart.tqcontains('.')==6))
{
int p2=nextPart.find("-");
MyString from=nextPart.left(p2);
MyString to=nextPart.mid(p2+1);
addSpec(RANGE_SPEC,ntohl(inet_addr(from.data())),ntohl(inet_addr(to.data())));
}
- else if ((nextPart.contains('-')==4) && (nextPart.contains('.')==3))
+ else if ((nextPart.tqcontains('-')==4) && (nextPart.tqcontains('.')==3))
{
unsigned int i1=0;
unsigned int i2=0;
@@ -114,12 +114,12 @@ void AddressValidator::setValidAddresses(MyString addressSpecs)
{
pos=nextPart.find('/');
MyString netStr=nextPart.left(pos);
- MyString maskStr=nextPart.mid(pos+1);
- 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);
+ MyString tqmaskStr=nextPart.mid(pos+1);
+ int tqmask=inet_addr(tqmaskStr.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);
}
}
}
@@ -130,19 +130,19 @@ void AddressValidator::clearSpecs()
for (int i=0; i<MAX_SPECS; i++)
{
specs[i].address=0;
- specs[i].mask=0;
+ specs[i].tqmask=0;
specs[i].typeOfSpec=NO_SPEC;
}
}
-void AddressValidator::addSpec(int type, int address, int mask)
+void AddressValidator::addSpec(int type, int address, int tqmask)
{
for (int i=0; i<MAX_SPECS; i++)
{
if (specs[i].typeOfSpec==NO_SPEC)
{
specs[i].address=address;
- specs[i].mask=mask;
+ specs[i].tqmask=tqmask;
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<<" mask: "<<localhostMask<<" AND: "<<(addressNBO &
+ std::ios::hex<<localhostNet<<" tqmask: "<<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].mask)<<" "<<
+ std::ios::hex<<(addressNBO & specs[i].tqmask)<<" "<<
specs[i].address<<std::ios::dec<<std::endl;
- if ((addressNBO & specs[i].mask) == specs[i].address)
+ if ((addressNBO & specs[i].tqmask) == specs[i].address)
{
- dcerr<<"isValid: net/mask"<<std::endl;
+ dcerr<<"isValid: net/tqmask"<<std::endl;
return 1;
}
}
else if (specs[i].typeOfSpec==RANGE_SPEC)
{
- if ((ntohl(addressNBO)>=specs[i].address) && (ntohl(addressNBO)<=specs[i].mask))
+ if ((ntohl(addressNBO)>=specs[i].address) && (ntohl(addressNBO)<=specs[i].tqmask))
{
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].mask<<dec<<std::endl;
- unsigned int mask=0x000000ff;
+ dcerr<<"isValid ntohl="<<hex<<addr<<" addr: "<<specs[i].address<<" ma: "<<specs[i].tqmask<<dec<<std::endl;
+ unsigned int tqmask=0x000000ff;
int failure=0;
for (int j=0; j<4; j++)
{
- 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)))
+ 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)))
{
failure=1;
break;
}
- mask=mask<<8;
+ tqmask=tqmask<<8;
}
dcerr<<"isValid: multirange"<<std::endl;
if (!failure)