Search in sources :

Example 1 with OspfNonPseudonode

use of org.onosproject.bgpio.types.OspfNonPseudonode in project onos by opennetworkinglab.

the class BgpDpid method add.

/**
 * Obtains instance of this class by appending stringBuilder with node descriptor value.
 *
 * @param value node descriptor
 * @return instance of this class
 */
public BgpDpid add(final NodeDescriptors value) {
    log.debug("BgpDpid :: add function");
    if (value != null) {
        List<BgpValueType> subTlvs = value.getSubTlvs();
        ListIterator<BgpValueType> listIterator = subTlvs.listIterator();
        while (listIterator.hasNext()) {
            BgpValueType tlv = listIterator.next();
            if (tlv.getType() == AutonomousSystemTlv.TYPE) {
                this.stringBuilder.append(":ASN=").append(((AutonomousSystemTlv) tlv).getAsNum());
            } else if (tlv.getType() == BgpLSIdentifierTlv.TYPE) {
                this.stringBuilder.append(":DOMAINID=").append(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier());
            } else if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
                if (tlv instanceof IsIsNonPseudonode) {
                    this.stringBuilder.append(":ISOID=").append(isoNodeIdString(((IsIsNonPseudonode) tlv).getIsoNodeId()));
                } else if (tlv instanceof IsIsPseudonode) {
                    IsIsPseudonode isisPseudonode = ((IsIsPseudonode) tlv);
                    this.stringBuilder.append(":ISOID=").append(isoNodeIdString(((IsIsPseudonode) tlv).getIsoNodeId()));
                    this.stringBuilder.append(":PSN=").append(isisPseudonode.getPsnIdentifier());
                } else if (tlv instanceof OspfNonPseudonode) {
                    this.stringBuilder.append(":RID=").append(((OspfNonPseudonode) tlv).getrouterID());
                } else if (tlv instanceof OspfPseudonode) {
                    this.stringBuilder.append(":RID=").append(((OspfPseudonode) tlv).getrouterID());
                }
            }
        }
    }
    return this;
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) IsIsPseudonode(org.onosproject.bgpio.types.IsIsPseudonode) OspfPseudonode(org.onosproject.bgpio.types.OspfPseudonode) BgpLSIdentifierTlv(org.onosproject.bgpio.types.BgpLSIdentifierTlv) OspfNonPseudonode(org.onosproject.bgpio.types.OspfNonPseudonode) IsIsNonPseudonode(org.onosproject.bgpio.types.IsIsNonPseudonode)

Example 2 with OspfNonPseudonode

use of org.onosproject.bgpio.types.OspfNonPseudonode 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;
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) IsIsPseudonode(org.onosproject.bgpio.types.IsIsPseudonode) OspfPseudonode(org.onosproject.bgpio.types.OspfPseudonode) OspfNonPseudonode(org.onosproject.bgpio.types.OspfNonPseudonode) IsIsNonPseudonode(org.onosproject.bgpio.types.IsIsNonPseudonode)

Aggregations

BgpValueType (org.onosproject.bgpio.types.BgpValueType)2 IsIsNonPseudonode (org.onosproject.bgpio.types.IsIsNonPseudonode)2 IsIsPseudonode (org.onosproject.bgpio.types.IsIsPseudonode)2 OspfNonPseudonode (org.onosproject.bgpio.types.OspfNonPseudonode)2 OspfPseudonode (org.onosproject.bgpio.types.OspfPseudonode)2 BgpLSIdentifierTlv (org.onosproject.bgpio.types.BgpLSIdentifierTlv)1