You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
763 B

  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 dragonfly freebsd netbsd
  5. package route
  6. func (w *wireFormat) parseInterfaceAnnounceMessage(_ 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 := &InterfaceAnnounceMessage{
  15. Version: int(b[2]),
  16. Type: int(b[3]),
  17. Index: int(nativeEndian.Uint16(b[4:6])),
  18. What: int(nativeEndian.Uint16(b[22:24])),
  19. raw: b[:l],
  20. }
  21. for i := 0; i < 16; i++ {
  22. if b[6+i] != 0 {
  23. continue
  24. }
  25. m.Name = string(b[6 : 6+i])
  26. break
  27. }
  28. return m, nil
  29. }