1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
2011-07-27 07:17:02 -07:00
|
|
|
/* OCaml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1999-11-17 10:59:06 -08:00
|
|
|
/* en Automatique. All rights reserved. This file is distributed */
|
2001-12-07 05:41:02 -08:00
|
|
|
/* under the terms of the GNU Library General Public License, with */
|
|
|
|
/* the special exception on linking described in file ../../LICENSE. */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-08-08 06:37:34 -07:00
|
|
|
#include <misc.h>
|
1995-05-08 08:18:32 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <netinet/in.h>
|
1996-09-04 07:15:31 -07:00
|
|
|
#include <arpa/inet.h>
|
1995-05-08 08:18:32 -07:00
|
|
|
|
1997-08-26 08:20:55 -07:00
|
|
|
union sock_addr_union {
|
1995-05-08 08:18:32 -07:00
|
|
|
struct sockaddr s_gen;
|
|
|
|
struct sockaddr_un s_unix;
|
|
|
|
struct sockaddr_in s_inet;
|
2004-04-09 06:25:23 -07:00
|
|
|
#ifdef HAS_IPV6
|
|
|
|
struct sockaddr_in6 s_inet6;
|
|
|
|
#endif
|
1997-08-26 08:20:55 -07:00
|
|
|
};
|
1995-05-08 08:18:32 -07:00
|
|
|
|
1999-12-17 04:43:06 -08:00
|
|
|
#ifdef HAS_SOCKLEN_T
|
2000-03-07 01:07:39 -08:00
|
|
|
typedef socklen_t socklen_param_type;
|
1999-12-17 04:43:06 -08:00
|
|
|
#else
|
2000-03-07 01:07:39 -08:00
|
|
|
typedef int socklen_param_type;
|
1999-12-17 04:43:06 -08:00
|
|
|
#endif
|
1995-05-08 08:18:32 -07:00
|
|
|
|
2004-04-09 06:25:23 -07:00
|
|
|
extern void get_sockaddr (value mladdr,
|
|
|
|
union sock_addr_union * addr /*out*/,
|
|
|
|
socklen_param_type * addr_len /*out*/);
|
2005-03-24 09:20:54 -08:00
|
|
|
CAMLexport value alloc_sockaddr (union sock_addr_union * addr /*in*/,
|
|
|
|
socklen_param_type addr_len, int close_on_error);
|
|
|
|
CAMLexport value alloc_inet_addr (struct in_addr * inaddr);
|
2004-04-09 06:25:23 -07:00
|
|
|
#define GET_INET_ADDR(v) (*((struct in_addr *) (v)))
|
1995-05-08 08:18:32 -07:00
|
|
|
|
2004-04-09 06:25:23 -07:00
|
|
|
#ifdef HAS_IPV6
|
2005-03-24 09:20:54 -08:00
|
|
|
CAMLexport value alloc_inet6_addr (struct in6_addr * inaddr);
|
2004-04-09 06:25:23 -07:00
|
|
|
#define GET_INET6_ADDR(v) (*((struct in6_addr *) (v)))
|
|
|
|
#endif
|