From e63291850fd0795c5700e25e67e5dee89ba54c5f Mon Sep 17 00:00:00 2001 From: Ashlee Young Date: Tue, 1 Dec 2015 05:49:27 -0800 Subject: onos commit hash c2999f30c69e50df905a9d175ef80b3f23a98514 Change-Id: I2bb8562c4942b6d6a6d60b663db2e17540477b81 Signed-off-by: Ashlee Young --- .../protocol/linkstate/PathAttrNlriDetails.java | 135 +++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100755 framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java (limited to 'framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java') diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java new file mode 100755 index 00000000..9578ccfe --- /dev/null +++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/linkstate/PathAttrNlriDetails.java @@ -0,0 +1,135 @@ +/* + * 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.bgpio.protocol.linkstate; + +import java.util.Iterator; +import java.util.List; +import java.util.Objects; + +import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType; +import org.onosproject.bgpio.types.BgpValueType; + +import com.google.common.base.MoreObjects; + +/** + * This Class stores path Attributes, protocol ID and Identifier of LinkState NLRI. + */ +public class PathAttrNlriDetails { + private List pathAttributes; + private ProtocolType protocolID; + private long identifier; + + /** + * Sets path attribute with specified path attribute. + * + * @param pathAttributes in update message + */ + public void setPathAttribute(List pathAttributes) { + this.pathAttributes = pathAttributes; + } + + /** + * Returns path attributes. + * + * @return path attributes + */ + public List pathAttributes() { + return this.pathAttributes; + } + + /** + * Sets protocolID with specified protocolID. + * + * @param protocolID in linkstate nlri + */ + public void setProtocolID(ProtocolType protocolID) { + this.protocolID = protocolID; + } + + /** + * Returns protocolID. + * + * @return protocolID + */ + public ProtocolType protocolID() { + return this.protocolID; + } + + /** + * Sets identifier with specified identifier. + * + * @param identifier in linkstate nlri + */ + public void setIdentifier(long identifier) { + this.identifier = identifier; + } + + /** + * Returns Identifier. + * + * @return Identifier + */ + public long identifier() { + return this.identifier; + } + + @Override + public int hashCode() { + return Objects.hash(pathAttributes, protocolID, identifier); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + if (obj instanceof PathAttrNlriDetails) { + int countObjSubTlv = 0; + int countOtherSubTlv = 0; + boolean isCommonSubTlv = true; + PathAttrNlriDetails other = (PathAttrNlriDetails) obj; + Iterator objListIterator = other.pathAttributes.iterator(); + countOtherSubTlv = other.pathAttributes.size(); + countObjSubTlv = pathAttributes.size(); + if (countObjSubTlv != countOtherSubTlv) { + return false; + } else { + while (objListIterator.hasNext() && isCommonSubTlv) { + BgpValueType subTlv = objListIterator.next(); + if (pathAttributes.contains(subTlv) && other.pathAttributes.contains(subTlv)) { + isCommonSubTlv = Objects.equals(pathAttributes.get(pathAttributes.indexOf(subTlv)), + other.pathAttributes.get(other.pathAttributes.indexOf(subTlv))); + } else { + isCommonSubTlv = false; + } + } + return isCommonSubTlv && Objects.equals(identifier, other.identifier) + && Objects.equals(protocolID, other.protocolID); + } + } + return false; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(getClass()) + .add("identifier", identifier) + .add("protocolID", protocolID) + .add("pathAttributes", pathAttributes) + .toString(); + } +} -- cgit 1.2.3-korg