dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libc / port / socket / weaks.c
blobb5d78bae2af566cc747b004677593d85df0b85c6
1 /*
2 * CDDL HEADER START
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]
19 * CDDL HEADER END
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>
36 #include <errno.h>
37 #include <stdlib.h>
38 #include <unistd.h>
39 #include <stropts.h>
40 #include <stdio.h>
41 #include <strings.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();
68 int
69 bind(int sock, const struct sockaddr *addr, socklen_t addrlen)
71 return (_so_bind(sock, addr, addrlen));
74 int
75 listen(int sock, int backlog)
77 return (_so_listen(sock, backlog));
80 int
81 accept(int sock, struct sockaddr *addr, socklen_t *addrlen)
83 return (_so_accept(sock, addr, addrlen, 0));
86 int
87 accept4(int sock, struct sockaddr *addr, socklen_t *addrlen, int flags)
89 return (_so_accept(sock, addr, addrlen, flags));
92 int
93 connect(int sock, const struct sockaddr *addr, socklen_t addrlen)
95 return (_so_connect(sock, addr, addrlen));
98 int
99 shutdown(int sock, int how)
101 return (_so_shutdown(sock, how));
104 ssize_t
105 recv(int sock, void *buf, size_t len, int flags)
107 return (_so_recv(sock, buf, len, flags));
110 ssize_t
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));
117 ssize_t
118 recvmsg(int sock, struct msghdr *msg, int flags)
120 return (_so_recvmsg(sock, msg, flags));
123 ssize_t
124 send(int sock, const void *buf, size_t len, int flags)
126 return (_so_send(sock, buf, len, flags));
129 ssize_t
130 sendmsg(int sock, const struct msghdr *msg, int flags)
132 return (_so_sendmsg(sock, msg, flags));
135 ssize_t
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) {
158 sctp_assoc_t id = 0;
159 socklen_t len = *optlen;
160 int err = 0;
161 struct sctpopt sopt;
163 switch (optname) {
164 case SCTP_RTOINFO:
165 case SCTP_ASSOCINFO:
166 case SCTP_SET_PEER_PRIMARY_ADDR:
167 case SCTP_PRIMARY_ADDR:
168 case SCTP_PEER_ADDR_PARAMS:
169 case SCTP_STATUS:
170 case SCTP_GET_PEER_ADDR_INFO:
172 * Association ID is the first element params struct
174 bcopy(optval, &id, sizeof (id));
175 break;
176 case SCTP_DEFAULT_SEND_PARAM:
177 bcopy(&((struct sctp_sndrcvinfo *)
178 optval)->sinfo_assoc_id, &id, sizeof (id));
179 break;
182 sopt.sopt_aid = id;
183 sopt.sopt_name = optname;
184 sopt.sopt_val = optval;
185 sopt.sopt_len = len;
186 if (ioctl(sock, SIOCSCTPGOPT, &sopt) == -1) {
187 err = -1;
188 } else {
189 *optlen = sopt.sopt_len;
191 return (err);
192 } else {
193 return (_so_getsockopt(sock, level, optname, optval, optlen));
198 setsockopt(int sock, int level, int optname, const void *optval,
199 socklen_t optlen)
201 return (_so_setsockopt(sock, level, optname, optval, optlen));