gaurav
Committed by Gerrit Code Review

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

Change-Id: Id2a81faa00592df4ede33f6679c2ba2dd8fb2293
1 COMPILE_DEPS = [ 1 COMPILE_DEPS = [
2 '//lib:CORE_DEPS', 2 '//lib:CORE_DEPS',
3 + '//incubator/api:onos-incubator-api',
3 ] 4 ]
4 5
5 osgi_jar ( 6 osgi_jar (
......
...@@ -49,6 +49,11 @@ ...@@ -49,6 +49,11 @@
49 49
50 <dependency> 50 <dependency>
51 <groupId>org.onosproject</groupId> 51 <groupId>org.onosproject</groupId>
52 + <artifactId>onos-incubator-api</artifactId>
53 + </dependency>
54 +
55 + <dependency>
56 + <groupId>org.onosproject</groupId>
52 <artifactId>onlab-osgi</artifactId> 57 <artifactId>onlab-osgi</artifactId>
53 <version>${project.version}</version> 58 <version>${project.version}</version>
54 </dependency> 59 </dependency>
......
...@@ -20,18 +20,25 @@ import org.onosproject.net.ConnectPoint; ...@@ -20,18 +20,25 @@ import org.onosproject.net.ConnectPoint;
20 import org.onosproject.net.config.Config; 20 import org.onosproject.net.config.Config;
21 21
22 import static org.onosproject.net.config.Config.FieldPresence.MANDATORY; 22 import static org.onosproject.net.config.Config.FieldPresence.MANDATORY;
23 +
24 +import org.onlab.packet.Ip4Address;
25 +import org.onlab.packet.MacAddress;
23 /** 26 /**
24 * DHCP Relay Config class. 27 * DHCP Relay Config class.
25 */ 28 */
26 public class DhcpRelayConfig extends Config<ApplicationId> { 29 public class DhcpRelayConfig extends Config<ApplicationId> {
27 30
28 private static final String DHCP_CONNECT_POINT = "dhcpserverConnectPoint"; 31 private static final String DHCP_CONNECT_POINT = "dhcpserverConnectPoint";
32 + private static final String DHCP_SERVER_IP = "serverip";
33 + private static final String DHCP_SERVER_MAC = "servermac";
29 34
30 @Override 35 @Override
31 public boolean isValid() { 36 public boolean isValid() {
32 37
33 - return hasOnlyFields(DHCP_CONNECT_POINT) && 38 + return hasOnlyFields(DHCP_CONNECT_POINT, DHCP_SERVER_IP, DHCP_SERVER_MAC) &&
34 - isConnectPoint(DHCP_CONNECT_POINT, MANDATORY); 39 + isConnectPoint(DHCP_CONNECT_POINT, MANDATORY) &&
40 + isIpAddress(DHCP_SERVER_IP, MANDATORY) &&
41 + isMacAddress(DHCP_SERVER_MAC, MANDATORY);
35 } 42 }
36 43
37 /** 44 /**
...@@ -42,4 +49,24 @@ public class DhcpRelayConfig extends Config<ApplicationId> { ...@@ -42,4 +49,24 @@ public class DhcpRelayConfig extends Config<ApplicationId> {
42 public ConnectPoint getDhcpServerConnectPoint() { 49 public ConnectPoint getDhcpServerConnectPoint() {
43 return ConnectPoint.deviceConnectPoint(object.path(DHCP_CONNECT_POINT).asText()); 50 return ConnectPoint.deviceConnectPoint(object.path(DHCP_CONNECT_POINT).asText());
44 } 51 }
52 +
53 + /**
54 + * Returns the dhcp server ip.
55 + *
56 + * @return ip address or null if not set
57 + */
58 + public Ip4Address getDhcpServerIp() {
59 + String ip = get(DHCP_SERVER_IP, null);
60 + return ip != null ? Ip4Address.valueOf(ip) : null;
61 + }
62 +
63 + /**
64 + * Returns the dhcp server mac.
65 + *
66 + * @return server mac or null if not set
67 + */
68 + public MacAddress getDhcpServermac() {
69 + String mac = get(DHCP_SERVER_MAC, null);
70 + return mac != null ? MacAddress.valueOf(mac) : null;
71 + }
45 } 72 }
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
2 "apps": { 2 "apps": {
3 "org.onosproject.dhcp-relay" : { 3 "org.onosproject.dhcp-relay" : {
4 "dhcprelay" : { 4 "dhcprelay" : {
5 - "dhcpserverConnectPoint": "of:0000000000000002/2" 5 + "dhcpserverConnectPoint": "of:0000000000000002/2",
6 + "serverip": "172.168.10.2",
7 + "servermac": "d2:70:98:90:8c:44"
6 } 8 }
7 } 9 }
8 } 10 }
......