use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotification in project bgpcep by opendaylight.
the class BmpRouterPeerImpl method createPeerEntry.
private MapEntryNode createPeerEntry(final PeerUpNotification peerUp) {
final PeerHeader peerHeader = peerUp.getPeerHeader();
final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder = Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_ID_QNAME, this.peerId.getValue())).withChild(ImmutableNodes.leafNode(PEER_TYPE_QNAME, peerHeader.getType().name().toLowerCase(Locale.ENGLISH))).withChild(ImmutableNodes.leafNode(PEER_ADDRESS_QNAME, getStringIpAddress(peerHeader.getAddress()))).withChild(ImmutableNodes.leafNode(PEER_AS_QNAME, peerHeader.getAs().getValue())).withChild(ImmutableNodes.leafNode(PEER_BGP_ID_QNAME, peerHeader.getBgpId().getValue())).withChild(createPeerSessionUp(peerUp, peerHeader.getTimestampSec())).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PrePolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build()).withChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(PostPolicyRib.QNAME)).withChild(ImmutableNodes.mapNodeBuilder(BMP_TABLES_QNAME).build()).build());
final PeerDistinguisher pd = peerHeader.getPeerDistinguisher();
if (pd != null) {
mapEntryBuilder.withChild(ImmutableNodes.leafNode(PEER_DISTINGUISHER_QNAME, pd.getRouteDistinguisher()));
}
return mapEntryBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotification 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.message.rev171207.PeerUpNotification in project bgpcep by opendaylight.
the class BmpMockUtil method createPeerUp.
static PeerUpNotification createPeerUp(final Ipv4Address peerIp, final InetAddress localAddress) {
final PeerUpNotificationBuilder msgBuilder = new PeerUpNotificationBuilder();
msgBuilder.setLocalAddress(new IpAddress(new Ipv4Address(localAddress.getHostAddress())));
msgBuilder.setLocalPort(PEER_PORT);
msgBuilder.setRemotePort(PEER_PORT);
msgBuilder.setReceivedOpen(new ReceivedOpenBuilder(createOpen(peerIp)).build());
msgBuilder.setSentOpen(new SentOpenBuilder(createOpen(new Ipv4Address(localAddress.getHostAddress()))).build());
msgBuilder.setPeerHeader(createPeerHeader(peerIp, AdjRibInType.PrePolicy));
return msgBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotification in project bgpcep by opendaylight.
the class BmpMockUtilTest method testCreatePeerUp.
@Test
public void testCreatePeerUp() {
final PeerUpNotification peerUp = BmpMockUtil.createPeerUp(PEER_IP, LOCAL_ADDRESS);
final PeerHeader peerHeader = peerUp.getPeerHeader();
assertEquals(PEER_IP, peerHeader.getAddress().getIpv4Address());
assertEquals(65431L, peerHeader.getAs().getValue().longValue());
assertEquals(PEER_IP, peerHeader.getBgpId());
assertEquals(PeerType.Global, peerHeader.getType());
assertNull(peerUp.getInformation());
assertEquals(LOCAL_ADDRESS.getHostAddress(), peerUp.getLocalAddress().getIpv4Address().getValue());
assertEquals(179, peerUp.getLocalPort().getValue().intValue());
assertEquals(179, peerUp.getRemotePort().getValue().intValue());
assertNotNull(peerUp.getReceivedOpen());
assertNotNull(peerUp.getSentOpen());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.PeerUpNotification in project bgpcep by opendaylight.
the class PeerUpHandler method serializeMessageBody.
@Override
public void serializeMessageBody(final Notification message, final ByteBuf buffer) {
super.serializeMessageBody(message, buffer);
Preconditions.checkArgument(message instanceof PeerUpNotification, "An instance of Peer Up notification is required");
final PeerUpNotification peerUp = (PeerUpNotification) message;
if (peerUp.getLocalAddress().getIpv4Address() != null) {
buffer.writeZero(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
ByteBufWriteUtil.writeIpv4Address(peerUp.getLocalAddress().getIpv4Address(), buffer);
} else {
ByteBufWriteUtil.writeIpv6Address(peerUp.getLocalAddress().getIpv6Address(), buffer);
}
ByteBufWriteUtil.writeUnsignedShort(peerUp.getLocalPort().getValue(), buffer);
ByteBufWriteUtil.writeUnsignedShort(peerUp.getRemotePort().getValue(), buffer);
this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getSentOpen()).build(), buffer);
this.msgRegistry.serializeMessage(new OpenBuilder(peerUp.getReceivedOpen()).build(), buffer);
serializeTlvs(peerUp.getInformation(), buffer);
}
Aggregations