1 /***********************************************************************/
5 /* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
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. */
12 /***********************************************************************/
18 #include "unixsupport.h"
22 #include "socketaddr.h"
24 CAMLprim value
unix_inet_addr_of_string(value s
)
27 struct in_addr address
;
28 struct in6_addr address6
;
29 if (inet_pton(AF_INET
, String_val(s
), &address
) > 0)
30 return alloc_inet_addr(&address
);
31 else if (inet_pton(AF_INET6
, String_val(s
), &address6
) > 0)
32 return alloc_inet6_addr(&address6
);
34 failwith("inet_addr_of_string");
35 #elif defined(HAS_INET_ATON)
36 struct in_addr address
;
37 if (inet_aton(String_val(s
), &address
) == 0)
38 failwith("inet_addr_of_string");
39 return alloc_inet_addr(&address
);
41 struct in_addr address
;
42 address
.s_addr
= inet_addr(String_val(s
));
43 if (address
.s_addr
== (uint32
) -1) failwith("inet_addr_of_string");
44 return alloc_inet_addr(&address
);
50 CAMLprim value
unix_inet_addr_of_string(value s
)
51 { invalid_argument("inet_addr_of_string not implemented"); }