summaryrefslogtreecommitdiffhomepage
path: root/packet/validate.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-16 19:13:32 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-16 19:13:32 +0900
commit1ee4e65bc9ed53887c9c835dfbb22d3b7817d71c (patch)
treea564456c286dbc48003830cdbf6915f48857022d /packet/validate.go
parent63908917a29f27e2edd0ad43fa25decf5164e038 (diff)
server: handle over 4096 byte size message
send notification. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'packet/validate.go')
-rw-r--r--packet/validate.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/packet/validate.go b/packet/validate.go
index 248dbb59..20464574 100644
--- a/packet/validate.go
+++ b/packet/validate.go
@@ -1,6 +1,7 @@
package bgp
import (
+ "encoding/binary"
"github.com/osrg/gobgp/config"
"net"
"strconv"
@@ -139,3 +140,12 @@ func ValidateFlags(t BGPAttrType, flags uint8) (bool, string) {
}
return true, ""
}
+
+func ValidateBGPMessage(m *BGPMessage) error {
+ if m.Header.Len > BGP_MAX_MESSAGE_LENGTH {
+ buf := make([]byte, 2)
+ binary.BigEndian.PutUint16(buf, m.Header.Len)
+ return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, buf, "too long length")
+ }
+ return nil
+}