1 /* GIO - GLib Input, Output and Streaming Library
3 * Copyright (C) 2008 Red Hat, Inc.
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.
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.
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.
21 #ifndef __G_NETWORKINGPRIVATE_H__
22 #define __G_NETWORKINGPRIVATE_H__
26 #define _WIN32_WINNT 0x0501
34 /* <wspiapi.h> in the Windows SDK and in mingw-w64 has wrappers for
35 * inline workarounds for getaddrinfo, getnameinfo and freeaddrinfo if
36 * they aren't present at run-time (on Windows 2000).
41 #else /* !G_OS_WIN32 */
43 #include <sys/types.h>
46 #include <netinet/in.h>
47 #include <netinet/tcp.h>
49 #include <sys/socket.h>
51 #include <arpa/inet.h>
52 #include <arpa/nameser.h>
53 #if defined(HAVE_ARPA_NAMESER_COMPAT_H) && !defined(GETSHORT)
54 #include <arpa/nameser_compat.h>
63 #define _PATH_RESCONF "/etc/resolv.conf"
67 /* CMSG_LEN and CMSG_SPACE are defined by RFC 2292, but missing on
68 * some older platforms.
70 #define CMSG_LEN(len) ((size_t)CMSG_DATA((struct cmsghdr *)NULL) + (len))
72 /* CMSG_SPACE must add at least as much padding as CMSG_NXTHDR()
73 * adds. We overestimate here.
75 #define ALIGN_TO_SIZEOF(len, obj) (((len) + sizeof (obj) - 1) & ~(sizeof (obj) - 1))
76 #define CMSG_SPACE(len) ALIGN_TO_SIZEOF (CMSG_LEN (len), struct cmsghdr)
82 extern struct addrinfo _g_resolver_addrinfo_hints;
84 GList *_g_resolver_addresses_from_addrinfo (const char *hostname,
89 void _g_resolver_address_to_sockaddr (GInetAddress *address,
90 struct sockaddr_storage *sa,
92 char *_g_resolver_name_from_nameinfo (GInetAddress *address,
97 #if defined(G_OS_UNIX)
98 gint _g_resolver_record_type_to_rrtype (GResolverRecordType record_type);
100 GList *_g_resolver_records_from_res_query (const gchar *rrname,
106 #elif defined(G_OS_WIN32)
107 WORD _g_resolver_record_type_to_dnstype (GResolverRecordType record_type);
109 GList *_g_resolver_records_from_DnsQuery (const gchar *rrname,
116 gboolean _g_uri_parse_authority (const char *uri,
120 gchar * _g_uri_from_authority (const gchar *protocol,
123 const gchar *userinfo);
127 #endif /* __G_NETWORKINGPRIVATE_H__ */