1
2
3
4
5
6
7
8 package route
9
10 func (w *wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) {
11 if len(b) < w.bodyOff {
12 return nil, errMessageTooShort
13 }
14 l := int(nativeEndian.Uint16(b[:2]))
15 if len(b) < l {
16 return nil, errInvalidMessage
17 }
18 m := &InterfaceAnnounceMessage{
19 Version: int(b[2]),
20 Type: int(b[3]),
21 Index: int(nativeEndian.Uint16(b[4:6])),
22 What: int(nativeEndian.Uint16(b[22:24])),
23 raw: b[:l],
24 }
25 for i := 0; i < 16; i++ {
26 if b[6+i] != 0 {
27 continue
28 }
29 m.Name = string(b[6 : 6+i])
30 break
31 }
32 return m, nil
33 }
34
View as plain text