gitee.com/ks-custle/core-gm@v0.0.0-20230922171213-b83bdd97b62c/net/route/interface_announce.go (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build dragonfly || freebsd || netbsd 6 // +build dragonfly freebsd netbsd 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 }