interface_multicast.go 822 B

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