David K. Bainbridge | 215e024 | 2017-09-05 23:18:24 -0700 | [diff] [blame] | 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 | |
| 5 | package icmp |
| 6 | |
| 7 | import ( |
| 8 | "net" |
| 9 | |
| 10 | "golang.org/x/net/internal/iana" |
| 11 | ) |
| 12 | |
| 13 | const ipv6PseudoHeaderLen = 2*net.IPv6len + 8 |
| 14 | |
| 15 | // IPv6PseudoHeader returns an IPv6 pseudo header for checksum |
| 16 | // calculation. |
| 17 | func IPv6PseudoHeader(src, dst net.IP) []byte { |
| 18 | b := make([]byte, ipv6PseudoHeaderLen) |
| 19 | copy(b, src.To16()) |
| 20 | copy(b[net.IPv6len:], dst.To16()) |
| 21 | b[len(b)-1] = byte(iana.ProtocolIPv6ICMP) |
| 22 | return b |
| 23 | } |