2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS WinSock 2 API
4 * FILE: dll/win32/ws2_32_new/src/enumprot.c
5 * PURPOSE: Protocol Enumeration
6 * PROGRAMMER: Alex Ionescu (alex@relsoft.net)
9 /* INCLUDES ******************************************************************/
16 /* FUNCTIONS *****************************************************************/
20 CheckProtocolMatch(IN LPINT ProtocolSet
,
21 IN LPWSAPROTOCOL_INFOW ProtocolInfo
)
27 /* Make sure we have a set */
30 /* Get the first ID */
31 ProtocolId
= ProtocolSet
[i
];
34 while (ProtocolId
!= 0)
36 /* Check if it's within ranges */
37 if ((ProtocolId
>= ProtocolInfo
->iProtocol
) &&
38 (ProtocolId
<= (ProtocolInfo
->iProtocol
+
39 ProtocolInfo
->iProtocolMaxOffset
)))
48 ProtocolId
= ProtocolSet
[i
];
63 ProtocolInfoFromContext(IN LPWSAPROTOCOL_INFOW ProtocolInfo
,
64 IN PPROTOCOL_ENUM_CONTEXT Context
)
66 /* Check if we'll have space */
67 if ((Context
->BufferUsed
+ sizeof(*ProtocolInfo
)) <=
68 (Context
->BufferLength
))
71 RtlMoveMemory((PVOID
)((ULONG_PTR
)Context
->ProtocolBuffer
+
74 sizeof(*ProtocolInfo
));
76 /* Increase the count */
83 ProtocolEnumerationProc(PVOID EnumContext
,
84 PTCATALOG_ENTRY Entry
)
86 PPROTOCOL_ENUM_CONTEXT Context
= (PPROTOCOL_ENUM_CONTEXT
)EnumContext
;
87 LPWSAPROTOCOL_INFOW ProtocolInfo
= &Entry
->ProtocolInfo
;
89 /* Check if this protocol matches */
90 if (CheckProtocolMatch(Context
->Protocols
, ProtocolInfo
))
92 /* Copy the information */
93 ProtocolInfoFromContext(ProtocolInfo
, Context
);
94 Context
->BufferUsed
+= sizeof(*ProtocolInfo
);
97 /* Continue enumeration */
103 OpenInitializedCatalog(VOID
)
108 /* Allocate the catalog */
109 Catalog
= WsTcAllocate();
112 /* Open the WS Key */
113 WsKey
= WsOpenRegistryRoot();
115 /* Initialize the catalog */
116 WsTcInitializeFromRegistry(Catalog
, WsKey
, NULL
);
131 WSCEnumProtocols(IN LPINT lpiProtocols
,
132 OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer
,
133 IN OUT LPDWORD lpdwBufferLength
,
138 PROTOCOL_ENUM_CONTEXT Context
;
139 DPRINT("WSCEnumProtocols: %p\n", lpiProtocols
);
141 /* Create a catalog object from the current one */
142 Catalog
= OpenInitializedCatalog();
145 /* Fail if we couldn't */
146 *lpErrno
= WSAENOBUFS
;
150 /* Setup the context */
151 Context
.Protocols
= lpiProtocols
;
152 Context
.ProtocolBuffer
= lpProtocolBuffer
;
153 Context
.BufferLength
= lpProtocolBuffer
? *lpdwBufferLength
: 0;
154 Context
.BufferUsed
= 0;
156 Context
.ErrorCode
= ERROR_SUCCESS
;
158 /* Enumerate the catalog */
159 WsTcEnumerateCatalogItems(Catalog
, ProtocolEnumerationProc
, &Context
);
162 Status
= Context
.Count
;
164 /* Check the error code */
165 if (Context
.ErrorCode
== ERROR_SUCCESS
)
167 /* Check if enough space was available */
168 if (Context
.BufferLength
< Context
.BufferUsed
)
170 /* Fail and tell them how much we need */
171 *lpdwBufferLength
= Context
.BufferUsed
;
172 *lpErrno
= WSAENOBUFS
;
173 Status
= SOCKET_ERROR
;
178 /* Failure, normalize error */
179 Status
= SOCKET_ERROR
;
180 *lpErrno
= Context
.ErrorCode
;
183 /* Delete the catalog object */
195 WSAEnumProtocolsA(IN LPINT lpiProtocols
,
196 OUT LPWSAPROTOCOL_INFOA lpProtocolBuffer
,
197 IN OUT LPDWORD lpdwBufferLength
)
199 DPRINT("WSAEnumProtocolsA: %p\n", lpiProtocols
);
201 SetLastError(WSAEINVAL
);
210 WSAEnumProtocolsW(IN LPINT lpiProtocols
,
211 OUT LPWSAPROTOCOL_INFOW lpProtocolBuffer
,
212 IN OUT LPDWORD lpdwBufferLength
)
214 DPRINT("WSAEnumProtocolsW: %p\n", lpiProtocols
);
216 SetLastError(WSAEINVAL
);
225 WPUGetProviderPath(IN LPGUID lpProviderId
,
226 OUT LPWSTR lpszProviderDllPath
,
227 IN OUT LPINT lpProviderDllPathLen
,
230 DPRINT("WPUGetProviderPath: %p\n", lpProviderId
);
240 WSAProviderConfigChange(IN OUT LPHANDLE lpNotificationHandle
,
241 IN LPWSAOVERLAPPED lpOverlapped
,
242 IN LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
)
244 DPRINT("WSAProviderConfigChange: %p\n", lpNotificationHandle
);
246 SetLastError(WSAEINVAL
);
255 WSCGetProviderPath(IN LPGUID lpProviderId
,
256 OUT LPWSTR lpszProviderDllPath
,
257 IN OUT LPINT lpProviderDllPathLen
,
260 DPRINT("WSCGetProviderPath: %p\n", lpProviderId
);
262 SetLastError(WSAEINVAL
);