use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder 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(Uint16.valueOf(30)).setHoldTimer(Uint16.valueOf(3)).setVersion(new ProtocolVersion(Uint8.valueOf(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());
assertEquals(BGPError.FSM_ERROR.getSubcode(), ((Notify) m).getErrorSubcode());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder in project bgpcep by opendaylight.
the class RouteMirroringMessageHandler method serializeTlvs.
protected void serializeTlvs(final Tlvs tlvs, final ByteBuf output) {
final ByteBuf tlvsBuffer = Unpooled.buffer();
if (tlvs.getMirrorInformationTlv() != null) {
serializeTlv(tlvs.getMirrorInformationTlv(), tlvsBuffer);
}
if (tlvs.getPduUpdateTlv() != null) {
getBgpMessageRegistry().serializeMessage(new UpdateBuilder(tlvs.getPduUpdateTlv()).build(), tlvsBuffer);
}
if (tlvs.getPduOpenTlv() != null) {
getBgpMessageRegistry().serializeMessage(new OpenBuilder(tlvs.getPduOpenTlv()).build(), tlvsBuffer);
}
output.writeBytes(tlvsBuffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder in project bgpcep by opendaylight.
the class PeerUpHandler method serializeMessageBody.
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
super.serializeMessageBody(message, buffer);
checkArgument(message instanceof PeerUpNotification, "An instance of Peer Up notification is required");
final PeerUpNotification peerUp = (PeerUpNotification) message;
if (peerUp.getLocalAddress().getIpv4AddressNoZone() != null) {
buffer.writeZero(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
Ipv4Util.writeIpv4Address(peerUp.getLocalAddress().getIpv4AddressNoZone(), buffer);
} else {
Ipv6Util.writeIpv6Address(peerUp.getLocalAddress().getIpv6AddressNoZone(), buffer);
}
ByteBufUtils.write(buffer, peerUp.getLocalPort().getValue());
ByteBufUtils.write(buffer, peerUp.getRemotePort().getValue());
this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getSentOpen()).build(), buffer);
this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getReceivedOpen()).build(), buffer);
serializeTlvs(peerUp.getInformation(), buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder in project bgpcep by opendaylight.
the class BmpMockUtil method createOpen.
private static OpenMessage createOpen(final Ipv4AddressNoZone address) {
final OpenBuilder msgBuilder = new OpenBuilder();
msgBuilder.setBgpIdentifier(address);
msgBuilder.setHoldTimer(HOLD_TIMER);
msgBuilder.setMyAsNumber(Uint16.valueOf(ASN.getValue()));
msgBuilder.setVersion(PROTOCOL_VERSION);
return msgBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.OpenBuilder in project bgpcep by opendaylight.
the class PCEPOpenMessageParser method validate.
@Override
protected org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final Object open = objects.poll();
if (!(open instanceof Open)) {
throw new PCEPDeserializerException("Open message doesn't contain OPEN object.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen((Open) open).build()).build();
}
Aggregations