diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-04-04 15:42:35 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-04-17 21:57:11 +0900 |
commit | 93c955a415f39f7f8d2a97a8298a8985d5dadc2f (patch) | |
tree | 84d1fa1ede4242ad73e72703d4462f703df5a92a /packet/bmp/bmp.go | |
parent | 5323187cf10bb0e2cc361aca0cfd9e84396828b9 (diff) |
packet/bmp: Obsolete policy argument for BMPPeerHeader
According to "draft-evens-grow-bmp-local-rib", the L flag in the Peer
Flags is NOT used for the locally sourced routes and the F flag is
defined into the same bit.
This patch removes "policy" argument and add "flags" argument for
BMPPeerHeader and NewBMPPeerHeader in order to distinguish which flag
is set (the L flag or the F flag).
Then introduce IsPostPolicy() func to show if the L flag is set or not.
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'packet/bmp/bmp.go')
-rw-r--r-- | packet/bmp/bmp.go | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/packet/bmp/bmp.go b/packet/bmp/bmp.go index 55481bcb..7cf4f5e6 100644 --- a/packet/bmp/bmp.go +++ b/packet/bmp/bmp.go @@ -71,27 +71,23 @@ func (h *BMPHeader) Serialize() ([]byte, error) { type BMPPeerHeader struct { PeerType uint8 - IsPostPolicy bool + Flags uint8 PeerDistinguisher uint64 PeerAddress net.IP PeerAS uint32 PeerBGPID net.IP Timestamp float64 - Flags uint8 } -func NewBMPPeerHeader(t uint8, policy bool, dist uint64, address string, as uint32, id string, stamp float64) *BMPPeerHeader { +func NewBMPPeerHeader(t uint8, flags uint8, dist uint64, address string, as uint32, id string, stamp float64) *BMPPeerHeader { h := &BMPPeerHeader{ PeerType: t, - IsPostPolicy: policy, + Flags: flags, PeerDistinguisher: dist, PeerAS: as, PeerBGPID: net.ParseIP(id).To4(), Timestamp: stamp, } - if policy == true { - h.Flags |= BMP_PEER_FLAG_POST_POLICY - } if net.ParseIP(address).To4() != nil { h.PeerAddress = net.ParseIP(address).To4() } else { @@ -101,14 +97,17 @@ func NewBMPPeerHeader(t uint8, policy bool, dist uint64, address string, as uint return h } -func (h *BMPPeerHeader) DecodeFromBytes(data []byte) error { - h.PeerType = data[0] - h.Flags = data[1] +func (h *BMPPeerHeader) IsPostPolicy() bool { if h.Flags&BMP_PEER_FLAG_POST_POLICY != 0 { - h.IsPostPolicy = true + return true } else { - h.IsPostPolicy = false + return false } +} + +func (h *BMPPeerHeader) DecodeFromBytes(data []byte) error { + h.PeerType = data[0] + h.Flags = data[1] h.PeerDistinguisher = binary.BigEndian.Uint64(data[2:10]) if h.Flags&BMP_PEER_FLAG_IPV6 != 0 { h.PeerAddress = net.IP(data[10:26]).To16() |