gaurav
Committed by Gerrit Code Review

using subnet as lease/range selection criteria in DHCP Relay App, addressed review comments

Change-Id: Id2a81faa00592df4ede33f6679c2ba2dd8fb2293
COMPILE_DEPS = [
'//lib:CORE_DEPS',
'//incubator/api:onos-incubator-api',
]
osgi_jar (
......
......@@ -49,6 +49,11 @@
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-osgi</artifactId>
<version>${project.version}</version>
</dependency>
......
......@@ -20,18 +20,25 @@ import org.onosproject.net.ConnectPoint;
import org.onosproject.net.config.Config;
import static org.onosproject.net.config.Config.FieldPresence.MANDATORY;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
/**
* DHCP Relay Config class.
*/
public class DhcpRelayConfig extends Config<ApplicationId> {
private static final String DHCP_CONNECT_POINT = "dhcpserverConnectPoint";
private static final String DHCP_SERVER_IP = "serverip";
private static final String DHCP_SERVER_MAC = "servermac";
@Override
public boolean isValid() {
return hasOnlyFields(DHCP_CONNECT_POINT) &&
isConnectPoint(DHCP_CONNECT_POINT, MANDATORY);
return hasOnlyFields(DHCP_CONNECT_POINT, DHCP_SERVER_IP, DHCP_SERVER_MAC) &&
isConnectPoint(DHCP_CONNECT_POINT, MANDATORY) &&
isIpAddress(DHCP_SERVER_IP, MANDATORY) &&
isMacAddress(DHCP_SERVER_MAC, MANDATORY);
}
/**
......@@ -42,4 +49,24 @@ public class DhcpRelayConfig extends Config<ApplicationId> {
public ConnectPoint getDhcpServerConnectPoint() {
return ConnectPoint.deviceConnectPoint(object.path(DHCP_CONNECT_POINT).asText());
}
/**
* Returns the dhcp server ip.
*
* @return ip address or null if not set
*/
public Ip4Address getDhcpServerIp() {
String ip = get(DHCP_SERVER_IP, null);
return ip != null ? Ip4Address.valueOf(ip) : null;
}
/**
* Returns the dhcp server mac.
*
* @return server mac or null if not set
*/
public MacAddress getDhcpServermac() {
String mac = get(DHCP_SERVER_MAC, null);
return mac != null ? MacAddress.valueOf(mac) : null;
}
}
......
......@@ -2,7 +2,9 @@
"apps": {
"org.onosproject.dhcp-relay" : {
"dhcprelay" : {
"dhcpserverConnectPoint": "of:0000000000000002/2"
"dhcpserverConnectPoint": "of:0000000000000002/2",
"serverip": "172.168.10.2",
"servermac": "d2:70:98:90:8c:44"
}
}
}
......