aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_network_lib.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_network_lib.h')
-rw-r--r--src/include/gnunet_network_lib.h172
1 files changed, 96 insertions, 76 deletions
diff --git a/src/include/gnunet_network_lib.h b/src/include/gnunet_network_lib.h
index 0f38b855f..65b2042d5 100644
--- a/src/include/gnunet_network_lib.h
+++ b/src/include/gnunet_network_lib.h
@@ -83,13 +83,10 @@ struct GNUNET_NETWORK_FDSet
83 * @param address_len length of address 83 * @param address_len length of address
84 * @return client socket 84 * @return client socket
85 */ 85 */
86struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_accept (const struct 86struct GNUNET_NETWORK_Handle *
87 GNUNET_NETWORK_Handle 87GNUNET_NETWORK_socket_accept (const struct GNUNET_NETWORK_Handle *desc,
88 *desc, 88 struct sockaddr *address,
89 struct sockaddr 89 socklen_t * address_len);
90 *address,
91 socklen_t *
92 address_len);
93 90
94 91
95/** 92/**
@@ -98,7 +95,8 @@ struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_accept (const struct
98 * @param fd socket to box 95 * @param fd socket to box
99 * @return NULL on error (including not supported on target platform) 96 * @return NULL on error (including not supported on target platform)
100 */ 97 */
101struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_box_native (int fd); 98struct GNUNET_NETWORK_Handle *
99GNUNET_NETWORK_socket_box_native (int fd);
102 100
103 101
104/** 102/**
@@ -109,9 +107,10 @@ struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_box_native (int fd);
109 * @param address_len length of address 107 * @param address_len length of address
110 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 108 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
111 */ 109 */
112int GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc, 110int
113 const struct sockaddr *address, 111GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
114 socklen_t address_len); 112 const struct sockaddr *address,
113 socklen_t address_len);
115 114
116/** 115/**
117 * Close a socket. 116 * Close a socket.
@@ -119,7 +118,8 @@ int GNUNET_NETWORK_socket_bind (struct GNUNET_NETWORK_Handle *desc,
119 * @param desc socket to close 118 * @param desc socket to close
120 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 119 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
121 */ 120 */
122int GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc); 121int
122GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc);
123 123
124 124
125/** 125/**
@@ -130,9 +130,10 @@ int GNUNET_NETWORK_socket_close (struct GNUNET_NETWORK_Handle *desc);
130 * @param address_len of address 130 * @param address_len of address
131 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 131 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
132 */ 132 */
133int GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc, 133int
134 const struct sockaddr *address, 134GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
135 socklen_t address_len); 135 const struct sockaddr *address,
136 socklen_t address_len);
136 137
137 138
138/** 139/**
@@ -145,9 +146,10 @@ int GNUNET_NETWORK_socket_connect (const struct GNUNET_NETWORK_Handle *desc,
145 * @param optlen length of optval 146 * @param optlen length of optval
146 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 147 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
147 */ 148 */
148int GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc, 149int
149 int level, int optname, void *optval, 150GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
150 socklen_t * optlen); 151 int level, int optname, void *optval,
152 socklen_t * optlen);
151 153
152 154
153/** 155/**
@@ -157,16 +159,18 @@ int GNUNET_NETWORK_socket_getsockopt (const struct GNUNET_NETWORK_Handle *desc,
157 * @param backlog length of the listen queue 159 * @param backlog length of the listen queue
158 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 160 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
159 */ 161 */
160int GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc, 162int
161 int backlog); 163GNUNET_NETWORK_socket_listen (const struct GNUNET_NETWORK_Handle *desc,
164 int backlog);
162 165
163 166
164/** 167/**
165 * How much data is available to be read on this descriptor? 168 * How much data is available to be read on this descriptor?
166 * @param desc socket 169 * @param desc socket
167 */ 170 */
168ssize_t GNUNET_NETWORK_socket_recvfrom_amount (const struct 171ssize_t
169 GNUNET_NETWORK_Handle *desc); 172GNUNET_NETWORK_socket_recvfrom_amount (const struct GNUNET_NETWORK_Handle
173 *desc);
170 174
171 175
172/** 176/**
@@ -178,12 +182,10 @@ ssize_t GNUNET_NETWORK_socket_recvfrom_amount (const struct
178 * to be filled in by recvfrom 182 * to be filled in by recvfrom
179 * @param addrlen length of the addr 183 * @param addrlen length of the addr
180 */ 184 */
181ssize_t GNUNET_NETWORK_socket_recvfrom (const struct 185ssize_t
182 GNUNET_NETWORK_Handle 186GNUNET_NETWORK_socket_recvfrom (const struct GNUNET_NETWORK_Handle *desc,
183 *desc, void *buffer, 187 void *buffer, size_t length,
184 size_t length, 188 struct sockaddr *src_addr, socklen_t * addrlen);
185 struct sockaddr *src_addr,
186 socklen_t * addrlen);
187 189
188 190
189/** 191/**
@@ -194,8 +196,9 @@ ssize_t GNUNET_NETWORK_socket_recvfrom (const struct
194 * @param length length of buffer 196 * @param length length of buffer
195 * @return number of bytes read 197 * @return number of bytes read
196 */ 198 */
197ssize_t GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc, 199ssize_t
198 void *buffer, size_t length); 200GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc,
201 void *buffer, size_t length);
199 202
200 203
201/** 204/**
@@ -206,10 +209,11 @@ ssize_t GNUNET_NETWORK_socket_recv (const struct GNUNET_NETWORK_Handle *desc,
206 * @param timeout relative value when to return 209 * @param timeout relative value when to return
207 * @return number of selected sockets, GNUNET_SYSERR on error 210 * @return number of selected sockets, GNUNET_SYSERR on error
208 */ 211 */
209int GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds, 212int
210 struct GNUNET_NETWORK_FDSet *wfds, 213GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
211 struct GNUNET_NETWORK_FDSet *efds, 214 struct GNUNET_NETWORK_FDSet *wfds,
212 struct GNUNET_TIME_Relative timeout); 215 struct GNUNET_NETWORK_FDSet *efds,
216 struct GNUNET_TIME_Relative timeout);
213 217
214 218
215/** 219/**
@@ -220,8 +224,9 @@ int GNUNET_NETWORK_socket_select (struct GNUNET_NETWORK_FDSet *rfds,
220 * @param length size of the buffer 224 * @param length size of the buffer
221 * @return number of bytes sent, GNUNET_SYSERR on error 225 * @return number of bytes sent, GNUNET_SYSERR on error
222 */ 226 */
223ssize_t GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc, 227ssize_t
224 const void *buffer, size_t length); 228GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc,
229 const void *buffer, size_t length);
225 230
226 231
227/** 232/**
@@ -235,10 +240,11 @@ ssize_t GNUNET_NETWORK_socket_send (const struct GNUNET_NETWORK_Handle *desc,
235 * @param dest_len length of address 240 * @param dest_len length of address
236 * @return number of bytes sent, GNUNET_SYSERR on error 241 * @return number of bytes sent, GNUNET_SYSERR on error
237 */ 242 */
238ssize_t GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc, 243ssize_t
239 const void *message, size_t length, 244GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc,
240 const struct sockaddr *dest_addr, 245 const void *message, size_t length,
241 socklen_t dest_len); 246 const struct sockaddr *dest_addr,
247 socklen_t dest_len);
242 248
243 249
244/** 250/**
@@ -251,10 +257,10 @@ ssize_t GNUNET_NETWORK_socket_sendto (const struct GNUNET_NETWORK_Handle *desc,
251 * @param option_len size of option_value 257 * @param option_len size of option_value
252 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 258 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
253 */ 259 */
254int GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, 260int
255 int level, int option_name, 261GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd, int level,
256 const void *option_value, 262 int option_name, const void *option_value,
257 socklen_t option_len); 263 socklen_t option_len);
258 264
259 265
260/** 266/**
@@ -264,8 +270,8 @@ int GNUNET_NETWORK_socket_setsockopt (struct GNUNET_NETWORK_Handle *fd,
264 * @param how type of shutdown 270 * @param how type of shutdown
265 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 271 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
266 */ 272 */
267int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, 273int
268 int how); 274GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc, int how);
269 275
270 276
271/** 277/**
@@ -277,7 +283,8 @@ int GNUNET_NETWORK_socket_shutdown (struct GNUNET_NETWORK_Handle *desc,
277 * @param desc socket 283 * @param desc socket
278 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 284 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
279 */ 285 */
280int GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc); 286int
287GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc);
281 288
282 289
283/** 290/**
@@ -290,9 +297,8 @@ int GNUNET_NETWORK_socket_disable_corking (struct GNUNET_NETWORK_Handle *desc);
290 * @param protocol network protocol 297 * @param protocol network protocol
291 * @return new socket, NULL on error 298 * @return new socket, NULL on error
292 */ 299 */
293struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_create (int domain, 300struct GNUNET_NETWORK_Handle *
294 int type, 301GNUNET_NETWORK_socket_create (int domain, int type, int protocol);
295 int protocol);
296 302
297 303
298/** 304/**
@@ -300,7 +306,8 @@ struct GNUNET_NETWORK_Handle *GNUNET_NETWORK_socket_create (int domain,
300 * 306 *
301 * @param fds fd set to clear 307 * @param fds fd set to clear
302 */ 308 */
303void GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds); 309void
310GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds);
304 311
305 312
306/** 313/**
@@ -308,8 +315,9 @@ void GNUNET_NETWORK_fdset_zero (struct GNUNET_NETWORK_FDSet *fds);
308 * @param fds fd set 315 * @param fds fd set
309 * @param desc socket to add 316 * @param desc socket to add
310 */ 317 */
311void GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds, 318void
312 const struct GNUNET_NETWORK_Handle *desc); 319GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
320 const struct GNUNET_NETWORK_Handle *desc);
313 321
314 322
315#ifdef __MINGW32__ 323#ifdef __MINGW32__
@@ -319,9 +327,9 @@ void GNUNET_NETWORK_fdset_set (struct GNUNET_NETWORK_FDSet *fds,
319 * @param fds fd set 327 * @param fds fd set
320 * @param h the file handle to add 328 * @param h the file handle to add
321 */ 329 */
322void GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct 330void
323 GNUNET_NETWORK_FDSet 331GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct GNUNET_NETWORK_FDSet
324 *fds, HANDLE h); 332 *fds, HANDLE h);
325#endif 333#endif
326 334
327 335
@@ -331,8 +339,9 @@ void GNUNET_NETWORK_fdset_handle_set_native_w32_handle (struct
331 * @param desc socket 339 * @param desc socket
332 * @return GNUNET_YES if the socket is in the set 340 * @return GNUNET_YES if the socket is in the set
333 */ 341 */
334int GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds, 342int
335 const struct GNUNET_NETWORK_Handle *desc); 343GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds,
344 const struct GNUNET_NETWORK_Handle *desc);
336 345
337 346
338/** 347/**
@@ -340,8 +349,9 @@ int GNUNET_NETWORK_fdset_isset (const struct GNUNET_NETWORK_FDSet *fds,
340 * @param dst the fd set to add to 349 * @param dst the fd set to add to
341 * @param src the fd set to add from 350 * @param src the fd set to add from
342 */ 351 */
343void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst, 352void
344 const struct GNUNET_NETWORK_FDSet *src); 353GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
354 const struct GNUNET_NETWORK_FDSet *src);
345 355
346 356
347/** 357/**
@@ -349,8 +359,9 @@ void GNUNET_NETWORK_fdset_add (struct GNUNET_NETWORK_FDSet *dst,
349 * @param to destination 359 * @param to destination
350 * @param from source 360 * @param from source
351 */ 361 */
352void GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to, 362void
353 const struct GNUNET_NETWORK_FDSet *from); 363GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
364 const struct GNUNET_NETWORK_FDSet *from);
354 365
355 366
356/** 367/**
@@ -359,7 +370,8 @@ void GNUNET_NETWORK_fdset_copy (struct GNUNET_NETWORK_FDSet *to,
359 * @param desc wrapper to process 370 * @param desc wrapper to process
360 * @return POSIX file descriptor 371 * @return POSIX file descriptor
361 */ 372 */
362int GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc); 373int
374GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc);
363 375
364 376
365/** 377/**
@@ -368,8 +380,9 @@ int GNUNET_NETWORK_get_fd (struct GNUNET_NETWORK_Handle *desc);
368 * @param from native source set 380 * @param from native source set
369 * @param nfds the biggest socket number in from + 1 381 * @param nfds the biggest socket number in from + 1
370 */ 382 */
371void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to, 383void
372 const fd_set * from, int nfds); 384GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
385 const fd_set * from, int nfds);
373 386
374 387
375/** 388/**
@@ -378,7 +391,8 @@ void GNUNET_NETWORK_fdset_copy_native (struct GNUNET_NETWORK_FDSet *to,
378 * @param to destination 391 * @param to destination
379 * @param nfd native FD to set 392 * @param nfd native FD to set
380 */ 393 */
381void GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, int nfd); 394void
395GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, int nfd);
382 396
383 397
384/** 398/**
@@ -388,8 +402,9 @@ void GNUNET_NETWORK_fdset_set_native (struct GNUNET_NETWORK_FDSet *to, int nfd);
388 * @param nfd native FD to test, -1 for none 402 * @param nfd native FD to test, -1 for none
389 * @return GNUNET_YES if to contains nfd 403 * @return GNUNET_YES if to contains nfd
390 */ 404 */
391int GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to, 405int
392 int nfd); 406GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to,
407 int nfd);
393 408
394 409
395/** 410/**
@@ -397,8 +412,9 @@ int GNUNET_NETWORK_fdset_test_native (const struct GNUNET_NETWORK_FDSet *to,
397 * @param fds fd set 412 * @param fds fd set
398 * @param h the file handle to add 413 * @param h the file handle to add
399 */ 414 */
400void GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, 415void
401 const struct GNUNET_DISK_FileHandle *h); 416GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
417 const struct GNUNET_DISK_FileHandle *h);
402 418
403 419
404/** 420/**
@@ -407,8 +423,9 @@ void GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds,
407 * @param h file handle 423 * @param h file handle
408 * @return GNUNET_YES if the file handle is part of the set 424 * @return GNUNET_YES if the file handle is part of the set
409 */ 425 */
410int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds, 426int
411 const struct GNUNET_DISK_FileHandle *h); 427GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
428 const struct GNUNET_DISK_FileHandle *h);
412 429
413 430
414/** 431/**
@@ -417,22 +434,25 @@ int GNUNET_NETWORK_fdset_handle_isset (const struct GNUNET_NETWORK_FDSet *fds,
417 * @param fds2 second fd set 434 * @param fds2 second fd set
418 * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise 435 * @return GNUNET_YES if they do overlap, GNUNET_NO otherwise
419 */ 436 */
420int GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1, 437int
421 const struct GNUNET_NETWORK_FDSet *fds2); 438GNUNET_NETWORK_fdset_overlap (const struct GNUNET_NETWORK_FDSet *fds1,
439 const struct GNUNET_NETWORK_FDSet *fds2);
422 440
423 441
424/** 442/**
425 * Creates an fd set 443 * Creates an fd set
426 * @return a new fd set 444 * @return a new fd set
427 */ 445 */
428struct GNUNET_NETWORK_FDSet *GNUNET_NETWORK_fdset_create (void); 446struct GNUNET_NETWORK_FDSet *
447GNUNET_NETWORK_fdset_create (void);
429 448
430 449
431/** 450/**
432 * Releases the associated memory of an fd set 451 * Releases the associated memory of an fd set
433 * @param fds fd set 452 * @param fds fd set
434 */ 453 */
435void GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds); 454void
455GNUNET_NETWORK_fdset_destroy (struct GNUNET_NETWORK_FDSet *fds);
436 456
437 457
438#if 0 /* keep Emacsens' auto-indent happy */ 458#if 0 /* keep Emacsens' auto-indent happy */