interface_multicast.go 864 B

12345678910111213141516171819202122232425262728293031
  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. //go:build darwin || dragonfly || freebsd
  5. // +build darwin dragonfly freebsd
  6. package route
  7. func (w *wireFormat) parseInterfaceMulticastAddrMessage(_ RIBType, b []byte) (Message, error) {
  8. if len(b) < w.bodyOff {
  9. return nil, errMessageTooShort
  10. }
  11. l := int(nativeEndian.Uint16(b[:2]))
  12. if len(b) < l {
  13. return nil, errInvalidMessage
  14. }
  15. m := &InterfaceMulticastAddrMessage{
  16. Version: int(b[2]),
  17. Type: int(b[3]),
  18. Flags: int(nativeEndian.Uint32(b[8:12])),
  19. Index: int(nativeEndian.Uint16(b[12:14])),
  20. raw: b[:l],
  21. }
  22. var err error
  23. m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:])
  24. if err != nil {
  25. return nil, err
  26. }
  27. return m, nil
  28. }