From 389447b4e02f380208eae8435f5e2653399ecfea Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Fri, 11 Mar 2022 13:38:05 +0100 Subject: Allow stop in opensent and established states --- src/main/java/com/lumaserv/bgp/BGPFsm.java | 61 ++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/main/java/com/lumaserv/bgp/BGPFsm.java') 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); -- cgit v1.2.3