diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2023-10-25 14:40:11 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2023-10-25 14:40:11 +0200 |
| commit | 8ed9ced09964a0f70ffcadd0aa8d25c7bc339352 (patch) | |
| tree | 4aefd3d5280837d2547a980995a3aa1a9eda4cb5 /vendor/golang.org/x/sys/unix/sockcmsg_unix.go | |
| parent | f308ca92d1631e579fbfe3b3da13c93709dc18a2 (diff) | |
| download | gofu-8ed9ced09964a0f70ffcadd0aa8d25c7bc339352.tar.gz | |
bump all dependencies to their latest versions
Diffstat (limited to 'vendor/golang.org/x/sys/unix/sockcmsg_unix.go')
| -rw-r--r-- | vendor/golang.org/x/sys/unix/sockcmsg_unix.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go index 453a942..3865943 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix.go @@ -52,6 +52,20 @@ func ParseSocketControlMessage(b []byte) ([]SocketControlMessage, error) { return msgs, nil } +// ParseOneSocketControlMessage parses a single socket control message from b, returning the message header, +// message data (a slice of b), and the remainder of b after that single message. +// When there are no remaining messages, len(remainder) == 0. +func ParseOneSocketControlMessage(b []byte) (hdr Cmsghdr, data []byte, remainder []byte, err error) { + h, dbuf, err := socketControlMessageHeaderAndData(b) + if err != nil { + return Cmsghdr{}, nil, nil, err + } + if i := cmsgAlignOf(int(h.Len)); i < len(b) { + remainder = b[i:] + } + return *h, dbuf, remainder, nil +} + func socketControlMessageHeaderAndData(b []byte) (*Cmsghdr, []byte, error) { h := (*Cmsghdr)(unsafe.Pointer(&b[0])) if h.Len < SizeofCmsghdr || uint64(h.Len) > uint64(len(b)) { |
