mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-21 02:37:16 +01:00
Host::getManagementAddress returns const InetAddr* so we can distinguish between address 0.0.0.0 and no address
This commit is contained in:
parent
e723f14712
commit
3bd45d2c36
@ -122,15 +122,13 @@ Management *Host::getManagementObject()
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* takes address from management interface and copies it into
|
||||
* Management object. If there is no management interface or no
|
||||
* address to be found, returns "0.0.0.0". May throw exception if
|
||||
* interface has invalid address.
|
||||
/**
|
||||
* returns address from management interface. If there is no
|
||||
* management interface or no address to be found, returns NULL.
|
||||
* May throw exception if interface has invalid address.
|
||||
*/
|
||||
InetAddr Host::getManagementAddress() throw(FWException)
|
||||
const InetAddr* Host::getManagementAddress() throw(FWException)
|
||||
{
|
||||
Management *mgmt=getManagementObject();
|
||||
FWObjectTypedChildIterator j = findByType(Interface::TYPENAME);
|
||||
for( ; j!=j.end(); ++j)
|
||||
{
|
||||
@ -139,15 +137,11 @@ InetAddr Host::getManagementAddress() throw(FWException)
|
||||
{
|
||||
FWObjectTypedChildIterator k = iface->findByType(IPv4::TYPENAME);
|
||||
if (k != k.end())
|
||||
{
|
||||
InetAddrMask *addr = dynamic_cast<InetAddrMask*>(*k);
|
||||
assert(addr);
|
||||
mgmt->setAddress( *(addr->getAddressPtr()) );
|
||||
return *(addr->getAddressPtr());
|
||||
}
|
||||
return Address::cast(*k)->getAddressPtr();
|
||||
|
||||
}
|
||||
}
|
||||
return InetAddr();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const Address* Host::getAddressObject() const
|
||||
|
||||
@ -65,7 +65,7 @@ class Host : public Address
|
||||
void addInterface(Interface *i);
|
||||
void removeInterface(Interface *i);
|
||||
|
||||
InetAddr getManagementAddress() throw(FWException);
|
||||
const InetAddr* getManagementAddress() throw(FWException);
|
||||
|
||||
/**
|
||||
* This method returns reference to the object representing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user