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