sockets: make shutdown(2) how argument a enum
Reviwed by: tuexen Differential Revision: https://reviews.freebsd.org/D43412
This commit is contained in:
@@ -2964,14 +2964,11 @@ soreceive(struct socket *so, struct sockaddr **psa, struct uio *uio,
|
||||
}
|
||||
|
||||
int
|
||||
soshutdown(struct socket *so, int how)
|
||||
soshutdown(struct socket *so, enum shutdown_how how)
|
||||
{
|
||||
struct protosw *pr;
|
||||
int error, soerror_enotconn;
|
||||
|
||||
if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR))
|
||||
return (EINVAL);
|
||||
|
||||
soerror_enotconn = 0;
|
||||
SOCK_LOCK(so);
|
||||
if ((so->so_state &
|
||||
|
||||
@@ -1172,6 +1172,9 @@ kern_shutdown(struct thread *td, int s, int how)
|
||||
struct file *fp;
|
||||
int error;
|
||||
|
||||
if (__predict_false(how < SHUT_RD || how > SHUT_RDWR))
|
||||
return (EINVAL);
|
||||
|
||||
AUDIT_ARG_FD(s);
|
||||
error = getsock(td, s, &cap_shutdown_rights, &fp);
|
||||
if (error == 0) {
|
||||
|
||||
+5
-3
@@ -627,9 +627,11 @@ struct omsghdr {
|
||||
/*
|
||||
* howto arguments for shutdown(2), specified by Posix.1g.
|
||||
*/
|
||||
#define SHUT_RD 0 /* shut down the reading side */
|
||||
#define SHUT_WR 1 /* shut down the writing side */
|
||||
#define SHUT_RDWR 2 /* shut down both sides */
|
||||
enum shutdown_how {
|
||||
SHUT_RD = 0, /* shut down the reading side */
|
||||
SHUT_WR, /* shut down the writing side */
|
||||
SHUT_RDWR /* shut down both sides */
|
||||
};
|
||||
|
||||
#if __BSD_VISIBLE
|
||||
/* for SCTP */
|
||||
|
||||
+2
-1
@@ -434,6 +434,7 @@ struct mbuf;
|
||||
struct sockaddr;
|
||||
struct ucred;
|
||||
struct uio;
|
||||
enum shutdown_how;
|
||||
|
||||
/* Return values for socket upcalls. */
|
||||
#define SU_OK 0
|
||||
@@ -512,7 +513,7 @@ int sosend_dgram(struct socket *so, struct sockaddr *addr,
|
||||
int sosend_generic(struct socket *so, struct sockaddr *addr,
|
||||
struct uio *uio, struct mbuf *top, struct mbuf *control,
|
||||
int flags, struct thread *td);
|
||||
int soshutdown(struct socket *so, int how);
|
||||
int soshutdown(struct socket *so, enum shutdown_how);
|
||||
void soupcall_clear(struct socket *, sb_which);
|
||||
void soupcall_set(struct socket *, sb_which, so_upcall_t, void *);
|
||||
void solisten_upcall_set(struct socket *, so_upcall_t, void *);
|
||||
|
||||
Reference in New Issue
Block a user