[tools] Add nuget-hash-extractor tool to help produce the runtime ignored assemblies...
[mono-project.git] / mono / utils / networking.h
blob370a3d0ffaf2dbe9070bc36e6aa8ee732dcd2d99
1 /*
2 * networking.h: Portable networking functions
4 * Author:
5 * Rodrigo Kumpera (kumpera@gmail.com)
7 * (C) 2015 Xamarin
8 */
11 #ifndef __MONO_NETWORKING_H__
12 #define __MONO_NETWORKING_H__
14 #include <config.h>
15 #include <glib.h>
17 #ifdef HAVE_ARPA_INET_H
18 #include <arpa/inet.h>
19 #endif
20 #include <sys/types.h>
21 #ifdef HAVE_SYS_SOCKET_H
22 #include <sys/socket.h>
23 #endif
24 #ifdef HAVE_SYS_SOCKIO_H
25 #include <sys/sockio.h>
26 #endif
28 #ifdef HAVE_NETINET_IN_H
29 #include <netinet/in.h>
30 #endif
32 #ifdef HOST_WIN32
33 #include <winsock2.h>
34 #include <ws2tcpip.h>
35 #endif
37 #include <mono/utils/mono-compiler.h>
39 typedef enum {
40 MONO_HINT_UNSPECIFIED = 0,
41 MONO_HINT_IPV4 = 1,
42 MONO_HINT_IPV6 = 2,
43 MONO_HINT_CANONICAL_NAME = 4,
44 MONO_HINT_CONFIGURED_ONLY = 8,
45 } MonoGetAddressHints;
47 typedef struct _MonoAddressEntry MonoAddressEntry;
49 struct _MonoAddressEntry {
50 int family;
51 int socktype;
52 int protocol;
53 int address_len;
54 union {
55 struct in_addr v4;
56 struct in6_addr v6;
57 } address;
58 const char *canonical_name;
59 MonoAddressEntry *next;
62 typedef struct {
63 MonoAddressEntry *entries;
64 char **aliases;
65 } MonoAddressInfo;
67 typedef union {
68 struct sockaddr_in v4;
69 struct sockaddr_in6 v6;
70 struct sockaddr addr;
71 } MonoSocketAddress;
73 typedef struct {
74 int family;
75 union {
76 struct in_addr v4;
77 struct in6_addr v6;
78 } addr;
79 } MonoAddress;
81 /* This only supports IPV4 / IPV6 and tcp */
82 int mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInfo **res);
84 void mono_free_address_info (MonoAddressInfo *ai);
86 void mono_socket_address_init (MonoSocketAddress *sa, socklen_t *len, int family, const void *address, int port);
88 void *mono_get_local_interfaces (int family, int *interface_count);
90 #ifndef HAVE_INET_PTON
91 int inet_pton (int family, const char *address, void *inaddrp);
92 #endif
94 void mono_address_init (MonoAddress *out_addr, int family, void *in_addr);
95 int mono_address_size_for_family (int family);
96 gboolean mono_networking_addr_to_str (MonoAddress *address, char *buffer, socklen_t buflen);
98 int mono_networking_get_tcp_protocol (void);
99 int mono_networking_get_ip_protocol (void);
100 int mono_networking_get_ipv6_protocol (void);
102 void mono_networking_init (void);
103 void mono_networking_shutdown (void);
106 #endif