use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer 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.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class BmpRouterImpl method delegateToPeer.
private synchronized void delegateToPeer(final Notification perPeerMessage) {
final PeerId peerId = getPeerId((PeerHeader) perPeerMessage);
final Optional<BmpRouterPeer> maybePeer = getPeer(peerId);
if (maybePeer.isPresent()) {
maybePeer.get().onPeerMessage(perPeerMessage);
if (perPeerMessage instanceof PeerDownNotification) {
this.peers.remove(peerId);
LOG.debug("Router {}: Peer {} removed.", this.routerIp, peerId.getValue());
}
} else {
LOG.debug("Peer: {} for Router: {} was not found.", peerId.getValue(), this.routerIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class BmpRouterImpl method onPeerUp.
private synchronized void onPeerUp(final PeerUpNotification peerUp) {
final PeerId peerId = getPeerIdFromOpen(peerUp.getReceivedOpen());
if (!getPeer(peerId).isPresent()) {
final BmpRouterPeer peer = BmpRouterPeerImpl.createRouterPeer(this.domTxChain, this.peersYangIId, peerUp, this.extensions, this.tree, peerId);
this.peers.put(peerId, peer);
LOG.debug("Router {}: Peer {} goes up.", this.routerIp, peerId.getValue());
} else {
LOG.debug("Peer: {} for Router: {} already exists.", peerId.getValue(), this.routerIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer in project bgpcep by opendaylight.
the class BmpMockSession method advertizePeers.
private void advertizePeers(final InetSocketAddress localAddress) {
channel.writeAndFlush(BmpMockUtil.createInitiation());
Ipv4AddressNoZone peerAddress = PEER_ADDRESS;
for (int i = 0; i < this.peersCount; i++) {
channel.writeAndFlush(BmpMockUtil.createPeerUp(peerAddress, localAddress.getAddress()));
LOG.debug("BMP router {} advertized peer {}", channel.localAddress(), peerAddress);
advertizeRoutes(this.prePolicyRoutesCount, AdjRibInType.PrePolicy, channel, peerAddress);
advertizeRoutes(this.postPolicyRoutesCount, AdjRibInType.PostPolicy, channel, peerAddress);
peerAddress = incrementIpv4Address(peerAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.Peer 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());
}
Aggregations