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
42
43
44
package packet
import (
"bytes"
"github.com/bio-routing/bio-rd/util/decoder"
)
const (
MinInformationTLVLen = 4
)
// InformationTLV represents an information TLV
type InformationTLV struct {
InformationType uint16
InformationLength uint16
Information []byte
}
func decodeInformationTLV(buf *bytes.Buffer) (*InformationTLV, error) {
infoTLV := &InformationTLV{}
fields := []interface{}{
&infoTLV.InformationType,
&infoTLV.InformationLength,
}
err := decoder.Decode(buf, fields)
if err != nil {
return infoTLV, err
}
infoTLV.Information = make([]byte, infoTLV.InformationLength)
fields = []interface{}{
&infoTLV.Information,
}
err = decoder.Decode(buf, fields)
if err != nil {
return infoTLV, err
}
return infoTLV, nil
}