summaryrefslogtreecommitdiff
path: root/src/main/java/com/lumaserv/bgp/BGPFsm.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/BGPFsm.java')
-rw-r--r--src/main/java/com/lumaserv/bgp/BGPFsm.java70
1 files changed, 66 insertions, 4 deletions
diff --git a/src/main/java/com/lumaserv/bgp/BGPFsm.java b/src/main/java/com/lumaserv/bgp/BGPFsm.java
index 9bfc30b..96378a5 100644
--- a/src/main/java/com/lumaserv/bgp/BGPFsm.java
+++ b/src/main/java/com/lumaserv/bgp/BGPFsm.java
@@ -171,8 +171,7 @@ public class BGPFsm {
// TODO TcpConnection_Valid event (Event 14)
// TODO Tcp_CR_Invalid event (Event 15)
- @Override
- void tcpCRAcked() { // Or incoming tcpConnectionConfirmed
+ protected void tcpCRAckedOrTcpConnectionConfirmed() {
if (delayOpen) {
setConnectRetryTimer(0);
// - sets the DelayOpenTimer to the initial value, and
@@ -190,6 +189,16 @@ public class BGPFsm {
}
}
+ @Override
+ void tcpCRAcked() {
+ tcpCRAckedOrTcpConnectionConfirmed();
+ }
+
+ @Override
+ void tcpConnectionConfirmed() {
+ tcpCRAckedOrTcpConnectionConfirmed();
+ }
+
// FIXME
@Override
void tcpConnectionFails() {
@@ -220,6 +229,50 @@ public class BGPFsm {
class Active extends State {
@Override
+ void manualStart() {}
+ @Override
+ void automaticStart() {}
+ @Override
+ void manualStartPassive() {}
+ @Override
+ void automaticStartPassive() {}
+
+ protected void stop() {
+ // - If the DelayOpenTimer is running and the
+ try {
+ BGPNotification notification = new BGPNotification()
+ .setMajorErrorCode(BGPNotification.Error.CEASE.getCode());
+ session.sendNotification(notification);
+ } catch (IOException ex) {
+ }
+ // - releases all BGP resources including stopping the
+ // DelayOpenTimer
+ session.dropConnection();
+ connectRetryCounter = 0;
+ setConnectRetryTimer(0);
+ setState(IDLE);
+ }
+
+ @Override
+ void manualStop() {
+ stop();
+ }
+
+ @Override
+ void automaticStop() {
+ stop();
+ }
+
+ @Override
+ void connectRetryTimerExpires() {
+ setConnectRetryTimer(connectRetryTime);
+ setState(CONNECT);
+ session.startOutgoing();
+ // - continues to listen for a TCP connection that may be initiated
+ // by a remote BGP peer, and
+ }
+
+ @Override
void tcpConnectionConfirmed() {
if (delayOpen) {
setConnectRetryTimer(0);
@@ -276,6 +329,15 @@ public class BGPFsm {
}
@Override
+ void tcpConnectionFails() {
+ session.dropConnection();
+ setConnectRetryTimer(connectRetryTime);
+ // - continues to listen for a connection that may be initiated by
+ // the remote BGP peer, and
+ setState(ACTIVE);
+ }
+
+ @Override
void openMsg(BGPOpen msg) {
System.out.println("openMsg:" + msg);
@@ -345,7 +407,7 @@ public class BGPFsm {
setConnectRetryTimer(0);
// - releases all BGP resources,
session.dropConnection();
- // - increments the ConnectRetryCounter by 1,
+ connectRetryCounter++;
// - (optionally) performs peer oscillation damping if the
// DampPeerOscillations attribute is set to TRUE, and
setState(IDLE);
@@ -432,7 +494,7 @@ public class BGPFsm {
// - deletes all routes associated with this connection,
// - releases all BGP resources,
session.dropConnection();
- // - increments the ConnectRetryCounter by 1,
+ connectRetryCounter++;
setState(IDLE);
}