本文整理汇总了Java中org.onosproject.bgpio.types.OspfPseudonode类的典型用法代码示例。如果您正苦于以下问题:Java OspfPseudonode类的具体用法?Java OspfPseudonode怎么用?Java OspfPseudonode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OspfPseudonode类属于org.onosproject.bgpio.types包,在下文中一共展示了OspfPseudonode类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: add
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
/**
* 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.info("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;
}
示例2: add
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
/**
* 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;
}
示例3: read
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
/**
* Reads node descriptors Sub-TLVs.
*
* @param cb ChannelBuffer
* @param desLength node descriptor length
* @param desType local node descriptor or remote node descriptor type
* @param protocolId protocol ID
* @return object of NodeDescriptors
* @throws BgpParseException while parsing node descriptors
*/
public static NodeDescriptors read(ChannelBuffer cb, short desLength, short desType, byte protocolId)
throws BgpParseException {
log.debug("Read NodeDescriptor");
List<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = null;
while (cb.readableBytes() > 0) {
ChannelBuffer tempBuf = cb.copy();
short type = cb.readShort();
short length = cb.readShort();
if (cb.readableBytes() < length) {
throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.OPTIONAL_ATTRIBUTE_ERROR,
tempBuf.readBytes(cb.readableBytes() + TYPE_AND_LEN));
}
ChannelBuffer tempCb = cb.readBytes(length);
switch (type) {
case AutonomousSystemTlv.TYPE:
tlv = AutonomousSystemTlv.read(tempCb);
break;
case BgpLSIdentifierTlv.TYPE:
tlv = BgpLSIdentifierTlv.read(tempCb);
break;
case AreaIDTlv.TYPE:
tlv = AreaIDTlv.read(tempCb);
break;
case IGP_ROUTERID_TYPE:
if (protocolId == IS_IS_LEVEL_1_PROTOCOL_ID || protocolId == IS_IS_LEVEL_2_PROTOCOL_ID) {
boolean isNonPseudoNode = true;
if ((length == ISISPSEUDONODE_LEN) && (tempCb.getByte(ISISPSEUDONODE_LEN - 1) != 0)) {
isNonPseudoNode = false;
}
if (isNonPseudoNode) {
tlv = IsIsNonPseudonode.read(tempCb);
} else {
tlv = IsIsPseudonode.read(tempCb);
}
} else if (protocolId == OSPF_V2_PROTOCOL_ID || protocolId == OSPF_V3_PROTOCOL_ID) {
if (length == OSPFNONPSEUDONODE_LEN) {
tlv = OspfNonPseudonode.read(tempCb);
} else if (length == OSPFPSEUDONODE_LEN) {
tlv = OspfPseudonode.read(tempCb);
}
}
break;
default:
UnSupportedAttribute.skipBytes(tempCb, length);
}
subTlvs.add(tlv);
}
return new NodeDescriptors(subTlvs, desLength, desType);
}
示例4: compareTo
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
/**
* 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;
}
示例5: addNode
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
@Override
public void addNode(BgpNodeLSNlriVer4 nodeNlri, PathAttrNlriDetails details) {
log.debug("Add node {}", nodeNlri.toString());
if (deviceProviderService == null || deviceService == null) {
return;
}
Device.Type deviceType = ROUTER;
BgpDpid nodeUri = new BgpDpid(nodeNlri);
DeviceId deviceId = deviceId(uri(nodeUri.toString()));
ChassisId cId = new ChassisId();
/*
* Check if device is already there (available) , if yes not updating to core.
*/
if (deviceService.isAvailable(deviceId)) {
return;
}
DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
newBuilder.set(AnnotationKeys.DRIVER, "l3Device");
newBuilder.set(AnnotationKeys.TYPE, "L3");
newBuilder.set(ROUTING_UNIVERSE, Long.toString(nodeNlri.getIdentifier()));
List<BgpValueType> tlvs = nodeNlri.getLocalNodeDescriptors().getNodedescriptors().getSubTlvs();
for (BgpValueType tlv : tlvs) {
if (tlv instanceof AutonomousSystemTlv) {
newBuilder.set(AS_NUMBER, Integer.toString(((AutonomousSystemTlv) tlv).getAsNum()));
} else if (tlv instanceof BgpLSIdentifierTlv) {
newBuilder.set(DOMAIN_IDENTIFIER,
Integer.toString(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier()));
}
if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
if (tlv instanceof IsIsPseudonode) {
deviceType = VIRTUAL;
newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsPseudonode) tlv)
.getIsoNodeId()));
} else if (tlv instanceof OspfPseudonode) {
deviceType = VIRTUAL;
newBuilder
.set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfPseudonode) tlv).getrouterID()));
} else if (tlv instanceof IsIsNonPseudonode) {
newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsNonPseudonode) tlv)
.getIsoNodeId()));
} else if (tlv instanceof OspfNonPseudonode) {
newBuilder.set(AnnotationKeys.ROUTER_ID,
Integer.toString(((OspfNonPseudonode) tlv).getrouterID()));
}
}
}
DefaultAnnotations.Builder anntotations = DefaultAnnotations.builder();
anntotations = getAnnotations(newBuilder, true, details);
DeviceDescription description = new DefaultDeviceDescription(uri(nodeUri.toString()), deviceType, UNKNOWN,
UNKNOWN, UNKNOWN, UNKNOWN, cId, anntotations.build());
deviceProviderService.deviceConnected(deviceId, description);
}
示例6: buildLinkDes
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
private LinkDescription buildLinkDes(BgpLinkLsNlriVer4 linkNlri, PathAttrNlriDetails details, boolean isAddLink)
throws BgpParseException {
long srcAddress = 0;
long dstAddress = 0;
boolean localPseduo = false;
boolean remotePseduo = false;
List<BgpValueType> localTlvs = linkNlri.getLinkIdentifier().localNodeDescriptors().getSubTlvs();
for (BgpValueType localTlv : localTlvs) {
if (localTlv instanceof IsIsPseudonode || localTlv instanceof OspfPseudonode) {
localPseduo = true;
}
}
List<BgpValueType> remoteTlvs = linkNlri.getLinkIdentifier().remoteNodeDescriptors().getSubTlvs();
for (BgpValueType remoteTlv : remoteTlvs) {
if (remoteTlv instanceof IsIsPseudonode || remoteTlv instanceof OspfPseudonode) {
remotePseduo = true;
}
}
List<BgpValueType> tlvs = linkNlri.getLinkIdentifier().linkDescriptors();
for (BgpValueType tlv : tlvs) {
if (tlv instanceof LinkLocalRemoteIdentifiersTlv) {
srcAddress = ((LinkLocalRemoteIdentifiersTlv) tlv).getLinkLocalIdentifier();
//Set 32nd bit.
srcAddress = srcAddress | IDENTIFIER_SET;
dstAddress = ((LinkLocalRemoteIdentifiersTlv) tlv).getLinkRemoteIdentifier();
dstAddress = dstAddress | IDENTIFIER_SET;
} else if (tlv instanceof IPv4AddressTlv) {
if (tlv.getType() == BgpLinkLSIdentifier.IPV4_INTERFACE_ADDRESS_TYPE) {
srcAddress = ((IPv4AddressTlv) tlv).address().toInt();
} else {
dstAddress = ((IPv4AddressTlv) tlv).address().toInt();
}
}
}
DeviceId srcId = deviceId(uri(new BgpDpid(linkNlri, BgpDpid.NODE_DESCRIPTOR_LOCAL).toString()));
DeviceId dstId = deviceId(uri(new BgpDpid(linkNlri, BgpDpid.NODE_DESCRIPTOR_REMOTE).toString()));
if (localPseduo && srcAddress == 0) {
srcAddress = PSEUDO_PORT;
} else if (remotePseduo && dstAddress == 0) {
dstAddress = PSEUDO_PORT;
}
ConnectPoint src = new ConnectPoint(srcId, PortNumber.portNumber(srcAddress));
ConnectPoint dst = new ConnectPoint(dstId, PortNumber.portNumber(dstAddress));
BgpNodeLSNlriVer4 srcNodeNlri = new BgpNodeLSNlriVer4(linkNlri.getIdentifier(), linkNlri.getProtocolId()
.getType(), new BgpNodeLSIdentifier(linkNlri.getLinkIdentifier().localNodeDescriptors()), false,
linkNlri.getRouteDistinguisher());
BgpNodeLSNlriVer4 dstNodeNlri = new BgpNodeLSNlriVer4(linkNlri.getIdentifier(), linkNlri.getProtocolId()
.getType(), new BgpNodeLSIdentifier(linkNlri.getLinkIdentifier().remoteNodeDescriptors()), false,
linkNlri.getRouteDistinguisher());
addOrDeletePseudoNode(isAddLink, localPseduo, remotePseduo, srcNodeNlri,
dstNodeNlri, srcId, dstId, details);
DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder();
if (details != null) {
annotationBuilder = getAnnotations(annotationBuilder, false, details);
}
return new DefaultLinkDescription(src, dst, Link.Type.DIRECT, false, annotationBuilder.build());
}
示例7: getAnnotations
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
private DefaultAnnotations.Builder getAnnotations(DefaultAnnotations.Builder annotationBuilder, boolean isNode,
PathAttrNlriDetails details) {
List<BgpValueType> attribute = details.pathAttributes().stream()
.filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
if (attribute.isEmpty()) {
return annotationBuilder;
}
List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
boolean abrBit = false;
boolean externalBit = false;
boolean pseudo = false;
int igpMetric = 0;
int teMetric = 0;
byte[] areaId = null;
Ip4Address routerId = null;
for (BgpValueType tlv : tlvs) {
switch (tlv.getType()) {
case LinkStateAttributes.ATTR_NODE_FLAG_BITS:
abrBit = ((BgpAttrNodeFlagBitTlv) tlv).abrBit();
externalBit = ((BgpAttrNodeFlagBitTlv) tlv).externalBit();
break;
case NodeDescriptors.IGP_ROUTERID_TYPE:
if (tlv instanceof IsIsPseudonode || tlv instanceof OspfPseudonode) {
pseudo = true;
}
break;
case LinkStateAttributes.ATTR_NODE_ISIS_AREA_ID:
areaId = ((BgpAttrNodeIsIsAreaId) tlv).attrNodeIsIsAreaId();
break;
case LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID:
routerId = ((BgpAttrRouterIdV4) tlv).attrRouterId();
break;
case LinkStateAttributes.ATTR_LINK_IGP_METRIC:
igpMetric = ((BgpLinkAttrIgpMetric) tlv).attrLinkIgpMetric();
break;
case LinkStateAttributes.ATTR_LINK_TE_DEFAULT_METRIC:
teMetric = ((BgpLinkAttrTeDefaultMetric) tlv).attrLinkDefTeMetric();
break;
default: // do nothing
}
}
// Annotations for device
if (isNode) {
boolean internalBit = false;
if (!abrBit && !externalBit) {
internalBit = true;
}
annotationBuilder.set(EXTERNAL_BIT, String.valueOf(externalBit));
annotationBuilder.set(ABR_BIT, String.valueOf(abrBit));
annotationBuilder.set(INTERNAL_BIT, String.valueOf(internalBit));
annotationBuilder.set(PSEUDO, String.valueOf(pseudo));
if (areaId != null) {
annotationBuilder.set(AREAID, new String(areaId));
}
if (routerId != null) {
// LsrID
annotationBuilder.set(LSRID, String.valueOf(routerId));
}
} else {
// Annotations for link
if (igpMetric != 0) {
annotationBuilder.set(COST, String.valueOf(igpMetric));
}
if (teMetric != 0) {
annotationBuilder.set(TE_COST, String.valueOf(teMetric));
}
}
return annotationBuilder;
}
示例8: addNode
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
@Override
public void addNode(BgpNodeLSNlriVer4 nodeNlri, PathAttrNlriDetails details) {
log.debug("Add node {}", nodeNlri.toString());
if (deviceProviderService == null || deviceService == null) {
return;
}
Device.Type deviceType = ROUTER;
BgpDpid nodeUri = new BgpDpid(nodeNlri);
DeviceId deviceId = deviceId(uri(nodeUri.toString()));
ChassisId cId = new ChassisId();
/*
* Check if device is already there (available) , if yes not updating to core.
*/
if (deviceService.isAvailable(deviceId)) {
return;
}
DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
newBuilder.set(AnnotationKeys.TYPE, "L3");
newBuilder.set(ROUTING_UNIVERSE, Long.toString(nodeNlri.getIdentifier()));
List<BgpValueType> tlvs = nodeNlri.getLocalNodeDescriptors().getNodedescriptors().getSubTlvs();
for (BgpValueType tlv : tlvs) {
if (tlv instanceof AutonomousSystemTlv) {
newBuilder.set(AS_NUMBER, Integer.toString(((AutonomousSystemTlv) tlv).getAsNum()));
} else if (tlv instanceof BgpLSIdentifierTlv) {
newBuilder.set(DOMAIN_IDENTIFIER,
Integer.toString(((BgpLSIdentifierTlv) tlv).getBgpLsIdentifier()));
}
if (tlv.getType() == NodeDescriptors.IGP_ROUTERID_TYPE) {
if (tlv instanceof IsIsPseudonode) {
deviceType = VIRTUAL;
newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsPseudonode) tlv)
.getIsoNodeId()));
} else if (tlv instanceof OspfPseudonode) {
deviceType = VIRTUAL;
newBuilder
.set(AnnotationKeys.ROUTER_ID, Integer.toString(((OspfPseudonode) tlv).getrouterID()));
} else if (tlv instanceof IsIsNonPseudonode) {
newBuilder.set(AnnotationKeys.ROUTER_ID, nodeUri.isoNodeIdString(((IsIsNonPseudonode) tlv)
.getIsoNodeId()));
} else if (tlv instanceof OspfNonPseudonode) {
newBuilder.set(AnnotationKeys.ROUTER_ID,
Integer.toString(((OspfNonPseudonode) tlv).getrouterID()));
}
}
}
DefaultAnnotations.Builder anntotations = DefaultAnnotations.builder();
anntotations = getAnnotations(newBuilder, true, details);
DeviceDescription description = new DefaultDeviceDescription(uri(nodeUri.toString()), deviceType, UNKNOWN,
UNKNOWN, UNKNOWN, UNKNOWN, cId, anntotations.build());
deviceProviderService.deviceConnected(deviceId, description);
}
示例9: getAnnotations
import org.onosproject.bgpio.types.OspfPseudonode; //导入依赖的package包/类
private DefaultAnnotations.Builder getAnnotations(DefaultAnnotations.Builder annotationBuilder, boolean isNode,
PathAttrNlriDetails details) {
List<BgpValueType> attribute = details.pathAttributes().stream()
.filter(attr -> attr instanceof LinkStateAttributes).collect(toList());
if (attribute.isEmpty()) {
return annotationBuilder;
}
List<BgpValueType> tlvs = ((LinkStateAttributes) attribute.iterator().next()).linkStateAttributes();
boolean abrBit = false;
boolean externalBit = false;
boolean pseudo = false;
byte[] areaId = null;
Ip4Address routerId = null;
for (BgpValueType tlv : tlvs) {
switch (tlv.getType()) {
case LinkStateAttributes.ATTR_NODE_FLAG_BITS:
abrBit = ((BgpAttrNodeFlagBitTlv) tlv).abrBit();
externalBit = ((BgpAttrNodeFlagBitTlv) tlv).externalBit();
break;
case NodeDescriptors.IGP_ROUTERID_TYPE:
if (tlv instanceof IsIsPseudonode || tlv instanceof OspfPseudonode) {
pseudo = true;
}
break;
case LinkStateAttributes.ATTR_NODE_ISIS_AREA_ID:
areaId = ((BgpAttrNodeIsIsAreaId) tlv).attrNodeIsIsAreaId();
break;
case LinkStateAttributes.ATTR_NODE_IPV4_LOCAL_ROUTER_ID:
routerId = ((BgpAttrRouterIdV4) tlv).attrRouterId();
break;
default: // do nothing
}
}
// Annotations for device
if (isNode) {
boolean internalBit = false;
if (!abrBit && !externalBit) {
internalBit = true;
}
annotationBuilder.set(EXTERNAL_BIT, String.valueOf(externalBit));
annotationBuilder.set(ABR_BIT, String.valueOf(abrBit));
annotationBuilder.set(INTERNAL_BIT, String.valueOf(internalBit));
annotationBuilder.set(PSEUDO, String.valueOf(pseudo));
if (areaId != null) {
annotationBuilder.set(AREAID, new String(areaId));
}
if (routerId != null) {
// LsrID
annotationBuilder.set(LSRID, String.valueOf(routerId));
}
}
return annotationBuilder;
}