Sys.Signals module for a Variant type of signals (and a set_signal function that...
[ocaml.git] / otherlibs / unix / socketaddr.h
blob79bc80fa7af69c984ee965217d87d760eacecf2c
1 /***********************************************************************/
2 /* */
3 /* Objective Caml */
4 /* */
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
6 /* */
7 /* Copyright 1996 Institut National de Recherche en Informatique et */
8 /* en Automatique. All rights reserved. This file is distributed */
9 /* under the terms of the GNU Library General Public License, with */
10 /* the special exception on linking described in file ../../LICENSE. */
11 /* */
12 /***********************************************************************/
14 /* $Id$ */
16 #include <misc.h>
17 #include <sys/types.h>
18 #include <sys/socket.h>
19 #include <sys/un.h>
20 #include <netinet/in.h>
21 #include <arpa/inet.h>
23 union sock_addr_union {
24 struct sockaddr s_gen;
25 struct sockaddr_un s_unix;
26 struct sockaddr_in s_inet;
27 #ifdef HAS_IPV6
28 struct sockaddr_in6 s_inet6;
29 #endif
32 #ifdef HAS_SOCKLEN_T
33 typedef socklen_t socklen_param_type;
34 #else
35 typedef int socklen_param_type;
36 #endif
38 extern void get_sockaddr (value mladdr,
39 union sock_addr_union * addr /*out*/,
40 socklen_param_type * addr_len /*out*/);
41 CAMLexport value alloc_sockaddr (union sock_addr_union * addr /*in*/,
42 socklen_param_type addr_len, int close_on_error);
43 CAMLexport value alloc_inet_addr (struct in_addr * inaddr);
44 #define GET_INET_ADDR(v) (*((struct in_addr *) (v)))
46 #ifdef HAS_IPV6
47 CAMLexport value alloc_inet6_addr (struct in6_addr * inaddr);
48 #define GET_INET6_ADDR(v) (*((struct in6_addr *) (v)))
49 #endif