+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.bgp.parser.message;
-
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * BGP KeepAlive message. Always empty.
- *
- * @see <a href="http://tools.ietf.org/html/rfc4271#section-4.4">BGP KeepAlive message</a>
- */
-public final class BGPKeepAliveMessage implements Notification {
-
- /**
- * Creates a BGP KeepAlive message.
- */
- public BGPKeepAliveMessage() {
-
- }
-}
type inet:ipv4-address;
mandatory true;
}
- list optional-parameters {
+ list bgp-parameters {
reference "http://tools.ietf.org/html/rfc3392#section-4";
choice parameters {
container as4-bytes {
}
}
- augment "/bgp-msg:open/bgp-msg:optional-parameters/bgp-msg:parameters" {
+ augment "/bgp-msg:open/bgp-msg:bgp-parameters/bgp-msg:parameters" {
case multiprotocol {
list capabilities {
container multiprotocol-capability {
import org.opendaylight.protocol.bgp.linkstate.RouteTag;
import org.opendaylight.protocol.bgp.linkstate.RouterIdentifier;
import org.opendaylight.protocol.bgp.linkstate.TopologyIdentifier;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.AS4BytesCapability;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
@Test
public void testBGPKeepAliveMessage() {
- final Notification msg = new BGPKeepAliveMessage();
- assertTrue(msg instanceof BGPKeepAliveMessage);
+ final Notification msg = new KeepaliveBuilder().build();
+ assertTrue(msg instanceof Keepalive);
}
@Test
import org.opendaylight.protocol.bgp.parser.impl.message.BGPNotificationMessageParser;
import org.opendaylight.protocol.bgp.parser.impl.message.BGPOpenMessageParser;
import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.framework.DeserializerException;
import org.opendaylight.protocol.framework.DocumentedException;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
logger.debug("Received and parsed Notification Message: {}", msg);
break;
case 4:
- msg = new BGPKeepAliveMessage();
+ msg = new KeepaliveBuilder().build();
if (messageLength != COMMON_HEADER_LENGTH) {
throw new BGPDocumentedException("Message length field not within valid range.", BGPError.BAD_MSG_LENGTH, ByteArray.subByte(
bs, 0, LENGTH_FIELD_LENGTH));
} else if (msg instanceof BGPNotificationMessage) {
msgType = 3;
msgBody = BGPNotificationMessageParser.put((BGPNotificationMessage) msg);
- } else if (msg instanceof BGPKeepAliveMessage) {
+ } else if (msg instanceof Keepalive) {
msgType = 4;
msgBody = new byte[0];
} else {
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
import org.opendaylight.protocol.bgp.parser.BGPTerminationReason;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.framework.AbstractProtocolSession;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final int DEFAULT_HOLD_TIMER_VALUE = 15;
+ private static final Notification keepalive = new KeepaliveBuilder().build();
+
public static int HOLD_TIMER_VALUE = DEFAULT_HOLD_TIMER_VALUE; // 240
/**
logger.info("Session closed because Notification message received: {}", ((BGPNotificationMessage) msg).getError());
this.closeWithoutMessage();
this.listener.onSessionTerminated(this, new BGPTerminationReason(((BGPNotificationMessage) msg).getError()));
- } else if (msg instanceof BGPKeepAliveMessage) {
+ } else if (msg instanceof Keepalive) {
// Keepalives are handled internally
logger.debug("Received KeepAlive messsage.");
this.kaCounter++;
long nextKeepalive = this.lastMessageSentAt + TimeUnit.SECONDS.toNanos(this.keepAlive);
if (ct >= nextKeepalive) {
- this.sendMessage(new BGPKeepAliveMessage());
+ this.sendMessage(keepalive);
nextKeepalive = this.lastMessageSentAt + TimeUnit.SECONDS.toNanos(this.keepAlive);
}
this.stateTimer.newTimeout(new TimerTask() {
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.CapabilityParameter;
import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
case Idle:
throw new IllegalStateException("Unexpected state " + this.state);
case OpenConfirm:
- if (msg instanceof BGPKeepAliveMessage) {
+ if (msg instanceof Keepalive) {
negotiationSuccessful(this.session);
} else if (msg instanceof BGPNotificationMessage) {
final BGPNotificationMessage ntf = (BGPNotificationMessage) msg;
final MultiprotocolCapability cap = (MultiprotocolCapability) param;
if (LinkstateAddressFamily.class == cap.getAfi() && LinkstateSubsequentAddressFamily.class == cap.getSafi()) {
this.remotePref = openObj;
- this.channel.writeAndFlush(new BGPKeepAliveMessage());
+ this.channel.writeAndFlush(new KeepaliveBuilder().build());
this.session = new BGPSessionImpl(this.timer, this.listener, this.channel, this.remotePref);
this.state = State.OpenConfirm;
logger.debug("Channel {} moved to OpenConfirm state with remote proposal {}", this.channel,
import org.opendaylight.protocol.bgp.concepts.BGPTableType;
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateSubsequentAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.yang.binding.Notification;
assertTrue(this.receivedMsgs.get(0) instanceof BGPOpenMessage);
this.clientSession.handleMessage(this.classicOpen);
assertEquals(2, this.receivedMsgs.size());
- assertTrue(this.receivedMsgs.get(1) instanceof BGPKeepAliveMessage);
- this.clientSession.handleMessage(new BGPKeepAliveMessage());
+ assertTrue(this.receivedMsgs.get(1) instanceof Keepalive);
+ this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPSessionNegotiator.State.Finished);
// Thread.sleep(3 * 1000);
// Thread.sleep(100);
public void sendNotification() {
this.clientSession.channelActive(null);
this.clientSession.handleMessage(this.classicOpen);
- this.clientSession.handleMessage(new BGPKeepAliveMessage());
+ this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPSessionNegotiator.State.Finished);
try {
this.clientSession.handleMessage(new BGPOpenMessage(new AsNumber((long) 30), (short) 3, null, null));
import org.opendaylight.protocol.bgp.parser.BGPError;
import org.opendaylight.protocol.bgp.parser.BGPParameter;
import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPNotificationMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.GracefulCapability;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.yang.binding.Notification;
@Test
public void testKeepAliveMsg() throws DeserializerException, DocumentedException {
- final Notification keepAlive = new BGPKeepAliveMessage();
+ final Notification keepAlive = new KeepaliveBuilder().build();
final byte[] bytes = this.factory.put(keepAlive);
assertArrayEquals(keepAliveBMsg, bytes);
final Notification m = this.factory.parse(bytes).get(0);
- assertTrue(m instanceof BGPKeepAliveMessage);
+ assertTrue(m instanceof Keepalive);
}
@Test
import org.opendaylight.protocol.bgp.parser.BGPParameter;
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
-import org.opendaylight.protocol.bgp.parser.message.BGPKeepAliveMessage;
import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
import org.opendaylight.protocol.bgp.parser.parameter.MultiprotocolCapability;
import org.opendaylight.protocol.concepts.ListenerRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130918.Keepalive;
import org.opendaylight.yangtools.yang.binding.Notification;
import com.google.common.collect.Sets;
return tts;
}
});
- } else if (message instanceof BGPKeepAliveMessage) {
+ } else if (message instanceof Keepalive) {
// do nothing
} else {
listener.onMessage(null, message);