Search in sources :

Example 41 with BgpValueType

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

the class BgpControllerImplTest method testBgpUpdateMessage8.

/**
 * 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));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) BgpPrefixLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpPrefixLSIdentifier) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) LinkedList(java.util.LinkedList) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) BgpId(org.onosproject.bgp.controller.BgpId) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) AdjRibIn(org.onosproject.bgp.controller.impl.AdjRibIn) Test(org.junit.Test)

Example 42 with BgpValueType

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

the class BgpControllerImplTest method bgpOpenMessageTest4.

@Test
public void bgpOpenMessageTest4() throws InterruptedException {
    // Open message with invalid as number
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    peer1.peerChannelHandler.isLargeAsCapabilitySet = true;
    BgpValueType tempTlv = new FourOctetAsNumCapabilityTlv(766545);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv);
    peer1.connect(connectToSocket);
    boolean result;
    result = peer1.peerFrameDecoder.receivedNotificationMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) FourOctetAsNumCapabilityTlv(org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv) Test(org.junit.Test)

Example 43 with BgpValueType

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

the class BgpControllerImplTest method testBgpUpdateMessage3.

/**
 * Peer1 has Link NLRI (MpReach).
 */
@Test
public void testBgpUpdateMessage3() throws InterruptedException, TestUtilsException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    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.10", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.10"));
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> localNodeSubTlvs = new LinkedList<>();
    LinkedList<BgpValueType> remoteNodeSubTlvs = new LinkedList<>();
    BgpValueType tlv = AutonomousSystemTlv.of(2222);
    localNodeSubTlvs.add(tlv);
    remoteNodeSubTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    localNodeSubTlvs.add(tlv);
    remoteNodeSubTlvs.add(tlv);
    byte[] isoNodeID = new byte[] { 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21 };
    tlv = IsIsPseudonode.of(isoNodeID, (byte) 0x03);
    localNodeSubTlvs.add(tlv);
    isoNodeID = new byte[] { 0x19, 0x00, (byte) 0x95, 0x02, 0x50, 0x21 };
    tlv = IsIsNonPseudonode.of(isoNodeID);
    remoteNodeSubTlvs.add(tlv);
    NodeDescriptors localNodeDes = new NodeDescriptors(localNodeSubTlvs, (short) 0x1b, (short) 256);
    NodeDescriptors remoteNodeDes = new NodeDescriptors(remoteNodeSubTlvs, (short) 0x1a, (short) 0x101);
    LinkedList<BgpValueType> linkDescriptor = new LinkedList<>();
    tlv = IPv4AddressTlv.of(Ip4Address.valueOf("2.2.2.2"), (short) 0x103);
    linkDescriptor.add(tlv);
    BgpLinkLSIdentifier key = new BgpLinkLSIdentifier(localNodeDes, remoteNodeDes, linkDescriptor);
    TimeUnit.MILLISECONDS.sleep(200);
    AdjRibIn adj = peer.adjRib();
    // In Adj-RIB, linkTree should contain specified key
    assertThat(adj.linkTree().containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRib();
    TimeUnit.MILLISECONDS.sleep(200);
    // In Local-RIB, linkTree should contain specified key
    assertThat(obj.linkTree().containsKey(key), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) LinkedList(java.util.LinkedList) BgpId(org.onosproject.bgp.controller.BgpId) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) AdjRibIn(org.onosproject.bgp.controller.impl.AdjRibIn) BgpLinkLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier) Test(org.junit.Test)

Example 44 with BgpValueType

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

the class BgpControllerImplTest method bgpOpenMessageTest6.

@Test
public void bgpOpenMessageTest6() throws InterruptedException {
    // Open message with as4 capability
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    peer1.peerChannelHandler.isLargeAsCapabilitySet = true;
    bgpControllerImpl.getConfig().setLargeASCapability(true);
    BgpValueType tempTlv = new FourOctetAsNumCapabilityTlv(200);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv);
    peer1.connect(connectToSocket);
    boolean result;
    result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
    result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
    result = peer1.peerFrameDecoder.receivedKeepaliveMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) FourOctetAsNumCapabilityTlv(org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv) Test(org.junit.Test)

Example 45 with BgpValueType

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

the class BgpControllerImplTest method bgpOpenMessageTest8.

@Test
public void bgpOpenMessageTest8() throws InterruptedException {
    // Open message with route policy distribution capability
    short afi = Constants.AFI_FLOWSPEC_RPD_VALUE;
    byte res = 0;
    byte safi = Constants.SAFI_FLOWSPEC_RPD_VALUE;
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    bgpControllerImpl.getConfig().setFlowSpecRpdCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer1.connect(connectToSocket);
    boolean result;
    result = peer1.peerFrameDecoder.receivedOpenMessageLatch.await(MESSAGE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
    assertThat(result, is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) Test(org.junit.Test)

Aggregations

BgpValueType (org.onosproject.bgpio.types.BgpValueType)83 Test (org.junit.Test)57 LinkedList (java.util.LinkedList)52 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)50 BgpHeader (org.onosproject.bgpio.types.BgpHeader)33 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)31 AsPath (org.onosproject.bgpio.types.AsPath)29 Origin (org.onosproject.bgpio.types.Origin)29 Med (org.onosproject.bgpio.types.Med)27 BgpPathAttributes (org.onosproject.bgpio.protocol.ver4.BgpPathAttributes)26 OriginType (org.onosproject.bgpio.types.Origin.OriginType)26 ProtocolType (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4.ProtocolType)24 LinkStateAttributes (org.onosproject.bgpio.types.LinkStateAttributes)24 IpPrefix (org.onlab.packet.IpPrefix)21 MultiProtocolExtnCapabilityTlv (org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv)16 NodeDescriptors (org.onosproject.bgpio.protocol.linkstate.NodeDescriptors)13 Ip4Address (org.onlab.packet.Ip4Address)12 PathAttrNlriDetails (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails)11 PathAttrNlriDetailsLocalRib (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib)11 IpAddress (org.onlab.packet.IpAddress)10