Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package packet
import (
"bytes"
"fmt"
)
// RouteMirroringMsg represents a route mirroring message
type RouteMirroringMsg struct {
CommonHeader *CommonHeader
PerPeerHeader *PerPeerHeader
TLVs []*InformationTLV
}
func decodeRouteMirroringMsg(buf *bytes.Buffer, ch *CommonHeader) (*RouteMirroringMsg, error) {
rm := &RouteMirroringMsg{
CommonHeader: ch,
}
pph, err := decodePerPeerHeader(buf)
if err != nil {
return nil, fmt.Errorf("Unable to decode per peer header: %v", err)
}
rm.PerPeerHeader = pph
toRead := buf.Len()
read := 0
for read < toRead {
tlv, err := decodeInformationTLV(buf)
if err != nil {
return nil, fmt.Errorf("Unable to decode TLV: %v", err)
}
rm.TLVs = append(rm.TLVs, tlv)
read += int(tlv.InformationLength) + MinInformationTLVLen
}
return rm, nil
}