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());
}
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());
}
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());
}
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());
}
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();
}
Aggregations