Search in sources :

Example 21 with Open

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open in project bgpcep by opendaylight.

the class FiniteStateMachineTest method testEstablishTLS.

/**
 * Establish PCEPS TLS connection with peer.
 */
@Test
public void testEstablishTLS() {
    final DefaultPCEPSessionNegotiator negotiator = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), this.channel, this.listener, (short) 1, 20, new OpenBuilder().setKeepalive(Uint8.ONE).build(), SslContextFactoryTest.createTlsConfig());
    negotiator.channelActive(null);
    assertEquals(1, this.msgsSend.size());
    assertTrue(this.msgsSend.get(0) instanceof Starttls);
    assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, negotiator.getState());
    negotiator.handleMessage(this.startTlsMsg);
    assertEquals(DefaultPCEPSessionNegotiator.State.OPEN_WAIT, negotiator.getState());
    assertEquals(2, this.msgsSend.size());
    assertTrue(this.msgsSend.get(1) instanceof Open);
    negotiator.handleMessage(this.openMsg);
    assertEquals(DefaultPCEPSessionNegotiator.State.KEEP_WAIT, negotiator.getState());
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder) Starttls(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Starttls) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open) Test(org.junit.Test)

Example 22 with Open

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open in project bgpcep by opendaylight.

the class PCCMockCommon method checkSynchronizedSession.

static void checkSynchronizedSession(final int numberOfLsp, final TestingSessionListener pceSessionListener, final Uint64 expectedeInitialDb) throws Exception {
    assertTrue(pceSessionListener.isUp());
    // Send Open with LspDBV = 1
    final int numberOfSyncMessage = 1;
    int numberOfLspExpected = numberOfLsp;
    if (!expectedeInitialDb.equals(Uint64.ZERO)) {
        checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedeInitialDb));
        numberOfLspExpected += numberOfSyncMessage;
    }
    checkReceivedMessages(pceSessionListener, numberOfLspExpected);
    final PCEPSession session = pceSessionListener.getSession();
    checkSession(session, DEAD_TIMER, KEEP_ALIVE);
    assertTrue(session.getRemoteTlvs().augmentation(Tlvs1.class).getStateful().augmentation(Stateful1.class).getInitiation());
    assertNull(session.getLocalTlvs().augmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue());
}
Also used : PCEPSession(org.opendaylight.protocol.pcep.PCEPSession) Tlvs3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.Tlvs3)

Example 23 with Open

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open in project controller by opendaylight.

the class CrossBrokerRpcTest method bindingRpcInvoker_DomRoutedProviderTest.

@Test
public void bindingRpcInvoker_DomRoutedProviderTest() throws Exception {
    KnockKnockOutputBuilder builder = new KnockKnockOutputBuilder();
    builder.setAnswer("open");
    final KnockKnockOutput output = builder.build();
    provisionRegistry.registerRpcImplementation((rpc, input) -> {
        ContainerNode result = testContext.getCodec().getCodecFactory().toNormalizedNodeRpcData(output);
        return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
    }, DOMRpcIdentifier.create(KNOCK_KNOCK_PATH, BI_NODE_C_ID));
    OpendaylightOfMigrationTestModelService baKnockInvoker = providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
    Future<RpcResult<KnockKnockOutput>> baResult = baKnockInvoker.knockKnock((knockKnock(BA_NODE_C_ID).setQuestion("Who's there?").build()));
    assertNotNull(baResult);
    assertEquals(output, baResult.get().getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) KnockKnockOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutputBuilder) KnockKnockOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockOutput) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) OpendaylightOfMigrationTestModelService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService) Test(org.junit.Test)

Example 24 with Open

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open in project controller by opendaylight.

the class CrossBrokerRpcTest method bindingRoutedRpcProvider_DomInvokerTest.

@Test
public void bindingRoutedRpcProvider_DomInvokerTest() throws Exception {
    // 
    knockService.registerPath(TestContext.class, // 
    BA_NODE_A_ID).registerPath(TestContext.class, // 
    BA_NODE_B_ID).setKnockKnockResult(knockResult(true, "open"));
    OpendaylightOfMigrationTestModelService baKnockInvoker = providerRegistry.getRpcService(OpendaylightOfMigrationTestModelService.class);
    assertNotSame(knockService, baKnockInvoker);
    KnockKnockInput knockKnockA = // 
    knockKnock(BA_NODE_A_ID).setQuestion("who's there?").build();
    ContainerNode knockKnockDom = toDomRpc(KNOCK_KNOCK_QNAME, knockKnockA);
    assertNotNull(knockKnockDom);
    DOMRpcResult domResult = biRpcInvoker.invokeRpc(KNOCK_KNOCK_PATH, knockKnockDom).get();
    assertNotNull(domResult);
    assertNotNull("DOM result is successful.", domResult.getResult());
    assertTrue("Bidning Add Flow RPC was captured.", knockService.getReceivedKnocks().containsKey(BA_NODE_A_ID));
    assertEquals(knockKnockA, knockService.getReceivedKnocks().get(BA_NODE_A_ID).iterator().next());
}
Also used : DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) BindingTestContext(org.opendaylight.controller.sal.binding.test.util.BindingTestContext) TestContext(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.rpc.routing.rev140701.TestContext) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) OpendaylightOfMigrationTestModelService(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.OpendaylightOfMigrationTestModelService) KnockKnockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.of.migration.test.model.rev150210.KnockKnockInput) Test(org.junit.Test)

Example 25 with Open

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open in project bgpcep by opendaylight.

the class BGPOpenMessageParser method parseMessageBody.

/**
 * Parses given byte array to BGP Open message
 *
 * @param body byte array representing BGP Open message, without header
 * @param messageLength the length of the message
 * @return {@link Open} BGP Open Message
 * @throws BGPDocumentedException if the parsing was unsuccessful
 */
@Override
public Open parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
    Preconditions.checkArgument(body != null, "Buffer cannot be null.");
    if (body.readableBytes() < MIN_MSG_LENGTH) {
        throw BGPDocumentedException.badMessageLength("Open message too small.", messageLength);
    }
    final int version = body.readUnsignedByte();
    if (version != BGP_VERSION) {
        throw new BGPDocumentedException("BGP Protocol version " + version + " not supported.", BGPError.VERSION_NOT_SUPPORTED);
    }
    final AsNumber as = new AsNumber((long) body.readUnsignedShort());
    final int holdTime = body.readUnsignedShort();
    if (holdTime == 1 || holdTime == 2) {
        throw new BGPDocumentedException("Hold time value not acceptable.", BGPError.HOLD_TIME_NOT_ACC);
    }
    Ipv4Address bgpId = null;
    try {
        bgpId = Ipv4Util.addressForByteBuf(body);
    } catch (final IllegalArgumentException e) {
        throw new BGPDocumentedException("BGP Identifier is not a valid IPv4 Address", BGPError.BAD_BGP_ID, e);
    }
    final int optLength = body.readUnsignedByte();
    final List<BgpParameters> optParams = new ArrayList<>();
    if (optLength > 0) {
        fillParams(body.slice(), optParams);
    }
    LOG.debug("BGP Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as, holdTime, bgpId, optParams);
    return new OpenBuilder().setMyAsNumber(as.getValue().intValue()).setHoldTimer(holdTime).setBgpIdentifier(bgpId).setBgpParameters(optParams).build();
}
Also used : OpenBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.OpenBuilder) BGPDocumentedException(org.opendaylight.protocol.bgp.parser.BGPDocumentedException) ArrayList(java.util.ArrayList) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)

Aggregations

Test (org.junit.Test)21 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Open)19 OpenBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder)14 BGPDocumentedException (org.opendaylight.protocol.bgp.parser.BGPDocumentedException)10 Ipv4AddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone)10 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParameters)10 Notification (org.opendaylight.yangtools.yang.binding.Notification)10 ByteBuf (io.netty.buffer.ByteBuf)9 ArrayList (java.util.ArrayList)9 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)8 BgpParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.BgpParametersBuilder)8 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities)8 OptionalCapabilitiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilitiesBuilder)8 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)8 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.ProtocolVersion)7 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder)7 MultiprotocolCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.MultiprotocolCapabilityBuilder)6 Open (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open)6 Notify (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Notify)5 BGPSessionPreferences (org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences)4