2010-05-05 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / socket-io.h
blob3408c161643c4a8d9825c47e9200e2337d15794d
1 /*
2 * socket-io.h: Socket IO internal calls
4 * Author:
5 * Dick Porter (dick@ximian.com)
7 * (C) 2001 Ximian, Inc.
8 */
10 #ifndef _MONO_METADATA_SOCKET_H_
11 #define _MONO_METADATA_SOCKET_H_
13 #include <config.h>
14 #include <glib.h>
16 #include <mono/metadata/object-internals.h>
17 #include <mono/io-layer/io-layer.h>
19 /* This is a copy of System.Net.Sockets.SocketType */
20 typedef enum {
21 SocketType_Stream=1,
22 SocketType_Dgram=2,
23 SocketType_Raw=3,
24 SocketType_Rdm=4,
25 SocketType_Seqpacket=5,
26 SocketType_Unknown=-1
27 } MonoSocketType;
29 /* This is a copy of System.Net.Sockets.AddressFamily */
30 typedef enum {
31 AddressFamily_Unknown=-1,
32 AddressFamily_Unspecified=0,
33 AddressFamily_Unix=1,
34 AddressFamily_InterNetwork=2,
35 AddressFamily_ImpLink=3,
36 AddressFamily_Pup=4,
37 AddressFamily_Chaos=5,
38 AddressFamily_NS=6,
39 AddressFamily_Ipx=6,
40 AddressFamily_Iso=7,
41 AddressFamily_Osi=7,
42 AddressFamily_Ecma=8,
43 AddressFamily_DataKit=9,
44 AddressFamily_Ccitt=10,
45 AddressFamily_Sna=11,
46 AddressFamily_DecNet=12,
47 AddressFamily_DataLink=13,
48 AddressFamily_Lat=14,
49 AddressFamily_HyperChannel=15,
50 AddressFamily_AppleTalk=16,
51 AddressFamily_NetBios=17,
52 AddressFamily_VoiceView=18,
53 AddressFamily_FireFox=19,
54 AddressFamily_Banyan=21,
55 AddressFamily_Atm=22,
56 AddressFamily_InterNetworkV6=23,
57 AddressFamily_Cluster=24,
58 AddressFamily_Ieee12844=25,
59 AddressFamily_Irda=26,
60 AddressFamily_NetworkDesigners=28
61 } MonoAddressFamily;
63 /* This is a copy of System.Net.Sockets.ProtocolType */
64 typedef enum {
65 ProtocolType_IP=0,
66 ProtocolType_Icmp=1,
67 ProtocolType_Igmp=2,
68 ProtocolType_Ggp=3,
69 ProtocolType_Tcp=6,
70 ProtocolType_Pup=12,
71 ProtocolType_Udp=17,
72 ProtocolType_Idp=22,
73 ProtocolType_IPv6=41,
74 ProtocolType_ND=77,
75 ProtocolType_Raw=255,
76 ProtocolType_Unspecified=0,
77 ProtocolType_Ipx=1000,
78 ProtocolType_Spx=1256,
79 ProtocolType_SpxII=1257,
80 ProtocolType_Unknown=-1
81 } MonoProtocolType;
83 /* This is a copy of System.Net.Sockets.SocketOptionLevel */
84 typedef enum {
85 SocketOptionLevel_Socket=65535,
86 SocketOptionLevel_IP=0,
87 SocketOptionLevel_IPv6=41,
88 SocketOptionLevel_Tcp=6,
89 SocketOptionLevel_Udp=17
90 } MonoSocketOptionLevel;
92 /* This is a copy of System.Net.Sockets.SocketOptionName */
93 typedef enum {
94 SocketOptionName_Debug=1,
95 SocketOptionName_AcceptConnection=2,
96 SocketOptionName_ReuseAddress=4,
97 SocketOptionName_KeepAlive=8,
98 SocketOptionName_DontRoute=16,
99 SocketOptionName_Broadcast=32,
100 SocketOptionName_UseLoopback=64,
101 SocketOptionName_Linger=128,
102 SocketOptionName_OutOfBandInline=256,
103 SocketOptionName_DontLinger= -129,
104 SocketOptionName_ExclusiveAddressUse= -5,
105 SocketOptionName_SendBuffer= 4097,
106 SocketOptionName_ReceiveBuffer=4098,
107 SocketOptionName_SendLowWater=4099,
108 SocketOptionName_ReceiveLowWater=4100,
109 SocketOptionName_SendTimeout=4101,
110 SocketOptionName_ReceiveTimeout=4102,
111 SocketOptionName_Error=4103,
112 SocketOptionName_Type=4104,
113 SocketOptionName_MaxConnections=2147483647,
114 SocketOptionName_IPOptions=1,
115 SocketOptionName_HeaderIncluded=2,
116 SocketOptionName_TypeOfService=3,
117 SocketOptionName_IpTimeToLive=4,
118 SocketOptionName_MulticastInterface=9,
119 SocketOptionName_MulticastTimeToLive=10,
120 SocketOptionName_MulticastLoopback=11,
121 SocketOptionName_AddMembership=12,
122 SocketOptionName_DropMembership=13,
123 SocketOptionName_DontFragment=14,
124 SocketOptionName_AddSourceMembership=15,
125 SocketOptionName_DropSourceMembership=16,
126 SocketOptionName_BlockSource=17,
127 SocketOptionName_UnblockSource=18,
128 SocketOptionName_PacketInformation=19,
129 SocketOptionName_NoDelay=1,
130 SocketOptionName_BsdUrgent=2,
131 SocketOptionName_Expedited=2,
132 SocketOptionName_NoChecksum=1,
133 SocketOptionName_ChecksumCoverage=20,
135 /* This is Mono-specific, keep it in sync with
136 * Mono.Posix/PeerCred.cs
138 SocketOptionName_PeerCred=10001
139 } MonoSocketOptionName;
141 /* This is a copy of System.Net.Sockets.SocketFlags */
142 typedef enum {
143 SocketFlags_None = 0x0000,
144 SocketFlags_OutOfBand = 0x0001,
145 SocketFlags_MaxIOVectorLength = 0x0010,
146 SocketFlags_Peek = 0x0002,
147 SocketFlags_DontRoute = 0x0004,
148 SocketFlags_Partial = 0x8000
149 } MonoSocketFlags;
152 Keep this in sync with SocketAsyncResult in
153 ./System.Net.Sockets/Socket.cs and ProcessAsyncReader
154 in System.Diagnostics/Process.cs.
156 typedef struct _MonoSocketAsyncResult {
157 MonoObject obj;
158 MonoObject *socket;
159 HANDLE handle;
160 MonoObject *state;
161 MonoDelegate *callback;
162 MonoWaitHandle *wait_handle;
163 MonoException *delayed_exc;
164 MonoObject *ep;
165 MonoArray *buffer;
166 gint offset;
167 gint size;
168 gint socket_flags;
169 MonoObject *accept_reuse_socket;
170 MonoArray *addresses;
171 gint port;
172 MonoObject *buffers;
173 MonoBoolean reusesocket;
174 MonoObject *acc_socket;
175 gint total;
176 MonoBoolean completed_synch;
177 MonoBoolean completed;
178 MonoBoolean blocking;
179 gint error;
180 gint operation;
181 MonoAsyncResult *ares;
182 } MonoSocketAsyncResult;
184 typedef struct
186 MonoObject obj;
187 gint pid;
188 gint uid;
189 gint gid;
190 } MonoPeerCredData;
192 extern gpointer ves_icall_System_Net_Sockets_Socket_Socket_internal(MonoObject *this, gint32 family, gint32 type, gint32 proto, gint32 *error) MONO_INTERNAL;
193 extern void ves_icall_System_Net_Sockets_Socket_Close_internal(SOCKET sock, gint32 *error) MONO_INTERNAL;
194 extern gint32 ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal(void) MONO_INTERNAL;
195 extern gint32 ves_icall_System_Net_Sockets_Socket_Available_internal(SOCKET sock, gint32 *error) MONO_INTERNAL;
196 extern void ves_icall_System_Net_Sockets_Socket_Blocking_internal(SOCKET sock, gboolean block, gint32 *error) MONO_INTERNAL;
197 extern gpointer ves_icall_System_Net_Sockets_Socket_Accept_internal(SOCKET sock, gint32 *error, gboolean blocking) MONO_INTERNAL;
198 extern void ves_icall_System_Net_Sockets_Socket_Listen_internal(SOCKET sock, guint32 backlog, gint32 *error) MONO_INTERNAL;
199 extern MonoObject *ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal(SOCKET sock, gint32 *error) MONO_INTERNAL;
200 extern MonoObject *ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal(SOCKET sock, gint32 *error) MONO_INTERNAL;
201 extern void ves_icall_System_Net_Sockets_Socket_Bind_internal(SOCKET sock, MonoObject *sockaddr, gint32 *error) MONO_INTERNAL;
202 extern void ves_icall_System_Net_Sockets_Socket_Connect_internal(SOCKET sock, MonoObject *sockaddr, gint32 *error) MONO_INTERNAL;
203 extern gint32 ves_icall_System_Net_Sockets_Socket_Receive_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *error) MONO_INTERNAL;
204 extern gint32 ves_icall_System_Net_Sockets_Socket_Receive_array_internal(SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *error) MONO_INTERNAL;
205 extern gint32 ves_icall_System_Net_Sockets_Socket_RecvFrom_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject **sockaddr, gint32 *error) MONO_INTERNAL;
206 extern gint32 ves_icall_System_Net_Sockets_Socket_Send_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, gint32 *error) MONO_INTERNAL;
207 extern gint32 ves_icall_System_Net_Sockets_Socket_Send_array_internal(SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *error) MONO_INTERNAL;
208 extern gint32 ves_icall_System_Net_Sockets_Socket_SendTo_internal(SOCKET sock, MonoArray *buffer, gint32 offset, gint32 count, gint32 flags, MonoObject *sockaddr, gint32 *error) MONO_INTERNAL;
209 extern void ves_icall_System_Net_Sockets_Socket_Select_internal(MonoArray **sockets, gint32 timeout, gint32 *error) MONO_INTERNAL;
210 extern void ves_icall_System_Net_Sockets_Socket_Shutdown_internal(SOCKET sock, gint32 how, gint32 *error) MONO_INTERNAL;
211 extern void ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal(SOCKET sock, gint32 level, gint32 name, MonoObject **obj_val, gint32 *error) MONO_INTERNAL;
212 extern void ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal(SOCKET sock, gint32 level, gint32 name, MonoArray **byte_val, gint32 *error) MONO_INTERNAL;
213 extern void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, gint32 level, gint32 name, MonoObject *obj_val, MonoArray *byte_val, gint32 int_val, gint32 *error) MONO_INTERNAL;
214 extern int ves_icall_System_Net_Sockets_Socket_WSAIoctl (SOCKET sock, gint32 code, MonoArray *input, MonoArray *output, gint32 *error) MONO_INTERNAL;
215 extern MonoBoolean ves_icall_System_Net_Dns_GetHostByName_internal(MonoString *host, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list) MONO_INTERNAL;
216 extern MonoBoolean ves_icall_System_Net_Dns_GetHostByAddr_internal(MonoString *addr, MonoString **h_name, MonoArray **h_aliases, MonoArray **h_addr_list) MONO_INTERNAL;
217 extern MonoBoolean ves_icall_System_Net_Dns_GetHostName_internal(MonoString **h_name) MONO_INTERNAL;
218 extern MonoBoolean ves_icall_System_Net_Sockets_Socket_Poll_internal (SOCKET sock, gint mode, gint timeout, gint32 *error) MONO_INTERNAL;
219 extern void ves_icall_System_Net_Sockets_Socket_Disconnect_internal(SOCKET sock, MonoBoolean reuse, gint32 *error) MONO_INTERNAL;
220 extern gboolean ves_icall_System_Net_Sockets_Socket_SendFile (SOCKET sock, MonoString *filename, MonoArray *pre_buffer, MonoArray *post_buffer, gint flags) MONO_INTERNAL;
222 extern void mono_network_init(void) MONO_INTERNAL;
223 extern void mono_network_cleanup(void) MONO_INTERNAL;
225 #endif /* _MONO_METADATA_SOCKET_H_ */