]> git.meshlink.io Git - catta/blob - avahi-compat-howl/include/salt/socket.h
add updated specs to svn
[catta] / avahi-compat-howl / include / salt / socket.h
1 #ifndef _sw_socket_h
2 #define _sw_socket_h
3
4 /*
5  * Copyright 2003, 2004 Porchdog Software. All rights reserved.
6  *
7  *      Redistribution and use in source and binary forms, with or without modification,
8  *      are permitted provided that the following conditions are met:
9  *
10  *              1. Redistributions of source code must retain the above copyright notice,
11  *                 this list of conditions and the following disclaimer.   
12  *              2. Redistributions in binary form must reproduce the above copyright notice,
13  *                 this list of conditions and the following disclaimer in the documentation
14  *                 and/or other materials provided with the distribution.
15  *
16  *      THIS SOFTWARE IS PROVIDED BY PORCHDOG SOFTWARE ``AS IS'' AND ANY
17  *      EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  *      WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  *      IN NO EVENT SHALL THE HOWL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20  *      INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21  *      BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  *      DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23  *      OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
24  *      OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
25  *      OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  *      The views and conclusions contained in the software and documentation are those
28  *      of the authors and should not be interpreted as representing official policies,
29  *      either expressed or implied, of Porchdog Software.
30  */
31
32 #include <salt/platform.h>
33 #include <salt/address.h>
34
35
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif 
40
41
42 struct                                                                                  _sw_socket;
43 typedef struct _sw_socket                               *       sw_socket;
44 struct                                                                                  _sw_socket_options;
45 typedef struct _sw_socket_options       *       sw_socket_options;
46 typedef sw_uint16                                                       sw_port;
47
48
49
50 sw_result HOWL_API
51 sw_tcp_socket_init(
52                                 sw_socket       *       self);
53
54
55 sw_result HOWL_API
56 sw_tcp_socket_init_with_desc(
57                                 sw_socket       *       self,
58                                 sw_sockdesc_t   desc);
59
60
61 sw_result HOWL_API
62 sw_udp_socket_init(
63                                 sw_socket       *       self);
64
65
66 sw_result HOWL_API
67 sw_multicast_socket_init(
68                                 sw_socket       *       self);
69                                     
70                                     
71 sw_result HOWL_API
72 sw_socket_fina(
73                                 sw_socket       self);
74
75
76 sw_result HOWL_API
77 sw_socket_bind(
78                                 sw_socket                       self,
79                                 sw_ipv4_address address,
80                                 sw_port                 port);
81
82
83 sw_result HOWL_API
84 sw_socket_join_multicast_group(
85                                 sw_socket                       self,
86                                 sw_ipv4_address local_address,
87                                 sw_ipv4_address multicast_address,
88                                 sw_uint32                       ttl);
89
90
91 sw_result HOWL_API
92 sw_socket_leave_multicast_group(
93                                 sw_socket       self);
94
95
96 sw_result HOWL_API
97 sw_socket_listen(
98                                 sw_socket       self,
99                                 int                     qsize);
100                                     
101                                      
102 sw_result HOWL_API
103 sw_socket_connect(
104                                 sw_socket                       self,
105                                 sw_ipv4_address address,
106                                 sw_port                 port);
107                                     
108                                     
109 sw_result HOWL_API
110 sw_socket_accept(
111                                 sw_socket               self,
112                                 sw_socket       *       socket);
113                                     
114                            
115 sw_result HOWL_API
116 sw_socket_send(
117                                 sw_socket               self,
118                                 sw_octets               buffer,
119                                 sw_size_t               len,
120                                 sw_size_t       *       bytesWritten);
121
122
123 sw_result HOWL_API
124 sw_socket_sendto(
125                                 sw_socket                       self,
126                                 sw_octets                       buffer,
127                                 sw_size_t                       len,
128                                 sw_size_t               *       bytesWritten,
129                                 sw_ipv4_address to,
130                                 sw_port                 port);
131
132                                     
133 sw_result HOWL_API
134 sw_socket_recv(
135                                 sw_socket               self,
136                                 sw_octets               buffer,
137                                 sw_size_t               max,
138                                 sw_size_t       *       len);
139
140
141 sw_result HOWL_API
142 sw_socket_recvfrom(
143                                 sw_socket                               self,
144                                 sw_octets                               buffer,
145                                 sw_size_t                               max,
146                                 sw_size_t                       *       len,
147                                 sw_ipv4_address *       from,
148                                 sw_port                 *       port,
149                                 sw_ipv4_address *       dest,
150                                 sw_uint32                               *       interface_index);
151
152
153 sw_result HOWL_API
154 sw_socket_set_blocking_mode(
155                                 sw_socket       self,
156                                 sw_bool blocking_mode);
157                                 
158                                 
159 sw_result HOWL_API
160 sw_socket_set_options(
161                                 sw_socket                               self,
162                                 sw_socket_options               options);
163                                  
164
165 sw_ipv4_address HOWL_API
166 sw_socket_ipv4_address(
167                                 sw_socket       self);
168
169
170 sw_port HOWL_API
171 sw_socket_port(
172                                 sw_socket       self);
173
174
175 sw_sockdesc_t HOWL_API
176 sw_socket_desc(
177                                 sw_socket       self);
178
179
180 sw_result HOWL_API
181 sw_socket_close(
182                                 sw_socket       self);
183
184
185 sw_result HOWL_API
186 sw_socket_options_init(
187                                 sw_socket_options       *       self);
188                                     
189
190 sw_result HOWL_API
191 sw_socket_options_fina(
192                                 sw_socket_options       self);
193                                     
194
195 sw_result HOWL_API
196 sw_socket_options_set_debug(
197                                 sw_socket_options               self,
198                                 sw_bool                                 val);
199                                
200
201 sw_result HOWL_API
202 sw_socket_options_set_nodelay(
203                                 sw_socket_options               self,
204                                 sw_bool                                 val);
205                                     
206                                     
207 sw_result HOWL_API
208 sw_socket_options_set_dontroute(
209                                 sw_socket_options               self,
210                                 sw_bool                                 val);
211                                     
212                              
213 sw_result HOWL_API
214 sw_socket_options_set_keepalive(
215                                 sw_socket_options               self,
216                                 sw_bool                                 val);
217
218
219 sw_result HOWL_API
220 sw_socket_options_set_linger(
221                                 sw_socket_options               self,
222                                 sw_bool                                 onoff,
223                                 sw_uint32                                       linger);
224                                     
225                                     
226 sw_result HOWL_API
227 sw_socket_options_set_reuseaddr(
228                                 sw_socket_options               self,
229                                 sw_bool                                 val);
230
231
232 sw_result HOWL_API
233 sw_socket_options_set_rcvbuf(
234                                 sw_socket_options               self,
235                                 sw_uint32                                       val);
236                                     
237                                     
238 sw_result HOWL_API
239 sw_socket_options_set_sndbuf(
240                                 sw_socket_options               self,
241                                 sw_uint32                                       val);
242
243
244 int
245 sw_socket_error_code(void); 
246
247
248 #define SW_E_SOCKET_BASE                0x80000200
249 #define SW_E_SOCKET                             (SW_E_SOCKET_BASE) + 1
250 #define SW_E_BIND                               (SW_E_SOCKET_BASE) + 2
251 #define SW_E_GETSOCKNAME                (SW_E_SOCKET_BASE) + 3
252 #define SW_E_ADD_MEMBERSHIP     (SW_E_SOCKET_BASE) + 4
253 #define SW_E_MULTICAST_TTL      (SW_E_SOCKET_BASE) + 5
254 #define SW_E_NOCONNECTION               (SW_E_SOCKET_BASE) + 6
255 #define SW_E_INPROGRESS         (SW_E_SOCKET_BASE) + 7
256
257
258 #ifdef __cplusplus
259 }
260 #endif 
261
262
263 #endif