use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder in project bgpcep by opendaylight.
the class FSMTest method sendNotification.
@Test
public void sendNotification() {
this.clientSession.channelActive(null);
this.clientSession.handleMessage(this.classicOpen);
this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPClientSessionNegotiator.State.FINISHED);
this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
assertEquals(3, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(2) instanceof Notify);
final Notification m = this.receivedMsgs.get(2);
assertEquals(BGPError.FSM_ERROR.getCode(), ((Notify) m).getErrorCode().shortValue());
assertEquals(BGPError.FSM_ERROR.getSubcode(), ((Notify) m).getErrorSubcode().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder in project bgpcep by opendaylight.
the class PCEPTestingToolTest method testSimpleSessionListener.
@Test
public void testSimpleSessionListener() {
final TestingSessionListener ssl = new TestingSessionListener();
assertEquals(0, ssl.messages().size());
ssl.onMessage(null, new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build());
assertEquals(1, ssl.messages().size());
assertTrue(ssl.messages().get(0) instanceof KeepaliveMessage);
assertFalse(ssl.isUp());
ssl.onSessionUp(null);
assertTrue(ssl.isUp());
ssl.onSessionDown(null, null);
assertFalse(ssl.isUp());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder in project bgpcep by opendaylight.
the class RegistryTest method testRegistry.
@Test
public void testRegistry() throws PCEPDeserializerException {
this.regs.add(this.ctx.registerXROSubobjectParser(2, this.xroParser));
this.regs.add(this.ctx.registerXROSubobjectSerializer(AsNumberCase.class, this.xroSerializer));
this.regs.add(this.ctx.registerRROSubobjectParser(3, this.rroParser));
this.regs.add(this.ctx.registerRROSubobjectSerializer(LabelCase.class, this.rroSerializer));
this.regs.add(this.ctx.registerEROSubobjectParser(4, this.eroParser));
this.regs.add(this.ctx.registerEROSubobjectSerializer(IpPrefixCase.class, this.eroSerializer));
this.regs.add(this.ctx.registerTlvParser(1, this.tlvParser));
this.regs.add(this.ctx.registerTlvSerializer(OfList.class, this.tlvSerializer));
this.regs.add(this.ctx.registerObjectParser(5, 1, this.objectParser));
this.regs.add(this.ctx.registerObjectSerializer(Rp.class, this.objectSerializer));
this.regs.add(this.ctx.registerMessageParser(6, this.msgParser));
this.regs.add(this.ctx.registerMessageSerializer(Keepalive.class, this.msgSerializer));
this.regs.add(this.ctx.registerLabelParser(7, this.labelParser));
this.regs.add(this.ctx.registerLabelSerializer(Type1LabelCase.class, this.labelSerializer));
this.regs.add(this.ctx.registerVendorInformationObjectParser(new EnterpriseNumber(10L), this.objectParser));
this.regs.add(this.ctx.registerVendorInformationObjectSerializer(EnterpriseSpecificInformation.class, this.objectSerializer));
this.regs.add(this.ctx.registerVendorInformationTlvParser(new EnterpriseNumber(12L), this.tlvParser));
this.regs.add(this.ctx.registerVendorInformationTlvSerializer(EnterpriseSpecificInformation.class, this.tlvSerializer));
final ByteBuf buffer = Unpooled.buffer();
this.ctx.getXROSubobjectHandlerRegistry().parseSubobject(2, buffer, false);
this.ctx.getXROSubobjectHandlerRegistry().serializeSubobject(new SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
this.ctx.getEROSubobjectHandlerRegistry().parseSubobject(3, buffer, true);
this.ctx.getEROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
this.ctx.getRROSubobjectHandlerRegistry().parseSubobject(4, buffer);
this.ctx.getRROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().build()).build(), buffer);
this.ctx.getLabelHandlerRegistry().parseLabel(1, buffer);
this.ctx.getLabelHandlerRegistry().serializeLabel(true, false, new Type1LabelCaseBuilder().build(), buffer);
this.ctx.getTlvHandlerRegistry().parseTlv(2, buffer);
this.ctx.getTlvHandlerRegistry().serializeTlv(new OfListBuilder().build(), buffer);
this.ctx.getObjectHandlerRegistry().parseObject(4, 1, new ObjectHeaderImpl(true, false), buffer);
this.ctx.getObjectHandlerRegistry().serializeObject(new OpenBuilder().build(), buffer);
this.ctx.getMessageHandlerRegistry().parseMessage(6, buffer, Collections.emptyList());
this.ctx.getMessageHandlerRegistry().serializeMessage(new KeepaliveBuilder().build(), buffer);
this.ctx.getVendorInformationObjectRegistry().parseVendorInformationObject(new EnterpriseNumber(10L), new ObjectHeaderImpl(true, false), buffer);
this.ctx.getVendorInformationObjectRegistry().serializeVendorInformationObject(this.esi, buffer);
this.ctx.getVendorInformationTlvRegistry().parseVendorInformationTlv(new EnterpriseNumber(12L), buffer);
this.ctx.getVendorInformationTlvRegistry().serializeVendorInformationTlv(this.viTlv, buffer);
this.activator.start(this.ctx);
this.activator.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder in project bgpcep by opendaylight.
the class ParserTest method testKeepAliveMsg.
@Test
public void testKeepAliveMsg() throws BGPParsingException, BGPDocumentedException {
final Notification keepAlive = new KeepaliveBuilder().build();
final ByteBuf buffer = Unpooled.buffer();
ParserTest.reg.serializeMessage(keepAlive, buffer);
assertArrayEquals(keepAliveBMsg, ByteArray.getAllBytes(buffer));
final Notification m = ParserTest.reg.parseMessage(Unpooled.copiedBuffer(ByteArray.getAllBytes(buffer)), null);
assertTrue(m instanceof Keepalive);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder in project bgpcep by opendaylight.
the class AbstractBGPSessionNegotiator method handleOpen.
private synchronized void handleOpen(final Open openObj) {
final IpAddress remoteIp = getRemoteIp();
final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp);
try {
final BGPSessionListener peer = this.registry.getPeer(remoteIp, getSourceId(openObj, preferences), getDestinationId(openObj, preferences), openObj);
sendMessage(new KeepaliveBuilder().build());
this.state = State.OPEN_CONFIRM;
this.session = new BGPSessionImpl(peer, this.channel, openObj, preferences, this.registry);
this.session.setChannelExtMsgCoder(openObj);
LOG.debug("Channel {} moved to OPEN_CONFIRM state with remote proposal {}", this.channel, openObj);
} catch (final BGPDocumentedException e) {
LOG.warn("Channel {} negotiation failed", this.channel, e);
negotiationFailed(e);
}
}
Aggregations