Changing default value for DHCP int config params from 0 to -1
Change-Id: Iee35a79e6e86f15f814ae40f2c6241f4f0727719
Showing
2 changed files
with
23 additions
and
20 deletions
| ... | @@ -41,6 +41,8 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -41,6 +41,8 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 41 | public static final String START_IP = "startip"; | 41 | public static final String START_IP = "startip"; |
| 42 | public static final String END_IP = "endip"; | 42 | public static final String END_IP = "endip"; |
| 43 | 43 | ||
| 44 | + public static final int DEFAULT = -1; | ||
| 45 | + | ||
| 44 | /** | 46 | /** |
| 45 | * Returns the dhcp server ip. | 47 | * Returns the dhcp server ip. |
| 46 | * | 48 | * |
| ... | @@ -124,10 +126,10 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -124,10 +126,10 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 124 | /** | 126 | /** |
| 125 | * Returns the Time To Live for the reply packets. | 127 | * Returns the Time To Live for the reply packets. |
| 126 | * | 128 | * |
| 127 | - * @return ttl or null if not set | 129 | + * @return ttl or -1 if not set |
| 128 | */ | 130 | */ |
| 129 | public int ttl() { | 131 | public int ttl() { |
| 130 | - return get(TTL, 0); | 132 | + return get(TTL, DEFAULT); |
| 131 | } | 133 | } |
| 132 | 134 | ||
| 133 | /** | 135 | /** |
| ... | @@ -143,10 +145,10 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -143,10 +145,10 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 143 | /** | 145 | /** |
| 144 | * Returns the Lease Time offered by the DHCP Server. | 146 | * Returns the Lease Time offered by the DHCP Server. |
| 145 | * | 147 | * |
| 146 | - * @return lease time or null if not set | 148 | + * @return lease time or -1 if not set |
| 147 | */ | 149 | */ |
| 148 | public int leaseTime() { | 150 | public int leaseTime() { |
| 149 | - return get(LEASE_TIME, 0); | 151 | + return get(LEASE_TIME, DEFAULT); |
| 150 | } | 152 | } |
| 151 | 153 | ||
| 152 | /** | 154 | /** |
| ... | @@ -162,10 +164,10 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -162,10 +164,10 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 162 | /** | 164 | /** |
| 163 | * Returns the Renew Time offered by the DHCP Server. | 165 | * Returns the Renew Time offered by the DHCP Server. |
| 164 | * | 166 | * |
| 165 | - * @return renew time or null if not set | 167 | + * @return renew time or -1 if not set |
| 166 | */ | 168 | */ |
| 167 | public int renewTime() { | 169 | public int renewTime() { |
| 168 | - return get(RENEW_TIME, 0); | 170 | + return get(RENEW_TIME, DEFAULT); |
| 169 | } | 171 | } |
| 170 | 172 | ||
| 171 | /** | 173 | /** |
| ... | @@ -181,10 +183,10 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -181,10 +183,10 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 181 | /** | 183 | /** |
| 182 | * Returns the Rebind Time offered by the DHCP Server. | 184 | * Returns the Rebind Time offered by the DHCP Server. |
| 183 | * | 185 | * |
| 184 | - * @return rebind time or null if not set | 186 | + * @return rebind time or -1 if not set |
| 185 | */ | 187 | */ |
| 186 | public int rebindTime() { | 188 | public int rebindTime() { |
| 187 | - return get(REBIND_TIME, 0); | 189 | + return get(REBIND_TIME, DEFAULT); |
| 188 | } | 190 | } |
| 189 | 191 | ||
| 190 | /** | 192 | /** |
| ... | @@ -238,12 +240,12 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -238,12 +240,12 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 238 | } | 240 | } |
| 239 | 241 | ||
| 240 | /** | 242 | /** |
| 241 | - * Returns the delay after which the dhcp server will purge expired entries. | 243 | + * Returns the delay in minutes after which the dhcp server will purge expired entries. |
| 242 | * | 244 | * |
| 243 | - * @return time delay or null if not set | 245 | + * @return time delay or -1 if not set |
| 244 | */ | 246 | */ |
| 245 | public int timerDelay() { | 247 | public int timerDelay() { |
| 246 | - return get(TIMER_DELAY, 0); | 248 | + return get(TIMER_DELAY, DEFAULT); |
| 247 | } | 249 | } |
| 248 | 250 | ||
| 249 | /** | 251 | /** |
| ... | @@ -259,10 +261,10 @@ public class DhcpConfig extends Config<ApplicationId> { | ... | @@ -259,10 +261,10 @@ public class DhcpConfig extends Config<ApplicationId> { |
| 259 | /** | 261 | /** |
| 260 | * Returns the default timeout for pending assignments. | 262 | * Returns the default timeout for pending assignments. |
| 261 | * | 263 | * |
| 262 | - * @return default timeout or null if not set | 264 | + * @return default timeout or -1 if not set |
| 263 | */ | 265 | */ |
| 264 | public int defaultTimeout() { | 266 | public int defaultTimeout() { |
| 265 | - return get(DEFAULT_TIMEOUT, 0); | 267 | + return get(DEFAULT_TIMEOUT, DEFAULT); |
| 266 | } | 268 | } |
| 267 | 269 | ||
| 268 | /** | 270 | /** | ... | ... |
| ... | @@ -74,6 +74,7 @@ import java.util.Date; | ... | @@ -74,6 +74,7 @@ import java.util.Date; |
| 74 | import java.util.HashSet; | 74 | import java.util.HashSet; |
| 75 | import java.util.List; | 75 | import java.util.List; |
| 76 | import java.util.Map; | 76 | import java.util.Map; |
| 77 | +import java.util.Objects; | ||
| 77 | import java.util.Set; | 78 | import java.util.Set; |
| 78 | import java.util.concurrent.TimeUnit; | 79 | import java.util.concurrent.TimeUnit; |
| 79 | 80 | ||
| ... | @@ -559,7 +560,7 @@ public class DhcpManager implements DhcpService { | ... | @@ -559,7 +560,7 @@ public class DhcpManager implements DhcpService { |
| 559 | ARP arpPacket = (ARP) packet.getPayload(); | 560 | ARP arpPacket = (ARP) packet.getPayload(); |
| 560 | 561 | ||
| 561 | if ((arpPacket.getOpCode() == ARP.OP_REQUEST) && | 562 | if ((arpPacket.getOpCode() == ARP.OP_REQUEST) && |
| 562 | - (myIP).equals(Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) { | 563 | + Objects.equals(myIP, Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) { |
| 563 | 564 | ||
| 564 | processARPPacket(context, packet); | 565 | processARPPacket(context, packet); |
| 565 | 566 | ||
| ... | @@ -597,22 +598,22 @@ public class DhcpManager implements DhcpService { | ... | @@ -597,22 +598,22 @@ public class DhcpManager implements DhcpService { |
| 597 | if (cfg.domainServer() != null) { | 598 | if (cfg.domainServer() != null) { |
| 598 | domainServer = cfg.domainServer(); | 599 | domainServer = cfg.domainServer(); |
| 599 | } | 600 | } |
| 600 | - if (cfg.ttl() != 0) { | 601 | + if (cfg.ttl() != -1) { |
| 601 | packetTTL = (byte) cfg.ttl(); | 602 | packetTTL = (byte) cfg.ttl(); |
| 602 | } | 603 | } |
| 603 | - if (cfg.leaseTime() != 0) { | 604 | + if (cfg.leaseTime() != -1) { |
| 604 | leaseTime = cfg.leaseTime(); | 605 | leaseTime = cfg.leaseTime(); |
| 605 | } | 606 | } |
| 606 | - if (cfg.renewTime() != 0) { | 607 | + if (cfg.renewTime() != -1) { |
| 607 | renewalTime = cfg.renewTime(); | 608 | renewalTime = cfg.renewTime(); |
| 608 | } | 609 | } |
| 609 | - if (cfg.rebindTime() != 0) { | 610 | + if (cfg.rebindTime() != -1) { |
| 610 | rebindingTime = cfg.rebindTime(); | 611 | rebindingTime = cfg.rebindTime(); |
| 611 | } | 612 | } |
| 612 | - if (cfg.defaultTimeout() != 0) { | 613 | + if (cfg.defaultTimeout() != -1) { |
| 613 | dhcpStore.setDefaultTimeoutForPurge(cfg.defaultTimeout()); | 614 | dhcpStore.setDefaultTimeoutForPurge(cfg.defaultTimeout()); |
| 614 | } | 615 | } |
| 615 | - if (cfg.timerDelay() != 0) { | 616 | + if (cfg.timerDelay() != -1) { |
| 616 | timerDelay = cfg.timerDelay(); | 617 | timerDelay = cfg.timerDelay(); |
| 617 | } | 618 | } |
| 618 | if ((cfg.startIp() != null) && (cfg.endIp() != null)) { | 619 | if ((cfg.startIp() != null) && (cfg.endIp() != null)) { | ... | ... |
-
Please register or login to post a comment