1 /* $NetBSD: rumpuser_net.c,v 1.6 2009/01/26 12:08:39 pooka Exp $ */
4 * Copyright (c) 2008 Antti Kantee. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 #include <sys/cdefs.h>
30 __RCSID("$NetBSD: rumpuser_net.c,v 1.6 2009/01/26 12:08:39 pooka Exp $");
33 #include <sys/types.h>
34 #include <sys/socket.h>
38 #include <rump/rumpuser.h>
40 #include "rumpuser_int.h"
43 rumpuser_net_socket(int domain
, int type
, int proto
, int *error
)
46 DOCALL_KLOCK(int, (socket(domain
, type
, proto
)));
50 rumpuser_net_sendmsg(int s
, const struct msghdr
*msg
, int flags
, int *error
)
53 DOCALL_KLOCK(ssize_t
, (sendmsg(s
, msg
, flags
)));
57 rumpuser_net_recvmsg(int s
, struct msghdr
*msg
, int flags
, int *error
)
60 DOCALL_KLOCK(ssize_t
, (recvmsg(s
, msg
, flags
)));
64 rumpuser_net_connect(int s
, const struct sockaddr
*name
, int len
, int *error
)
67 DOCALL_KLOCK(int, (connect(s
, name
, (socklen_t
)len
)));
71 rumpuser_net_bind(int s
, const struct sockaddr
*name
, int len
, int *error
)
74 DOCALL_KLOCK(int, (bind(s
, name
, (socklen_t
)len
)));
78 rumpuser_net_accept(int s
, struct sockaddr
*name
, int *lenp
, int *error
)
81 DOCALL_KLOCK(int, (accept(s
, name
, (socklen_t
*)lenp
)));
85 rumpuser_net_listen(int s
, int backlog
, int *error
)
88 DOCALL_KLOCK(int, (listen(s
, backlog
)));
92 rumpuser_net_getname(int s
, struct sockaddr
*so
, int *lenp
,
93 enum rumpuser_getnametype which
, int *error
)
95 socklen_t slen
= *lenp
;
98 if (which
== RUMPUSER_SOCKNAME
)
99 rv
= getsockname(s
, so
, &slen
);
101 rv
= getpeername(s
, so
, &slen
);
113 rumpuser_net_setsockopt(int s
, int level
, int name
,
114 const void *data
, int dlen
, int *error
)
116 socklen_t slen
= dlen
;
119 rv
= setsockopt(s
, level
, name
, data
, slen
);