Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/uipc_syscalls.c
Show First 20 Lines • Show All 1,379 Lines • ▼ Show 20 Lines | kern_getsockname(struct thread *td, int fd, struct sockaddr **sa, | ||||
AUDIT_ARG_FD(fd); | AUDIT_ARG_FD(fd); | ||||
error = getsock_cap(td, fd, &cap_getsockname_rights, | error = getsock_cap(td, fd, &cap_getsockname_rights, | ||||
&fp, NULL, NULL); | &fp, NULL, NULL); | ||||
if (error != 0) | if (error != 0) | ||||
return (error); | return (error); | ||||
so = fp->f_data; | so = fp->f_data; | ||||
*sa = NULL; | *sa = NULL; | ||||
CURVNET_SET(so->so_vnet); | CURVNET_SET(so->so_vnet); | ||||
error = (*so->so_proto->pr_usrreqs->pru_sockaddr)(so, sa); | error = so->so_proto->pr_sockaddr(so, sa); | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
if (error != 0) | if (error != 0) | ||||
goto bad; | goto bad; | ||||
if (*sa == NULL) | if (*sa == NULL) | ||||
len = 0; | len = 0; | ||||
else | else | ||||
len = MIN(*alen, (*sa)->sa_len); | len = MIN(*alen, (*sa)->sa_len); | ||||
*alen = len; | *alen = len; | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (error != 0) | ||||
return (error); | return (error); | ||||
so = fp->f_data; | so = fp->f_data; | ||||
if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) { | if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0) { | ||||
error = ENOTCONN; | error = ENOTCONN; | ||||
goto done; | goto done; | ||||
} | } | ||||
*sa = NULL; | *sa = NULL; | ||||
CURVNET_SET(so->so_vnet); | CURVNET_SET(so->so_vnet); | ||||
error = (*so->so_proto->pr_usrreqs->pru_peeraddr)(so, sa); | error = so->so_proto->pr_peeraddr(so, sa); | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
if (error != 0) | if (error != 0) | ||||
goto bad; | goto bad; | ||||
if (*sa == NULL) | if (*sa == NULL) | ||||
len = 0; | len = 0; | ||||
else | else | ||||
len = MIN(*alen, (*sa)->sa_len); | len = MIN(*alen, (*sa)->sa_len); | ||||
*alen = len; | *alen = len; | ||||
▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines |