Added text to note that although POSIX says msg_controllen

should be socklen_t, glibc actually uses size_t.
Various formatting fixes.
This commit is contained in:
Michael Kerrisk 2006-03-12 19:09:15 +00:00
parent d02aa9bc8c
commit ea4adf4ba9
2 changed files with 73 additions and 60 deletions

View File

@ -144,52 +144,49 @@ and
for more information.
The payload of the original packet that caused the error
is passed as normal data via
.BR msg_iovec .
.IR msg_iovec .
The original destination address of the datagram that caused the error
is supplied via
.BR msg_name .
.IR msg_name .
.IP
For local errors, no address is passed (this can be checked with the
.I cmsg_len
member of the
.BR cmsghdr ).
.IR cmsghdr ).
For error receives, the
.B MSG_ERRQUEUE
is set in the
.BR msghdr .
.IR msghdr .
After an error has been passed, the pending socket error
is regenerated based on the next queued error and will be passed
on the next socket operation.
The error is supplied in a
.B sock_extended_err
.I sock_extended_err
structure:
.IP
.RS
.ne 18
.in +0.25i
.nf
.ta 4n 20n 32n
#define SO_EE_ORIGIN_NONE 0
#define SO_EE_ORIGIN_LOCAL 1
#define SO_EE_ORIGIN_ICMP 2
#define SO_EE_ORIGIN_ICMP6 3
#define SO_EE_ORIGIN_NONE 0
#define SO_EE_ORIGIN_LOCAL 1
#define SO_EE_ORIGIN_ICMP 2
#define SO_EE_ORIGIN_ICMP6 3
struct sock_extended_err
{
u_int32_t ee_errno; /* error number */
u_int8_t ee_origin; /* where the error originated */
u_int8_t ee_type; /* type */
u_int8_t ee_code; /* code */
u_int8_t ee_pad;
u_int32_t ee_info; /* additional information */
u_int32_t ee_data; /* other data */
/* More data may follow */
u_int32_t ee_errno; /* error number */
u_int8_t ee_origin; /* where the error originated */
u_int8_t ee_type; /* type */
u_int8_t ee_code; /* code */
u_int8_t ee_pad;
u_int32_t ee_info; /* additional information */
u_int32_t ee_data; /* other data */
/* More data may follow */
};
struct sockaddr *SO_EE_OFFENDER(struct sock_extended_err *);
.ta
.fi
.RE
.in -0.25i
.IP
.B ee_errno
contains the errno number of the queued error.
@ -214,12 +211,12 @@ For local errors, no address is passed (this
can be checked with the
.I cmsg_len
member of the
.BR cmsghdr ).
.IR cmsghdr ).
For error receives,
the
.B MSG_ERRQUEUE
is set in the
.BR msghdr .
.IR msghdr .
After an error has been passed, the pending socket error
is regenerated based on the next queued error and will be passed
on the next socket operation.
@ -252,22 +249,20 @@ call uses a
structure to minimize the number of directly supplied parameters. This
structure has the following form, as defined in
.IR <sys/socket.h> :
.IP
.RS
.in +0.25i
.nf
.ta 4n 17n 33n
struct msghdr {
void * msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec * msg_iov; /* scatter/gather array */
size_t msg_iovlen; /* # elements in msg_iov */
void * msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
void *msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter/gather array */
size_t msg_iovlen; /* # elements in msg_iov */
void *msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
};
.ta
.fi
.RE
.in -0.25i
.PP
Here
.I msg_name
@ -297,20 +292,18 @@ upon return from a successful call it will contain the length
of the control message sequence.
.PP
The messages are of the form:
.PP
.RS
.in +0.25i
.nf
.ta 4n 16n 28n
struct cmsghdr {
socklen_t cmsg_len; /* data byte count, including hdr */
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
socklen_t cmsg_len; /* data byte count, including hdr */
int cmsg_level; /* originating protocol */
int cmsg_type; /* protocol-specific type */
/* followed by
u_char cmsg_data[]; */
u_char cmsg_data[]; */
};
.ta
.fi
.RE
.in -0.25i
.PP
Ancillary data should only be accessed by the macros defined in
.BR cmsg (3).
@ -402,7 +395,7 @@ POSIX only describes the
and
.B MSG_WAITALL
flags.
.SH NOTE
.SH NOTES
The prototypes given above follow glibc2.
The Single Unix Specification agrees, except that it has return values
of type `ssize_t' (while 4.x BSD and libc4 and libc5 all have `int').
@ -418,6 +411,17 @@ argument is `int *' in 4.x BSD, libc4 and libc5.
The present `socklen_t *' was invented by POSIX.
See also
.BR accept (2).
According to POSIX.1-2001, the
.I msg_controllen
field of the
.I msghdr
structure should be typed as
.IR socklen_t ,
but glibc currently (2.4) types it as
.IR size_t .
.\" FIXME . glibc bug raised 12 Mar 2006
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=2448
.SH "SEE ALSO"
.BR fcntl (2),
.BR getsockopt (2),

View File

@ -217,22 +217,20 @@ The definition of the
structure follows. See
.BR recv (2)
and below for an exact description of its fields.
.IP
.RS
.in +0.25i
.nf
.ta 4n 17n 33n
struct msghdr {
void * msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec * msg_iov; /* scatter/gather array */
size_t msg_iovlen; /* # elements in msg_iov */
void * msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
void *msg_name; /* optional address */
socklen_t msg_namelen; /* size of address */
struct iovec *msg_iov; /* scatter/gather array */
size_t msg_iovlen; /* # elements in msg_iov */
void *msg_control; /* ancillary data, see below */
socklen_t msg_controllen; /* ancillary data buffer len */
int msg_flags; /* flags on received message */
};
.ta
.fi
.RE
.in -0.25i
.PP
You may send control information using the
.I msg_control
@ -341,7 +339,7 @@ flags.
The
.B MSG_CONFIRM
flag is a Linux extension.
.SH NOTE
.SH NOTES
The prototypes given above follow the Single Unix Specification,
as glibc2 also does; the
.I flags
@ -354,6 +352,17 @@ the
argument was `int' in 4.x BSD and libc4 and libc5.
See also
.BR accept (2).
According to POSIX.1-2001, the
.I msg_controllen
field of the
.I msghdr
structure should be typed as
.IR socklen_t ,
but glibc currently (2.4) types it as
.IR size_t .
.\" FIXME . glibc bug raised 12 Mar 2006
.\" http://sourceware.org/bugzilla/show_bug.cgi?id=2448
.SH BUGS
Linux may return EPIPE instead of ENOTCONN.
.SH "SEE ALSO"