github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/net/route/interface_multicast.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 darwin || dragonfly || freebsd 6 // +build darwin dragonfly freebsd 7 8 package route 9 10 func (w *wireFormat) parseInterfaceMulticastAddrMessage(_ 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 := &InterfaceMulticastAddrMessage{ 19 Version: int(b[2]), 20 Type: int(b[3]), 21 Flags: int(nativeEndian.Uint32(b[8:12])), 22 Index: int(nativeEndian.Uint16(b[12:14])), 23 raw: b[:l], 24 } 25 var err error 26 m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:]) 27 if err != nil { 28 return nil, err 29 } 30 return m, nil 31 }