- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (0);
-
- case FIONREAD:
- *(int *)data = so->so_rcv.sb_cc;
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (0);
-
- case SIOCSPGRP:
- so->so_pgid = *(int *)data;
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (0);
-
- case SIOCGPGRP:
- *(int *)data = so->so_pgid;
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (0);
-
- case SIOCATMARK:
- *(int *)data = (so->so_state&SS_RCVATMARK) != 0;
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (0);
-
- case SIOCSETOT: {
- /*
- * Set socket level options here and then call protocol
- * specific routine.
- */
- struct socket *cloned_so = NULL;
- int cloned_fd = *(int *)data;
-
- /* let's make sure it's either -1 or a valid file descriptor */
- if (cloned_fd != -1) {
- struct file *cloned_fp;
- error = getsock(p->p_fd, cloned_fd, &cloned_fp);
- if (error) {
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (error);
- }
-
- cloned_so = (struct socket *)cloned_fp->f_data;
- }
-
- /* Always set socket non-blocking for OT */
- fp->f_flag |= FNONBLOCK;
- so->so_state |= SS_NBIO;
- so->so_options |= SO_DONTTRUNC | SO_WANTMORE;
-
- if (cloned_so && so != cloned_so) {
- /* Flags options */
- so->so_options |= cloned_so->so_options & ~SO_ACCEPTCONN;
-
- /* SO_LINGER */
- if (so->so_options & SO_LINGER)
- so->so_linger = cloned_so->so_linger;
-
- /* SO_SNDBUF, SO_RCVBUF */
- if (cloned_so->so_snd.sb_hiwat > 0) {
- if (sbreserve(&so->so_snd, cloned_so->so_snd.sb_hiwat) == 0) {
- error = ENOBUFS;
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (error);
- }
- }
- if (cloned_so->so_rcv.sb_hiwat > 0) {
- if (sbreserve(&so->so_rcv, cloned_so->so_rcv.sb_hiwat) == 0) {
- error = ENOBUFS;
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (error);
- }
- }
-
- /* SO_SNDLOWAT, SO_RCVLOWAT */
- so->so_snd.sb_lowat =
- (cloned_so->so_snd.sb_lowat > so->so_snd.sb_hiwat) ?
- so->so_snd.sb_hiwat : cloned_so->so_snd.sb_lowat;
- so->so_rcv.sb_lowat =
- (cloned_so->so_rcv.sb_lowat > so->so_rcv.sb_hiwat) ?
- so->so_rcv.sb_hiwat : cloned_so->so_rcv.sb_lowat;
-
- /* SO_SNDTIMEO, SO_RCVTIMEO */
- so->so_snd.sb_timeo = cloned_so->so_snd.sb_timeo;
- so->so_rcv.sb_timeo = cloned_so->so_rcv.sb_timeo;
- }
-
- error = (*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, 0, p);
- /* Just ignore protocols that do not understand it */
- if (error == EOPNOTSUPP)
- error = 0;
-
- thread_funnel_switch(NETWORK_FUNNEL, KERNEL_FUNNEL);
- return (error);
- }
+ goto out;
+
+ case FIONREAD: /* int */
+ bcopy(&so->so_rcv.sb_cc, data, sizeof(u_int32_t));
+ goto out;
+
+ case SIOCSPGRP: /* int */
+ bcopy(data, &so->so_pgid, sizeof(pid_t));
+ goto out;
+
+ case SIOCGPGRP: /* int */
+ bcopy(&so->so_pgid, data, sizeof(pid_t));
+ goto out;
+
+ case SIOCATMARK: /* int */
+ int_arg = (so->so_state & SS_RCVATMARK) != 0;
+ bcopy(&int_arg, data, sizeof(int_arg));
+ goto out;
+
+ case SIOCSETOT: /* int; deprecated */
+ error = EOPNOTSUPP;
+ goto out;
+
+ case SIOCGASSOCIDS32: /* so_aidreq32 */
+ case SIOCGASSOCIDS64: /* so_aidreq64 */
+ case SIOCGCONNIDS32: /* so_cidreq32 */
+ case SIOCGCONNIDS64: /* so_cidreq64 */
+ case SIOCGCONNINFO32: /* so_cinforeq32 */
+ case SIOCGCONNINFO64: /* so_cinforeq64 */
+ case SIOCSCONNORDER: /* so_cordreq */
+ case SIOCGCONNORDER: /* so_cordreq */
+ error = (*so->so_proto->pr_usrreqs->pru_control)(so,
+ cmd, data, NULL, p);
+ goto out;