diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-03-11 13:38:05 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2022-03-12 22:53:22 +0100 |
commit | 389447b4e02f380208eae8435f5e2653399ecfea (patch) | |
tree | c6b39cd4e07569f238f102ae538cfd928b90a621 /src/main/java/com/lumaserv/bgp/BGPFsm.java | |
parent | 6303d84ef047721e972ae7407e94320afeb3db24 (diff) |
Allow stop in opensent and established states
Diffstat (limited to 'src/main/java/com/lumaserv/bgp/BGPFsm.java')
-rw-r--r-- | src/main/java/com/lumaserv/bgp/BGPFsm.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/main/java/com/lumaserv/bgp/BGPFsm.java b/src/main/java/com/lumaserv/bgp/BGPFsm.java index a2143bd..7929d36 100644 --- a/src/main/java/com/lumaserv/bgp/BGPFsm.java +++ b/src/main/java/com/lumaserv/bgp/BGPFsm.java @@ -244,6 +244,36 @@ public class BGPFsm { } class OpenSent extends State { + protected void stop(boolean isAutomatic) { + try { + BGPNotification notification = new BGPNotification() + .setMajorErrorCode(BGPNotification.Error.CEASE.getCode()); + session.sendNotification(notification); + } catch (IOException ex) { + } + setConnectRetryTimer(0); + // - releases all the BGP resources, + session.dropConnection(); + if (isAutomatic) { + connectRetryCounter++; + // - (optionally) performs peer oscillation damping if the + // DampPeerOscillations attribute is set to TRUE, and + } else { + connectRetryCounter = 0; + } + setState(IDLE); + } + + @Override + void manualStop() { + stop(false); + } + + @Override + void automaticStop() { + stop(true); + } + @Override void openMsg(BGPOpen msg) { System.out.println("openMsg:" + msg); @@ -311,6 +341,37 @@ public class BGPFsm { } class Established extends State { + protected void stop(boolean isAutomatic) { + try { + BGPNotification notification = new BGPNotification() + .setMajorErrorCode(BGPNotification.Error.CEASE.getCode()); + session.sendNotification(notification); + } catch (IOException ex) { + } + setConnectRetryTimer(0); + // - deletes all routes associated with this connection, + // - releases all BGP resources, + session.dropConnection(); + if (isAutomatic) { + connectRetryCounter++; + // - (optionally in automaticStop) performs peer oscillation damping if the + // DampPeerOscillations attribute is set to TRUE, and + } else { + connectRetryCounter = 0; + } + setState(IDLE); + } + + @Override + void manualStop() { + stop(false); + } + + @Override + void automaticStop() { + stop(true); + } + @Override void keepAliveMsg() { setHoldTimer(holdTime); |