samanwita pal

Changing default value for DHCP int config params from 0 to -1

Change-Id: Iee35a79e6e86f15f814ae40f2c6241f4f0727719
......@@ -41,6 +41,8 @@ public class DhcpConfig extends Config<ApplicationId> {
public static final String START_IP = "startip";
public static final String END_IP = "endip";
public static final int DEFAULT = -1;
/**
* Returns the dhcp server ip.
*
......@@ -124,10 +126,10 @@ public class DhcpConfig extends Config<ApplicationId> {
/**
* Returns the Time To Live for the reply packets.
*
* @return ttl or null if not set
* @return ttl or -1 if not set
*/
public int ttl() {
return get(TTL, 0);
return get(TTL, DEFAULT);
}
/**
......@@ -143,10 +145,10 @@ public class DhcpConfig extends Config<ApplicationId> {
/**
* Returns the Lease Time offered by the DHCP Server.
*
* @return lease time or null if not set
* @return lease time or -1 if not set
*/
public int leaseTime() {
return get(LEASE_TIME, 0);
return get(LEASE_TIME, DEFAULT);
}
/**
......@@ -162,10 +164,10 @@ public class DhcpConfig extends Config<ApplicationId> {
/**
* Returns the Renew Time offered by the DHCP Server.
*
* @return renew time or null if not set
* @return renew time or -1 if not set
*/
public int renewTime() {
return get(RENEW_TIME, 0);
return get(RENEW_TIME, DEFAULT);
}
/**
......@@ -181,10 +183,10 @@ public class DhcpConfig extends Config<ApplicationId> {
/**
* Returns the Rebind Time offered by the DHCP Server.
*
* @return rebind time or null if not set
* @return rebind time or -1 if not set
*/
public int rebindTime() {
return get(REBIND_TIME, 0);
return get(REBIND_TIME, DEFAULT);
}
/**
......@@ -238,12 +240,12 @@ public class DhcpConfig extends Config<ApplicationId> {
}
/**
* Returns the delay after which the dhcp server will purge expired entries.
* Returns the delay in minutes after which the dhcp server will purge expired entries.
*
* @return time delay or null if not set
* @return time delay or -1 if not set
*/
public int timerDelay() {
return get(TIMER_DELAY, 0);
return get(TIMER_DELAY, DEFAULT);
}
/**
......@@ -259,10 +261,10 @@ public class DhcpConfig extends Config<ApplicationId> {
/**
* Returns the default timeout for pending assignments.
*
* @return default timeout or null if not set
* @return default timeout or -1 if not set
*/
public int defaultTimeout() {
return get(DEFAULT_TIMEOUT, 0);
return get(DEFAULT_TIMEOUT, DEFAULT);
}
/**
......
......@@ -74,6 +74,7 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
......@@ -559,7 +560,7 @@ public class DhcpManager implements DhcpService {
ARP arpPacket = (ARP) packet.getPayload();
if ((arpPacket.getOpCode() == ARP.OP_REQUEST) &&
(myIP).equals(Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) {
Objects.equals(myIP, Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) {
processARPPacket(context, packet);
......@@ -597,22 +598,22 @@ public class DhcpManager implements DhcpService {
if (cfg.domainServer() != null) {
domainServer = cfg.domainServer();
}
if (cfg.ttl() != 0) {
if (cfg.ttl() != -1) {
packetTTL = (byte) cfg.ttl();
}
if (cfg.leaseTime() != 0) {
if (cfg.leaseTime() != -1) {
leaseTime = cfg.leaseTime();
}
if (cfg.renewTime() != 0) {
if (cfg.renewTime() != -1) {
renewalTime = cfg.renewTime();
}
if (cfg.rebindTime() != 0) {
if (cfg.rebindTime() != -1) {
rebindingTime = cfg.rebindTime();
}
if (cfg.defaultTimeout() != 0) {
if (cfg.defaultTimeout() != -1) {
dhcpStore.setDefaultTimeoutForPurge(cfg.defaultTimeout());
}
if (cfg.timerDelay() != 0) {
if (cfg.timerDelay() != -1) {
timerDelay = cfg.timerDelay();
}
if ((cfg.startIp() != null) && (cfg.endIp() != null)) {
......