少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
 * \file
 * Portable networking functions
 *
 * Author:
 *    Rodrigo Kumpera (kumpera@gmail.com)
 *
 * (C) 2015 Xamarin
 */
 
 
#ifndef __MONO_NETWORKING_H__
#define __MONO_NETWORKING_H__
 
#include <config.h>
#include <glib.h>
 
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
 
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
 
#ifdef HOST_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
 
#include <mono/utils/mono-compiler.h>
 
typedef enum {
    MONO_HINT_UNSPECIFIED        = 0,
    MONO_HINT_IPV4                = 1,
    MONO_HINT_IPV6                = 2,
    MONO_HINT_CANONICAL_NAME    = 4,
    MONO_HINT_CONFIGURED_ONLY    = 8,
} MonoGetAddressHints;
 
typedef struct _MonoAddressEntry MonoAddressEntry;
 
struct _MonoAddressEntry {
    int family;
    int socktype;
    int protocol;
    int address_len;
    union {
        struct in_addr v4;
#ifdef HAVE_STRUCT_SOCKADDR_IN6
        struct in6_addr v6;
#endif
    } address;
    const char *canonical_name;
    MonoAddressEntry *next;
};
 
typedef struct {
    MonoAddressEntry *entries;
    char **aliases;
} MonoAddressInfo;
 
typedef union {
    struct sockaddr_in v4;
#ifdef HAVE_STRUCT_SOCKADDR_IN6
    struct sockaddr_in6 v6;
#endif
    struct sockaddr addr;
} MonoSocketAddress;
 
typedef struct {
    int family;
    union {
        struct in_addr v4;
#ifdef HAVE_STRUCT_SOCKADDR_IN6
        struct in6_addr v6;
#endif
    } addr;
} MonoAddress;
 
/* This only supports IPV4 / IPV6 and tcp */
int mono_get_address_info (const char *hostname, int port, int flags, MonoAddressInfo **res);
 
void mono_free_address_info (MonoAddressInfo *ai);
 
void mono_socket_address_init (MonoSocketAddress *sa, socklen_t *len, int family, const void *address, int port);
 
void *mono_get_local_interfaces (int family, int *interface_count);
 
#ifndef HAVE_INET_PTON
int inet_pton (int family, const char *address, void *inaddrp);
#endif
 
void mono_address_init (MonoAddress *out_addr, int family, void *in_addr);
int mono_address_size_for_family (int family);
gboolean mono_networking_addr_to_str (MonoAddress *address, char *buffer, socklen_t buflen);
 
int mono_networking_get_tcp_protocol (void);
int mono_networking_get_ip_protocol (void);
int mono_networking_get_ipv6_protocol (void);
 
void mono_networking_init (void);
void mono_networking_shutdown (void);
 
 
#endif