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