// Instead we will need to use the address assigned to the interface
// on which the query has been received. In other cases, we will just
// use this address as a source address for the response.
- if (local_addr == IOAddress::IPV4_BCAST_ADDRESS()) {
+ if (local_addr.isV4Bcast()) {
SocketInfo sock_info = IfaceMgr::instance().getSocket(*query);
local_addr = sock_info.addr_;
}
if (query->getType() == DHCPINFORM) {
// If client adheres to RFC2131 it will set the ciaddr and in this
// case we always unicast our response to this address.
- if (query->getCiaddr() != IOAddress::IPV4_ZERO_ADDRESS()) {
+ if (!query->getCiaddr().isV4Zero()) {
response->setRemoteAddr(query->getCiaddr());
// If we received DHCPINFORM via relay and the ciaddr is not set we
// the message is relayed. Therefore, we set the BROADCAST flag so
// as the relay can broadcast the packet.
if ((query->getType() == DHCPINFORM) &&
- (query->getCiaddr() == IOAddress::IPV4_ZERO_ADDRESS())) {
+ query->getCiaddr().isV4Zero()) {
response->setFlags(BOOTP_BROADCAST);
}
response->setRemoteAddr(query->getGiaddr());
// If giaddr is 0 but client set ciaddr, server should unicast the
// response to ciaddr.
- } else if (query->getCiaddr() != IOAddress::IPV4_ZERO_ADDRESS()) {
+ } else if (!query->getCiaddr().isV4Zero()) {
response->setRemoteAddr(query->getCiaddr());
// We can't unicast the response to the client when sending NAK,
response->setRemoteAddr(IOAddress::IPV4_BCAST_ADDRESS());
// If yiaddr is set it means that we have created a lease for a client.
- } else if (response->getYiaddr() != IOAddress::IPV4_ZERO_ADDRESS()) {
+ } else if (!response->getYiaddr().isV4Zero()) {
// If the broadcast bit is set in the flags field, we have to
// send the response to broadcast address. Client may have requested it
// because it doesn't support reception of messages on the interface
// to respond if the ciaddr was not present.
try {
if (pkt->getType() == DHCPINFORM) {
- if ((pkt->getRemoteAddr() == IOAddress::IPV4_ZERO_ADDRESS()) &&
- (pkt->getCiaddr() == IOAddress::IPV4_ZERO_ADDRESS())) {
+ if (pkt->getRemoteAddr().isV4Zero() &&
+ pkt->getCiaddr().isV4Zero()) {
return (false);
}
}
// we validate the message type prior to calling this function.
return (false);
}
- return ((pkt->getLocalAddr() != IOAddress::IPV4_BCAST_ADDRESS()
- || selectSubnet(pkt)));
+ return (!pkt->getLocalAddr().isV4Bcast() || selectSubnet(pkt));
}
bool
void
Dhcp4Client::doRelease() {
- if (config_.lease_.addr_ == IOAddress::IPV4_ZERO_ADDRESS()) {
+ if (config_.lease_.addr_.isV4Zero()) {
isc_throw(Dhcp4ClientError, "failed to send the release"
" message because client doesn't have a lease");
}
void
Dhcp4Client::doDecline() {
- if (config_.lease_.addr_ == IOAddress::IPV4_ZERO_ADDRESS()) {
+ if (config_.lease_.addr_.isV4Zero()) {
isc_throw(Dhcp4ClientError, "failed to send the decline"
" message because client doesn't have a lease");
}
using namespace isc::asiolink;
-namespace {
-
-/// @brief Holds IPv4 address set to "0.0.0.0".
-const IOAddress ZERO_ADDRESS("0.0.0.0");
-
-/// @brief Holds IPv4 broadcast address.
-const IOAddress BCAST_ADDRESS("255.255.255.255");
-
-} // end of anonymous namespace
-
namespace isc {
namespace dhcp {
// address will not match with any of the relay addresses accross all
// subnets, but we need to verify that for all subnets before we can try
// to use the giaddr to match with the subnet prefix.
- if (selector.giaddr_ != ZERO_ADDRESS) {
+ if (!selector.giaddr_.isV4Zero()) {
for (Subnet4Collection::const_iterator subnet = subnets_.begin();
subnet != subnets_.end(); ++subnet) {
// what address from the client's packet to use to match with the
// subnets' prefixes.
- IOAddress address = ZERO_ADDRESS;
+ IOAddress address = IOAddress::IPV6_ZERO_ADDRESS();
// If there is a giaddr, use it for subnet selection.
- if (selector.giaddr_ != ZERO_ADDRESS) {
+ if (!selector.giaddr_.isV4Zero()) {
address = selector.giaddr_;
// If it is a Renew or Rebind, use the ciaddr.
- } else if ((selector.ciaddr_ != ZERO_ADDRESS) &&
- (selector.local_address_ != BCAST_ADDRESS)) {
+ } else if (!selector.ciaddr_.isV4Zero() &&
+ !selector.local_address_.isV4Bcast()) {
address = selector.ciaddr_;
// If ciaddr is not specified, use the source address.
- } else if ((selector.remote_address_ != ZERO_ADDRESS) &&
- (selector.local_address_ != BCAST_ADDRESS)) {
+ } else if (!selector.remote_address_.isV4Zero() &&
+ !selector.local_address_.isV4Bcast()) {
address = selector.remote_address_;
// If local interface name is known, use the local address on this
}
// Unable to find a suitable address to use for subnet selection.
- if (address == ZERO_ADDRESS) {
+ if (address.isV4Zero()) {
return (Subnet4Ptr());
}