use of org.onosproject.bgpio.types.BgpValueType in project onos by opennetworkinglab.
the class BgpLinkLSIdentifier method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpLinkLSIdentifier) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
BgpLinkLSIdentifier other = (BgpLinkLSIdentifier) obj;
Iterator<BgpValueType> objListIterator = other.linkDescriptor.iterator();
countOtherSubTlv = other.linkDescriptor.size();
countObjSubTlv = linkDescriptor.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
BgpValueType subTlv = objListIterator.next();
if (linkDescriptor.contains(subTlv) && other.linkDescriptor.contains(subTlv)) {
isCommonSubTlv = Objects.equals(linkDescriptor.get(linkDescriptor.indexOf(subTlv)), other.linkDescriptor.get(other.linkDescriptor.indexOf(subTlv)));
} else {
isCommonSubTlv = false;
}
}
return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors) && Objects.equals(this.remoteNodeDescriptors, other.remoteNodeDescriptors);
}
}
return false;
}
use of org.onosproject.bgpio.types.BgpValueType in project onos by opennetworkinglab.
the class BgpPrefixLSIdentifier method equals.
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BgpPrefixLSIdentifier) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
BgpPrefixLSIdentifier other = (BgpPrefixLSIdentifier) obj;
Iterator<BgpValueType> objListIterator = other.prefixDescriptor.iterator();
countOtherSubTlv = other.prefixDescriptor.size();
countObjSubTlv = prefixDescriptor.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
BgpValueType subTlv = objListIterator.next();
if (prefixDescriptor.contains(subTlv) && other.prefixDescriptor.contains(subTlv)) {
isCommonSubTlv = Objects.equals(prefixDescriptor.get(prefixDescriptor.indexOf(subTlv)), other.prefixDescriptor.get(other.prefixDescriptor.indexOf(subTlv)));
} else {
isCommonSubTlv = false;
}
}
return isCommonSubTlv && Objects.equals(this.localNodeDescriptors, other.localNodeDescriptors);
}
}
return false;
}
use of org.onosproject.bgpio.types.BgpValueType in project onos by opennetworkinglab.
the class BgpPrefixLSIdentifier method parsePrefixDescriptors.
/**
* Parse list of prefix descriptors.
*
* @param cb ChannelBuffer
* @return list of prefix descriptors
* @throws BgpParseException while parsing list of prefix descriptors
*/
public static List<BgpValueType> parsePrefixDescriptors(ChannelBuffer cb) throws BgpParseException {
LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
BgpValueType tlv = null;
boolean isIpReachInfo = false;
ChannelBuffer tempCb;
int count = 0;
while (cb.readableBytes() > 0) {
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
// length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
tempCb = cb.readBytes(length);
switch(type) {
case OspfRouteTypeTlv.TYPE:
tlv = OspfRouteTypeTlv.read(tempCb);
break;
case IPReachabilityInformationTlv.TYPE:
tlv = IPReachabilityInformationTlv.read(tempCb, length);
isIpReachInfo = true;
break;
case BgpAttrNodeMultiTopologyId.ATTRNODE_MULTITOPOLOGY:
tlv = BgpAttrNodeMultiTopologyId.read(tempCb, length);
count = count + 1;
if (count > 1) {
// length + 4 implies data contains type, length and value
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, tempBuf.readBytes(length + TYPE_AND_LEN));
}
break;
default:
UnSupportedAttribute.skipBytes(tempCb, length);
}
prefixDescriptor.add(tlv);
}
if (!isIpReachInfo) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR, null);
}
return prefixDescriptor;
}
use of org.onosproject.bgpio.types.BgpValueType in project onos by opennetworkinglab.
the class NodeDescriptors method compareTo.
/**
* Compares this and o object.
*
* @param o object to be compared with this object
* @return which object is greater
*/
public int compareTo(Object o) {
if (this.equals(o)) {
return 0;
}
ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
int countOtherSubTlv = ((NodeDescriptors) o).subTlvs.size();
int countObjSubTlv = subTlvs.size();
boolean tlvFound = false;
if (countOtherSubTlv != countObjSubTlv) {
if (countOtherSubTlv > countObjSubTlv) {
return 1;
} else {
return -1;
}
} else {
while (listIterator.hasNext()) {
BgpValueType tlv1 = listIterator.next();
log.debug("NodeDescriptor compare subtlv's");
for (BgpValueType tlv : ((NodeDescriptors) o).subTlvs) {
if (tlv.getType() == tlv1.getType()) {
if (tlv.getType() == IGP_ROUTERID_TYPE) {
if ((tlv1 instanceof IsIsNonPseudonode && tlv instanceof IsIsPseudonode) || (tlv1 instanceof IsIsPseudonode && tlv instanceof IsIsNonPseudonode) || (tlv1 instanceof OspfNonPseudonode && tlv instanceof OspfPseudonode) || (tlv1 instanceof OspfPseudonode && tlv instanceof OspfNonPseudonode)) {
continue;
}
}
int result = subTlvs.get(subTlvs.indexOf(tlv1)).compareTo(((NodeDescriptors) o).subTlvs.get(((NodeDescriptors) o).subTlvs.indexOf(tlv)));
if (result != 0) {
return result;
}
tlvFound = true;
break;
}
}
if (!tlvFound) {
return 1;
}
}
}
return 0;
}
use of org.onosproject.bgpio.types.BgpValueType in project onos by opennetworkinglab.
the class PathAttrNlriDetails method equals.
@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<BgpValueType> 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;
}
Aggregations