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.

23 lines
553 B

  1. // Copyright 2013 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. package icmp
  5. import (
  6. "net"
  7. "golang.org/x/net/internal/iana"
  8. )
  9. const ipv6PseudoHeaderLen = 2*net.IPv6len + 8
  10. // IPv6PseudoHeader returns an IPv6 pseudo header for checksum
  11. // calculation.
  12. func IPv6PseudoHeader(src, dst net.IP) []byte {
  13. b := make([]byte, ipv6PseudoHeaderLen)
  14. copy(b, src.To16())
  15. copy(b[net.IPv6len:], dst.To16())
  16. b[len(b)-1] = byte(iana.ProtocolIPv6ICMP)
  17. return b
  18. }