summaryrefslogtreecommitdiffhomepage
path: root/server/util.go
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-01-18 13:28:46 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-02-03 22:47:34 -0800
commit1063bcab1ee22cac4c7e375aaf37589747bad133 (patch)
tree1045a331ace96926da8728915318e0084eb8c5c5 /server/util.go
parent356c01a9d061b2b6bb4c3068a9888b56dc435600 (diff)
cli: Communication on Administrative Shutdown NOTIFICATION
This patch enable to send an arbitrary message on the Cease NOTIFICATION message with "Administrative Shutdown" and "Administrative Reset" subcodes with "--reason" option. Usage: $ gobgp neighbor <neighbor address> shutdown --reason "some messages" $ gobgp neighbor <neighbor address> reset --reason "some messages" Reference: https://tools.ietf.org/html/draft-ietf-idr-shutdown-04 Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'server/util.go')
-rw-r--r--server/util.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/util.go b/server/util.go
index 43c85bc1..9e11a0a1 100644
--- a/server/util.go
+++ b/server/util.go
@@ -15,7 +15,10 @@
package server
-import "github.com/eapache/channels"
+import (
+ "github.com/eapache/channels"
+ "github.com/osrg/gobgp/packet/bgp"
+)
func cleanInfiniteChannel(ch *channels.InfiniteChannel) {
ch.Close()
@@ -23,3 +26,20 @@ func cleanInfiniteChannel(ch *channels.InfiniteChannel) {
for range ch.Out() {
}
}
+
+// Returns the binary formatted Administrative Shutdown Communication from the
+// given string value.
+func newAdministrativeCommunication(communication string) (data []byte) {
+ if communication == "" {
+ return nil
+ }
+ com := []byte(communication)
+ if len(com) > bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX {
+ data = []byte{bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX}
+ data = append(data, com[:bgp.BGP_ERROR_ADMINISTRATIVE_COMMUNICATION_MAX]...)
+ } else {
+ data = []byte{byte(len(com))}
+ data = append(data, com...)
+ }
+ return data
+}