*/
package org.opendaylight.protocol.pcep;
+import java.net.InetAddress;
+
import org.opendaylight.protocol.framework.ProtocolSession;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
/**
* PCEP Session represents the finite state machine in PCEP, including timers and its purpose is to create a PCEP
* Sends message from user to PCE/PCC. If the user sends an Open Message, the session returns an error (open message
* is only allowed, when a PCEP handshake is in progress). Close message will close the session and free all the
* resources.
- *
+ *
* @param message message to be sent
*/
public void sendMessage(Message message);
public void close(TerminationReason reason);
+
+ public Tlvs getRemoteTlvs();
+
+ public InetAddress getRemoteAddress();
}
import io.netty.util.TimerTask;
import java.io.IOException;
+import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.util.Date;
import java.util.LinkedList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.c.close.message.CCloseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Sends message to serialization.
- *
+ *
* @param msg to be sent
*/
@Override
this.channel.close();
}
+ @Override
+ public Tlvs getRemoteTlvs() {
+ return remoteOpen.getTlvs();
+ }
+
+ @Override
+ public InetAddress getRemoteAddress() {
+ return ((InetSocketAddress) this.channel.remoteAddress()).getAddress();
+ }
+
private synchronized void terminate(final TerminationReason reason) {
this.listener.onSessionTerminated(this, new PCEPCloseTermination(reason));
this.closed = true;
/**
* Sends PCEP Error Message with one PCEPError and Open Object.
- *
+ *
* @param value
* @param open
*/
* sent (CAPABILITY_NOT_SUPPORTED) and the method checks if the MAX_UNKNOWN_MSG per minute wasn't overstepped.
* Second, any other error occurred that is specified by rfc. In this case, the an error message is generated and
* sent.
- *
+ *
* @param error documented error in RFC5440 or draft
*/
@VisibleForTesting
/**
* Handles incoming message. If the session is up, it notifies the user. The user is notified about every message
* except KeepAlive.
- *
+ *
* @param msg incoming message
*/
@Override
@Override
public String getNodeIdentifier() {
- if (this.remoteOpen.getTlvs() == null)
+ if (this.remoteOpen.getTlvs() == null) {
if (this.remoteOpen.getTlvs().getPredundancyGroupId() != null) {
return new String(this.remoteOpen.getTlvs().getPredundancyGroupId().getIdentifier());
}
+ }
return "";
}