mirror of
https://github.com/golang/sys.git
synced 2026-02-09 04:06:04 +03:00
unix: add SetsockoptTCPMD5Sig on linux
This allows to set the TCP MD5 signature (see https://www.rfc-editor.org/rfc/rfc2385) using TCPMD5Sig introduced in CL 106656. Also export the storage data field in SockaddrStorage and convert it to a byte array so the address in TCPMD5Sig.Addr can be set from an net.IP without conversion. Change-Id: I6bccfab57c188fcef857a6a3c514c943ca00b670 Reviewed-on: https://go-review.googlesource.com/c/sys/+/472835 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
This commit is contained in:
committed by
Gopher Robot
parent
a6bfb89d2f
commit
147085206c
@@ -110,6 +110,15 @@ func main() {
|
||||
icmpV6Regex := regexp.MustCompile(`type (ICMPv6Filter) struct {(\s+)X__icmp6_filt(\s+\S+\s+)}`)
|
||||
b = icmpV6Regex.ReplaceAll(b, []byte("type $1 struct {${2}Filt$3}"))
|
||||
|
||||
// Intentionally export address storage field in SockaddrStorage convert it to [N]byte.
|
||||
convertSockaddrStorageData := regexp.MustCompile(`(X__ss_padding)\s+\[(\d+)\]u?int8`)
|
||||
sockaddrStorageType := regexp.MustCompile(`type SockaddrStorage struct {[^}]*}`)
|
||||
sockaddrStorageStructs := sockaddrStorageType.FindAll(b, -1)
|
||||
for _, s := range sockaddrStorageStructs {
|
||||
newNames := convertSockaddrStorageData.ReplaceAll(s, []byte("Data [$2]byte"))
|
||||
b = bytes.Replace(b, s, newNames, 1)
|
||||
}
|
||||
|
||||
// If we have empty Ptrace structs, we should delete them. Only s390x emits
|
||||
// nonempty Ptrace structs.
|
||||
ptraceRexexp := regexp.MustCompile(`type Ptrace((Psw|Fpregs|Per) struct {\s*})`)
|
||||
|
||||
@@ -1364,6 +1364,10 @@ func SetsockoptTCPRepairOpt(fd, level, opt int, o []TCPRepairOpt) (err error) {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(&o[0]), uintptr(SizeofTCPRepairOpt*len(o)))
|
||||
}
|
||||
|
||||
func SetsockoptTCPMD5Sig(fd, level, opt int, s *TCPMD5Sig) error {
|
||||
return setsockopt(fd, level, opt, unsafe.Pointer(s), unsafe.Sizeof(*s))
|
||||
}
|
||||
|
||||
// Keyctl Commands (http://man7.org/linux/man-pages/man2/keyctl.2.html)
|
||||
|
||||
// KeyctlInt calls keyctl commands in which each argument is an int.
|
||||
|
||||
@@ -414,7 +414,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [122]int8
|
||||
Data [122]byte
|
||||
_ uint32
|
||||
}
|
||||
|
||||
|
||||
@@ -427,7 +427,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -405,7 +405,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [122]uint8
|
||||
Data [122]byte
|
||||
_ uint32
|
||||
}
|
||||
|
||||
|
||||
@@ -406,7 +406,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [122]int8
|
||||
Data [122]byte
|
||||
_ uint32
|
||||
}
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -410,7 +410,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [122]int8
|
||||
Data [122]byte
|
||||
_ uint32
|
||||
}
|
||||
|
||||
|
||||
@@ -417,7 +417,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [122]uint8
|
||||
Data [122]byte
|
||||
_ uint32
|
||||
}
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]uint8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -416,7 +416,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]uint8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -434,7 +434,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]uint8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
@@ -411,7 +411,7 @@ const (
|
||||
|
||||
type SockaddrStorage struct {
|
||||
Family uint16
|
||||
_ [118]int8
|
||||
Data [118]byte
|
||||
_ uint64
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user