Misc networking build fixes
[platform/upstream/glib.git] / gio / gnetworkingprivate.h
1 /* GIO - GLib Input, Output and Streaming Library
2  *
3  * Copyright (C) 2008 Red Hat, Inc.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __G_NETWORKINGPRIVATE_H__
22 #define __G_NETWORKINGPRIVATE_H__
23
24 #ifdef G_OS_WIN32
25
26 #define _WIN32_WINNT 0x0501
27 #include <winsock2.h>
28 #undef interface
29 #include <ws2tcpip.h>
30 #include <windns.h>
31 #include <mswsock.h>
32
33 #else /* !G_OS_WIN32 */
34
35 #include <sys/types.h>
36 #include <arpa/inet.h>
37 #include <arpa/nameser.h>
38 #if defined(HAVE_ARPA_NAMESER_COMPAT_H) && !defined(GETSHORT)
39 #include <arpa/nameser_compat.h>
40 #endif
41
42 #ifndef T_SRV
43 #define T_SRV 33
44 #endif
45
46 /* We're supposed to define _GNU_SOURCE to get EAI_NODATA, but that
47  * won't actually work since <features.h> has already been included at
48  * this point. So we define __USE_GNU instead.
49  */
50 #define __USE_GNU
51 #include <netdb.h>
52 #undef __USE_GNU
53 #include <netinet/in.h>
54 #include <netinet/tcp.h>
55 #include <resolv.h>
56 #include <sys/socket.h>
57 #include <sys/un.h>
58
59 #endif
60
61 G_BEGIN_DECLS
62
63 extern struct addrinfo _g_resolver_addrinfo_hints;
64
65 GList *_g_resolver_addresses_from_addrinfo (const char       *hostname,
66                                             struct addrinfo  *res,
67                                             gint              gai_retval,
68                                             GError          **error);
69
70 void   _g_resolver_address_to_sockaddr     (GInetAddress            *address,
71                                             struct sockaddr_storage *sa,
72                                             gsize                   *sa_len);
73 char  *_g_resolver_name_from_nameinfo      (GInetAddress     *address,
74                                             const gchar      *name,
75                                             gint              gni_retval,
76                                             GError          **error);
77
78 #if defined(G_OS_UNIX)
79 GList *_g_resolver_targets_from_res_query  (const gchar      *rrname,
80                                             guchar           *answer,
81                                             gint              len,
82                                             gint              herr,
83                                             GError          **error);
84 #elif defined(G_OS_WIN32)
85 GList *_g_resolver_targets_from_DnsQuery   (const gchar      *rrname,
86                                             DNS_STATUS        status,
87                                             DNS_RECORD       *results,
88                                             GError          **error);
89 #endif
90
91 G_END_DECLS
92
93 #endif /* __G_NETWORKINGPRIVATE_H__ */