The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/compat/osf1/osf1_socket.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: osf1_socket.c,v 1.19 2007/12/20 23:03:03 dsl Exp $ */
    2 
    3 /*
    4  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
    5  *
    6  * Redistribution and use in source and binary forms, with or without
    7  * modification, are permitted provided that the following conditions
    8  * are met:
    9  * 1. Redistributions of source code must retain the above copyright
   10  *    notice, this list of conditions and the following disclaimer.
   11  * 2. Redistributions in binary form must reproduce the above copyright
   12  *    notice, this list of conditions and the following disclaimer in the
   13  *    documentation and/or other materials provided with the distribution.
   14  * 3. All advertising materials mentioning features or use of this software
   15  *    must display the following acknowledgement:
   16  *      This product includes software developed by Christopher G. Demetriou
   17  *      for the NetBSD Project.
   18  * 4. The name of the author may not be used to endorse or promote products
   19  *    derived from this software without specific prior written permission
   20  *
   21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
   35  * All rights reserved.
   36  *
   37  * Author: Chris G. Demetriou
   38  *
   39  * Permission to use, copy, modify and distribute this software and
   40  * its documentation is hereby granted, provided that both the copyright
   41  * notice and this permission notice appear in all copies of the
   42  * software, derivative works or modified versions, and any portions
   43  * thereof, and that both notices appear in supporting documentation.
   44  *
   45  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   46  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
   47  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   48  *
   49  * Carnegie Mellon requests users of this software to return to
   50  *
   51  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   52  *  School of Computer Science
   53  *  Carnegie Mellon University
   54  *  Pittsburgh PA 15213-3890
   55  *
   56  * any improvements or extensions that they make and grant Carnegie the
   57  * rights to redistribute these changes.
   58  */
   59 
   60 #include <sys/cdefs.h>
   61 __KERNEL_RCSID(0, "$NetBSD: osf1_socket.c,v 1.19 2007/12/20 23:03:03 dsl Exp $");
   62 
   63 #include <sys/param.h>
   64 #include <sys/systm.h>
   65 #include <sys/namei.h>
   66 #include <sys/proc.h>
   67 #include <sys/file.h>
   68 #include <sys/malloc.h>
   69 #include <sys/mount.h>
   70 #include <sys/syscallargs.h>
   71 #include <sys/socket.h>
   72 #include <sys/socketvar.h>
   73 #include <sys/exec.h>
   74 
   75 #include <compat/osf1/osf1.h>
   76 #include <compat/osf1/osf1_syscallargs.h>
   77 #include <compat/common/compat_util.h>
   78 #include <compat/osf1/osf1_cvt.h>
   79 
   80 int
   81 osf1_sys_recvmsg_xopen(struct lwp *l, const struct osf1_sys_recvmsg_xopen_args *uap, register_t *retval)
   82 {
   83 
   84         /* XXX */
   85         return (EINVAL);
   86 }
   87 
   88 int
   89 osf1_sys_sendmsg_xopen(struct lwp *l, const struct osf1_sys_sendmsg_xopen_args *uap, register_t *retval)
   90 {
   91         struct osf1_msghdr_xopen osf_msghdr;
   92         struct osf1_iovec_xopen osf_iovec, *osf_iovec_ptr;
   93         struct msghdr bsd_msghdr;
   94         struct iovec *bsd_iovec;
   95         unsigned long leftovers;
   96         int flags;
   97         unsigned int i, iov_len;
   98         int error;
   99 
  100         /*
  101          * translate msghdr structure
  102          */
  103         if ((error = copyin(SCARG(uap, msg), &osf_msghdr,
  104             sizeof osf_msghdr)) != 0)
  105                 return (error);
  106 
  107         error = osf1_cvt_msghdr_xopen_to_native(&osf_msghdr, &bsd_msghdr);
  108         if (error != 0)
  109                 return (error);
  110 
  111         /*
  112          * translate flags
  113          */
  114         flags = emul_flags_translate(osf1_sendrecv_msg_flags_xtab,
  115             SCARG(uap, flags), &leftovers);
  116         if (leftovers != 0)
  117 {
  118 printf("sendmsg flags leftover: 0x%lx\n", leftovers);
  119                 return (EINVAL);
  120 }
  121 
  122         iov_len = bsd_msghdr.msg_iovlen;
  123         if (iov_len > IOV_MAX)
  124                 return EMSGSIZE;
  125         bsd_iovec = malloc(iov_len * sizeof (struct iovec), M_IOV, M_WAITOK);
  126         bsd_msghdr.msg_iov = bsd_iovec;
  127 
  128         osf_iovec_ptr = osf_msghdr.msg_iov;
  129         for (i = 0; i < iov_len; i++) {
  130                 error = copyin(&osf_iovec_ptr[i], &osf_iovec, sizeof osf_iovec);
  131                 if (error != 0) {
  132                         free(bsd_iovec, M_TEMP);
  133                         return (error);
  134                 }
  135                 bsd_iovec[i].iov_base = osf_iovec.iov_base;
  136                 bsd_iovec[i].iov_len = osf_iovec.iov_len;
  137         }
  138 
  139         error = do_sys_sendmsg(l, SCARG(uap, s), &bsd_msghdr, flags, retval);
  140         free(bsd_iovec, M_TEMP);
  141         return error;
  142 }
  143 
  144 int
  145 osf1_sys_sendto(struct lwp *l, const struct osf1_sys_sendto_args *uap, register_t *retval)
  146 {
  147         struct sys_sendto_args a;
  148         unsigned long leftovers;
  149 
  150         SCARG(&a, s) = SCARG(uap, s);
  151         SCARG(&a, buf) = SCARG(uap, buf);
  152         SCARG(&a, len) = SCARG(uap, len);
  153         SCARG(&a, to) = SCARG(uap, to);
  154         SCARG(&a, tolen) = SCARG(uap, tolen);
  155 
  156         /* translate flags */
  157         SCARG(&a, flags) = emul_flags_translate(osf1_sendrecv_msg_flags_xtab,
  158             SCARG(uap, flags), &leftovers);
  159         if (leftovers != 0)
  160                 return (EINVAL);
  161 
  162         return sys_sendto(l, &a, retval);
  163 }
  164 
  165 int
  166 osf1_sys_socket(struct lwp *l, const struct osf1_sys_socket_args *uap, register_t *retval)
  167 {
  168         struct compat_30_sys_socket_args a;
  169 
  170         /* XXX TRANSLATE */
  171 
  172         if (SCARG(uap, domain) > AF_LINK)
  173                 return (EINVAL);        /* XXX After AF_LINK, divergence. */
  174 
  175         SCARG(&a, domain) = SCARG(uap, domain);
  176         SCARG(&a, type) = SCARG(uap, type);
  177         SCARG(&a, protocol) = SCARG(uap, protocol);
  178 
  179         return compat_30_sys_socket(l, &a, retval);
  180 }
  181 
  182 int
  183 osf1_sys_socketpair(struct lwp *l, const struct osf1_sys_socketpair_args *uap, register_t *retval)
  184 {
  185         struct sys_socketpair_args a;
  186 
  187         /* XXX TRANSLATE */
  188 
  189         if (SCARG(uap, domain) > AF_LINK)
  190                 return (EINVAL);        /* XXX After AF_LINK, divergence. */
  191 
  192         SCARG(&a, domain) = SCARG(uap, domain);
  193         SCARG(&a, type) = SCARG(uap, type);
  194         SCARG(&a, protocol) = SCARG(uap, protocol);
  195         SCARG(&a, rsv) = SCARG(uap, rsv);
  196 
  197         return sys_socketpair(l, &a, retval);
  198 }

Cache object: fc9da1003920727ea4ed4871580c937f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.