use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.
the class BGPActivator method registerCapabilityParsers.
private static void registerCapabilityParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
final AddressFamilyRegistry afiReg = context.getAddressFamilyRegistry();
final SubsequentAddressFamilyRegistry safiReg = context.getSubsequentAddressFamilyRegistry();
final MultiProtocolCapabilityHandler multi = new MultiProtocolCapabilityHandler(afiReg, safiReg);
regs.add(context.registerCapabilityParser(MultiProtocolCapabilityHandler.CODE, multi));
regs.add(context.registerCapabilitySerializer(MultiprotocolCapability.class, multi));
final AddPathCapabilityHandler addPath = new AddPathCapabilityHandler(afiReg, safiReg);
regs.add(context.registerCapabilityParser(AddPathCapabilityHandler.CODE, addPath));
regs.add(context.registerCapabilitySerializer(AddPathCapability.class, addPath));
final RouteRefreshCapabilityHandler routeRefresh = new RouteRefreshCapabilityHandler();
regs.add(context.registerCapabilityParser(RouteRefreshCapabilityHandler.CODE, routeRefresh));
regs.add(context.registerCapabilitySerializer(RouteRefreshCapability.class, routeRefresh));
final As4CapabilityHandler as4 = new As4CapabilityHandler();
regs.add(context.registerCapabilityParser(As4CapabilityHandler.CODE, as4));
regs.add(context.registerCapabilitySerializer(As4BytesCapability.class, as4));
final GracefulCapabilityHandler grace = new GracefulCapabilityHandler(afiReg, safiReg);
regs.add(context.registerCapabilitySerializer(GracefulRestartCapability.class, grace));
regs.add(context.registerCapabilityParser(GracefulCapabilityHandler.CODE, grace));
final CapabilityParameterParser cpp = new CapabilityParameterParser(context.getCapabilityRegistry());
regs.add(context.registerParameterParser(CapabilityParameterParser.TYPE, cpp));
regs.add(context.registerParameterSerializer(BgpParameters.class, cpp));
final BgpExtendedMessageCapabilityHandler bgpextmessage = new BgpExtendedMessageCapabilityHandler();
regs.add(context.registerCapabilityParser(BgpExtendedMessageCapabilityHandler.CODE, bgpextmessage));
regs.add(context.registerCapabilitySerializer(BgpExtendedMessageCapability.class, bgpextmessage));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.
the class BGPRouteRefreshMessageParser method serializeMessage.
/**
* Serializes BGP Route Refresh message.
*
* @param message to be serialized
* @param bytes ByteBuf where the message will be serialized
*/
@Override
public void serializeMessage(final Notification message, final ByteBuf bytes) {
checkArgument(message instanceof RouteRefresh, ARGUMENT_ERROR);
final RouteRefresh msg = (RouteRefresh) message;
final ByteBuf msgBuf = Unpooled.buffer(TRIPLET_BYTE_SIZE);
MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, msg.getAfi(), msg.getSafi(), msgBuf);
if (LOG.isTraceEnabled()) {
LOG.trace("RouteRefresh message serialized to: {}", ByteBufUtil.hexDump(msgBuf));
}
MessageUtil.formatMessage(TYPE, msgBuf, bytes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.
the class BGPSessionImpl method handleMessage.
/**
* Handles incoming message based on their type.
*
* @param msg incoming message
*/
void handleMessage(final Notification msg) {
// synchronize on listener and then on this object to ensure correct order of locking
synchronized (this.listener) {
synchronized (this) {
if (this.state == State.IDLE) {
return;
}
try {
// Update last reception time
this.lastMessageReceivedAt = System.nanoTime();
if (msg instanceof Open) {
// Open messages should not be present here
terminate(new BGPDocumentedException(null, BGPError.FSM_ERROR));
} else if (msg instanceof Notify) {
final Notify notify = (Notify) msg;
// Notifications are handled internally
LOG.info("Session closed because Notification message received: {} / {}, data={}", notify.getErrorCode(), notify.getErrorSubcode(), notify.getData() != null ? ByteBufUtil.hexDump(notify.getData()) : null);
notifyTerminationReasonAndCloseWithoutMessage(notify.getErrorCode(), notify.getErrorSubcode());
} else if (msg instanceof Keepalive) {
// Keepalives are handled internally
LOG.trace("Received KeepAlive message.");
this.kaCounter++;
if (this.kaCounter >= 2) {
this.sync.kaReceived();
}
} else if (msg instanceof RouteRefresh) {
this.listener.onMessage(this, msg);
} else if (msg instanceof Update) {
this.listener.onMessage(this, msg);
this.sync.updReceived((Update) msg);
} else {
LOG.warn("Ignoring unhandled message: {}.", msg.getClass());
}
this.sessionState.messageReceived(msg);
} catch (final BGPDocumentedException e) {
terminate(e);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.
the class BGPRouteRefreshMessageParser method parseMessageBody.
/**
* Parses BGP Route Refresh message to bytes.
*
* @param body ByteBuf to be parsed
* @param messageLength the length of the message
* @return {@link RouteRefresh} which represents BGP notification message
* @throws BGPDocumentedException if parsing goes wrong
*/
@Override
public RouteRefresh parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
Preconditions.checkArgument(body != null, "Body buffer cannot be null.");
if (body.readableBytes() < TRIPLET_BYTE_SIZE) {
throw BGPDocumentedException.badMessageLength("RouteRefresh message is too small.", messageLength);
}
final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(body, this.afiReg, this.safiReg);
if (!parsedAfiSafi.isPresent()) {
throw new BGPDocumentedException("Unsupported afi/safi in Route Refresh message.", BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
}
return new RouteRefreshBuilder(parsedAfiSafi.get()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.RouteRefresh in project bgpcep by opendaylight.
the class BGPPeer method onRouteRefreshMessage.
private void onRouteRefreshMessage(final RouteRefresh message) {
final Class<? extends AddressFamily> rrAfi = message.getAfi();
final Class<? extends SubsequentAddressFamily> rrSafi = message.getSafi();
final TablesKey key = new TablesKey(rrAfi, rrSafi);
synchronized (this) {
final AdjRibOutListener listener = this.adjRibOutListenerSet.remove(key);
if (listener != null) {
listener.close();
createAdjRibOutListener(key, listener.isMpSupported());
} else {
LOG.info("Ignoring RouteRefresh message. Afi/Safi is not supported: {}, {}.", rrAfi, rrSafi);
}
}
}
Aggregations