Deleted Added
full compact
linux_socket.c (192205) linux_socket.c (192206)
1/*-
2 * Copyright (c) 1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1995 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_socket.c 192205 2009-05-16 18:46:51Z dchagin $");
30__FBSDID("$FreeBSD: head/sys/compat/linux/linux_socket.c 192206 2009-05-16 18:48:41Z dchagin $");
31
32/* XXX we use functions that might not exist. */
33#include "opt_compat.h"
34#include "opt_inet6.h"
35
36#include <sys/param.h>
37#include <sys/proc.h>
38#include <sys/systm.h>

--- 549 unchanged lines hidden (view full) ---

588 INIT_VNET_INET6(curvnet);
589#endif
590#endif
591 struct socket_args /* {
592 int domain;
593 int type;
594 int protocol;
595 } */ bsd_args;
31
32/* XXX we use functions that might not exist. */
33#include "opt_compat.h"
34#include "opt_inet6.h"
35
36#include <sys/param.h>
37#include <sys/proc.h>
38#include <sys/systm.h>

--- 549 unchanged lines hidden (view full) ---

588 INIT_VNET_INET6(curvnet);
589#endif
590#endif
591 struct socket_args /* {
592 int domain;
593 int type;
594 int protocol;
595 } */ bsd_args;
596 int retval_socket;
596 int retval_socket, socket_flags;
597
598 bsd_args.protocol = args->protocol;
597
598 bsd_args.protocol = args->protocol;
599 bsd_args.type = args->type;
599 socket_flags = args->type & ~LINUX_SOCK_TYPE_MASK;
600 if (socket_flags & ~(LINUX_SOCK_CLOEXEC | LINUX_SOCK_NONBLOCK))
601 return (EINVAL);
602 bsd_args.type = args->type & LINUX_SOCK_TYPE_MASK;
600 if (bsd_args.type < 0 || bsd_args.type > LINUX_SOCK_MAX)
601 return (EINVAL);
602 bsd_args.domain = linux_to_bsd_domain(args->domain);
603 if (bsd_args.domain == -1)
604 return (EAFNOSUPPORT);
605
606 retval_socket = socket(td, &bsd_args);
607 if (retval_socket)
608 return (retval_socket);
609
603 if (bsd_args.type < 0 || bsd_args.type > LINUX_SOCK_MAX)
604 return (EINVAL);
605 bsd_args.domain = linux_to_bsd_domain(args->domain);
606 if (bsd_args.domain == -1)
607 return (EAFNOSUPPORT);
608
609 retval_socket = socket(td, &bsd_args);
610 if (retval_socket)
611 return (retval_socket);
612
613 if (socket_flags & LINUX_SOCK_NONBLOCK) {
614 retval_socket = kern_fcntl(td, td->td_retval[0],
615 F_SETFL, O_NONBLOCK);
616 if (retval_socket) {
617 (void)kern_close(td, td->td_retval[0]);
618 goto out;
619 }
620 }
621 if (socket_flags & LINUX_SOCK_CLOEXEC) {
622 retval_socket = kern_fcntl(td, td->td_retval[0],
623 F_SETFD, FD_CLOEXEC);
624 if (retval_socket) {
625 (void)kern_close(td, td->td_retval[0]);
626 goto out;
627 }
628 }
629
610 if (bsd_args.type == SOCK_RAW
611 && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
612 && bsd_args.domain == PF_INET) {
613 /* It's a raw IP socket: set the IP_HDRINCL option. */
614 int hdrincl;
615
616 hdrincl = 1;
617 /* We ignore any error returned by kern_setsockopt() */

--- 19 unchanged lines hidden (view full) ---

637
638 v6only = 0;
639 /* We ignore any error returned by setsockopt() */
640 kern_setsockopt(td, td->td_retval[0], IPPROTO_IPV6, IPV6_V6ONLY,
641 &v6only, UIO_SYSSPACE, sizeof(v6only));
642 }
643#endif
644
630 if (bsd_args.type == SOCK_RAW
631 && (bsd_args.protocol == IPPROTO_RAW || bsd_args.protocol == 0)
632 && bsd_args.domain == PF_INET) {
633 /* It's a raw IP socket: set the IP_HDRINCL option. */
634 int hdrincl;
635
636 hdrincl = 1;
637 /* We ignore any error returned by kern_setsockopt() */

--- 19 unchanged lines hidden (view full) ---

657
658 v6only = 0;
659 /* We ignore any error returned by setsockopt() */
660 kern_setsockopt(td, td->td_retval[0], IPPROTO_IPV6, IPV6_V6ONLY,
661 &v6only, UIO_SYSSPACE, sizeof(v6only));
662 }
663#endif
664
665out:
645 return (retval_socket);
646}
647
648struct linux_bind_args {
649 int s;
650 l_uintptr_t name;
651 int namelen;
652};

--- 826 unchanged lines hidden ---
666 return (retval_socket);
667}
668
669struct linux_bind_args {
670 int s;
671 l_uintptr_t name;
672 int namelen;
673};

--- 826 unchanged lines hidden ---