4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. */
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <sys/stropts.h>
32 #include <sys/stream.h>
33 #include <sys/socketvar.h>
34 #include <sys/sockio.h>
42 #include <netinet/sctp.h>
44 #pragma weak __xnet_bind = bind
45 #pragma weak __xnet_listen = listen
46 #pragma weak __xnet_connect = connect
47 #pragma weak __xnet_recvmsg = recvmsg
48 #pragma weak __xnet_sendmsg = sendmsg
49 #pragma weak __xnet_sendto = sendto
50 #pragma weak __xnet_getsockopt = getsockopt
52 extern int _so_bind();
53 extern int _so_listen();
54 extern int _so_accept();
55 extern int _so_connect();
56 extern int _so_shutdown();
57 extern int _so_recv();
58 extern int _so_recvfrom();
59 extern int _so_recvmsg();
60 extern int _so_send();
61 extern int _so_sendmsg();
62 extern int _so_sendto();
63 extern int _so_getpeername();
64 extern int _so_getsockname();
65 extern int _so_getsockopt();
66 extern int _so_setsockopt();
69 bind(int sock
, const struct sockaddr
*addr
, socklen_t addrlen
)
71 return (_so_bind(sock
, addr
, addrlen
));
75 listen(int sock
, int backlog
)
77 return (_so_listen(sock
, backlog
));
81 accept(int sock
, struct sockaddr
*addr
, socklen_t
*addrlen
)
83 return (_so_accept(sock
, addr
, addrlen
, 0));
87 accept4(int sock
, struct sockaddr
*addr
, socklen_t
*addrlen
, int flags
)
89 return (_so_accept(sock
, addr
, addrlen
, flags
));
93 connect(int sock
, const struct sockaddr
*addr
, socklen_t addrlen
)
95 return (_so_connect(sock
, addr
, addrlen
));
99 shutdown(int sock
, int how
)
101 return (_so_shutdown(sock
, how
));
105 recv(int sock
, void *buf
, size_t len
, int flags
)
107 return (_so_recv(sock
, buf
, len
, flags
));
111 recvfrom(int sock
, void *buf
, size_t len
, int flags
,
112 struct sockaddr
*addr
, socklen_t
*addrlen
)
114 return (_so_recvfrom(sock
, buf
, len
, flags
, addr
, addrlen
));
118 recvmsg(int sock
, struct msghdr
*msg
, int flags
)
120 return (_so_recvmsg(sock
, msg
, flags
));
124 send(int sock
, const void *buf
, size_t len
, int flags
)
126 return (_so_send(sock
, buf
, len
, flags
));
130 sendmsg(int sock
, const struct msghdr
*msg
, int flags
)
132 return (_so_sendmsg(sock
, msg
, flags
));
136 sendto(int sock
, const void *buf
, size_t len
, int flags
,
137 const struct sockaddr
*addr
, socklen_t addrlen
)
139 return (_so_sendto(sock
, buf
, len
, flags
, addr
, addrlen
));
143 getpeername(int sock
, struct sockaddr
*name
, socklen_t
*namelen
)
145 return (_so_getpeername(sock
, name
, namelen
));
149 getsockname(int sock
, struct sockaddr
*name
, socklen_t
*namelen
)
151 return (_so_getsockname(sock
, name
, namelen
));
155 getsockopt(int sock
, int level
, int optname
, void *optval
, socklen_t
*optlen
)
157 if (level
== IPPROTO_SCTP
) {
159 socklen_t len
= *optlen
;
166 case SCTP_SET_PEER_PRIMARY_ADDR
:
167 case SCTP_PRIMARY_ADDR
:
168 case SCTP_PEER_ADDR_PARAMS
:
170 case SCTP_GET_PEER_ADDR_INFO
:
172 * Association ID is the first element params struct
174 bcopy(optval
, &id
, sizeof (id
));
176 case SCTP_DEFAULT_SEND_PARAM
:
177 bcopy(&((struct sctp_sndrcvinfo
*)
178 optval
)->sinfo_assoc_id
, &id
, sizeof (id
));
183 sopt
.sopt_name
= optname
;
184 sopt
.sopt_val
= optval
;
186 if (ioctl(sock
, SIOCSCTPGOPT
, &sopt
) == -1) {
189 *optlen
= sopt
.sopt_len
;
193 return (_so_getsockopt(sock
, level
, optname
, optval
, optlen
));
198 setsockopt(int sock
, int level
, int optname
, const void *optval
,
201 return (_so_setsockopt(sock
, level
, optname
, optval
, optlen
));