Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip SetChecksum on Windows #24

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net"
"runtime"
"time"

"golang.org/x/net/icmp"
Expand Down Expand Up @@ -63,10 +64,13 @@ func Dial(ifi *net.Interface, addr Addr) (*Conn, net.IP, error) {
return nil, nil, err
}

// Calculate and place ICMPv6 checksum at correct offset in all messages.
const chkOff = 2
if err := pc.SetChecksum(true, chkOff); err != nil {
return nil, nil, err
if runtime.GOOS != "windows" {
// Calculate and place ICMPv6 checksum at correct offset in all
// messages (not implemented by golang.org/x/net/ipv6 on Windows).
const chkOff = 2
if err := pc.SetChecksum(true, chkOff); err != nil {
return nil, nil, fmt.Errorf("set checksum: %w", err)
}
}

return newConn(pc, ipAddr, ifi)
Expand Down