Search in sources :

Example 1 with RouteDistinguisher

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

the class BgpEvpnRouteType2Nlri method read.

/**
 * Reads the Evpn type 2 attributes.
 *
 * @param cb channel buffer
 * @return type2 route
 * @throws BgpParseException parse exception
 */
public static BgpEvpnRouteType2Nlri read(ChannelBuffer cb) throws BgpParseException {
    if (cb.readableBytes() == 0) {
        return null;
    }
    RouteDistinguisher rd = RouteDistinguisher.read(cb);
    BgpEvpnEsi esi = BgpEvpnEsi.read(cb);
    int ethernetTagID = cb.readInt();
    byte macAddressLength = cb.readByte();
    MacAddress macAddress = Validation.toMacAddress(macAddressLength / 8, cb);
    byte ipAddressLength = cb.readByte();
    InetAddress ipAddress = null;
    if (ipAddressLength > 0) {
        ipAddress = Validation.toInetAddress(ipAddressLength / 8, cb);
    }
    BgpEvpnLabel mplsLabel1 = BgpEvpnLabel.read(cb);
    BgpEvpnLabel mplsLabel2 = null;
    if (cb.readableBytes() > 0) {
        mplsLabel2 = BgpEvpnLabel.read(cb);
    }
    return new BgpEvpnRouteType2Nlri(rd, esi, ethernetTagID, macAddress, ipAddress, mplsLabel1, mplsLabel2);
}
Also used : BgpEvpnLabel(org.onosproject.bgpio.types.BgpEvpnLabel) BgpEvpnEsi(org.onosproject.bgpio.types.BgpEvpnEsi) RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher) MacAddress(org.onlab.packet.MacAddress) InetAddress(java.net.InetAddress)

Example 2 with RouteDistinguisher

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

the class BgpNodeLSNlriVer4 method read.

/**
 * Reads from channelBuffer and parses Node LS Nlri.
 *
 * @param cb ChannelBuffer
 * @param afi Address Family Identifier
 * @param safi Subsequent Address Family Identifier
 * @return object of this class
 * @throws BgpParseException while parsing node descriptors
 */
public static BgpNodeLSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
    boolean isVpn = false;
    RouteDistinguisher routeDistinguisher = null;
    if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
        routeDistinguisher = new RouteDistinguisher();
        routeDistinguisher = RouteDistinguisher.read(cb);
        isVpn = true;
    } else {
        isVpn = false;
    }
    byte protocolId = cb.readByte();
    long identifier = cb.readLong();
    log.debug("Parse local node descriptors");
    BgpNodeLSIdentifier localNodeDescriptors = new BgpNodeLSIdentifier();
    localNodeDescriptors = BgpNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
    return new BgpNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
}
Also used : RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher)

Example 3 with RouteDistinguisher

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

the class BgpPrefixIPv4LSNlriVer4 method read.

/**
 * Reads from channelBuffer and parses Prefix LS Nlri.
 *
 * @param cb ChannelBuffer
 * @param afi Address family identifier
 * @param safi Subsequent address family identifier
 * @return object of BGPPrefixIPv4LSNlriVer4
 * @throws BgpParseException while parsing Prefix LS Nlri
 */
public static BgpPrefixIPv4LSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BgpParseException {
    boolean isVpn = false;
    RouteDistinguisher routeDistinguisher = null;
    if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
        routeDistinguisher = new RouteDistinguisher();
        routeDistinguisher = RouteDistinguisher.read(cb);
        isVpn = true;
    } else {
        isVpn = false;
    }
    byte protocolId = cb.readByte();
    long identifier = cb.readLong();
    BgpPrefixLSIdentifier bgpPrefixLSIdentifier = new BgpPrefixLSIdentifier();
    bgpPrefixLSIdentifier = BgpPrefixLSIdentifier.parsePrefixIdendifier(cb, protocolId);
    return new BgpPrefixIPv4LSNlriVer4(identifier, protocolId, bgpPrefixLSIdentifier, routeDistinguisher, isVpn);
}
Also used : RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher)

Example 4 with RouteDistinguisher

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

the class BgpControllerImplTest method testBgpUpdateMessage4.

/**
 * Peer1 has Node NLRI and Peer2 has Node NLRI with different MpReach and MpUnReach with VPN.
 */
@Test
public void testBgpUpdateMessage4() throws InterruptedException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    short afi = 16388;
    byte res = 0;
    byte safi = (byte) 0x80;
    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    Channel channel = peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.35", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    IpAddress ipAddress = IpAddress.valueOf("127.0.0.35");
    BgpId bgpId = new BgpId(ipAddress);
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> subTlvs1 = new LinkedList<>();
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = AutonomousSystemTlv.of(2478);
    subTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs.add(tlv);
    NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256);
    BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes);
    RouteDistinguisher rd = new RouteDistinguisher((long) 0x0A);
    VpnAdjRibIn vpnAdj = peer.vpnAdjRib();
    // In Adj-RIB, vpnNodeTree should contain rd
    assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true));
    Map<BgpNodeLSIdentifier, PathAttrNlriDetails> treeValue = vpnAdj.vpnNodeTree().get(rd);
    // In Adj-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(treeValue.containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn();
    // In Local-RIB, vpnNodeTree should contain rd
    assertThat(obj.vpnNodeTree().containsKey(rd), is(true));
    Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> value = obj.vpnNodeTree().get(rd);
    // In Local-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(value.containsKey(key), is(true));
    peer2.peerChannelHandler.asNumber = 200;
    peer2.peerChannelHandler.version = 4;
    peer2.peerChannelHandler.holdTime = 120;
    bgpControllerImpl.getConfig().setLsCapability(true);
    tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer2.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.40", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer2
    bgpId = new BgpId(IpAddress.valueOf("127.0.0.40"));
    peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    tlv = AutonomousSystemTlv.of(686);
    subTlvs1.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs1.add(tlv);
    nodeDes = new NodeDescriptors(subTlvs1, (short) 0x10, (short) 256);
    key = new BgpNodeLSIdentifier(nodeDes);
    vpnAdj = peer.vpnAdjRib();
    // In Adj-RIB, vpnNodeTree should contain rd
    assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true));
    treeValue = vpnAdj.vpnNodeTree().get(rd);
    // In Adj-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(treeValue.containsKey(key), is(true));
    // Disconnect peer1
    channel.disconnect();
    channel.close();
    obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn();
    // In Local-RIB, vpnNodeTree should contain rd
    assertThat(obj.vpnNodeTree().containsKey(rd), is(true));
    value = obj.vpnNodeTree().get(rd);
    // In Local-RIB, vpnNodeTree should contain rd key which contains specified value
    assertThat(value.containsKey(key), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.netty.channel.Channel) RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) LinkedList(java.util.LinkedList) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) BgpId(org.onosproject.bgp.controller.BgpId) PathAttrNlriDetails(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails) IpAddress(org.onlab.packet.IpAddress) Test(org.junit.Test)

Example 5 with RouteDistinguisher

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

the class BgpControllerImplTest method testBgpUpdateMessage9.

/**
 * Peer1 has Node NLRI (MpReach) and Peer2 has node NLRI with different MpReach
 * and MpUnReach with IsIsNonPseudonode.
 */
@Test
public void testBgpUpdateMessage9() throws InterruptedException {
    // Initiate the connections
    peer1.peerChannelHandler.asNumber = 200;
    peer1.peerChannelHandler.version = 4;
    peer1.peerChannelHandler.holdTime = 120;
    short afi = 16388;
    byte res = 0;
    byte safi = (byte) 0x80;
    bgpControllerImpl.getConfig().setLsCapability(true);
    BgpValueType tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer1.peerChannelHandler.capabilityTlv.add(tempTlv1);
    Channel channel = peer1.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.30", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer1
    BgpId bgpId = new BgpId(IpAddress.valueOf("127.0.0.30"));
    BgpPeerImpl peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    LinkedList<BgpValueType> subTlvs = new LinkedList<>();
    BgpValueType tlv = AutonomousSystemTlv.of(2478);
    subTlvs.add(tlv);
    tlv = BgpLSIdentifierTlv.of(33686018);
    subTlvs.add(tlv);
    NodeDescriptors nodeDes = new NodeDescriptors(subTlvs, (short) 0x10, (short) 256);
    BgpNodeLSIdentifier key = new BgpNodeLSIdentifier(nodeDes);
    RouteDistinguisher rd = new RouteDistinguisher((long) 0x0A);
    VpnAdjRibIn vpnAdj = peer.vpnAdjRib();
    // In Adj-RIB, vpnNodeTree should contain specified rd
    assertThat(vpnAdj.vpnNodeTree().containsKey(rd), is(true));
    Map<BgpNodeLSIdentifier, PathAttrNlriDetails> treeValue = vpnAdj.vpnNodeTree().get(rd);
    // In Adj-RIB, vpnNodeTree should contain specified rd with specified value
    assertThat(treeValue.containsKey(key), is(true));
    BgpLocalRibImpl obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn();
    // In Local-RIB, vpnNodeTree should contain specified rd
    assertThat(obj.vpnNodeTree().containsKey(rd), is(true));
    Map<BgpNodeLSIdentifier, PathAttrNlriDetailsLocalRib> value = obj.vpnNodeTree().get(rd);
    // In Local-RIB, vpnNodeTree should contain specified rd with specified value
    assertThat(value.containsKey(key), is(true));
    peer2.peerChannelHandler.asNumber = 200;
    peer2.peerChannelHandler.version = 4;
    peer2.peerChannelHandler.holdTime = 120;
    bgpControllerImpl.getConfig().setLsCapability(true);
    tempTlv1 = new MultiProtocolExtnCapabilityTlv(afi, res, safi);
    peer2.peerChannelHandler.capabilityTlv.add(tempTlv1);
    peer2.connectFrom(connectToSocket, new InetSocketAddress("127.0.0.50", 0));
    TimeUnit.MILLISECONDS.sleep(1000);
    // Get peer2
    bgpId = new BgpId(IpAddress.valueOf("127.0.0.50"));
    peer = (BgpPeerImpl) bgpControllerImpl.getPeer(bgpId);
    key = new BgpNodeLSIdentifier(nodeDes);
    vpnAdj = peer.vpnAdjRib();
    // In Adj-RIB, vpnNodeTree should be empty
    assertThat(vpnAdj.vpnNodeTree().isEmpty(), is(true));
    // peer1 disconnects
    channel.disconnect();
    channel.close();
    obj = (BgpLocalRibImpl) bgpControllerImpl.bgpLocalRibVpn();
    TimeUnit.MILLISECONDS.sleep(200);
    // In Local-RIB, vpnNodeTree should be empty
    assertThat(obj.vpnNodeTree().isEmpty(), is(true));
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) PathAttrNlriDetailsLocalRib(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib) BgpPeerImpl(org.onosproject.bgp.controller.impl.BgpPeerImpl) MultiProtocolExtnCapabilityTlv(org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv) BgpLocalRibImpl(org.onosproject.bgp.controller.impl.BgpLocalRibImpl) InetSocketAddress(java.net.InetSocketAddress) Channel(org.jboss.netty.channel.Channel) RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher) NodeDescriptors(org.onosproject.bgpio.protocol.linkstate.NodeDescriptors) BgpNodeLSIdentifier(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier) LinkedList(java.util.LinkedList) VpnAdjRibIn(org.onosproject.bgp.controller.impl.VpnAdjRibIn) BgpId(org.onosproject.bgp.controller.BgpId) PathAttrNlriDetails(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails) Test(org.junit.Test)

Aggregations

RouteDistinguisher (org.onosproject.bgpio.types.RouteDistinguisher)9 PathAttrNlriDetails (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails)5 BgpNodeLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSIdentifier)3 InetSocketAddress (java.net.InetSocketAddress)2 LinkedList (java.util.LinkedList)2 Channel (org.jboss.netty.channel.Channel)2 Test (org.junit.Test)2 BgpId (org.onosproject.bgp.controller.BgpId)2 BgpLocalRibImpl (org.onosproject.bgp.controller.impl.BgpLocalRibImpl)2 BgpPeerImpl (org.onosproject.bgp.controller.impl.BgpPeerImpl)2 VpnAdjRibIn (org.onosproject.bgp.controller.impl.VpnAdjRibIn)2 NodeDescriptors (org.onosproject.bgpio.protocol.linkstate.NodeDescriptors)2 PathAttrNlriDetailsLocalRib (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetailsLocalRib)2 BgpValueType (org.onosproject.bgpio.types.BgpValueType)2 MultiProtocolExtnCapabilityTlv (org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv)2 InetAddress (java.net.InetAddress)1 IpAddress (org.onlab.packet.IpAddress)1 MacAddress (org.onlab.packet.MacAddress)1 BgpLinkLSIdentifier (org.onosproject.bgpio.protocol.linkstate.BgpLinkLSIdentifier)1 BgpLinkLsNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4)1