import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.Update;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.BgpParameters;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.bgp.parameters.CParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.bgp.parameters.OptionalCapabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.open.bgp.parameters.optional.capabilities.CParameters;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.c.parameters.MultiprotocolCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.optional.capabilities.c.parameters.MultiprotocolCase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.slf4j.Logger;
* is half-alive, e.g. the timers are running, but the session is not completely up, e.g. it has not been
* announced to the listener. If the session is torn down in this state, we do not inform the listener.
*/
- OpenConfirm,
+ OPEN_CONFIRM,
/**
* The session has been completely established.
*/
- Up,
+ UP,
/**
* The session has been closed. It will not be resurrected.
*/
- Idle,
+ IDLE,
}
/**
private final Channel channel;
@GuardedBy("this")
- private State state = State.OpenConfirm;
+ private State state = State.OPEN_CONFIRM;
private final Set<BgpTableType> tableTypes;
private final int holdTimerValue;
final Set<BgpTableType> tats = Sets.newHashSet();
if (remoteOpen.getBgpParameters() != null) {
for (final BgpParameters param : remoteOpen.getBgpParameters()) {
- final CParameters cp = param.getCParameters();
- if (cp instanceof MultiprotocolCase) {
- final TablesKey tt = new TablesKey(((MultiprotocolCase) cp).getMultiprotocolCapability().getAfi(),
- ((MultiprotocolCase) cp).getMultiprotocolCapability().getSafi());
- LOG.trace("Added table type to sync {}", tt);
- tts.add(tt);
- tats.add(new BgpTableTypeImpl(tt.getAfi(), tt.getSafi()));
+ for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
+ final CParameters cp = optCapa.getCParameters();
+ if (cp instanceof MultiprotocolCase) {
+ final TablesKey tt = new TablesKey(((MultiprotocolCase) cp).getMultiprotocolCapability().getAfi(),
+ ((MultiprotocolCase) cp).getMultiprotocolCapability().getSafi());
+ LOG.trace("Added table type to sync {}", tt);
+ tts.add(tt);
+ tats.add(new BgpTableTypeImpl(tt.getAfi(), tt.getSafi()));
+ }
}
}
}
@Override
public synchronized void close() {
LOG.info("Closing session: {}", this);
- if (this.state != State.Idle) {
- this.sendMessage(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).setErrorSubcode((short)0).build());
+ if (this.state != State.IDLE) {
+ this.sendMessage(new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).setErrorSubcode(
+ BGPError.CEASE.getSubcode()).build());
this.channel.close();
- this.state = State.Idle;
+ this.state = State.IDLE;
}
}
@Override
public synchronized void endOfInput() {
- if (this.state == State.Up) {
+ if (this.state == State.UP) {
this.listener.onSessionDown(this, new IOException("End of input detected. Close the session."));
}
}
private synchronized void closeWithoutMessage() {
LOG.debug("Closing session: {}", this);
this.channel.close();
- this.state = State.Idle;
+ this.state = State.IDLE;
}
/**
* state will become IDLE), then rescheduling won't occur.
*/
private synchronized void handleHoldTimer() {
- if (this.state == State.Idle) {
+ if (this.state == State.IDLE) {
return;
}
* starts to execute (the session state will become IDLE), that rescheduling won't occur.
*/
private synchronized void handleKeepaliveTimer() {
- if (this.state == State.Idle) {
+ if (this.state == State.IDLE) {
return;
}
@Override
protected synchronized void sessionUp() {
this.sessionStats.startSessionStopwatch();
- this.state = State.Up;
+ this.state = State.UP;
this.listener.onSessionUp(this);
}
}
@Override
- public BgpSessionState getBgpSesionState() {
+ public synchronized BgpSessionState getBgpSesionState() {
return this.sessionStats.getBgpSessionState(this.state);
}