ONOS-6903 Move EVPN from incubator to apps
Change-Id: Id84c59e28f2591535b0726afbc1a2fa3caf07db5
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstance.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstance.java
new file mode 100644
index 0000000..5288db7
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstance.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.List;
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a evpn instance.
+ */
+public final class EvpnInstance {
+
+ private final RouteDistinguisher rd;
+ private final List<VpnRouteTarget> importRtList;
+ private final List<VpnRouteTarget> exportRtList;
+ private final EvpnInstanceName evpnName;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param rd route distinguisher
+ * @param importRtList import rotue targets
+ * @param exportRtList export rotue targets
+ * @param evpnName vpn instance name
+ */
+ private EvpnInstance(RouteDistinguisher rd,
+ List<VpnRouteTarget> importRtList,
+ List<VpnRouteTarget> exportRtList,
+ EvpnInstanceName evpnName) {
+ checkNotNull(rd);
+ //checkNotNull(rt);
+ checkNotNull(evpnName);
+ this.rd = rd;
+ this.importRtList = importRtList;
+ this.exportRtList = exportRtList;
+ this.evpnName = evpnName;
+ }
+
+ /**
+ * Creats the instance of EvpnInstance.
+ *
+ * @param rd route distinguisher
+ * @param importRtList import rotue targets
+ * @param exportRtList export rotue targets
+ * @param evpnName vpn instance name
+ * @return EvpnInstance
+ */
+ public static EvpnInstance evpnInstance(RouteDistinguisher rd,
+ List<VpnRouteTarget> importRtList,
+ List<VpnRouteTarget> exportRtList,
+ EvpnInstanceName evpnName) {
+ return new EvpnInstance(rd, importRtList, exportRtList, evpnName);
+ }
+
+ /**
+ * Getter of RouteDistinguisher.
+ *
+ * @return RouteDistinguisher
+ */
+ public RouteDistinguisher routeDistinguisher() {
+ return rd;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+
+ public List<VpnRouteTarget> importRouteTarget() {
+ return importRtList;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+ public List<VpnRouteTarget> exportRouteTarget() {
+ return exportRtList;
+ }
+
+ /**
+ * Getter of vpn instance name.
+ *
+ * @return evpnName
+ */
+ public EvpnInstanceName evpnName() {
+ return evpnName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rd, importRtList, exportRtList, evpnName);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnInstance)) {
+ return false;
+ }
+
+ EvpnInstance that = (EvpnInstance) other;
+
+ return Objects.equals(this.evpnName, that.evpnName)
+ && Objects.equals(this.rd, that.rd)
+ && Objects.equals(this.importRtList, that.importRtList)
+ && Objects.equals(this.exportRtList, that.exportRtList);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("evpnName", this.evpnName)
+ .add("rd", this.rd).add("import rt", this.importRtList)
+ .add("export rt", this.exportRtList).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceName.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceName.java
new file mode 100644
index 0000000..f1ea22a
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceName.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents the EvpnInstanceName.
+ */
+public final class EvpnInstanceName {
+ private final String evpnName;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param evpnName EvpnInstanceName
+ */
+ private EvpnInstanceName(String evpnName) {
+ this.evpnName = evpnName;
+ }
+
+ /**
+ * Creates instance of EvpnInstanceName.
+ *
+ * @param evpnName evpnName
+ * @return evpnInstanceName
+ */
+ public static EvpnInstanceName evpnName(String evpnName) {
+ return new EvpnInstanceName(evpnName);
+ }
+
+ /**
+ * Get vpn instance name.
+ *
+ * @return evpnName
+ */
+ public String getEvpnName() {
+ return evpnName;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(evpnName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof EvpnInstanceName) {
+ EvpnInstanceName other = (EvpnInstanceName) obj;
+ return Objects.equals(this.evpnName, other.evpnName);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("evpnName", evpnName).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceNextHop.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceNextHop.java
new file mode 100644
index 0000000..49ad2c5
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceNextHop.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents a evpn instance nexthop.
+ */
+public final class EvpnInstanceNextHop {
+
+ private final IpAddress nextHop;
+ private final Label label;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param nextHop nexthop
+ * @param label label
+ */
+ private EvpnInstanceNextHop(IpAddress nextHop, Label label) {
+ this.nextHop = nextHop;
+ this.label = label;
+ }
+
+ /**
+ * creates instance of EvpnInstanceNextHop.
+ *
+ * @param nextHop nexthop
+ * @param label label
+ * @return evpnInstanceNexthop
+ */
+ public static EvpnInstanceNextHop evpnNextHop(IpAddress nextHop,
+ Label label) {
+ return new EvpnInstanceNextHop(nextHop, label);
+ }
+
+ /**
+ * Returns the next hop IP address.
+ *
+ * @return next hop
+ */
+ public IpAddress nextHop() {
+ return nextHop;
+ }
+
+ /**
+ * Returns the label.
+ *
+ * @return Label
+ */
+ public Label label() {
+ return label;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nextHop, label);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnInstanceNextHop)) {
+ return false;
+ }
+
+ EvpnInstanceNextHop that = (EvpnInstanceNextHop) other;
+
+ return Objects.equals(this.nextHop(), that.nextHop())
+ && Objects.equals(this.label, that.label);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("nextHop", this.nextHop())
+ .add("label", this.label).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstancePrefix.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstancePrefix.java
new file mode 100644
index 0000000..2f30538
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstancePrefix.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a evpn instance prefix.
+ */
+public final class EvpnInstancePrefix {
+
+ private final MacAddress macAddress;
+ private final IpPrefix ipPrefix;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param macAddress Mac address
+ * @param ipPrefix IP address
+ */
+ private EvpnInstancePrefix(MacAddress macAddress,
+ IpPrefix ipPrefix) {
+ checkNotNull(macAddress);
+ this.macAddress = macAddress;
+ this.ipPrefix = ipPrefix;
+ }
+
+ /**
+ * Creates the instance of EvpnInstancePrefix.
+ *
+ * @param macAddress Mac address
+ * @param ipPrefix IP address
+ * @return Evpn instance prefix
+ */
+ public static EvpnInstancePrefix evpnPrefix(MacAddress macAddress,
+ IpPrefix ipPrefix) {
+ return new EvpnInstancePrefix(macAddress, ipPrefix);
+ }
+
+ /**
+ * Returns the MAC of the route.
+ *
+ * @return MAC address
+ */
+ public MacAddress macAddress() {
+ return macAddress;
+ }
+
+ /**
+ * Returns the IP prefix of the route.
+ *
+ * @return IP prefix
+ */
+ public IpPrefix ipPrefix() {
+ return ipPrefix;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(macAddress);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnInstancePrefix)) {
+ return false;
+ }
+
+ EvpnInstancePrefix that = (EvpnInstancePrefix) other;
+
+ return Objects.equals(this.macAddress, that.macAddress)
+ && Objects.equals(this.ipPrefix, that.ipPrefix);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("macAddress", this.macAddress)
+ .add("ipAddress", this.ipPrefix).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceRoute.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceRoute.java
new file mode 100644
index 0000000..3e98531
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInstanceRoute.java
@@ -0,0 +1,219 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a evpn instance route.
+ */
+public class EvpnInstanceRoute {
+
+ private final EvpnInstanceName evpnName;
+ private final RouteDistinguisher rd;
+ private List<VpnRouteTarget> importRtList;
+ private List<VpnRouteTarget> exportRtList;
+ private final EvpnInstancePrefix evpnInstancePrefix;
+ private final EvpnInstanceNextHop evpnInstanceNextHop;
+ private final IpPrefix prefix;
+ private final IpAddress nextHop;
+ private final Label label;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param evpnName vpn instance name
+ * @param rd route distinguisher
+ * @param importRtList import route targets
+ * @param exportRtList export route targets
+ * @param evpnInstancePrefix evpn intance prefix
+ * @param evpnInstanceNextHop evpn instance nexthop
+ * @param prefix evpn prefix
+ * @param nextHop evpn nexthop
+ * @param label label
+ */
+ public EvpnInstanceRoute(EvpnInstanceName evpnName,
+ RouteDistinguisher rd,
+ List<VpnRouteTarget> importRtList,
+ List<VpnRouteTarget> exportRtList,
+ EvpnInstancePrefix evpnInstancePrefix,
+ EvpnInstanceNextHop evpnInstanceNextHop,
+ IpPrefix prefix,
+ IpAddress nextHop,
+ Label label) {
+ checkNotNull(evpnName);
+ checkNotNull(prefix);
+ //checkNotNull(nextHop); //can be NULL in MP un reach
+ checkNotNull(rd);
+
+ this.evpnName = evpnName;
+ this.rd = rd;
+ this.importRtList = importRtList;
+ this.exportRtList = exportRtList;
+ this.prefix = prefix;
+ this.nextHop = nextHop;
+ this.evpnInstancePrefix = evpnInstancePrefix;
+ this.evpnInstanceNextHop = evpnInstanceNextHop;
+ this.label = label;
+ }
+
+ /**
+ * Returns the evpnName.
+ *
+ * @return EvpnInstanceName
+ */
+ public EvpnInstanceName evpnInstanceName() {
+ return evpnName;
+ }
+
+ /**
+ * Returns the route distinguisher.
+ *
+ * @return RouteDistinguisher
+ */
+ public RouteDistinguisher routeDistinguisher() {
+ return rd;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+
+ public List<VpnRouteTarget> importRouteTarget() {
+ return importRtList;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+ public List<VpnRouteTarget> exportRouteTarget() {
+ return exportRtList;
+ }
+
+ /**
+ * Set import list.
+ *
+ * @param importRtList import list
+ */
+ public void setImportRtList(List<VpnRouteTarget> importRtList) {
+ this.importRtList = importRtList;
+ }
+
+ /**
+ * Set export list.
+ *
+ * @param exportRtList export list
+ */
+ public void setExportRtList(List<VpnRouteTarget> exportRtList) {
+ this.exportRtList = exportRtList;
+ }
+
+ /**
+ * Returns EvpnInstancePrefix of the evpn private route.
+ *
+ * @return EvpnInstancePrefix
+ */
+
+ public EvpnInstancePrefix getevpnInstancePrefix() {
+ return evpnInstancePrefix;
+ }
+
+ /**
+ * Returns EvpnInstanceNextHop of the evpn private route.
+ *
+ * @return EvpnInstancePrefix
+ */
+
+ public EvpnInstanceNextHop getEvpnInstanceNextHop() {
+ return evpnInstanceNextHop;
+ }
+
+ /**
+ * Returns prefix of the evpn private route.
+ *
+ * @return EvpnInstancePrefix
+ */
+ public IpPrefix prefix() {
+ return prefix;
+ }
+
+ /**
+ * Returns the label.
+ *
+ * @return EvpnInstanceName
+ */
+ public Label getLabel() {
+ return label;
+ }
+
+ /**
+ * Returns the label.
+ *
+ * @return EvpnInstanceName
+ */
+ public IpAddress getNextHopl() {
+ return nextHop;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(evpnName, prefix, nextHop,
+ rd, importRtList, exportRtList);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnInstanceRoute)) {
+ return false;
+ }
+
+ EvpnInstanceRoute that = (EvpnInstanceRoute) other;
+
+ return Objects.equals(prefix, prefix)
+ && Objects.equals(nextHop, that.nextHop)
+ && Objects.equals(evpnName, that.evpnName)
+ && Objects.equals(rd, that.rd)
+ && Objects.equals(importRtList, that.importRtList)
+ && Objects.equals(exportRtList, that.exportRtList);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("prefix", prefix)
+ .add("nextHop", nextHop)
+ .add("rd", rd)
+ .add("import rt", importRtList)
+ .add("export rt", exportRtList)
+ .add("evpnName", evpnName)
+ .toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInternalRouteEvent.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInternalRouteEvent.java
new file mode 100644
index 0000000..7a71875
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnInternalRouteEvent.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import org.onosproject.event.AbstractEvent;
+
+/**
+ * Route event for signalling between the store and the manager.
+ */
+public class EvpnInternalRouteEvent extends
+ AbstractEvent<EvpnInternalRouteEvent.Type, EvpnRouteSet> {
+
+ /**
+ * Internal route event type.
+ */
+ public enum Type {
+ /**
+ * Indicates a route was added to the store.
+ */
+ ROUTE_ADDED,
+
+ /**
+ * Indicates a route was removed from the store.
+ */
+ ROUTE_REMOVED
+ }
+
+ /**
+ * Creates a new internal route event.
+ *
+ * @param type route event type
+ * @param subject route set
+ */
+ public EvpnInternalRouteEvent(Type type, EvpnRouteSet subject) {
+ super(type, subject);
+ }
+
+ public EvpnInternalRouteEvent(Type type, EvpnRouteSet subject, long time) {
+ super(type, subject, time);
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnNextHop.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnNextHop.java
new file mode 100644
index 0000000..ac1e06b
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnNextHop.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents a evpn next hop.
+ */
+public final class EvpnNextHop {
+
+ private final IpAddress nextHop;
+ private final List<VpnRouteTarget> importRtList;
+ private final List<VpnRouteTarget> exportRtList;
+ private final Label label;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param nextHop evpn next hop
+ * @param importRtList import route targets
+ * @param importRtList export route targets
+ * @param label label
+ */
+ private EvpnNextHop(IpAddress nextHop, List<VpnRouteTarget> importRtList, List<VpnRouteTarget> exportRtList,
+ Label label) {
+ this.nextHop = nextHop;
+ this.importRtList = importRtList;
+ this.exportRtList = exportRtList;
+ this.label = label;
+ }
+
+ /**
+ * Creates the Evpn Next hop with given parameters.
+ *
+ * @param nextHop Next hop of the route
+ * @param importRtList route target import list
+ * @param exportRtList route target export list
+ * @param label label of evpn route
+ * @return EvpnNextHop
+ */
+ public static EvpnNextHop evpnNextHop(IpAddress nextHop, List<VpnRouteTarget> importRtList,
+ List<VpnRouteTarget> exportRtList,
+ Label label) {
+ return new EvpnNextHop(nextHop, importRtList, exportRtList, label);
+ }
+
+ /**
+ * Returns the next hop IP address.
+ *
+ * @return next hop
+ */
+ public IpAddress nextHop() {
+ return nextHop;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+
+ public List<VpnRouteTarget> importRouteTarget() {
+ return importRtList;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+ public List<VpnRouteTarget> exportRouteTarget() {
+ return exportRtList;
+ }
+
+ /**
+ * Returns the label of evpn route.
+ *
+ * @return Label
+ */
+ public Label label() {
+ return label;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nextHop, importRtList, exportRtList, label);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnNextHop)) {
+ return false;
+ }
+
+ EvpnNextHop that = (EvpnNextHop) other;
+
+ return Objects.equals(this.nextHop(), that.nextHop())
+ && Objects.equals(this.importRtList, that.importRtList)
+ && Objects.equals(this.exportRtList, that.exportRtList)
+ && Objects.equals(this.label, that.label);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("nextHop", this.nextHop())
+ .add("import rt list", this.importRtList).add("export rt list", this.exportRtList)
+ .add("label", this.label).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnPrefix.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnPrefix.java
new file mode 100644
index 0000000..3f70ef5
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnPrefix.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a evpn prefix.
+ */
+public final class EvpnPrefix {
+
+ private final RouteDistinguisher rd;
+ private final MacAddress macAddress;
+ private final IpPrefix ipAddress;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param rd route distinguisher
+ * @param macAddress mac address
+ * @param ipAddress IP address
+ */
+ public EvpnPrefix(RouteDistinguisher rd, MacAddress macAddress,
+ IpPrefix ipAddress) {
+ checkNotNull(rd);
+ checkNotNull(macAddress);
+ checkNotNull(ipAddress);
+ this.rd = rd;
+ this.macAddress = macAddress;
+ this.ipAddress = ipAddress;
+ }
+
+ /**
+ * Creates the evpn prefix by given parameters.
+ *
+ * @param rd route distinguisher
+ * @param macAddress mac address
+ * @param ipAddress ip address
+ * @return EvpnPrefix
+ */
+ public static EvpnPrefix evpnPrefix(RouteDistinguisher rd,
+ MacAddress macAddress,
+ IpPrefix ipAddress) {
+ return new EvpnPrefix(rd, macAddress, ipAddress);
+ }
+
+ /**
+ * Returns the route distinguisher.
+ *
+ * @return RouteDistinguisher
+ */
+ public RouteDistinguisher routeDistinguisher() {
+ return rd;
+ }
+
+ /**
+ * Returns the mac address.
+ *
+ * @return MacAddress
+ */
+ public MacAddress macAddress() {
+ return macAddress;
+ }
+
+ /**
+ * Returns the IP address.
+ *
+ * @return Ip4Address
+ */
+ public IpPrefix ipAddress() {
+ return ipAddress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rd, macAddress, ipAddress);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnPrefix)) {
+ return false;
+ }
+
+ EvpnPrefix that = (EvpnPrefix) other;
+
+ return Objects.equals(this.macAddress(), that.macAddress())
+ && Objects.equals(this.ipAddress, that.ipAddress)
+ && Objects.equals(this.rd, that.rd);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("macAddress", this.macAddress())
+ .add("ipAddress", this.ipAddress()).add("rd", this.rd)
+ .toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRoute.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRoute.java
new file mode 100644
index 0000000..9449093
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRoute.java
@@ -0,0 +1,282 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a evpn route.
+ */
+public class EvpnRoute {
+
+
+ /**
+ * Source of the route.
+ */
+ public enum Source {
+ /**
+ * Route came from app source.
+ */
+ LOCAL,
+
+ /**
+ * Route came from remote bgp peer source.
+ */
+ REMOTE,
+ }
+
+ private final Source source;
+ private final MacAddress prefixMac;
+ private final IpPrefix prefix;
+ private final IpAddress nextHop;
+ private final RouteDistinguisher rd;
+ private List<VpnRouteTarget> importRtList;
+ private List<VpnRouteTarget> exportRtList;
+ private final Label label;
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param source route source
+ * @param prefixMac mac address
+ * @param prefix ip address
+ * @param nextHop evpn nexthop
+ * @param rd route distinguisher
+ * @param importRtList import route targets
+ * @param exportRtList export route targets
+ * @param label evpn route label
+ */
+ public EvpnRoute(Source source,
+ MacAddress prefixMac,
+ IpPrefix prefix,
+ IpAddress nextHop,
+ RouteDistinguisher rd,
+ List<VpnRouteTarget> importRtList,
+ List<VpnRouteTarget> exportRtList,
+ Label label) {
+
+ checkNotNull(prefixMac);
+ checkNotNull(prefix);
+ //checkNotNull(nextHop);//next hop can be null in case of MP un reach.
+ checkNotNull(rd);
+ checkNotNull(label);
+ this.source = checkNotNull(source);
+ this.prefix = prefix;
+ this.prefixMac = prefixMac;
+ this.nextHop = nextHop;
+ this.rd = rd;
+ this.importRtList = importRtList;
+ this.exportRtList = exportRtList;
+ this.label = label;
+ }
+
+ /**
+ * Constructor to initialize the parameters.
+ *
+ * @param source route source
+ * @param prefixMac mac address
+ * @param prefix ip address
+ * @param nextHop evpn nexthop
+ * @param rdToString route distinguisher
+ * @param importRtList import route targets
+ * @param exportRtList export route targets
+ * @param labelToInt evpn route label
+ */
+ public EvpnRoute(Source source,
+ MacAddress prefixMac,
+ IpPrefix prefix,
+ IpAddress nextHop,
+ String rdToString,
+ List<VpnRouteTarget> importRtList,
+ List<VpnRouteTarget> exportRtList,
+ int labelToInt) {
+ checkNotNull(prefixMac);
+ checkNotNull(prefix);
+ //checkNotNull(nextHop); //next hop can be null in case of MP un reach.
+ checkNotNull(labelToInt);
+ this.source = checkNotNull(source);
+ this.prefix = prefix;
+ this.prefixMac = prefixMac;
+ this.nextHop = nextHop;
+ this.rd = RouteDistinguisher.routeDistinguisher(rdToString);
+ this.importRtList = importRtList;
+ this.exportRtList = exportRtList;
+ this.label = Label.label(labelToInt);
+ }
+
+ /**
+ * Returns the route source.
+ *
+ * @return route source
+ */
+ public Source source() {
+ return source;
+ }
+
+ /**
+ * Returns the address.
+ *
+ * @return MacAddress
+ */
+ public MacAddress prefixMac() {
+ return prefixMac;
+ }
+
+ /**
+ * Returns the IPv4 address.
+ *
+ * @return Ip4Address
+ */
+ public IpPrefix prefixIp() {
+ return prefix;
+ }
+
+ /**
+ * Returns the IPv4 address.
+ *
+ * @return Ip4Address
+ */
+ public EvpnPrefix evpnPrefix() {
+ return new EvpnPrefix(rd, prefixMac,
+ prefix);
+ }
+
+
+ /**
+ * Returns the next hop IP address.
+ *
+ * @return Ip4Address
+ */
+ public IpAddress ipNextHop() {
+ return nextHop;
+ }
+
+ public EvpnNextHop nextHop() {
+ return EvpnNextHop.evpnNextHop(nextHop,
+ importRtList,
+ exportRtList,
+ label);
+ }
+
+ /**
+ * Returns the routeDistinguisher.
+ *
+ * @return RouteDistinguisher
+ */
+ public RouteDistinguisher routeDistinguisher() {
+ return rd;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+
+ public List<VpnRouteTarget> importRouteTarget() {
+ return importRtList;
+ }
+
+ /**
+ * Returns the Route targets.
+ *
+ * @return RouteTarget List
+ */
+ public List<VpnRouteTarget> exportRouteTarget() {
+ return exportRtList;
+ }
+
+ /**
+ * Set import list.
+ *
+ * @param importRtList import list
+ */
+ public void setImportRtList(List<VpnRouteTarget> importRtList) {
+ this.importRtList = importRtList;
+ }
+
+ /**
+ * Set export list.
+ *
+ * @param exportRtList export list
+ */
+ public void setExportRtList(List<VpnRouteTarget> exportRtList) {
+ this.exportRtList = exportRtList;
+ }
+
+ /**
+ * Returns the label.
+ *
+ * @return Label
+ */
+ public Label label() {
+ return label;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(prefixMac,
+ prefix,
+ nextHop,
+ rd,
+ importRtList,
+ exportRtList,
+ label);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnRoute)) {
+ return false;
+ }
+
+ EvpnRoute that = (EvpnRoute) other;
+
+ return Objects.equals(prefixMac, prefixMac)
+ && Objects.equals(prefix, that.prefix)
+ && Objects.equals(nextHop, that.nextHop)
+ && Objects.equals(this.rd, that.rd)
+ && Objects.equals(this.importRtList, that.importRtList)
+ && Objects.equals(this.exportRtList, that.exportRtList)
+ && Objects.equals(this.label, that.label);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("prefixMac", prefixMac)
+ .add("prefix", prefix)
+ .add("nextHop", nextHop)
+ .add("rd", this.rd)
+ .add("import rt", this.importRtList)
+ .add("export rt", this.exportRtList)
+ .add("label", this.label)
+ .toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteAdminService.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteAdminService.java
new file mode 100644
index 0000000..cc9e200
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteAdminService.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Collection;
+
+/**
+ * Service allowing mutation of EVPN routing state.
+ */
+public interface EvpnRouteAdminService extends EvpnRouteService {
+
+ /**
+ * Updates the given routes in the route service.
+ *
+ * @param routes collection of routes to update
+ */
+ void update(Collection<EvpnRoute> routes);
+
+ /**
+ * Withdraws the given routes from the route service.
+ *
+ * @param routes collection of routes to withdraw
+ */
+ void withdraw(Collection<EvpnRoute> routes);
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
new file mode 100644
index 0000000..ae3d93a
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteEvent.java
@@ -0,0 +1,195 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Objects;
+
+import org.joda.time.LocalDateTime;
+import org.onosproject.event.AbstractEvent;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Describes an event about a route.
+ */
+public class EvpnRouteEvent extends AbstractEvent<EvpnRouteEvent.Type,
+ EvpnRoute> {
+
+ private final EvpnRoute prevSubject;
+ private final Collection<EvpnRoute> alternativeRoutes;
+
+ /**
+ * Route event type.
+ */
+ public enum Type {
+
+ /**
+ * Route is new and the next hop is resolved.
+ * <p>
+ * The subject of this event should be the route being added.
+ * The prevSubject of this event should be null.
+ * </p>
+ */
+ ROUTE_ADDED,
+
+ /**
+ * Route has updated information.
+ * <p>
+ * The subject of this event should be the new route.
+ * The prevSubject of this event should be the old route.
+ * </p>
+ */
+ ROUTE_UPDATED,
+
+ /**
+ * Route was removed or the next hop becomes unresolved.
+ * <p>
+ * The subject of this event should be the route being removed.
+ * The prevSubject of this event should be null.
+ * </p>
+ */
+ ROUTE_REMOVED,
+
+ /**
+ * The set of alternative routes for the subject's prefix has changed,
+ * but the best route is still the same.
+ * <p>
+ * The subject is the best route for the prefix (which has already been
+ * notified in a previous event).
+ * The prevSubject of this event is null.
+ * The alternatives contains the new set of alternative routes.
+ * </p>
+ */
+ ALTERNATIVE_ROUTES_CHANGED
+ }
+
+ /**
+ * Creates a new route event without specifying previous subject.
+ *
+ * @param type event type
+ * @param subject event subject
+ */
+ public EvpnRouteEvent(Type type, EvpnRoute subject) {
+ this(type, subject, null, Collections.emptySet());
+ }
+
+ /**
+ * Creates a new route event without specifying previous subject.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param alternatives alternative routes for subject's prefix
+ */
+ public EvpnRouteEvent(Type type, EvpnRoute subject,
+ Collection<EvpnRoute> alternatives) {
+ this(type, subject, null, alternatives);
+ }
+
+ /**
+ * Creates a new route event.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param time event time
+ */
+ protected EvpnRouteEvent(Type type, EvpnRoute subject, long time) {
+ super(type, subject, time);
+ this.prevSubject = null;
+
+ this.alternativeRoutes = Collections.emptySet();
+ }
+
+ /**
+ * Creates a new route event with previous subject.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param prevSubject previous subject
+ */
+ public EvpnRouteEvent(Type type, EvpnRoute subject, EvpnRoute prevSubject) {
+ this(type, subject, prevSubject, Collections.emptySet());
+ }
+
+ /**
+ * Creates a new route event with a previous subject and alternative routes.
+ *
+ * @param type event type
+ * @param subject event subject
+ * @param prevSubject previous subject
+ * @param alternatives alternative routes for subject's prefix
+ */
+ public EvpnRouteEvent(Type type, EvpnRoute subject, EvpnRoute prevSubject,
+ Collection<EvpnRoute> alternatives) {
+ super(type, subject);
+ this.prevSubject = prevSubject;
+ this.alternativeRoutes = alternatives;
+ }
+
+ /**
+ * Returns the previous subject of the event.
+ *
+ * @return previous subject to which this event pertains
+ */
+ public EvpnRoute prevSubject() {
+ return prevSubject;
+ }
+
+ /**
+ * Returns the set of alternative routes for the subject's prefix.
+ *
+ * @return alternative routes
+ */
+ public Collection<EvpnRoute> alternatives() {
+ return alternativeRoutes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(subject(), type(), prevSubject(), alternativeRoutes);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnRouteEvent)) {
+ return false;
+ }
+
+ EvpnRouteEvent that = (EvpnRouteEvent) other;
+
+ return Objects.equals(this.subject(), that.subject()) &&
+ Objects.equals(this.type(), that.type()) &&
+ Objects.equals(this.prevSubject, that.prevSubject) &&
+ Objects.equals(this.alternativeRoutes, that.alternativeRoutes);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("time", new LocalDateTime(time()))
+ .add("type", type())
+ .add("subject", subject())
+ .add("prevSubject", prevSubject)
+ .add("alternatives", alternativeRoutes)
+ .toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteListener.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteListener.java
new file mode 100644
index 0000000..32a35c2
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteListener.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import org.onosproject.event.EventListener;
+
+/**
+ * Listener for route events.
+ */
+public interface EvpnRouteListener extends EventListener<EvpnRouteEvent> {
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteService.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteService.java
new file mode 100644
index 0000000..ca9c031
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteService.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Collection;
+
+import org.onosproject.event.ListenerService;
+
+/**
+ * EVPN route service.
+ */
+public interface EvpnRouteService extends ListenerService<EvpnRouteEvent,
+ EvpnRouteListener> {
+
+
+ /**
+ * Returns the set of route tables in the system.
+ *
+ * @return collection of route table IDs.
+ */
+ Collection<EvpnRouteTableId> getRouteTables();
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteSet.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteSet.java
new file mode 100644
index 0000000..707df22
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteSet.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+import java.util.Set;
+
+import com.google.common.collect.ImmutableSet;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * A set of routes for a particular prefix in a route table.
+ */
+public class EvpnRouteSet {
+ private final EvpnRouteTableId tableId;
+
+ private final EvpnPrefix prefix;
+ private final Set<EvpnRoute> routes;
+
+ /**
+ * Creates a new route set.
+ *
+ * @param tableId route table ID
+ * @param prefix IP prefix
+ * @param routes routes for the given prefix
+ */
+ public EvpnRouteSet(EvpnRouteTableId tableId, EvpnPrefix prefix, Set<EvpnRoute>
+ routes) {
+ this.tableId = checkNotNull(tableId);
+ this.prefix = checkNotNull(prefix);
+ this.routes = ImmutableSet.copyOf(checkNotNull(routes));
+ }
+
+ /**
+ * Returns the route table ID.
+ *
+ * @return route table ID
+ */
+ public EvpnRouteTableId tableId() {
+ return tableId;
+ }
+
+ /**
+ * Returns the IP prefix.
+ *
+ * @return IP prefix
+ */
+ public EvpnPrefix prefix() {
+ return prefix;
+ }
+
+ /**
+ * Returns the set of routes.
+ *
+ * @return routes
+ */
+ public Set<EvpnRoute> routes() {
+ return routes;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tableId, prefix, routes);
+ }
+
+ @Override
+ public boolean equals(Object other) {
+ if (this == other) {
+ return true;
+ }
+
+ if (!(other instanceof EvpnRouteSet)) {
+ return false;
+ }
+
+ EvpnRouteSet that = (EvpnRouteSet) other;
+
+ return Objects.equals(this.tableId, that.tableId) &&
+ Objects.equals(this.prefix, that.prefix) &&
+ Objects.equals(this.routes, that.routes);
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStore.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStore.java
new file mode 100644
index 0000000..c06704f
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStore.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.store.Store;
+
+/**
+ * EVPN route store.
+ */
+public interface EvpnRouteStore extends Store<EvpnInternalRouteEvent,
+ EvpnRouteStoreDelegate> {
+
+ /**
+ * Adds or updates the given route in the store.
+ *
+ * @param route route to add or update
+ */
+ void updateRoute(EvpnRoute route);
+
+ /**
+ * Removes the given route from the store.
+ *
+ * @param route route to remove
+ */
+ void removeRoute(EvpnRoute route);
+
+ /**
+ * Returns the IDs for all route tables in the store.
+ *
+ * @return route table IDs
+ */
+ Set<EvpnRouteTableId> getRouteTables();
+
+ /**
+ * Returns the routes in the given route table, grouped by prefix.
+ *
+ * @param table route table ID
+ * @return routes
+ */
+ Collection<EvpnRouteSet> getRoutes(EvpnRouteTableId table);
+
+ /**
+ * Returns the routes that point to the given next hop IP address.
+ *
+ * @param ip IP address of the next hop
+ * @return routes for the given next hop
+ */
+ // TODO think about including route table info
+ Collection<EvpnRoute> getRoutesForNextHop(IpAddress ip);
+
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStoreDelegate.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStoreDelegate.java
new file mode 100644
index 0000000..d714adc
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteStoreDelegate.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import org.onosproject.store.StoreDelegate;
+
+/**
+ * Route store delegate abstraction.
+ */
+public interface EvpnRouteStoreDelegate extends
+ StoreDelegate<EvpnInternalRouteEvent> {
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteTableId.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteTableId.java
new file mode 100644
index 0000000..846a8d1
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnRouteTableId.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+/**
+ * Identifier for an EVPN routing table.
+ */
+public class EvpnRouteTableId {
+ private final String name;
+
+ /**
+ * Creates a new route table ID.
+ *
+ * @param name unique name for the route table
+ */
+ public EvpnRouteTableId(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Returns the name of the route table.
+ *
+ * @return table name
+ */
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof EvpnRouteTableId) {
+ EvpnRouteTableId that = (EvpnRouteTableId) obj;
+
+ return Objects.equals(this.name, that.name);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnTable.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnTable.java
new file mode 100755
index 0000000..0b3379f
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/EvpnTable.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Collection;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * Represents a route table that stores routes.
+ */
+public interface EvpnTable {
+
+ /**
+ * Adds a route to the route table.
+ *
+ * @param route route
+ */
+ void update(EvpnRoute route);
+
+ /**
+ * Removes a route from the route table.
+ *
+ * @param route route
+ */
+ void remove(EvpnRoute route);
+
+ /**
+ * Returns the route table ID.
+ *
+ * @return route table ID
+ */
+ EvpnRouteTableId id();
+
+ /**
+ * Returns all routes in the route table.
+ *
+ * @return collection of routes, grouped by prefix
+ */
+ Collection<EvpnRouteSet> getRoutes();
+
+ /**
+ * Returns the routes in this table pertaining to a given prefix.
+ *
+ * @param prefix IP prefix
+ * @return routes for the prefix
+ */
+ EvpnRouteSet getRoutes(EvpnPrefix prefix);
+
+ /**
+ * Returns all routes that have the given next hop.
+ *
+ * @param nextHop next hop IP address
+ * @return collection of routes
+ */
+ Collection<EvpnRoute> getRoutesForNextHop(IpAddress nextHop);
+
+ /**
+ * Releases route table resources held locally.
+ */
+ void shutdown();
+
+ /**
+ * Releases route table resources across the entire cluster.
+ */
+ void destroy();
+
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/Label.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/Label.java
new file mode 100644
index 0000000..8d90611
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/Label.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents label of the route.
+ */
+public final class Label {
+ private final int label;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param label route label
+ */
+ private Label(int label) {
+ this.label = label;
+ }
+
+ /**
+ * Creates the label for evpn route.
+ *
+ * @param label label of evpn route
+ * @return Label
+ */
+ public static Label label(int label) {
+ return new Label(label);
+ }
+
+ /**
+ * Returns the label.
+ *
+ * @return label
+ */
+ public int getLabel() {
+ return label;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(label);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof Label) {
+ Label other = (Label) obj;
+ return Objects.equals(label, other.label);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("label", label).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/RouteDistinguisher.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/RouteDistinguisher.java
new file mode 100644
index 0000000..ca217b6
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/RouteDistinguisher.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents Route Distinguisher of device in the network.
+ */
+public final class RouteDistinguisher {
+ private final String routeDistinguisher;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param routeDistinguisher route distinguisher
+ */
+ private RouteDistinguisher(String routeDistinguisher) {
+ this.routeDistinguisher = routeDistinguisher;
+ }
+
+ /**
+ * Creates the route distinguisher.
+ *
+ * @param routeDistinguisher route distinguisher
+ * @return RouteDistinguisher
+ */
+ public static RouteDistinguisher routeDistinguisher(String routeDistinguisher) {
+ checkNotNull(routeDistinguisher);
+ return new RouteDistinguisher(routeDistinguisher);
+ }
+
+ /**
+ * get route distinguisher.
+ *
+ * @return distinguisher
+ */
+ public String getRouteDistinguisher() {
+ return routeDistinguisher;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(routeDistinguisher);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof RouteDistinguisher) {
+ RouteDistinguisher other = (RouteDistinguisher) obj;
+ return Objects.equals(this.routeDistinguisher, other.routeDistinguisher);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("routeDistinguisher", this.routeDistinguisher).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/VpnRouteTarget.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/VpnRouteTarget.java
new file mode 100644
index 0000000..51a9a59
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/VpnRouteTarget.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.evpnrouteservice;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Represents Route target of vpn instance.
+ */
+public final class VpnRouteTarget {
+ private final String routeTarget;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param routeTarget route target
+ */
+ private VpnRouteTarget(String routeTarget) {
+ this.routeTarget = routeTarget;
+ }
+
+ /**
+ * Creates the vpn route target.
+ *
+ * @param routeTarget route target
+ * @return route target
+ */
+ public static VpnRouteTarget routeTarget(String routeTarget) {
+ return new VpnRouteTarget(routeTarget);
+ }
+
+ /**
+ * get the route target.
+ *
+ * @return route target
+ */
+ public String getRouteTarget() {
+ return routeTarget;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(routeTarget);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof VpnRouteTarget) {
+ VpnRouteTarget other = (VpnRouteTarget) obj;
+ return Objects.equals(routeTarget, other.routeTarget);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("routeTarget", routeTarget).toString();
+ }
+}
diff --git a/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/package-info.java b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/package-info.java
new file mode 100644
index 0000000..3514c80
--- /dev/null
+++ b/apps/evpn-route-service/api/src/main/java/org/onosproject/evpnrouteservice/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Unicast routing service.
+ */
+package org.onosproject.evpnrouteservice;