本文整理汇总了Java中org.onosproject.bgpio.types.IPReachabilityInformationTlv类的典型用法代码示例。如果您正苦于以下问题:Java IPReachabilityInformationTlv类的具体用法?Java IPReachabilityInformationTlv怎么用?Java IPReachabilityInformationTlv使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IPReachabilityInformationTlv类属于org.onosproject.bgpio.types包,在下文中一共展示了IPReachabilityInformationTlv类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testBgpUpdateMessage8
import org.onosproject.bgpio.types.IPReachabilityInformationTlv; //导入依赖的package包/类
/**
* Peer1 has Prefix NLRI (MpReach).
*/
@Test
public void testBgpUpdateMessage8() throws InterruptedException {
// Initiate the connections
peer1.peerChannelHandler.asNumber = 200;
peer1.peerChannelHandler.version = 4;
peer1.peerChannelHandler.holdTime = 150;
short afi = 16388;
byte res = 0;
byte safi = 71;
bgpControllerImpl.getConfig().setLsCapability(true);
BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.20", 0));
TimeUnit.MILLISECONDS.sleep(1000);
//Get peer1
BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.20"));
BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
LinkedList<BgpValueType> subTlvs = new LinkedList<>();
BgpValueType tlv = AutonomousSystemTlv.of(2222);
subTlvs.add(tlv);
tlv = BgpLSIdentifierTlv.of(33686018);
subTlvs.add(tlv);
byte[] isoNodeID = new byte[] {0x19, 0x21, 0x68, 0x07, 0x70, 0x01};
tlv = IsIsNonPseudonode.of(isoNodeID);
subTlvs.add(tlv);
NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x1a, (short) 256);
LinkedList<BgpValueType> prefixDescriptor = new LinkedList<>();
byte[] prefix = new byte[] {0x20, (byte) 0xc0, (byte) 0xa8, 0x4d, 0x01};
ChannelBuffer tempCb = ChannelBuffers.dynamicBuffer();
tempCb.writeBytes(prefix);
tlv = IPReachabilityInformationTlv.read(tempCb, (short) 5);
prefixDescriptor.add(tlv);
BgpPrefixLSIdentifier key = new BgpPrefixLSIdentifier(nodeDes, prefixDescriptor);
AdjRibIn adj = peer.adjRib();
//In Adj-RIB, prefixTree should contain specified key
assertThat(adj.prefixTree().containsKey(key), is(true));
BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
//In Local-RIB, prefixTree should contain specified key
assertThat(obj.prefixTree().containsKey(key), is(true));
}
示例2: parsePrefixDescriptors
import org.onosproject.bgpio.types.IPReachabilityInformationTlv; //导入依赖的package包/类
/**
* 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);
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;
}