diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-06-23 22:54:45 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-06-25 22:24:28 +0900 |
commit | d933f0a0c1a0b64ec1bf19bdc113acf8b04af7e8 (patch) | |
tree | 30aec07f4e4c348ab30a3f89e836950b60a3fa2a | |
parent | 4eb025700bd5cf85065cb788f6778d9e60446f87 (diff) |
mrt: bug fix of decoding BGP4MPHeader
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | gomrt/packet/mrt.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gomrt/packet/mrt.go b/gomrt/packet/mrt.go index d8b490d8..29718403 100644 --- a/gomrt/packet/mrt.go +++ b/gomrt/packet/mrt.go @@ -481,21 +481,23 @@ func (m *BGP4MPHeader) decodeFromBytes(data []byte) ([]byte, error) { if m.isAS4 { m.PeerAS = binary.BigEndian.Uint32(data[:4]) m.LocalAS = binary.BigEndian.Uint32(data[4:8]) + data = data[8:] } else { m.PeerAS = uint32(binary.BigEndian.Uint16(data[:2])) m.LocalAS = uint32(binary.BigEndian.Uint16(data[2:4])) + data = data[4:] } - m.InterfaceIndex = binary.BigEndian.Uint16(data[4:6]) - m.AddressFamily = binary.BigEndian.Uint16(data[6:8]) + m.InterfaceIndex = binary.BigEndian.Uint16(data[:2]) + m.AddressFamily = binary.BigEndian.Uint16(data[2:4]) switch m.AddressFamily { case bgp.AFI_IP: - m.PeerIpAddress = net.IP(data[8:12]) - m.LocalIpAddress = net.IP(data[12:16]) - data = data[16:] + m.PeerIpAddress = net.IP(data[4:8]) + m.LocalIpAddress = net.IP(data[8:12]) + data = data[12:] case bgp.AFI_IP6: - m.PeerIpAddress = net.IP(data[8:24]) - m.LocalIpAddress = net.IP(data[24:40]) - data = data[40:] + m.PeerIpAddress = net.IP(data[4:20]) + m.LocalIpAddress = net.IP(data[20:36]) + data = data[36:] default: return nil, fmt.Errorf("unsupported address family: %d", m.AddressFamily) } |