diff options
Diffstat (limited to 'framework/src/onos/apps/iptopology-api')
67 files changed, 5428 insertions, 0 deletions
diff --git a/framework/src/onos/apps/iptopology-api/pom.xml b/framework/src/onos/apps/iptopology-api/pom.xml new file mode 100644 index 00000000..50cb4adc --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/pom.xml @@ -0,0 +1,29 @@ +<!-- + ~ Copyright 2015 Open Networking Laboratory + ~ + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onosproject</groupId> + <artifactId>onos-apps</artifactId> + <version>1.4.0-SNAPSHOT</version> + </parent> + <artifactId>onos-app-iptopology-api</artifactId> + <packaging>bundle</packaging> + + <description>IP Layer Topology API</description> +</project> diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/AreaId.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/AreaId.java new file mode 100644 index 00000000..79a326da --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/AreaId.java @@ -0,0 +1,70 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Area identifier class (32 Bit Area-ID).
+ */
+public class AreaId {
+ private final int areaId;
+
+ /**
+ * Constructor to set area identifier.
+ *
+ * @param areaId area id
+ */
+ public AreaId(int areaId) {
+ this.areaId = areaId;
+ }
+
+ /**
+ * obtain area identifier.
+ *
+ * @return area identifier
+ */
+ public int areaId() {
+ return areaId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(areaId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof AreaId) {
+ AreaId other = (AreaId) obj;
+ return Objects.equals(areaId, other.areaId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("areaId", areaId)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/AsNumber.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/AsNumber.java new file mode 100644 index 00000000..3159b20a --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/AsNumber.java @@ -0,0 +1,70 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Autonomous system Number class (32 Bit ASNumber).
+ */
+public class AsNumber {
+ private final int asNum;
+
+ /**
+ * Constructor to set As number.
+ *
+ * @param asNum As number
+ */
+ public AsNumber(int asNum) {
+ this.asNum = asNum;
+ }
+
+ /**
+ * Obtain autonomous system number.
+ *
+ * @return autonomous system number
+ */
+ public int asNum() {
+ return asNum;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asNum);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof AsNumber) {
+ AsNumber other = (AsNumber) obj;
+ return Objects.equals(asNum, other.asNum);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("asNum", asNum)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Color.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Color.java new file mode 100644 index 00000000..cb38fa67 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Color.java @@ -0,0 +1,72 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents administrative group color. + * bit mask - least significant bit is referred to as 'group 0', + * and the most significant bit is referred to as 'group 31' + */ +public class Color { + private final int color; + + /** + * Constructor to initialize its parameter. + * + * @param color assigned by the network administrator + */ + public Color(int color) { + this.color = color; + } + + /** + * Obtains administrative group. + * + * @return administrative group + */ + public int color() { + return color; + } + + @Override + public int hashCode() { + return Objects.hash(color); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof Color) { + Color other = (Color) obj; + return Objects.equals(color, other.color); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("color", color) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultDeviceIntf.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultDeviceIntf.java new file mode 100644 index 00000000..e40cbfc0 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultDeviceIntf.java @@ -0,0 +1,79 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+import org.onosproject.net.Element;
+
+/**
+ * Default Device interface implementation.
+ */
+public class DefaultDeviceIntf implements DeviceIntf {
+
+ private final Element element;
+ private final DeviceInterface deviceInterface;
+
+ /**
+ * Constructor to initialize device interface parameters.
+ *
+ * @param element parent network element
+ * @param deviceInterface device interface
+ */
+ public DefaultDeviceIntf(Element element, DeviceInterface deviceInterface) {
+ this.element = element;
+ this.deviceInterface = deviceInterface;
+ }
+
+ @Override
+ public Element element() {
+ return element;
+ }
+
+ @Override
+ public DeviceInterface deviceInterface() {
+ return deviceInterface;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(element, deviceInterface);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof DefaultDeviceIntf) {
+ final DefaultDeviceIntf other = (DefaultDeviceIntf) obj;
+ return Objects.equals(this.element.id(), other.element.id())
+ && Objects.equals(this.deviceInterface, other.deviceInterface);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("element", element.id())
+ .add("deviceInterface", deviceInterface)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultDevicePrefix.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultDevicePrefix.java new file mode 100644 index 00000000..2b1dde6f --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultDevicePrefix.java @@ -0,0 +1,95 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.AbstractAnnotated;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.Element;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Default Device prefix implementation.
+ */
+public class DefaultDevicePrefix extends AbstractAnnotated implements DevicePrefix {
+
+ private final Element element;
+ private final PrefixIdentifier prefixIdentifier;
+ private final PrefixTed prefixTed;
+
+ /**
+ * Creates a network device prefix attributed to the specified element.
+ *
+ * @param element parent network element
+ * @param prefixIdentifier prefix identifier
+ * @param prefixTed prefid traffic engineering parameters
+ * @param annotations optional key/value annotations
+ */
+ public DefaultDevicePrefix(Element element, PrefixIdentifier prefixIdentifier,
+ PrefixTed prefixTed, Annotations... annotations) {
+ super(annotations);
+ this.element = element;
+ this.prefixIdentifier = prefixIdentifier;
+ this.prefixTed = prefixTed;
+ }
+
+ @Override
+ public Element element() {
+ return element;
+ }
+
+ @Override
+ public PrefixIdentifier prefixIdentifier() {
+ return prefixIdentifier;
+ }
+
+ @Override
+ public PrefixTed prefixTed() {
+ return prefixTed;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(element, prefixIdentifier, prefixTed);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultDevicePrefix) {
+ final DefaultDevicePrefix other = (DefaultDevicePrefix) obj;
+ return Objects.equals(this.element.id(), other.element.id()) &&
+ Objects.equals(this.prefixIdentifier, other.prefixIdentifier) &&
+ Objects.equals(this.prefixTed, other.prefixTed) &&
+ Objects.equals(this.annotations(), other.annotations());
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("element", element.id())
+ .add("prefixIdentifier", prefixIdentifier)
+ .add("prefixTed", prefixTed)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultIpDevice.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultIpDevice.java new file mode 100644 index 00000000..a2d0165c --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultIpDevice.java @@ -0,0 +1,113 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.AbstractElement;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.provider.ProviderId;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Default ip device model implementation.
+ */
+public class DefaultIpDevice extends AbstractElement implements IpDevice {
+
+ private final Type type;
+ private final IpDeviceIdentifier deviceIdentifier;
+ private final DeviceTed deviceTed;
+
+
+ /**
+ * For Serialization.
+ */
+ private DefaultIpDevice() {
+ this.type = null;
+ this.deviceIdentifier = null;
+ this.deviceTed = null;
+ }
+
+ /**
+ * Creates a network element attributed to the specified provider.
+ *
+ * @param providerId identity of the provider
+ * @param id device identifier
+ * @param type device type
+ * @param deviceIdentifier provides device identifier details
+ * @param deviceTed device traffic engineering parameters
+ * @param annotations optional key/value annotations
+ */
+ public DefaultIpDevice(ProviderId providerId, DeviceId id, Type type,
+ IpDeviceIdentifier deviceIdentifier, DeviceTed deviceTed,
+ Annotations... annotations) {
+ super(providerId, id, annotations);
+ this.type = type;
+ this.deviceIdentifier = deviceIdentifier;
+ this.deviceTed = deviceTed;
+ }
+
+ @Override
+ public DeviceId id() {
+ return (DeviceId) id;
+ }
+
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ @Override
+ public IpDeviceIdentifier deviceIdentifier() {
+ return deviceIdentifier;
+ }
+
+ @Override
+ public DeviceTed deviceTed() {
+ return deviceTed; }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(type, deviceIdentifier, deviceTed);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof DefaultIpDevice) {
+ final DefaultIpDevice other = (DefaultIpDevice) obj;
+ return Objects.equals(this.id, other.id) &&
+ Objects.equals(this.type, other.type) &&
+ Objects.equals(this.deviceIdentifier, other.deviceIdentifier) &&
+ Objects.equals(this.deviceTed, other.deviceTed);
+ }
+ return false;
+ }
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("id", id)
+ .add("deviceIdentifier", deviceIdentifier)
+ .add("deviceTed", deviceTed)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultIpLink.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultIpLink.java new file mode 100644 index 00000000..41f06047 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DefaultIpLink.java @@ -0,0 +1,105 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.AbstractModel;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.provider.ProviderId;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * This class provides Link identifier and link ted details.
+ */
+public class DefaultIpLink extends AbstractModel implements IpLink {
+
+ private final TerminationPoint src;
+ private final TerminationPoint dst;
+ private final IpLinkIdentifier linkIdentifier;
+ private final LinkTed linkTed;
+
+ /**
+ * Constructor to initialize its parameters.
+ *
+ * @param src link source termination point
+ * @param dst link destination termination point
+ * @param linkIdentifier provides link identifier details
+ * @param linkTed provides link traffic engineering details
+ * @param annotations optional key/value annotations
+ */
+ public DefaultIpLink(ProviderId providerId, TerminationPoint src, TerminationPoint dst,
+ IpLinkIdentifier linkIdentifier, LinkTed linkTed,
+ Annotations... annotations) {
+ super(providerId, annotations);
+ this.src = src;
+ this.dst = dst;
+ this.linkIdentifier = linkIdentifier;
+ this.linkTed = linkTed;
+ }
+
+ @Override
+ public TerminationPoint src() {
+ return src;
+ }
+
+ @Override
+ public TerminationPoint dst() {
+ return dst;
+ }
+
+ @Override
+ public IpLinkIdentifier linkIdentifier() {
+ return linkIdentifier;
+ }
+
+ @Override
+ public LinkTed linkTed() {
+ return linkTed;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(src, dst, linkIdentifier, linkTed);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultIpLink) {
+ final DefaultIpLink other = (DefaultIpLink) obj;
+ return Objects.equals(this.src, other.src) &&
+ Objects.equals(this.dst, other.dst) &&
+ Objects.equals(this.linkIdentifier, other.linkIdentifier) &&
+ Objects.equals(this.linkTed, other.linkTed);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("src", src)
+ .add("dst", dst)
+ .add("linkIdentifier", linkIdentifier)
+ .add("linkTed", linkTed)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceInterface.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceInterface.java new file mode 100644 index 00000000..131aa623 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceInterface.java @@ -0,0 +1,100 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import java.util.Objects;
+
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip6Address;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Representation of device interface.
+ */
+public class DeviceInterface {
+ private final Ip4Address ip4Address;
+ private final Ip6Address ip6Address;
+ private final InterfaceIdentifier interfaceId;
+
+ /**
+ * Constructor to initialize its parameter.
+ *
+ * @param ip4Address ipv4 interface address
+ * @param ip6Address ipv6 interface address
+ * @param interfaceId interface Identifier
+ */
+ public DeviceInterface(Ip4Address ip4Address, Ip6Address ip6Address, InterfaceIdentifier interfaceId) {
+ this.ip4Address = ip4Address;
+ this.ip6Address = ip6Address;
+ this.interfaceId = interfaceId;
+ }
+
+ /**
+ * obtains ipv4 address of an interface.
+ *
+ * @return ipv4 interface address
+ */
+ public Ip4Address ip4Address() {
+ return ip4Address;
+ }
+
+ /**
+ * obtains ipv6 interface address.
+ *
+ * @return ipv6 interface address
+ */
+ public Ip6Address ip6Address() {
+ return ip6Address;
+ }
+
+ /**
+ * obtains interface identifier.
+ *
+ * @return interface identifier
+ */
+ public InterfaceIdentifier interfaceId() {
+ return interfaceId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ip4Address, ip6Address, interfaceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DeviceInterface) {
+ final DeviceInterface other = (DeviceInterface) obj;
+ return Objects.equals(this.ip4Address, other.ip4Address)
+ && Objects.equals(this.ip6Address, other.ip6Address)
+ && Objects.equals(this.interfaceId, other.interfaceId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("ip4Address", ip4Address)
+ .add("ip6Address", ip6Address)
+ .add("interfaceId", interfaceId)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceIntf.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceIntf.java new file mode 100644 index 00000000..ff18d3ac --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceIntf.java @@ -0,0 +1,37 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.Element;
+
+/**
+ * Abstraction of Device interface.
+ */
+public interface DeviceIntf {
+ /**
+ * Returns the parent network element to which this interface belongs.
+ *
+ * @return parent network element
+ */
+ Element element();
+
+ /**
+ * Returns device interface details.
+ *
+ * @return device interface details
+ */
+ DeviceInterface deviceInterface();
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DevicePrefix.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DevicePrefix.java new file mode 100644 index 00000000..89efccd4 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DevicePrefix.java @@ -0,0 +1,46 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.Annotated;
+import org.onosproject.net.Element;
+
+/**
+ * Abstraction of Device Prefix.
+ */
+public interface DevicePrefix extends Annotated {
+
+ /**
+ * Returns the parent network element to which this port belongs.
+ *
+ * @return parent network element
+ */
+ Element element();
+
+ /**
+ * Returns prefix identifier details.
+ *
+ * @return prefix identifier details
+ */
+ PrefixIdentifier prefixIdentifier();
+
+ /**
+ * Returns prefix Traffic engineering parameters.
+ *
+ * @return prefix Traffic engineering parameters
+ */
+ PrefixTed prefixTed();
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceTed.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceTed.java new file mode 100644 index 00000000..4d9da55d --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DeviceTed.java @@ -0,0 +1,173 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Iterator; +import java.util.List; +import java.util.Objects; + +import org.onlab.packet.Ip4Address; +import org.onlab.packet.Ip6Address; + +/** + * Represents Device Traffic Engineering parameters. + */ +public class DeviceTed { + private final List<Ip4Address> ipv4RouterIds; + private final List<Ip6Address> ipv6RouterIds; + private final List<TopologyId> topologyIds; + private final Position position; + + /** + * Constructor to initialize the parameter fields. + * + * @param ipv4RouterIds Router ids of Ipv4 + * @param ipv6RouterIds Router ids of Ipv6 + * @param topologyIds list of multi-topology IDs of the node + * @param position of router whether it is ABR or ASBR + */ + public DeviceTed(List<Ip4Address> ipv4RouterIds, List<Ip6Address> ipv6RouterIds, + List<TopologyId> topologyIds, Position position) { + this.ipv4RouterIds = ipv4RouterIds; + this.ipv6RouterIds = ipv6RouterIds; + this.topologyIds = topologyIds; + this.position = position; + } + + /** + * Obtain list of Ipv4 Router id. + * + * @return Ipv4 Router ids + */ + public List<Ip4Address> ipv4RouterIds() { + return ipv4RouterIds; + } + + /** + * Obtain list of Ipv6 Router id. + * + * @return Ipv6 Router ids + */ + public List<Ip6Address> ipv6RouterIds() { + return ipv6RouterIds; + } + + /** + * Obtain the list of topology ID's. + * + * @return list of topology id's + */ + public List<TopologyId> topologyIds() { + return topologyIds; + } + + + /** + * Obtain position of device in the network. + * + * @return position of device in the network + */ + public Position position() { + return position; + } + + @Override + public int hashCode() { + return Objects.hash(ipv4RouterIds, ipv6RouterIds, topologyIds, position); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof DeviceTed) { + int countObjSubTlv = 0; + int countOtherSubTlv = 0; + int countObjTopologyId = 0; + int countOtherTopologyId = 0; + boolean isCommonSubTlv = true; + boolean isCommonSubTlv6 = true; + boolean isCommonTopology = true; + DeviceTed other = (DeviceTed) obj; + Iterator<Ip4Address> objListIterator = other.ipv4RouterIds.iterator(); + countOtherSubTlv = other.ipv4RouterIds.size(); + countObjSubTlv = ipv4RouterIds.size(); + + Iterator<Ip6Address> objListIteratorIpv6 = other.ipv6RouterIds.iterator(); + int countOtherSubTlv6 = other.ipv6RouterIds.size(); + int countObjSubTlv6 = ipv6RouterIds.size(); + + Iterator<TopologyId> topologyId = other.topologyIds.iterator(); + countOtherTopologyId = other.topologyIds.size(); + countObjTopologyId = topologyIds.size(); + + if (countObjSubTlv != countOtherSubTlv || countOtherSubTlv6 != countObjSubTlv6 + || countObjTopologyId != countOtherTopologyId) { + return false; + } else { + while (objListIterator.hasNext() && isCommonSubTlv) { + Ip4Address subTlv = objListIterator.next(); + //find index of that element and then get that from the list and then compare + if (ipv4RouterIds.contains(subTlv) && other.ipv4RouterIds.contains(subTlv)) { + isCommonSubTlv = Objects.equals(ipv4RouterIds.get(ipv4RouterIds.indexOf(subTlv)), + other.ipv4RouterIds.get(other.ipv4RouterIds.indexOf(subTlv))); + } else { + isCommonSubTlv = false; + } + } + while (objListIteratorIpv6.hasNext() && isCommonSubTlv6) { + Ip6Address subTlv = objListIteratorIpv6.next(); + //find index of that element and then get that from the list and then compare + if (ipv6RouterIds.contains(subTlv) && other.ipv6RouterIds.contains(subTlv)) { + isCommonSubTlv6 = Objects.equals(ipv6RouterIds.get(ipv6RouterIds.indexOf(subTlv)), + other.ipv6RouterIds.get(other.ipv6RouterIds.indexOf(subTlv))); + } else { + isCommonSubTlv6 = false; + } + } + while (topologyId.hasNext() && isCommonTopology) { + TopologyId subTlv = topologyId.next(); + //find index of that element and then get that from the list and then compare + if (topologyIds.contains(subTlv) && other.topologyIds.contains(subTlv)) { + isCommonTopology = Objects.equals(topologyIds.get(topologyIds.indexOf(subTlv)), + other.topologyIds.get(other.topologyIds.indexOf(subTlv))); + } else { + isCommonTopology = false; + } + } + return isCommonSubTlv && isCommonSubTlv6 && isCommonTopology + && Objects.equals(position, other.position); + } + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .omitNullValues() + .add("ipv6RouterIds", ipv6RouterIds) + .add("ipv4RouterIds", ipv4RouterIds) + .add("topologyIds", topologyIds) + .add("position", position) + .toString(); + } + +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DomainId.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DomainId.java new file mode 100644 index 00000000..4fb10701 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/DomainId.java @@ -0,0 +1,71 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Domain Identifier(32 Bit).
+ */
+public class DomainId {
+ private final int domainIdentifier;
+
+ /**
+ * Constructor to initialize domain identifier.
+ *
+ * @param domainIdentifier domain identifier
+ */
+ public DomainId(int domainIdentifier) {
+ this.domainIdentifier = domainIdentifier;
+ }
+
+ /**
+ * Obtain domain identifier.
+ *
+ * @return domain identifier
+ */
+ public int domainIdentifier() {
+ return domainIdentifier;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(domainIdentifier);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof DomainId) {
+ DomainId other = (DomainId) obj;
+ return Objects.equals(domainIdentifier, other.domainIdentifier);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("domainIdentifier", domainIdentifier)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/ExtendedRouteTag.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/ExtendedRouteTag.java new file mode 100644 index 00000000..9bd87c1b --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/ExtendedRouteTag.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents the extended igp administrative tags of the prefix. + */ +public class ExtendedRouteTag { + private final long extRouteTag; + + /** + * Constructor to initialize its parameter. + * + * @param extRouteTag extended ISIS route tag + */ + public ExtendedRouteTag(long extRouteTag) { + this.extRouteTag = extRouteTag; + } + + /** + * Obtains extended igp administrative tags. + * + * @return extended igp administrative tags + */ + public long extRouteTag() { + return extRouteTag; + } + + @Override + public int hashCode() { + return Objects.hash(extRouteTag); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof ExtendedRouteTag) { + ExtendedRouteTag other = (ExtendedRouteTag) obj; + return Objects.equals(extRouteTag, other.extRouteTag); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("extRouteTag", extRouteTag) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IgpFlags.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IgpFlags.java new file mode 100644 index 00000000..59084c04 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IgpFlags.java @@ -0,0 +1,114 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * This class provides implementation IS-IS and OSPF flags assigned to the prefix. + */ +public class IgpFlags { + private final boolean isisUpDown; + private final boolean ospfNoUnicast; + private final boolean ospfLclAddr; + private final boolean ospfNssa; + + /** + * Constructor to initialize its parameters. + * + * @param isisUpDown IS-IS Up/Down + * @param ospfNoUnicast OSPF no unicast + * @param ospfLclAddr OSPF local address + * @param ospfNssa OSPF propagate NSSA + */ + public IgpFlags(boolean isisUpDown, boolean ospfNoUnicast, boolean ospfLclAddr, + boolean ospfNssa) { + this.isisUpDown = isisUpDown; + this.ospfNoUnicast = ospfNoUnicast; + this.ospfLclAddr = ospfLclAddr; + this.ospfNssa = ospfNssa; + } + + /** + * Provides information whether IS-IS is Up/Down. + * + * @return IS-IS Up/Down bit enabled or not + */ + public boolean isisUpDown() { + return isisUpDown; + } + + /** + * Provides information whether OSPF is unicast or not. + * + * @return OSPF no unicast Bit set or not + */ + public boolean ospfNoUnicast() { + return ospfNoUnicast; + } + + /** + * Provides information on OSPF local address. + * + * @return OSPF local address Bit set or not + */ + public boolean ospfLclAddr() { + return ospfLclAddr; + } + + /** + * Provides information on OSPF propagate NSSA. + * + * @return OSPF propagate NSSA Bit set or not + */ + public boolean ospfNssa() { + return ospfNssa; + } + + @Override + public int hashCode() { + return Objects.hash(isisUpDown, ospfNoUnicast, ospfLclAddr, + ospfNssa); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof IgpFlags) { + IgpFlags other = (IgpFlags) obj; + return Objects.equals(isisUpDown, other.isisUpDown) + && Objects.equals(ospfNoUnicast, other.ospfNoUnicast) + && Objects.equals(ospfLclAddr, other.ospfLclAddr) + && Objects.equals(ospfNssa, other.ospfNssa); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("isisUpDown", isisUpDown) + .add("ospfNoUnicast", ospfNoUnicast) + .add("ospfLclAddr", ospfLclAddr) + .add("ospfNssa", ospfNssa) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/InterfaceIdentifier.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/InterfaceIdentifier.java new file mode 100644 index 00000000..405e1417 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/InterfaceIdentifier.java @@ -0,0 +1,71 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * This class provides information on Local Interface Identifier and Remote + * Interface Identifier of the link. + */ +public class InterfaceIdentifier { + private final Integer identifier; + + /** + * Constructor to initialize identifier. + * + * @param identifier local/remote interface identifier + */ + public InterfaceIdentifier(Integer identifier) { + this.identifier = identifier; + } + + /** + * Provides the local/remote interface identifier of the link. + * + * @return interface identifier + */ + public Integer identifier() { + return identifier; + } + + @Override + public int hashCode() { + return Objects.hash(identifier); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof InterfaceIdentifier) { + InterfaceIdentifier other = (InterfaceIdentifier) obj; + return Objects.equals(identifier, other.identifier); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("identifier", identifier) + .toString(); + } +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpDevice.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpDevice.java new file mode 100644 index 00000000..131b7eae --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpDevice.java @@ -0,0 +1,68 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Element;
+
+/**
+ * Abstraction of Ip Device.
+ */
+public interface IpDevice extends Element {
+ /**
+ ** Enum type to store Device Type.
+ */
+ enum Type {
+ /**
+ * Signifies that the device is pseudo device.
+ */
+ PSEUDO,
+
+ /**
+ * Signifies that the device is non-pseudo device.
+ */
+ NONPSEUDO;
+ }
+
+ /**
+ * Obtains device id.
+ *
+ * @return device id
+ */
+ @Override
+ DeviceId id();
+
+ /**
+ * Obtains device type.
+ *
+ * @return device type
+ */
+ Type type();
+
+ /**
+ * Obtains Device identifier details.
+ *
+ * @return identifier of the device
+ */
+ IpDeviceIdentifier deviceIdentifier();
+
+ /**
+ * Obtains the traffic engineering parameters of the device.
+ *
+ * @return traffic engineering parameters of the device
+ */
+ DeviceTed deviceTed();
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpDeviceIdentifier.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpDeviceIdentifier.java new file mode 100644 index 00000000..472fe008 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpDeviceIdentifier.java @@ -0,0 +1,141 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Represents IP Device Identifiers.
+ */
+public class IpDeviceIdentifier {
+
+ private final RouteDistinguisher routeDish;
+ private final RouteInstance routeInstance;
+ private final AsNumber asNum;
+ private final DomainId domainIdentifier;
+ private final AreaId areaId;
+ private final RouteIdentifier routerIdentifier;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param routeInstance routing protocol instance
+ * @param asNum AS number
+ * @param domainIdentifier BGP-LS domain
+ * @param areaId Area ID
+ * @param routerIdentifier IGP router ID
+ */
+ public IpDeviceIdentifier(RouteDistinguisher routeDish, RouteInstance routeInstance, AsNumber asNum,
+ DomainId domainIdentifier, AreaId areaId, RouteIdentifier routerIdentifier) {
+ this.routeDish = routeDish;
+ this.areaId = areaId;
+ this.asNum = asNum;
+ this.domainIdentifier = domainIdentifier;
+ this.routeInstance = routeInstance;
+ this.routerIdentifier = routerIdentifier;
+ }
+
+ /**
+ * Obtains Route Distinguisher of Ip Device.
+ *
+ * @return Area ID
+ */
+ public RouteDistinguisher routeDish() {
+ return routeDish;
+ }
+
+ /**
+ * Obtains Area ID if Ip Device.
+ *
+ * @return Area ID
+ */
+ public AreaId areaId() {
+ return areaId;
+ }
+
+ /**
+ * Obtains AS number of Ip Device.
+ *
+ * @return AS number
+ */
+ public AsNumber asNum() {
+ return asNum;
+ }
+
+ /**
+ * Obtains domain identifier of Ip Device.
+ *
+ * @return domain identifier
+ */
+ public DomainId domainIdentifier() {
+ return domainIdentifier;
+ }
+
+ /**
+ * Obtains Router id of Ip Device.
+ *
+ * @return Router id
+ */
+ public RouteIdentifier routerIdentifier() {
+ return routerIdentifier;
+ }
+
+ /**
+ * Obtains routing protocol instance.
+ *
+ * @return routing protocol instance
+ */
+ public RouteInstance routeInstance() {
+ return routeInstance;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(routeDish, areaId, asNum, domainIdentifier, routerIdentifier, routeInstance);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof IpDeviceIdentifier) {
+ IpDeviceIdentifier other = (IpDeviceIdentifier) obj;
+ return Objects.equals(areaId, other.areaId) && Objects.equals(asNum, other.asNum)
+ && Objects.equals(domainIdentifier, other.domainIdentifier)
+ && Objects.equals(routerIdentifier, other.routerIdentifier)
+ && Objects.equals(routeInstance, other.routeInstance)
+ && Objects.equals(routeDish, other.routeDish);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("areaId", areaId)
+ .add("asNum", asNum)
+ .add("domainIdentifier", domainIdentifier)
+ .add("routerIdentifier", routerIdentifier)
+ .add("routeInstance", routeInstance)
+ .add("routeDish", routeDish)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpLink.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpLink.java new file mode 100644 index 00000000..d632d2db --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpLink.java @@ -0,0 +1,54 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import org.onosproject.net.Annotated;
+import org.onosproject.net.NetworkResource;
+import org.onosproject.net.Provided;
+
+/**
+ * Abstraction of a network ip link.
+ */
+public interface IpLink extends Annotated, Provided, NetworkResource {
+
+ /**
+ * Returns source termination point of link.
+ *
+ * @return source termination point of link
+ */
+ TerminationPoint src();
+
+ /**
+ * Returns destination termination point of link.
+ *
+ * @return destination termination point of link
+ */
+ TerminationPoint dst();
+
+ /**
+ * Returns link identifier details.
+ *
+ * @return link identifier details
+ */
+ IpLinkIdentifier linkIdentifier();
+
+ /**
+ * Returns the link traffic engineering parameters.
+ *
+ * @return links traffic engineering parameters
+ */
+ LinkTed linkTed();
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpLinkIdentifier.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpLinkIdentifier.java new file mode 100644 index 00000000..8522f945 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpLinkIdentifier.java @@ -0,0 +1,161 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip6Address;
+
+/**
+ * Represents Ip Link Identifier.
+ */
+public class IpLinkIdentifier {
+ private final InterfaceIdentifier localIndentifier;
+ private final InterfaceIdentifier remoteIndentifier;
+ private final Ip4Address localIpv4Addr;
+ private final Ip4Address remoteIpv4Addr;
+ private final Ip6Address localIpv6Addr;
+ private final Ip6Address remoteIpv6Addr;
+ private final TopologyId topologyId;
+
+ /**
+ * Constructor to initialize its parameters.
+ *
+ * @param localIndentifier local interface identifier of the link
+ * @param remoteIndentifier remote interface identifier of the link
+ * @param localIpv4Addr local IPv4 address of the link
+ * @param remoteIpv4Addr remote IPv4 address of the link
+ * @param localIpv6Addr local IPv6 address of the link
+ * @param remoteIpv6Addr remote IPv6 address of the link
+ * @param topologyId link topology identifier
+ */
+ public IpLinkIdentifier(InterfaceIdentifier localIndentifier, InterfaceIdentifier remoteIndentifier,
+ Ip4Address localIpv4Addr, Ip4Address remoteIpv4Addr, Ip6Address localIpv6Addr,
+ Ip6Address remoteIpv6Addr, TopologyId topologyId) {
+ this.localIndentifier = localIndentifier;
+ this.remoteIndentifier = remoteIndentifier;
+ this.localIpv4Addr = localIpv4Addr;
+ this.remoteIpv4Addr = remoteIpv4Addr;
+ this.localIpv6Addr = localIpv6Addr;
+ this.remoteIpv6Addr = remoteIpv6Addr;
+ this.topologyId = topologyId;
+ }
+
+ /**
+ * Obtains link local identifier.
+ *
+ * @return link local identifier
+ */
+ public InterfaceIdentifier localIndentifier() {
+ return localIndentifier;
+ }
+
+ /**
+ * Obtains link local identifier.
+ *
+ * @return link local identifier
+ */
+ public InterfaceIdentifier remoteIndentifier() {
+ return remoteIndentifier;
+ }
+
+ /**
+ * Obtains local IPv4 address of the link.
+ *
+ * @return local IPv4 address of the link
+ */
+ public Ip4Address localIpv4Addr() {
+ return localIpv4Addr;
+ }
+
+ /**
+ * Obtains remote IPv4 address of the link.
+ *
+ * @return remote IPv4 address of the link
+ */
+ public Ip4Address remoteIpv4Addr() {
+ return remoteIpv4Addr;
+ }
+
+ /**
+ * Obtains local IPv6 address of the link.
+ *
+ * @return local IPv6 address of the link
+ */
+ public Ip6Address localIpv6Addr() {
+ return localIpv6Addr;
+ }
+
+ /**
+ * Obtains remote IPv6 address of the link.
+ *
+ * @return remote IPv6 address of the link
+ */
+ public Ip6Address remoteIpv6Addr() {
+ return remoteIpv6Addr;
+ }
+
+ /**
+ * Obtains Topology ID of the link.
+ *
+ * @return Topology ID of the link
+ */
+ public TopologyId topologyId() {
+ return topologyId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localIndentifier, remoteIndentifier, localIpv4Addr, remoteIpv4Addr,
+ localIpv6Addr, remoteIpv6Addr, topologyId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof IpLinkIdentifier) {
+ IpLinkIdentifier other = (IpLinkIdentifier) obj;
+ return Objects.equals(topologyId, other.topologyId)
+ && Objects.equals(localIndentifier, other.localIndentifier)
+ && Objects.equals(remoteIndentifier, other.remoteIndentifier)
+ && Objects.equals(localIpv4Addr, other.localIpv4Addr)
+ && Objects.equals(remoteIpv4Addr, other.remoteIpv4Addr)
+ && Objects.equals(localIpv6Addr, other.localIpv6Addr)
+ && Objects.equals(remoteIpv6Addr, other.remoteIpv6Addr);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("localIndentifier", localIndentifier)
+ .add("remoteIndentifier", remoteIndentifier)
+ .add("localIpv4Addr", localIpv4Addr)
+ .add("remoteIpv4Addr", remoteIpv4Addr)
+ .add("localIpv6Addr", localIpv6Addr)
+ .add("remoteIpv6Addr", remoteIpv6Addr)
+ .add("topologyId", topologyId)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpReachability.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpReachability.java new file mode 100644 index 00000000..8fdd4d31 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IpReachability.java @@ -0,0 +1,73 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.packet.IpPrefix; + +/** + * Provides information of IP address prefix in the IGP topology and a router advertises + * this to each of its BGP nexthop. + */ +public class IpReachability { + private final IpPrefix ipPrefix; + + /** + * Constructor to initialize IP prefix. + * + * @param ipPrefix IP address prefix + */ + public IpReachability(IpPrefix ipPrefix) { + this.ipPrefix = ipPrefix; + } + + /** + * Provides IP Address prefix reachability. + * + * @return IP Address prefix + */ + public IpPrefix ipPrefix() { + return ipPrefix; + } + + @Override + public int hashCode() { + return Objects.hash(ipPrefix); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof IpReachability) { + IpReachability other = (IpReachability) obj; + return Objects.equals(ipPrefix, other.ipPrefix); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("ipPrefix", ipPrefix) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IsIsPseudonode.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IsIsPseudonode.java new file mode 100644 index 00000000..064d830b --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IsIsPseudonode.java @@ -0,0 +1,93 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents the Pseudonode information of device in ISIS domain. + */ +public class IsIsPseudonode implements RouteIdentifier { + private final IsoNodeId isoNodeId; + private final byte psnIdentifier; + private final ProtocolType type; + + /** + * Constructor to initialize the values. + * + * @param isoNodeId ISO system-ID + * @param psnIdentifier Pseudonode identifier + * @param type Protocol ID + */ + public IsIsPseudonode(IsoNodeId isoNodeId, byte psnIdentifier, ProtocolType type) { + this.isoNodeId = isoNodeId; + this.psnIdentifier = psnIdentifier; + this.type = type; + } + + /** + * Obtains iso system id of Pseudonode of device in ISIS domain. + * + * @return ISO system Id + */ + public IsoNodeId isoNodeId() { + return isoNodeId; + } + + /** + * Obtains Pseudonode identifier. + * + * @return Pseudonode identifier + */ + public byte psnIdentifier() { + return psnIdentifier; + } + + @Override + public ProtocolType type() { + return type; + } + + @Override + public int hashCode() { + return Objects.hash(isoNodeId, psnIdentifier, type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof IsIsPseudonode) { + IsIsPseudonode other = (IsIsPseudonode) obj; + return Objects.equals(isoNodeId, other.isoNodeId) && Objects.equals(psnIdentifier, other.psnIdentifier) + && Objects.equals(type, other.type); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("isoNodeId", isoNodeId) + .add("psnIdentifier", psnIdentifier) + .add("type", type) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IsoNodeId.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IsoNodeId.java new file mode 100644 index 00000000..8bb3d8b9 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/IsoNodeId.java @@ -0,0 +1,79 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents ISO system id of the device. + */ +public class IsoNodeId implements RouteIdentifier { + private final byte[] isoNodeId; + private final ProtocolType type; + + /** + * Constructor to initialize the values. + * + * @param isoNodeId ISO system-ID + * @param type Protocol type + */ + public IsoNodeId(byte[] isoNodeId, ProtocolType type) { + this.isoNodeId = isoNodeId; + this.type = type; + } + + /** + * Obtains ISO system id of the device. + * + * @return ISO system id + */ + public byte[] isoNodeId() { + return isoNodeId; + } + + @Override + public ProtocolType type() { + return type; + } + + @Override + public int hashCode() { + return Objects.hash(isoNodeId, type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof IsoNodeId) { + IsoNodeId other = (IsoNodeId) obj; + return Objects.equals(isoNodeId, other.isoNodeId) && Objects.equals(type, other.type); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("isoNodeId", isoNodeId) + .add("type", type) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/LinkTed.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/LinkTed.java new file mode 100644 index 00000000..3a686034 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/LinkTed.java @@ -0,0 +1,349 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Iterator; +import java.util.List; +import java.util.Objects; + +import org.onlab.packet.Ip4Address; +import org.onlab.packet.Ip6Address; +import org.onlab.util.Bandwidth; + +/** + * Represents Link Traffic engineering parameters. + */ +public class LinkTed { + private final Bandwidth maximumLink; + private final Bandwidth maxReserved; + private final List<Bandwidth> maxUnResBandwidth; + private final Metric teMetric; + private final Metric igpMetric; + private final List<Ip4Address> ipv4LocRouterId; + private final List<Ip6Address> ipv6LocRouterId; + private final List<Ip4Address> ipv4RemRouterId; + private final List<Ip6Address> ipv6RemRouterId; + private final Color color; + private final Signalling signalType; + private final List<Srlg> srlgGroup; + private final ProtectionType protectType; + + /** + * Constructor to initialize its parameter. + * + * @param maximumLink maximum bandwidth can be used + * @param maxReserved max bandwidth that can be reserved + * @param maxUnResBandwidth amount of bandwidth reservable + * @param teMetric Traffic engineering metric + * @param igpMetric IGP metric + * @param color information on administrative group assigned to the interface + * @param signalType MPLS signaling protocols + * @param srlgGroup Shared Risk Link Group information + * @param protectType protection capabilities of the link + * @param ipv4LocRouterId IPv4 router-Id of local node + * @param ipv6LocRouterId IPv6 router-Id of local node + * @param ipv4RemRouterId IPv4 router-Id of remote node + * @param ipv6RemRouterId IPv6 router-Id of remote node + */ + public LinkTed(Bandwidth maximumLink, Bandwidth maxReserved, List<Bandwidth> maxUnResBandwidth, + Metric teMetric, Metric igpMetric, Color color, Signalling signalType, List<Srlg> srlgGroup, + ProtectionType protectType, List<Ip4Address> ipv4LocRouterId, List<Ip6Address> ipv6LocRouterId, + List<Ip4Address> ipv4RemRouterId, List<Ip6Address> ipv6RemRouterId) { + this.maximumLink = maximumLink; + this.maxReserved = maxReserved; + this.maxUnResBandwidth = maxUnResBandwidth; + this.teMetric = teMetric; + this.igpMetric = igpMetric; + this.color = color; + this.signalType = signalType; + this.srlgGroup = srlgGroup; + this.protectType = protectType; + this.ipv4LocRouterId = ipv4LocRouterId; + this.ipv6LocRouterId = ipv6LocRouterId; + this.ipv4RemRouterId = ipv4RemRouterId; + this.ipv6RemRouterId = ipv6RemRouterId; + } + + /** + * Provides maximum bandwidth can be used on the link. + * + * @return maximum bandwidth + */ + public Bandwidth maximumLink() { + return maximumLink; + } + + /** + * Amount of bandwidth reservable on the link. + * + * @return unreserved bandwidth + */ + public List<Bandwidth> maxUnResBandwidth() { + return maxUnResBandwidth; + } + + /** + * Provides max bandwidth that can be reserved on the link. + * + * @return max bandwidth reserved + */ + public Bandwidth maxReserved() { + return maxReserved; + } + + /** + * Provides Traffic engineering metric for the link. + * + * @return Traffic engineering metric + */ + public Metric teMetric() { + return teMetric; + } + + /** + * Provides IGP metric for the link. + * + * @return IGP metric + */ + public Metric igpMetric() { + return igpMetric; + } + + /** + * Provides protection capabilities of the link. + * + * @return link protection type + */ + public ProtectionType protectType() { + return protectType; + } + + /** + * Provides Shared Risk Link Group information. + * + * @return Shared Risk Link Group value + */ + public List<Srlg> srlgGroup() { + return srlgGroup; + } + + /** + * Provides which MPLS signaling protocols are enabled. + * + * @return signal type + */ + public Signalling signalType() { + return signalType; + } + + /** + * Provides information on administrative group assigned to the interface. + * + * @return 4-octect bit mask assigned by network administrator + */ + public Color color() { + return color; + } + + /** + * Provides IPv4 router-Id of local node. + * + * @return IPv4 router-Id of local node + */ + public List<Ip4Address> ipv4LocRouterId() { + return ipv4LocRouterId; + } + + /** + * Provides IPv6 router-Id of local node. + * + * @return IPv6 router-Id of local node + */ + public List<Ip6Address> ipv6LocRouterId() { + return ipv6LocRouterId; + } + + /** + * Provides IPv4 router-Id of remote node. + * + * @return IPv4 router-Id of remote node + */ + public List<Ip4Address> ipv4RemRouterId() { + return ipv4RemRouterId; + } + + /** + * Provides IPv6 router-Id of remote node. + * + * @return IPv6 router-Id of remote node + */ + public List<Ip6Address> ipv6RemRouterId() { + return ipv6RemRouterId; + } + + @Override + public int hashCode() { + return Objects.hash(maximumLink, maxReserved, maxUnResBandwidth, teMetric, igpMetric, + ipv4LocRouterId, ipv6LocRouterId, ipv4RemRouterId, ipv6RemRouterId, + color, signalType, srlgGroup, protectType); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof LinkTed) { + int countCommonBandwidth = 0; + int countOtherCommonBandwidth = 0; + int countOther4LocRouterId = 0; + int countCommon4LocRouterId = 0; + int countOther6RemRouterId = 0; + int countCommon6RemRouterId = 0; + int countOther4RemRouterId = 0; + int countCommon4RemRouterId = 0; + int countCommon6LocRouterId = 0; + int countOther6LocRouterId = 0; + int countCommonSrlg = 0; + int countOtherSrlg = 0; + boolean isCommonBandwidth = true; + boolean isCommonIp4Loc = true; + boolean isCommonIp4Rem = true; + boolean isCommonIp6Loc = true; + boolean isCommonIp6Rem = true; + boolean isCommonSrlg = true; + LinkTed other = (LinkTed) obj; + Iterator<Bandwidth> objListIterator = other.maxUnResBandwidth.iterator(); + countOtherCommonBandwidth = other.maxUnResBandwidth.size(); + countCommonBandwidth = maxUnResBandwidth.size(); + + Iterator<Ip4Address> ipv4local = other.ipv4LocRouterId.iterator(); + countOther4LocRouterId = other.ipv4LocRouterId.size(); + countCommon4LocRouterId = ipv4LocRouterId.size(); + + Iterator<Ip4Address> ipv4remote = other.ipv4RemRouterId.iterator(); + countOther4RemRouterId = other.ipv4RemRouterId.size(); + countCommon4RemRouterId = ipv4RemRouterId.size(); + + Iterator<Ip6Address> ipv6local = other.ipv6LocRouterId.iterator(); + countOther6LocRouterId = other.ipv6LocRouterId.size(); + countCommon6LocRouterId = ipv6LocRouterId.size(); + + Iterator<Ip6Address> ipv6remote = other.ipv6RemRouterId.iterator(); + countOther6RemRouterId = other.ipv6RemRouterId.size(); + countCommon6RemRouterId = ipv6RemRouterId.size(); + + Iterator<Srlg> srlg = other.srlgGroup.iterator(); + countOtherSrlg = other.srlgGroup.size(); + countCommonSrlg = srlgGroup.size(); + + if (countOtherCommonBandwidth != countCommonBandwidth + || countOther4LocRouterId != countCommon4LocRouterId + || countOther4RemRouterId != countCommon4RemRouterId + || countOther6LocRouterId != countCommon6LocRouterId + || countOther6RemRouterId != countCommon6RemRouterId + || countOtherSrlg != countCommonSrlg) { + return false; + } else { + while (objListIterator.hasNext() && isCommonBandwidth) { + Bandwidth subTlv = objListIterator.next(); + if (maxUnResBandwidth.contains(subTlv) && other.maxUnResBandwidth.contains(subTlv)) { + isCommonBandwidth = Objects.equals(maxUnResBandwidth.get(maxUnResBandwidth.indexOf(subTlv)), + other.maxUnResBandwidth.get(other.maxUnResBandwidth.indexOf(subTlv))); + } else { + isCommonBandwidth = false; + } + } + while (ipv4local.hasNext() && isCommonIp4Loc) { + Ip4Address subTlv = ipv4local.next(); + if (ipv4LocRouterId.contains(subTlv) && other.ipv4LocRouterId.contains(subTlv)) { + isCommonIp4Loc = Objects.equals(ipv4LocRouterId.get(ipv4LocRouterId.indexOf(subTlv)), + other.ipv4LocRouterId.get(other.ipv4LocRouterId.indexOf(subTlv))); + } else { + isCommonIp4Loc = false; + } + } + while (ipv4remote.hasNext() && isCommonIp4Rem) { + Ip4Address subTlv = ipv4remote.next(); + if (ipv4RemRouterId.contains(subTlv) && other.ipv4RemRouterId.contains(subTlv)) { + isCommonIp4Rem = Objects.equals(ipv4RemRouterId.get(ipv4RemRouterId.indexOf(subTlv)), + other.ipv4RemRouterId.get(other.ipv4RemRouterId.indexOf(subTlv))); + } else { + isCommonIp4Rem = false; + } + } + while (ipv6remote.hasNext() && isCommonIp6Rem) { + Ip6Address subTlv = ipv6remote.next(); + if (ipv6RemRouterId.contains(subTlv) && other.ipv6RemRouterId.contains(subTlv)) { + isCommonIp6Rem = Objects.equals(ipv6RemRouterId.get(ipv6RemRouterId.indexOf(subTlv)), + other.ipv6RemRouterId.get(other.ipv6RemRouterId.indexOf(subTlv))); + } else { + isCommonIp6Rem = false; + } + } + while (ipv6local.hasNext() && isCommonIp6Loc) { + Ip6Address subTlv = ipv6local.next(); + if (ipv6LocRouterId.contains(subTlv) && other.ipv6LocRouterId.contains(subTlv)) { + isCommonIp6Loc = Objects.equals(ipv6LocRouterId.get(ipv6LocRouterId.indexOf(subTlv)), + other.ipv6LocRouterId.get(other.ipv6LocRouterId.indexOf(subTlv))); + } else { + isCommonIp6Loc = false; + } + } + while (srlg.hasNext() && isCommonIp6Loc) { + Srlg subTlv = srlg.next(); + if (srlgGroup.contains(subTlv) && other.srlgGroup.contains(subTlv)) { + isCommonSrlg = Objects.equals(srlgGroup.get(srlgGroup.indexOf(subTlv)), + other.srlgGroup.get(other.srlgGroup.indexOf(subTlv))); + } else { + isCommonSrlg = false; + } + } + return isCommonBandwidth && isCommonIp4Loc && isCommonIp4Rem && isCommonIp6Rem && isCommonIp6Loc + && isCommonSrlg + && Objects.equals(igpMetric, other.igpMetric) + && Objects.equals(teMetric, other.teMetric) + && Objects.equals(maximumLink, other.maximumLink) + && Objects.equals(protectType, other.protectType) + && Objects.equals(color, other.color) + && Objects.equals(signalType, other.signalType); + } + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("igpMetric", igpMetric) + .add("teMetric", teMetric) + .add("maximumLink", maximumLink) + .add("maxReserved", maxReserved) + .add("maxUnResBandwidth", maxUnResBandwidth) + .add("ipv4LocRouterId", ipv4LocRouterId) + .add("ipv4RemRouterId", ipv4RemRouterId) + .add("ipv6LocRouterId", ipv6LocRouterId) + .add("ipv6RemRouterId", ipv6RemRouterId) + .add("protectType", protectType) + .add("color", color) + .add("srlgGroup", srlgGroup) + .add("signalType", signalType) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Metric.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Metric.java new file mode 100644 index 00000000..0af95b01 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Metric.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents Traffic engineering metrics. + */ +public class Metric { + private final Integer metric; + + /** + * Constructor to initialize its metric. + * + * @param metric can be TE metric or IGP metric or Prefix metric + */ + public Metric(Integer metric) { + this.metric = metric; + } + + /** + * Obtains traffic engineering metric. + * + * @return traffic engineering metric + */ + public Integer metric() { + return metric; + } + + @Override + public int hashCode() { + return Objects.hash(metric); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof Metric) { + Metric other = (Metric) obj; + return Objects.equals(metric, other.metric); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("metric", metric) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/OspfPseudonode.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/OspfPseudonode.java new file mode 100644 index 00000000..86d96acb --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/OspfPseudonode.java @@ -0,0 +1,96 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.packet.Ip4Address; + +/** + * Represents Pseudonode information of OSFP device. + */ +public class OspfPseudonode implements RouteIdentifier { + private final RouterId designatedRouter; + private final Ip4Address drInterface; + private final ProtocolType type; + + /** + * Constructor to initialize the values. + * + * @param designatedRouter Router Id of designated router + * @param drInterface IP address of Designated Router interface + * @param type Protocol ID + */ + public OspfPseudonode(RouterId designatedRouter, Ip4Address drInterface, ProtocolType type) { + this.designatedRouter = designatedRouter; + this.drInterface = drInterface; + this.type = type; + } + + /** + * Obtains designated Router Id. + * + * @return designated Router Id + */ + public RouterId designatedRouter() { + return designatedRouter; + } + + /** + * Obtains IP address of Designated Router interface. + * + * @return IP address of Designated Router interface + */ + public Ip4Address drInterface() { + return drInterface; + } + + @Override + public ProtocolType type() { + return type; + } + + @Override + public int hashCode() { + return Objects.hash(designatedRouter, drInterface, type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof OspfPseudonode) { + OspfPseudonode other = (OspfPseudonode) obj; + return Objects.equals(designatedRouter, other.designatedRouter) + && Objects.equals(drInterface, other.drInterface) + && Objects.equals(type, other.type); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("designatedRouter", designatedRouter) + .add("drInterface", drInterface) + .add("type", type) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Position.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Position.java new file mode 100644 index 00000000..f81f9fd3 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Position.java @@ -0,0 +1,84 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents Position of device in the network. + */ +public class Position { + private final Boolean asbr; + private final Boolean abr; + + /** + * Constructor to set position of device. + * + * @param asbr autonomous system boundary router + * @param abr area boundary router + */ + public Position(Boolean asbr, Boolean abr) { + this.asbr = asbr; + this.abr = abr; + } + + /** + * obtain whether the device is autonomous system boundary router or not. + * + * @return autonomous system boundary router or not + */ + Boolean asbr() { + return asbr; + } + + /** + * obtain whether the device is area boundary router or not. + * + * @return area boundary router or not + */ + Boolean abr() { + return abr; + } + + @Override + public int hashCode() { + return Objects.hash(abr, asbr); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof Position) { + Position other = (Position) obj; + return Objects.equals(abr, other.abr) && Objects.equals(asbr, other.asbr); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .omitNullValues() + .add("abrBit", abr) + .add("asbrBit", asbr) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/PrefixIdentifier.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/PrefixIdentifier.java new file mode 100644 index 00000000..b41b5d71 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/PrefixIdentifier.java @@ -0,0 +1,98 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * This class provides Prefix Identifier details.
+ */
+public class PrefixIdentifier {
+ private final TopologyId topologyId;
+ private final RouteType routeType;
+ private final IpReachability ipReach;
+
+ /**
+ * Constructor to initialize its parameters.
+ *
+ * @param topologyId topology ID of prefix
+ * @param routeType OSPF Route type of the prefix
+ * @param ipReach IP address prefix reachability information
+ */
+ public PrefixIdentifier(TopologyId topologyId, RouteType routeType, IpReachability ipReach) {
+ this.topologyId = topologyId;
+ this.routeType = routeType;
+ this.ipReach = ipReach;
+ }
+
+ /**
+ * Provides topology ID of prefix.
+ *
+ * @return topology id
+ */
+ public TopologyId topologyId() {
+ return this.topologyId;
+ }
+
+ /**
+ * Provides IP address prefix reachability information.
+ *
+ * @return IP address prefix
+ */
+ public IpReachability ipReach() {
+ return this.ipReach;
+ }
+
+ /**
+ * Provides OSPF Route type of the prefix.
+ *
+ * @return Route type
+ */
+ public RouteType routeType() {
+ return this.routeType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(topologyId, routeType, ipReach);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof PrefixIdentifier) {
+ PrefixIdentifier other = (PrefixIdentifier) obj;
+ return Objects.equals(topologyId, other.topologyId) && Objects.equals(routeType, other.routeType)
+ && Objects.equals(ipReach, other.ipReach);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .omitNullValues()
+ .add("routeType", routeType)
+ .add("ipReach", ipReach)
+ .add("topologyId", topologyId)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/PrefixTed.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/PrefixTed.java new file mode 100644 index 00000000..9f1c40ad --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/PrefixTed.java @@ -0,0 +1,138 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +import org.onlab.packet.IpAddress; + +/** + * This class provides implementation of prefix traffic engineering data. + */ +public class PrefixTed { + private final IgpFlags igpFlags; + private final RouteTag routeTag; + private final ExtendedRouteTag extendedRouteTag; + private final Metric metric; + private final IpAddress fwdingAddress; + + /** + * Constructor to initialize its parameters. + * + * @param igpFlags igp flags + * @param routeTag ospf route tag + * @param extendedRouteTag isis route tag + * @param metric prefix metric + * @param fwdingAddress forwarding address + */ + /** + * Constructor to initialize its parameters. + * + * @param igpFlags IS-IS and OSPF flags assigned to the prefix + * @param routeTag IGP (ISIS or OSPF) tags of the prefix + * @param extendedRouteTag extended ISIS route tags of the prefix + * @param metric metric of the prefix + * @param fwdingAddress OSPF forwarding address + */ + public PrefixTed(IgpFlags igpFlags, RouteTag routeTag, ExtendedRouteTag extendedRouteTag, + Metric metric, IpAddress fwdingAddress) { + this.igpFlags = igpFlags; + this.routeTag = routeTag; + this.extendedRouteTag = extendedRouteTag; + this.metric = metric; + this.fwdingAddress = fwdingAddress; + } + + /** + * Provides IS-IS and OSPF flags assigned to the prefix. + * + * @return IGP flags + */ + public IgpFlags igpFlags() { + return igpFlags; + } + + /** + * Provides IGP (ISIS or OSPF) tags of the prefix. + * + * @return IGP route tag. + */ + public RouteTag routeTag() { + return routeTag; + } + + /** + * Provides extended ISIS route tags of the prefix. + * + * @return extended IS-IS route tag + */ + public ExtendedRouteTag extendedRouteTag() { + return extendedRouteTag; + } + + /** + * Provides metric of the prefix. + * + * @return prefix metric + */ + public Metric metric() { + return metric; + } + + /** + * Provides OSPF forwarding address. + * + * @return forwarding address + */ + public IpAddress fwdingAddress() { + return fwdingAddress; + } + + + @Override + public int hashCode() { + return Objects.hash(igpFlags, routeTag, extendedRouteTag, metric, fwdingAddress); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof PrefixTed) { + PrefixTed other = (PrefixTed) obj; + return Objects.equals(igpFlags, other.igpFlags) && Objects.equals(extendedRouteTag, other.extendedRouteTag) + && Objects.equals(routeTag, other.routeTag) && Objects.equals(metric, other.metric) + && Objects.equals(fwdingAddress, other.fwdingAddress); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .omitNullValues() + .add("igpFlags", igpFlags) + .add("extendedRouteTag", extendedRouteTag) + .add("routeTag", routeTag) + .add("metric", metric) + .add("fwdingAddress", fwdingAddress) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/ProtectionType.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/ProtectionType.java new file mode 100644 index 00000000..be7fb5a9 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/ProtectionType.java @@ -0,0 +1,97 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents protection capabilities of the link. + */ +public class ProtectionType { + private final LinkProtectionType protectionType; + + /** + * Enum to provide Link Protection type. + */ + public enum LinkProtectionType { + Extra_Traffic(1), Unprotected(2), Shared(4), Enhanced(0x20), Dedicated_OneIsToOne(8), + Dedicated_OnePlusOne(0x10), Reserved(0x40); + int value; + + /** + * Constructor to assign value. + * + * @param val link protection type + */ + LinkProtectionType(int val) { + value = val; + } + + /** + * Provides Link protection type. + * + * @return protection type + */ + public byte type() { + return (byte) value; + } + } + + /** + * Constructor to initialize protection type. + * + * @param protectionType link protection type + */ + public ProtectionType(LinkProtectionType protectionType) { + this.protectionType = protectionType; + } + + /** + * Provides protection capabilities of the link. + * + * @return link protection type. + */ + public LinkProtectionType protectionType() { + return protectionType; + } + + @Override + public int hashCode() { + return Objects.hash(protectionType); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof ProtectionType) { + ProtectionType other = (ProtectionType) obj; + return Objects.equals(protectionType, other.protectionType); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("protectionType", protectionType) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteDistinguisher.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteDistinguisher.java new file mode 100644 index 00000000..b6b83368 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteDistinguisher.java @@ -0,0 +1,74 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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. + */ + +/** + * Implementation of RouteDistinguisher. + */ +package org.onosproject.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents Route Distinguisher of device in the network. + */ +public class RouteDistinguisher { + private final Long routeDistinguisher; + + /** + * Constructor to initialize parameters. + * + * @param routeDistinguisher route distinguisher + */ + public RouteDistinguisher(Long routeDistinguisher) { + this.routeDistinguisher = routeDistinguisher; + } + + /** + * Obtain route distinguisher. + * + * @return route distinguisher + */ + public Long routeDistinguisher() { + 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(routeDistinguisher, other.routeDistinguisher); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("routeDistinguisher", routeDistinguisher) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteIdentifier.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteIdentifier.java new file mode 100644 index 00000000..73cda7a6 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteIdentifier.java @@ -0,0 +1,54 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +/** + * Abstraction of Router ID to identify the router with a distinct IP address. + */ +public interface RouteIdentifier { + /** + * Enum to provide Protocol type. + */ + public enum ProtocolType { + ISIS_LevelOne(1), ISIS_LevelTwo(2), OSPFv2(3), Direct(4), Static_Configuration(5), OSPFv3(6); + int value; + + /** + * Sets protocol ID. + * + * @param val protocol ID + */ + ProtocolType(int val) { + value = val; + } + + /** + * Provides Protocol ID. + * + * @return Protocol ID + */ + public byte getType() { + return (byte) value; + } + } + + /** + * Provides Protocol ID to identify which protocol routing instance is used. + * + * @return Protocol type + */ + ProtocolType type(); +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteInstance.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteInstance.java new file mode 100644 index 00000000..fbca820c --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteInstance.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents routing universe where the network element belongs. + */ +public class RouteInstance { + private final long routeInstance; + + /** + * Constructor to initialize routeInstance. + * + * @param routeInstance routing protocol instance + */ + public RouteInstance(long routeInstance) { + this.routeInstance = routeInstance; + } + + /** + * Obtain route instance. + * + * @return route instance + */ + public long routeInstance() { + return routeInstance; + } + + @Override + public int hashCode() { + return Objects.hash(routeInstance); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof RouteInstance) { + RouteInstance other = (RouteInstance) obj; + return Objects.equals(routeInstance, other.routeInstance); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("routeInstance", routeInstance) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteTag.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteTag.java new file mode 100644 index 00000000..f77cc5e6 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteTag.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents the igp administrative tags of the prefix. + */ +public class RouteTag { + private final int routeTag; + + /** + * Constructor to initialize its parameter. + * + * @param routeTag IGP route tag + */ + public RouteTag(int routeTag) { + this.routeTag = routeTag; + } + + /** + * Obtains igp administrative tags of the prefix. + * + * @return igp administrative tags of the prefix + */ + public int routeTag() { + return routeTag; + } + + @Override + public int hashCode() { + return Objects.hash(routeTag); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof RouteTag) { + RouteTag other = (RouteTag) obj; + return Objects.equals(routeTag, other.routeTag); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("routeTag", routeTag) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteType.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteType.java new file mode 100644 index 00000000..11268f6f --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouteType.java @@ -0,0 +1,96 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents Route type of the prefix in the OSPF domain. + */ +public class RouteType { + private final Type routeType; + + /** + * Enum to provide Route type. + */ + public enum Type { + Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6); + int value; + + /** + * Constructor to assign value. + * + * @param val route type + */ + Type(int val) { + value = val; + } + + /** + * Provides route type. + * + * @return route type + */ + public byte type() { + return (byte) value; + } + } + + /** + * Constructor to initialize routeType. + * + * @param routeType Route type + */ + public RouteType(Type routeType) { + this.routeType = routeType; + } + + /** + * Provides Route type of the prefix. + * + * @return Route type + */ + public Type routeType() { + return routeType; + } + + @Override + public int hashCode() { + return Objects.hash(routeType); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof RouteType) { + RouteType other = (RouteType) obj; + return Objects.equals(routeType, other.routeType); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("routeType", routeType) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouterId.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouterId.java new file mode 100644 index 00000000..85714cb1 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/RouterId.java @@ -0,0 +1,78 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents Router ID of the device. + */ +public class RouterId implements RouteIdentifier { + private final int routerId; + private final ProtocolType type; + + /** + * Constructor to initialize its parameters. + * + * @param routerId Router ID of designated router + */ + public RouterId(int routerId, ProtocolType type) { + this.routerId = routerId; + this.type = type; + } + + /** + * Obtains Router Id of the device. + * + * @return Router Id of the device + */ + public int routerId() { + return routerId; + } + + @Override + public ProtocolType type() { + return type; + } + + @Override + public int hashCode() { + return Objects.hash(routerId, type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof RouterId) { + RouterId other = (RouterId) obj; + return Objects.equals(routerId, other.routerId) && Objects.equals(type, other.type); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("routerId", routerId) + .add("type", type) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Signalling.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Signalling.java new file mode 100644 index 00000000..41593977 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Signalling.java @@ -0,0 +1,83 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents signaling protocols that are enabled. + */ +public class Signalling { + private final Boolean ldp; + private final Boolean rsvpte; + + /** + * Constructor to initialize the values. + * + * @param ldp Label Distribution Protocol whether enabled or not + * @param rsvpte RSVP TE whether enabled or not + */ + public Signalling(Boolean ldp, Boolean rsvpte) { + this.ldp = ldp; + this.rsvpte = rsvpte; + } + + /** + * Obtains whether LDP signalling protocol is enabled or not. + * + * @return LDP signalling protocol is enabled or not + */ + public Boolean ldp() { + return ldp; + } + + /** + * Obtains whether rsvp-te signalling protocol is enabled or not. + * + * @return rsvp-te signalling protocol is enabled or not + */ + public Boolean rsvpte() { + return rsvpte; + } + + @Override + public int hashCode() { + return Objects.hash(ldp, rsvpte); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof Signalling) { + Signalling other = (Signalling) obj; + return Objects.equals(ldp, other.ldp) && Objects.equals(rsvpte, other.rsvpte); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("ldp", ldp) + .add("rsvpte", rsvpte) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Srlg.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Srlg.java new file mode 100644 index 00000000..1f39bad2 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/Srlg.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import static com.google.common.base.MoreObjects.toStringHelper; + +import java.util.Objects; + +/** + * Represents Shared Risk Link Group information. + */ +public class Srlg { + private final int srlgGroup; + + /** + * Constructor to initialize its parameter. + * + * @param srlgGroup list of Shared Risk Link Group value + */ + public Srlg(int srlgGroup) { + this.srlgGroup = srlgGroup; + } + + /** + * Provides Shared Risk link group. + * + * @return Shared Risk link group value + */ + public int srlgGroup() { + return srlgGroup; + } + + @Override + public int hashCode() { + return Objects.hash(srlgGroup); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof Srlg) { + Srlg other = (Srlg) obj; + return Objects.equals(srlgGroup, other.srlgGroup); + } + return false; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("srlgGroup", srlgGroup) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/TerminationPoint.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/TerminationPoint.java new file mode 100644 index 00000000..9c21cb46 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/TerminationPoint.java @@ -0,0 +1,104 @@ +/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * 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.iptopology.api;
+
+import java.util.Objects;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.ElementId;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Abstraction of a network termination point expressed as a pair of the network element identifier and device
+ * interface.
+ */
+public class TerminationPoint {
+ private final ElementId elementId;
+ private final DeviceInterface deviceInterface;
+
+ /**
+ * Constructor to initialize its parameters.
+ *
+ * @param elementId network element identifier
+ * @param deviceInterface device interface
+ */
+ public TerminationPoint(ElementId elementId, DeviceInterface deviceInterface) {
+ this.elementId = elementId;
+ this.deviceInterface = deviceInterface;
+ }
+
+ /**
+ * Returns the network element identifier.
+ *
+ * @return element identifier
+ */
+ public ElementId elementId() {
+ return elementId;
+ }
+
+ /**
+ * Returns the identifier of the infrastructure device if the termination
+ * point belongs to a network element which is indeed an ip
+ * device.
+ *
+ * @return network element identifier as a device identifier
+ * @throws java.lang.IllegalStateException if termination point is not
+ * associated with a device
+ */
+ public DeviceId deviceId() {
+ if (elementId instanceof DeviceId) {
+ return (DeviceId) elementId;
+ }
+ throw new IllegalStateException("Termination point not associated " +
+ "with an ip device");
+ }
+
+ /**
+ * Returns Device interface details.
+ *
+ * @return device interface details
+ */
+ public DeviceInterface deviceInterface() {
+ return deviceInterface;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(elementId, deviceInterface);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TerminationPoint) {
+ final TerminationPoint other = (TerminationPoint) obj;
+ return Objects.equals(this.elementId, other.elementId)
+ && Objects.equals(this.deviceInterface, other.deviceInterface);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("elementId", elementId)
+ .add("deviceInterface", deviceInterface)
+ .toString();
+ }
+}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/TopologyId.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/TopologyId.java new file mode 100644 index 00000000..9d414e35 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/TopologyId.java @@ -0,0 +1,70 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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.iptopology.api; + +import java.util.Objects; + +import com.google.common.base.MoreObjects; + +/** + * Represents Multi-Topology IDs for a network link, node or prefix. + */ +public class TopologyId { + private final short topologyId; + + /** + * Constructor to initialize its parameter. + * + * @param topologyId topology id for node/link/prefix + */ + public TopologyId(short topologyId) { + this.topologyId = topologyId; + } + + /** + * Obtains the topology ID. + * + * @return topology ID + */ + public short topologyId() { + return topologyId; + } + + @Override + public int hashCode() { + return Objects.hash(topologyId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof TopologyId) { + TopologyId other = (TopologyId) obj; + return Objects.equals(topologyId, other.topologyId); + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("topologyId", topologyId) + .toString(); + } +}
\ No newline at end of file diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultInterfaceDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultInterfaceDescription.java new file mode 100644 index 00000000..c7e413d7 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultInterfaceDescription.java @@ -0,0 +1,97 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import com.google.common.base.MoreObjects; +import org.onlab.packet.Ip6Address; +import org.onlab.packet.Ip4Address; +import org.onosproject.iptopology.api.InterfaceIdentifier; +import org.onosproject.net.AbstractDescription; +import org.onosproject.net.SparseAnnotations; + +/** + * Default implementation of immutable Interface description. + */ +public class DefaultInterfaceDescription extends AbstractDescription + implements InterfaceDescription { + + private final InterfaceIdentifier intfId; + private final Ip4Address ipv4Address; + private final Ip6Address ipv6Address; + + + + /** + * Creates an interface description using the supplied information. + * + * @param intfId interface identifier + * @param ipv4Address ipv4 address of an interface + * @param ipv6Address ipv6 address of an interface + * @param annotations optional key/value annotations map + */ + public DefaultInterfaceDescription(InterfaceIdentifier intfId, Ip4Address ipv4Address, + Ip6Address ipv6Address, SparseAnnotations...annotations) { + super(annotations); + this.intfId = intfId; + this.ipv4Address = ipv4Address; + this.ipv6Address = ipv6Address; + } + + /** + * Default constructor for serialization. + */ + private DefaultInterfaceDescription() { + this.intfId = null; + this.ipv4Address = null; + this.ipv6Address = null; + } + + /** + * Creates an interface description using the supplied information. + * + * @param base InterfaceDescription to get basic information from + * @param annotations optional key/value annotations map + */ + public DefaultInterfaceDescription(InterfaceDescription base, + SparseAnnotations annotations) { + this(base.intfId(), base.ipv4Address(), base.ipv6Address(), annotations); + } + + @Override + public InterfaceIdentifier intfId() { + return intfId; + } + + @Override + public Ip4Address ipv4Address() { + return ipv4Address; + } + + @Override + public Ip6Address ipv6Address() { + return ipv6Address; } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("intfId", intfId) + .add("ipv4Address", ipv4Address) + .add("ipv6Address", ipv6Address) + .add("annotations", annotations()) + .toString(); + } + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultIpDeviceDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultIpDeviceDescription.java new file mode 100644 index 00000000..889e48a7 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultIpDeviceDescription.java @@ -0,0 +1,117 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.iptopology.api.DeviceTed; +import org.onosproject.iptopology.api.IpDeviceIdentifier; +import org.onosproject.net.AbstractDescription; +import org.onosproject.net.SparseAnnotations; + +import java.net.URI; + +import static com.google.common.base.MoreObjects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.onosproject.iptopology.api.IpDevice.Type; + +/** + * Default implementation of immutable device description entity. + */ +public class DefaultIpDeviceDescription extends AbstractDescription + implements IpDeviceDescription { + private final URI uri; + private final Type type; + private final IpDeviceIdentifier deviceIdentifier; + private final DeviceTed deviceTed; + + /** + * Creates an ip device description using the supplied information. + * + * @param uri device URI + * @param type device type + * @param deviceIdentifier device manufacturer + * @param deviceTed device Traffic Engineering parameters + * @param annotations optional key/value annotations map + */ + public DefaultIpDeviceDescription(URI uri, Type type, IpDeviceIdentifier deviceIdentifier, + DeviceTed deviceTed, SparseAnnotations... annotations) { + super(annotations); + this.uri = checkNotNull(uri, "Device URI cannot be null"); + this.type = checkNotNull(type, "Device type cannot be null"); + this.deviceIdentifier = deviceIdentifier; + this.deviceTed = deviceTed; + } + + /** + * Creates an ip device description using the supplied information. + * @param base IpDeviceDescription to basic information + * @param annotations Annotations to use. + */ + public DefaultIpDeviceDescription(IpDeviceDescription base, SparseAnnotations... annotations) { + this(base.deviceURI(), base.type(), base.deviceIdentifier(), + base.deviceTed(), annotations); + } + + /** + * Creates an ip device description using the supplied information. + * @param base IpDeviceDescription to basic information (except for type) + * @param type device type + * @param annotations Annotations to use. + */ + public DefaultIpDeviceDescription(IpDeviceDescription base, Type type, SparseAnnotations... annotations) { + this(base.deviceURI(), type, base.deviceIdentifier(), + base.deviceTed(), annotations); + } + + @Override + public URI deviceURI() { + return uri; + } + + @Override + public Type type() { + return type; + } + + @Override + public IpDeviceIdentifier deviceIdentifier() { + return deviceIdentifier; + } + + @Override + public DeviceTed deviceTed() { + return deviceTed; + } + + @Override + public String toString() { + return toStringHelper(this) + .add("uri", uri) + .add("type", type) + .add("devid", deviceIdentifier) + .add("devTed", deviceTed) + .toString(); + } + + /** + * Default constructor for serialization. + */ + private DefaultIpDeviceDescription() { + this.uri = null; + this.type = null; + this.deviceIdentifier = null; + this.deviceTed = null; + } +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultPrefixDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultPrefixDescription.java new file mode 100644 index 00000000..36cc14a6 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/DefaultPrefixDescription.java @@ -0,0 +1,86 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import com.google.common.base.MoreObjects; +import org.onosproject.iptopology.api.PrefixIdentifier; +import org.onosproject.iptopology.api.PrefixTed; +import org.onosproject.net.AbstractDescription; +import org.onosproject.net.SparseAnnotations; + +/** + * Default implementation of immutable Prefix description. + */ +public class DefaultPrefixDescription extends AbstractDescription + implements PrefixDescription { + + private final PrefixIdentifier prefixIdentifier; + private final PrefixTed prefixTed; + + + /** + * Creates prefix description using the supplied information. + * + * @param prefixIdentifier prefix identifier + * @param prefixTed prefix traffic engineering parameters + * @param annotations optional key/value annotations map + */ + public DefaultPrefixDescription(PrefixIdentifier prefixIdentifier, PrefixTed prefixTed, + SparseAnnotations...annotations) { + super(annotations); + this.prefixIdentifier = prefixIdentifier; + this.prefixTed = prefixTed; + } + + /** + * Default constructor for serialization. + */ + private DefaultPrefixDescription() { + this.prefixIdentifier = null; + this.prefixTed = null; + } + + /** + * Creates prefix description using the supplied information. + * + * @param base PrefixDescription to get basic information from + * @param annotations optional key/value annotations map + */ + public DefaultPrefixDescription(PrefixDescription base, + SparseAnnotations annotations) { + this(base.prefixIdentifier(), base.prefixTed(), annotations); + } + + @Override + public PrefixIdentifier prefixIdentifier() { + return prefixIdentifier; + } + + @Override + public PrefixTed prefixTed() { + return prefixTed; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("prefixIdentifier", prefixIdentifier) + .add("prefixTed", prefixTed) + .add("annotations", annotations()) + .toString(); + } + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/InterfaceDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/InterfaceDescription.java new file mode 100644 index 00000000..6e7804d9 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/InterfaceDescription.java @@ -0,0 +1,51 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onlab.packet.Ip4Address; +import org.onlab.packet.Ip6Address; +import org.onosproject.iptopology.api.InterfaceIdentifier; +import org.onosproject.net.Description; + + +/** + * Information about an interface. + */ +public interface InterfaceDescription extends Description { + + /** + * Returns the IPv4 Address of an interface. + * + * @return ipv4 address + */ + Ip4Address ipv4Address(); + + /** + * Returns the IPv6 Address of an interface. + * + * @return ipv6 address + */ + Ip6Address ipv6Address(); + + + /** + * Returns the interface id of the interface. + * + * @return interface identifier + */ + InterfaceIdentifier intfId(); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceDescription.java new file mode 100644 index 00000000..c0a4391d --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceDescription.java @@ -0,0 +1,61 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.iptopology.api.DeviceTed; +import org.onosproject.iptopology.api.IpDevice; +import org.onosproject.iptopology.api.IpDeviceIdentifier; +import org.onosproject.net.Description; + + +import java.net.URI; + +/** + * Carrier of immutable information about an ip device. + */ +public interface IpDeviceDescription extends Description { + + /** + * Protocol/provider specific URI that can be used to encode the identity + * information required to communicate with the ip device externally, e.g. + * datapath ID. + * + * @return provider specific URI for the ip device + */ + URI deviceURI(); + + /** + * Returns the type of the ip device. For ex: Psuedo or actual + * + * @return type of the device + */ + IpDevice.Type type(); + + /** + * Returns the device identifier details. + * + * @return identifier of the device + */ + IpDeviceIdentifier deviceIdentifier(); + + /** + * Returns the traffic engineering parameters of the device. + * + * @return traffic engineering parameters of the device + */ + DeviceTed deviceTed(); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java new file mode 100644 index 00000000..07f263e4 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceEvent.java @@ -0,0 +1,183 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.joda.time.LocalDateTime; +import org.onosproject.event.AbstractEvent; +import org.onosproject.iptopology.api.DeviceIntf; +import org.onosproject.iptopology.api.DevicePrefix; +import org.onosproject.iptopology.api.IpDevice; + + +import static com.google.common.base.MoreObjects.toStringHelper; + +/** + * Describes ip device event. + */ +public class IpDeviceEvent extends AbstractEvent<IpDeviceEvent.Type, IpDevice> { + + private final DeviceIntf devInterface; + private final DevicePrefix devicePrefix; + + /** + * Type of device events. + */ + public enum Type { + /** + * Signifies that a new device has been detected. + */ + DEVICE_ADDED, + + /** + * Signifies that some device attributes have changed; excludes + * availability changes. + */ + DEVICE_UPDATED, + + /** + * Signifies that a device has been removed. + */ + DEVICE_REMOVED, + + /** + * Signifies that an interface has been added. + */ + INTERFACE_ADDED, + + /** + * Signifies that an interface has been updated. + */ + INTERFACE_UPDATED, + + /** + * Signifies that an interface has been removed. + */ + INTERFACE_REMOVED, + + /** + * Signifies that a prefix has been added. + */ + PREFIX_ADDED, + + /** + * Signifies that a prefix has been updated. + */ + PREFIX_UPDATED, + + /** + * Signifies that a prefix has been removed. + */ + PREFIX_REMOVED, + + } + + /** + * Creates an event of a given type and for the specified ip device. + * + * @param type device event type + * @param device event device subject + */ + public IpDeviceEvent(Type type, IpDevice device) { + this(type, device, null, null); + } + + /** + * Creates an event of a given type and for the specified device and interface. + * + * @param type device event type + * @param device event device subject + * @param devInterface optional interface subject + */ + public IpDeviceEvent(Type type, IpDevice device, DeviceIntf devInterface) { + this(type, device, devInterface, null); + } + + /** + * Creates an event of a given type and for the specified device and interface. + * + * @param type device event type + * @param device event device subject + * @param devicePrefix optional prefix subject + */ + public IpDeviceEvent(Type type, IpDevice device, DevicePrefix devicePrefix) { + this(type, device, null, devicePrefix); + } + + + /** + * Creates an event of a given type and for the specified device, interface and prefix. + * + * @param type device event type + * @param device event device subject + * @param devInterface optional interface subject + * @param devicePrefix optional prefix subject + */ + public IpDeviceEvent(Type type, IpDevice device, DeviceIntf devInterface, DevicePrefix devicePrefix) { + super(type, device); + this.devInterface = devInterface; + this.devicePrefix = devicePrefix; + } + + + /** + * Creates an event of a given type and for the specified device, interface and time. + * + * @param type device event type + * @param device event device subject + * @param devInterface optional interface subject + * @param devicePrefix optional prefix subject + * @param time occurrence time + */ + + public IpDeviceEvent(Type type, IpDevice device, DeviceIntf devInterface, DevicePrefix devicePrefix, long time) { + super(type, device, time); + this.devInterface = devInterface; + this.devicePrefix = devicePrefix; + } + + + /** + * Returns the interface subject. + * + * @return interface subject or null if the event is not interface specific. + */ + public DeviceIntf deviceInterface() { + return devInterface; + } + + /** + * Returns the prefix subject. + * + * @return prefix subject or null if the event is not prefix specific. + */ + public DevicePrefix prefix() { + return devicePrefix; + } + + @Override + public String toString() { + if (devInterface == null || devicePrefix == null) { + return super.toString(); + } + return toStringHelper(this) + .add("time", new LocalDateTime(time())) + .add("type", type()) + .add("subject", subject()) + .add("interface", devInterface) + .add("prefix", devicePrefix) + .toString(); + } +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceListener.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceListener.java new file mode 100644 index 00000000..cd40c405 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceListener.java @@ -0,0 +1,24 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.event.EventListener; + +/** + * Entity capable of receiving ip device related events. + */ +public interface IpDeviceListener extends EventListener<IpDeviceEvent> { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProvider.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProvider.java new file mode 100644 index 00000000..67502eb6 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProvider.java @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.net.provider.Provider; + +/** + * Abstraction of a ip device information provider. + */ +public interface IpDeviceProvider extends Provider { + // Currently there is none to set some information into the network +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProviderRegistry.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProviderRegistry.java new file mode 100644 index 00000000..74b27415 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProviderRegistry.java @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.net.provider.ProviderRegistry; + +/** + * Abstraction of a ip device provider registry. + */ +public interface IpDeviceProviderRegistry + extends ProviderRegistry<IpDeviceProvider, IpDeviceProviderService> { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProviderService.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProviderService.java new file mode 100644 index 00000000..f84b8b74 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceProviderService.java @@ -0,0 +1,78 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.net.DeviceId; +import org.onosproject.net.provider.ProviderService; + +import java.util.List; + +/** + * Service through which ip device providers can inject ip device information into + * the core. + */ +public interface IpDeviceProviderService extends ProviderService<IpDeviceProvider> { + + /** + * Signals the core that an ip device is added or updated with IP topology information. + * + * @param deviceId device identifier + * @param deviceDescription information about network ip device + */ + void addOrUpdateIpDevice(DeviceId deviceId, IpDeviceDescription deviceDescription); + + /** + * Signals the core that an ip device is removed. + * + * @param deviceId identity of the ip device to be removed + */ + void removeIpDevice(DeviceId deviceId); + + /** + * Sends information about all interfaces of a device. It is up to the core to + * determine what has changed. + * + * @param deviceId identity of the ip device + * @param interfaceDescriptions list of device interfaces + */ + void updateInterfaces(DeviceId deviceId, List<InterfaceDescription> interfaceDescriptions); + + /** + * signals interfaces of a device is deleted. + * + * @param deviceId identity of the ip device + * @param interfaceDescriptions list of device interfaces + */ + void removeInterfaces(DeviceId deviceId, List<InterfaceDescription> interfaceDescriptions); + + /** + * Sends information about all ip prefix of a device. It is up to the core to + * determine what has changed. + * + * @param deviceId identity of the ip device + * @param prefixDescriptions list of device ip prefixes + */ + void updatePrefixes(DeviceId deviceId, List<PrefixDescription> prefixDescriptions); + + /** + * signals ip prefix of a device is deleted. + * + * @param deviceId identity of the ip device + * @param prefixDescriptions list of device ip prefixes + */ + void removePrefixes(DeviceId deviceId, List<PrefixDescription> prefixDescriptions); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceService.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceService.java new file mode 100644 index 00000000..4b126eb3 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceService.java @@ -0,0 +1,111 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.event.ListenerService; +import org.onosproject.iptopology.api.DeviceIntf; +import org.onosproject.iptopology.api.DevicePrefix; +import org.onosproject.iptopology.api.InterfaceIdentifier; +import org.onosproject.iptopology.api.IpDevice; +import org.onosproject.net.DeviceId; +import org.onlab.packet.Ip4Address; +import org.onlab.packet.Ip6Address; + +import java.util.List; + +/** + * Service for interacting with the inventory of ip devices. + */ +public interface IpDeviceService + extends ListenerService<IpDeviceEvent, IpDeviceListener> { + + /** + * Returns the number of ip devices known to the system. + * + * @return number of infrastructure devices + */ + int getIpDeviceCount(); + + /** + * Returns a collection of the currently known ip + * devices. + * + * @return collection of devices + */ + Iterable<IpDevice> getIpDevices(); + + /** + * Returns a collection of the currently known ip + * devices by device type. + * + * @param type device type + * @return collection of devices + */ + Iterable<IpDevice> getIpDevices(IpDevice.Type type); + + + /** + * Returns the ip device with the specified identifier. + * + * @param deviceId device identifier + * @return device or null if one with the given identifier is not known + */ + IpDevice getIpDevice(DeviceId deviceId); + + /** + * Returns the list of interfaces associated with the device. + * + * @param deviceId device identifier + * @return list of device interfaces + */ + List<DeviceIntf> getInterfaces(DeviceId deviceId); + + /** + * Returns the interface with the specified ipv4 address and hosted by the given device. + * + * @param deviceId device identifier + * @param ipv4Address ipv4 address + * @return device interface + */ + DeviceIntf getInterface(DeviceId deviceId, Ip4Address ipv4Address); + + /** + * Returns the interface with the specified ipv6 address and hosted by the given device. + * + * @param deviceId device identifier + * @param ipv6Address ipv6 address + * @return device interface + */ + DeviceIntf getInterface(DeviceId deviceId, Ip6Address ipv6Address); + + /** + * Returns the interface with the specified interface id and hosted by the given device. + * + * @param deviceId device identifier + * @param intfId interface id + * @return device interface + */ + DeviceIntf getInterface(DeviceId deviceId, InterfaceIdentifier intfId); + + /** + * Returns the list of ip prefix associated with the device. + * + * @param deviceId device identifier + * @return list of device prefixes + */ + List<DevicePrefix> getPrefixes(DeviceId deviceId); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceStore.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceStore.java new file mode 100644 index 00000000..db1dd429 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceStore.java @@ -0,0 +1,164 @@ +/* + * Copyright 2014-2015 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onlab.packet.Ip4Address; +import org.onlab.packet.Ip6Address; +import org.onosproject.iptopology.api.DevicePrefix; +import org.onosproject.iptopology.api.InterfaceIdentifier; +import org.onosproject.iptopology.api.IpDevice; +import org.onosproject.iptopology.api.DeviceIntf; +import org.onosproject.net.DeviceId; +import org.onosproject.net.provider.ProviderId; +import org.onosproject.store.Store; + +import java.util.List; + +/** + * Manages inventory of ip devices; not intended for direct use. + */ +public interface IpDeviceStore extends Store<IpDeviceEvent, IpDeviceStoreDelegate> { + + /** + * Returns the number of ip devices known to the system. + * + * @return number of ip devices + */ + int getIpDeviceCount(); + + /** + * Returns an iterable collection of all ip devices known to the system. + * + * @return ip device collection + */ + Iterable<IpDevice> getIpDevices(); + + + /** + * Returns an ip device with the specified identifier. + * + * @param deviceId device identifier + * @return ip device + */ + IpDevice getIpDevice(DeviceId deviceId); + + /** + * Creates a new infrastructure ip device, or updates an existing one using + * the supplied device description. + * + * @param providerId provider identifier + * @param deviceId device identifier + * @param deviceDescription device description + * @return ready to send event describing what occurred; null if no change + */ + IpDeviceEvent createOrUpdateIpDevice(ProviderId providerId, DeviceId deviceId, + IpDeviceDescription deviceDescription); + + /** + * Administratively removes the specified ip device from the store. + * + * @param deviceId device to be removed + * @return null if no such ip device + */ + IpDeviceEvent removeIpDevice(DeviceId deviceId); + + /** + * Updates the interface of the specified ip device using the given + * list of interface descriptions. The list is assumed to be comprehensive. + * + * @param providerId provider identifier + * @param deviceId ip device identifier + * @param interfaceDescriptions list of interface descriptions + * @return ready to send events describing what occurred; empty list if no change + */ + List<IpDeviceEvent> updateInterfaces(ProviderId providerId, DeviceId deviceId, + List<InterfaceDescription> interfaceDescriptions); + + /** + * Administratively removes the specified interface from the store. + * + * @param deviceId device of the interfaces to be removed + * @param interfaceDescriptions list of interface descriptions + * @return ready to send events describing what occurred. + */ + List<IpDeviceEvent> removeInterfaces(DeviceId deviceId, List<InterfaceDescription> interfaceDescriptions); + + /** + * Returns the list of interfaces that belong to the specified device. + * + * @param deviceId device identifier + * @return list of device interfaces + */ + List<DeviceIntf> getInterfaces(DeviceId deviceId); + + /** + * Returns the specified device interface. + * + * @param deviceId device identifier + * @param ipv4Address ipv4 address of the interface + * @return device interface + */ + DeviceIntf getInterface(DeviceId deviceId, Ip4Address ipv4Address); + + /** + * Returns the specified device interface. + * + * @param deviceId device identifier + * @param ipv6Address ipv6 address of the interface + * @return device interface + */ + DeviceIntf getInterface(DeviceId deviceId, Ip6Address ipv6Address); + + /** + * Returns the specified device interface. + * + * @param deviceId device identifier + * @param intfId interface identifier of the interface + * @return device interface + */ + DeviceIntf getInterface(DeviceId deviceId, InterfaceIdentifier intfId); + + /** + * Updates the prefix information of the specified ip device using the given + * list of prefix descriptions. The list is assumed to be comprehensive. + * + * @param providerId provider identifier + * @param deviceId ip device identifier + * @param prefixDescriptions list of prefix descriptions + * @return ready to send events describing what occurred; empty list if no change + */ + List<IpDeviceEvent> updatePrefixes(ProviderId providerId, DeviceId deviceId, + List<PrefixDescription> prefixDescriptions); + + /** + * Administratively removes the specified prefix from the store. + * + * @param deviceId device of the prefix to be removed + * @param prefixDescriptions list of prefix descriptions + * @return ready to send events describing what occurred. + */ + List<IpDeviceEvent> removePrefixes(DeviceId deviceId, List<PrefixDescription> prefixDescriptions); + + /** + * Returns the list of prefixes that belong to the specified device. + * + * @param deviceId device identifier + * @return list of device prefixes + */ + List<DevicePrefix> getPrefixes(DeviceId deviceId); + +} + diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceStoreDelegate.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceStoreDelegate.java new file mode 100644 index 00000000..14efe064 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/IpDeviceStoreDelegate.java @@ -0,0 +1,24 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.store.StoreDelegate; + +/** + * Infrastructure ip topology store delegate abstraction. + */ +public interface IpDeviceStoreDelegate extends StoreDelegate<IpDeviceEvent> { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/PrefixDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/PrefixDescription.java new file mode 100644 index 00000000..eb1ece33 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/PrefixDescription.java @@ -0,0 +1,41 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.device; + +import org.onosproject.iptopology.api.PrefixIdentifier; +import org.onosproject.iptopology.api.PrefixTed; +import org.onosproject.net.Description; + +/** + * Information about a prefix. + */ +public interface PrefixDescription extends Description { + + /** + * Returns the prefix identifier. + * + * @return prefix identifier + */ + PrefixIdentifier prefixIdentifier(); + + /** + * Returns the prefix Traffic Engineering parameters. + * + * @return prefix Traffic Engineering parameters + */ + PrefixTed prefixTed(); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/package-info.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/package-info.java new file mode 100644 index 00000000..5e4e29b1 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/device/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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. + */ + +/** + * Ip device model & related services API definitions. + */ +package org.onosproject.iptopology.api.device; diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/DefaultIpLinkDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/DefaultIpLinkDescription.java new file mode 100644 index 00000000..4a3b46d2 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/DefaultIpLinkDescription.java @@ -0,0 +1,95 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import com.google.common.base.MoreObjects; +import org.onosproject.iptopology.api.IpLinkIdentifier; +import org.onosproject.iptopology.api.LinkTed; +import org.onosproject.iptopology.api.TerminationPoint; +import org.onosproject.net.AbstractDescription; +import org.onosproject.net.SparseAnnotations; + +/** + * Default implementation of immutable ip link description entity. + */ +public class DefaultIpLinkDescription extends AbstractDescription + implements IpLinkDescription { + + private final TerminationPoint src; + private final TerminationPoint dst; + private final IpLinkIdentifier linkIdentifier; + private final LinkTed linkTed; + + /** + * Creates an ip link description using the supplied information. + * + * @param src link source + * @param dst link destination + * @param linkIdentifier link identifier + * @param linkTed link traffic engineering parameters + * @param annotations optional key/value annotations + */ + public DefaultIpLinkDescription(TerminationPoint src, TerminationPoint dst, + IpLinkIdentifier linkIdentifier, LinkTed linkTed, + SparseAnnotations... annotations) { + super(annotations); + this.src = src; + this.dst = dst; + this.linkIdentifier = linkIdentifier; + this.linkTed = linkTed; + } + + /** + * Creates an ip link description using the supplied information. + * + * @param base IpLinkDescription to basic information + * @param annotations optional key/value annotations + */ + public DefaultIpLinkDescription(IpLinkDescription base, SparseAnnotations... annotations) { + this(base.src(), base.dst(), base.linkIdentifier(), + base.linkTed(), annotations); + } + + @Override + public TerminationPoint src() { + return src; + } + + @Override + public TerminationPoint dst() { + return dst; + } + + @Override + public IpLinkIdentifier linkIdentifier() { + return linkIdentifier; + } + + @Override + public LinkTed linkTed() { + return linkTed; } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("src", src()) + .add("dst", dst()) + .add("linkIdentifier", linkIdentifier()) + .add("linkTed", linkTed()) + .toString(); + } + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkDescription.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkDescription.java new file mode 100644 index 00000000..258e7444 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkDescription.java @@ -0,0 +1,55 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.iptopology.api.IpLinkIdentifier; +import org.onosproject.iptopology.api.LinkTed; +import org.onosproject.iptopology.api.TerminationPoint; +import org.onosproject.net.Description; + +/** + * Describes an ip link. + */ +public interface IpLinkDescription extends Description { + + /** + * Returns the link source. + * + * @return links source + */ + TerminationPoint src(); + + /** + * Returns the link destination. + * + * @return links destination + */ + TerminationPoint dst(); + + /** + * Returns the link identifier. + * + * @return links identifier informations + */ + IpLinkIdentifier linkIdentifier(); + + /** + * Returns the link traffic engineering parameters. + * + * @return links traffic engineering parameters + */ + LinkTed linkTed(); +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkEvent.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkEvent.java new file mode 100644 index 00000000..4050734a --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkEvent.java @@ -0,0 +1,68 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.event.AbstractEvent; +import org.onosproject.iptopology.api.IpLink; + +/** + * Describes ip link event. + */ +public class IpLinkEvent extends AbstractEvent<IpLinkEvent.Type, IpLink> { + + /** + * Type of link events. + */ + public enum Type { + /** + * Signifies that a new ip link has been detected. + */ + LINK_ADDED, + + /** + * Signifies that an ip link has been updated or changed state. + */ + LINK_UPDATED, + + /** + * Signifies that an ip link has been removed. + */ + LINK_REMOVED + } + + /** + * Creates an event of a given type and for the specified ip link and the + * current time. + * + * @param type link event type + * @param link event link subject + */ + public IpLinkEvent(Type type, IpLink link) { + super(type, link); + } + + /** + * Creates an event of a given type and for the specified ip link and time. + * + * @param type link event type + * @param link event link subject + * @param time occurrence time + */ + public IpLinkEvent(Type type, IpLink link, long time) { + super(type, link, time); + } + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkListener.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkListener.java new file mode 100644 index 00000000..5acb73aa --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkListener.java @@ -0,0 +1,24 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.event.EventListener; + +/** + * Entity capable of receiving ip link related events. + */ +public interface IpLinkListener extends EventListener<IpLinkEvent> { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProvider.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProvider.java new file mode 100644 index 00000000..a58bf610 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProvider.java @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.net.provider.Provider; + +/** + * Abstraction of an entity providing information about ip links + * to the core. + */ +public interface IpLinkProvider extends Provider { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProviderRegistry.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProviderRegistry.java new file mode 100644 index 00000000..e060ae68 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProviderRegistry.java @@ -0,0 +1,25 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.net.provider.ProviderRegistry; + +/** + * Abstraction of an ip link provider registry. + */ +public interface IpLinkProviderRegistry + extends ProviderRegistry<IpLinkProvider, IpLinkProviderService> { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProviderService.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProviderService.java new file mode 100644 index 00000000..c2554425 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkProviderService.java @@ -0,0 +1,57 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + + +import org.onosproject.iptopology.api.TerminationPoint; +import org.onosproject.net.DeviceId; +import org.onosproject.net.provider.ProviderService; + +/** + * Means for injecting ip link information into the core. + */ +public interface IpLinkProviderService extends ProviderService<IpLinkProvider> { + + /** + * Signals that an ip link is added or updated with IP topology information. + * + * @param linkDescription ip link information + */ + void addOrUpdateIpLink(IpLinkDescription linkDescription); + + /** + * Signals that an ip link has disappeared. + * + * @param linkDescription ip link information + */ + void removeIpLink(IpLinkDescription linkDescription); + + /** + * Signals that ip links associated with the specified + * termination point have vanished. + * + * @param terminationPoint termination point + */ + void removeIpLink(TerminationPoint terminationPoint); + + /** + * Signals that ip links associated with the specified + * device have vanished. + * + * @param deviceId device identifier + */ + void removeIpLink(DeviceId deviceId); +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkService.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkService.java new file mode 100644 index 00000000..723e907b --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkService.java @@ -0,0 +1,108 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import java.util.Set; + +import org.onosproject.event.ListenerService; +import org.onosproject.iptopology.api.IpLink; +import org.onosproject.iptopology.api.TerminationPoint; +import org.onosproject.net.DeviceId; + +/** + * Service for interacting with the inventory of infrastructure links. + */ +public interface IpLinkService + extends ListenerService<IpLinkEvent, IpLinkListener> { + + /** + * Returns the count of all known ip links. + * + * @return number of ip links + */ + int getIpLinkCount(); + + /** + * Returns a collection of all ip links. + * + * @return all ip links + */ + Iterable<IpLink> getIpLinks(); + + + /** + * Returns set of all ip links leading to and from the + * specified ip device. + * + * @param deviceId device identifier + * @return set of ip device links + */ + Set<IpLink> getIpDeviceLinks(DeviceId deviceId); + + /** + * Returns set of all ip links leading from the specified ip device. + * + * @param deviceId device identifier + * @return set of ip device egress links + */ + Set<IpLink> getIpDeviceEgressLinks(DeviceId deviceId); + + /** + * Returns set of all ip links leading to the specified ip device. + * + * @param deviceId device identifier + * @return set of ip device ingress links + */ + Set<IpLink> getIpDeviceIngressLinks(DeviceId deviceId); + + /** + * Returns set of all ip links leading to and from the + * specified termination point. + * + * @param terminationPoint termination point + * @return set of ip links + */ + Set<IpLink> getIpLinks(TerminationPoint terminationPoint); + + /** + * Returns set of all ip links leading from the specified + * termination point. + * + * @param terminationPoint termination point + * @return set of ip device egress links + */ + Set<IpLink> getEgressIpLinks(TerminationPoint terminationPoint); + + /** + * Returns set of all ip links leading to the specified + * termination point. + * + * @param terminationPoint termination point + * @return set of ip device ingress links + */ + Set<IpLink> getIngressIpLinks(TerminationPoint terminationPoint); + + /** + * Returns the ip links between the specified source + * and destination termination points. + * + * @param src source termination point + * @param dst destination termination point + * @return ip link from source to destination; null if none found + */ + IpLink getIpLink(TerminationPoint src, TerminationPoint dst); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkStore.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkStore.java new file mode 100644 index 00000000..8f5c60f7 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkStore.java @@ -0,0 +1,115 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.iptopology.api.IpLink; +import org.onosproject.iptopology.api.TerminationPoint; +import org.onosproject.net.DeviceId; +import org.onosproject.net.provider.ProviderId; +import org.onosproject.store.Store; + +import java.util.Set; + +/** + * Manages inventory of ip links; not intended for direct use. + */ +public interface IpLinkStore extends Store<IpLinkEvent, IpLinkStoreDelegate> { + + /** + * Returns the number of ip links in the store. + * + * @return number of ip links + */ + int getIpLinkCount(); + + /** + * Returns an iterable collection of all ip links in the inventory. + * + * @return collection of all ip links + */ + Iterable<IpLink> getIpLinks(); + + /** + * Returns all ip links egressing from the specified device. + * + * @param deviceId device identifier + * @return set of ip device links + */ + Set<IpLink> getIpDeviceEgressLinks(DeviceId deviceId); + + /** + * Returns all ip links ingressing from the specified device. + * + * @param deviceId device identifier + * @return set of ip device links + */ + Set<IpLink> getIpDeviceIngressLinks(DeviceId deviceId); + + /** + * Returns the ip link between the two termination points. + * + * @param src source termination point + * @param dst destination termination point + * @return ip link or null if one not found between the termination points + */ + IpLink getIpLink(TerminationPoint src, TerminationPoint dst); + + /** + * Returns all ip links egressing from the specified termination point. + * + * @param src source termination point + * @return set of termination point ip links + */ + Set<IpLink> getEgressIpLinks(TerminationPoint src); + + /** + * Returns all ip links ingressing to the specified termination point. + * + * @param dst destination termination point + * @return set of termination point ip links + */ + Set<IpLink> getIngressIpLinks(TerminationPoint dst); + + /** + * Creates a new ip link, or updates an existing one, based on the given + * information. + * + * @param providerId provider identity + * @param linkDescription ip link description + * @return create or update ip link event, or null if no change resulted + */ + IpLinkEvent createOrUpdateIpLink(ProviderId providerId, + IpLinkDescription linkDescription); + + /** + * Removes ip link, based on the specified information. + * + * @param src ip link source + * @param dst ip link destination + * @return remove or update ip link event, or null if no change resulted + */ + IpLinkEvent removeOrDownIpLink(TerminationPoint src, TerminationPoint dst); + + /** + * Removes ip link based on the specified information. + * + * @param src ip link source + * @param dst ip link destination + * @return remove ip link event, or null if no change resulted + */ + IpLinkEvent removeIpLink(TerminationPoint src, TerminationPoint dst); + +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkStoreDelegate.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkStoreDelegate.java new file mode 100644 index 00000000..9397a499 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/IpLinkStoreDelegate.java @@ -0,0 +1,24 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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.iptopology.api.link; + +import org.onosproject.store.StoreDelegate; + +/** + * Ip link store delegate abstraction. + */ +public interface IpLinkStoreDelegate extends StoreDelegate<IpLinkEvent> { +} diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/package-info.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/package-info.java new file mode 100644 index 00000000..581c2367 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/link/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2014 Open Networking Laboratory + * + * 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. + */ + +/** + * Ip link model & related services API definitions. + */ +package org.onosproject.iptopology.api.link; diff --git a/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/package-info.java b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/package-info.java new file mode 100644 index 00000000..e1133554 --- /dev/null +++ b/framework/src/onos/apps/iptopology-api/src/main/java/org/onosproject/iptopology/api/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2015 Open Networking Laboratory + * + * 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. + */ + +/** + * Ip Topology API. + */ +package org.onosproject.iptopology.api; |