| 1 | /* $Id: protocol.cpp,v 1.2 2002-03-09 16:07:11 achimha Exp $ */
|
|---|
| 2 | /*
|
|---|
| 3 | * based on Windows Sockets 1.1 specs
|
|---|
| 4 | * (ftp.microsoft.com:/Advsys/winsock/spec11/WINSOCK.TXT)
|
|---|
| 5 | *
|
|---|
| 6 | * (C) 1993,1994,1996,1997 John Brezak, Erik Bos, Alex Korobka.
|
|---|
| 7 | *
|
|---|
| 8 | * NOTE: If you make any changes to fix a particular app, make sure
|
|---|
| 9 | * they don't break something else like Netscape or telnet and ftp
|
|---|
| 10 | * clients and servers (www.winsite.com got a lot of those).
|
|---|
| 11 | *
|
|---|
| 12 | * NOTE 2: Many winsock structs such as servent, hostent, protoent, ...
|
|---|
| 13 | * are used with 1-byte alignment for Win16 programs and 4-byte alignment
|
|---|
| 14 | * for Win32 programs in winsock.h. winsock2.h uses forced 4-byte alignment.
|
|---|
| 15 | * So we have non-forced (just as MSDN) ws_XXXXent (winsock.h), 4-byte forced
|
|---|
| 16 | * ws_XXXXent32 (winsock2.h) and 1-byte forced ws_XXXXent16 (winsock16.h).
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 | /*****************************************************************************
|
|---|
| 21 | * Includes *
|
|---|
| 22 | *****************************************************************************/
|
|---|
| 23 |
|
|---|
| 24 | #include <odin.h>
|
|---|
| 25 | #include <winsock2.h>
|
|---|
| 26 | #include <debugtools.h>
|
|---|
| 27 | #include <odinwrap.h>
|
|---|
| 28 | #include <wchar.h>
|
|---|
| 29 |
|
|---|
| 30 | #ifdef __EMX__
|
|---|
| 31 | // EMX currently lacks POSIX swprintf, use snwprinf from NTDLL
|
|---|
| 32 | #include <minivcrt.h>
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | //#include "nspapi.h"
|
|---|
| 36 |
|
|---|
| 37 | ODINDEBUGCHANNEL(WS2_32-PROTOCOL)
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | #ifdef __WIN32OS2__
|
|---|
| 41 | #define WS_IPPROTO_TCP IPPROTO_TCP
|
|---|
| 42 | #define WS_IPPROTO_UDP IPPROTO_UDP
|
|---|
| 43 | #define WS_AF_NETBIOS AF_NETBIOS
|
|---|
| 44 | #define WS_AF_INET AF_INET
|
|---|
| 45 | #define strlenW lstrlenW
|
|---|
| 46 | #define strcpyW lstrcpyW
|
|---|
| 47 | #define strncpyW lstrcpynW
|
|---|
| 48 |
|
|---|
| 49 | #define WS_IPPROTO_NETBIOS_MAGIC 0x4e455442
|
|---|
| 50 |
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | /***
|
|---|
| 55 | * Predefined protocol structures for the known protocols
|
|---|
| 56 | * for OS/2
|
|---|
| 57 | ***/
|
|---|
| 58 |
|
|---|
| 59 | #define myDEFINE_GUID(l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
|---|
| 60 | { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 | static WSAPROTOCOL_INFOW sProtocol_TcpIp =
|
|---|
| 64 | {
|
|---|
| 65 | 0x20066, // XP_FRAGMENTATION | XP_EXPEDITED_DATA | XP_GRACEFUL_CLOSE | XP_GUARANTEED_ORDER | XP_GUARANTEED_DELIVERY,
|
|---|
| 66 | 0, // service flags
|
|---|
| 67 | 0,
|
|---|
| 68 | 0,
|
|---|
| 69 | 0x00000008, // provider flags
|
|---|
| 70 | myDEFINE_GUID(0xe70f1aa0, 0xab8b, 0x11cf, 0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92),
|
|---|
| 71 | 0x000003e9, // catalog entry ID
|
|---|
| 72 | {0x00000001,}, // protocol chain
|
|---|
| 73 | 0, // version
|
|---|
| 74 | WS_AF_INET, // address family
|
|---|
| 75 | 0, // max sock addr
|
|---|
| 76 | 0, // min sock addr
|
|---|
| 77 | SOCK_STREAM, // socket type
|
|---|
| 78 | WS_IPPROTO_TCP, // protocol
|
|---|
| 79 | 0, // protocol max. offset
|
|---|
| 80 | 0, // network byte order
|
|---|
| 81 | 0, // security scheme
|
|---|
| 82 | 0, // message size
|
|---|
| 83 | 0, // provider reserved
|
|---|
| 84 | 'M','S','A','F','D',' ','T','c','p','I','p',' ','[','T','C','P','/','I','P',']',']'
|
|---|
| 85 | };
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | static WSAPROTOCOL_INFOW sProtocol_UdpIp =
|
|---|
| 89 | {
|
|---|
| 90 | 0x20609, // XP_FRAGMENTATION | XP_SUPPORTS_BROADCAST | XP_SUPPORTS_MULTICAST | XP_MESSAGE_ORIENTED | XP_CONNECTIONLESS
|
|---|
| 91 | 0, // service flags
|
|---|
| 92 | 0,
|
|---|
| 93 | 0,
|
|---|
| 94 | 0x00000008, // provider flags
|
|---|
| 95 | myDEFINE_GUID(0xe70f1aa0, 0xab8b, 0x11cf, 0x8c, 0xa3, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92),
|
|---|
| 96 | 0x000003ea, // catalog entry ID
|
|---|
| 97 | {0x00000001,}, // protocol chain
|
|---|
| 98 | 0, // version
|
|---|
| 99 | WS_AF_INET, // address family
|
|---|
| 100 | 0, // max sock addr
|
|---|
| 101 | 0, // min sock addr
|
|---|
| 102 | SOCK_DGRAM, // socket type
|
|---|
| 103 | WS_IPPROTO_UDP, // protocol
|
|---|
| 104 | 0, // protocol max. offset
|
|---|
| 105 | 0, // network byte order
|
|---|
| 106 | 0, // security scheme
|
|---|
| 107 | 65467, // message size
|
|---|
| 108 | 0, // provider reserved
|
|---|
| 109 | 'M','S','A','F','D',' ','T','c','p','I','p',' ','[','U','D','P','/','I','P',']',']'
|
|---|
| 110 | };
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 | static WSAPROTOCOL_INFOW sProtocol_NetBtSeq =
|
|---|
| 114 | {
|
|---|
| 115 | 0x2000e,
|
|---|
| 116 | 0, // service flags
|
|---|
| 117 | 0,
|
|---|
| 118 | 0,
|
|---|
| 119 | 0x00000008, // provider flags
|
|---|
| 120 | myDEFINE_GUID(0x8d5f1830, 0xc273, 0x11cf, 0x95, 0xc8, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92),
|
|---|
| 121 | 0x000003ee, // catalog entry ID
|
|---|
| 122 | {0x00000001,}, // protocol chain
|
|---|
| 123 | 0, // version
|
|---|
| 124 | WS_AF_NETBIOS, // address family
|
|---|
| 125 | 0, // max sock addr
|
|---|
| 126 | 0, // min sock addr
|
|---|
| 127 | SOCK_SEQPACKET, // socket type
|
|---|
| 128 | WS_IPPROTO_NETBIOS_MAGIC, // protocol (encoded LANA Number)
|
|---|
| 129 | 0, // protocol max. offset
|
|---|
| 130 | 0, // network byte order
|
|---|
| 131 | 0, // security scheme
|
|---|
| 132 | 64000, // message size
|
|---|
| 133 | 0, // provider reserved
|
|---|
| 134 |
|
|---|
| 135 | // is completed dynamically,
|
|---|
| 136 | // Note: "NetBT" is a signature string, don't change it.
|
|---|
| 137 | 'M','S','A','F','D',' ','N','e','t','B','I','O','S',' ',
|
|---|
| 138 | '[','\\','D','e','v','i','c','e','\\','N','e','t','B','T',
|
|---|
| 139 | '_','T','c','p','i','p','%','l','s',' ','S','E','Q','P','A',
|
|---|
| 140 | 'C','K','E','T',' ','%','d'
|
|---|
| 141 | };
|
|---|
| 142 |
|
|---|
| 143 |
|
|---|
| 144 | static WSAPROTOCOL_INFOW sProtocol_NetBtDgram =
|
|---|
| 145 | {
|
|---|
| 146 | 0x20209,
|
|---|
| 147 | 0, // service flags
|
|---|
| 148 | 0,
|
|---|
| 149 | 0,
|
|---|
| 150 | 0x00000008, // provider flags
|
|---|
| 151 | myDEFINE_GUID(0x8d5f1830, 0xc273, 0x11cf, 0x95, 0xc8, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92),
|
|---|
| 152 | 0x000003ea, // catalog entry ID
|
|---|
| 153 | {0x00000001,}, // protocol chain
|
|---|
| 154 | 0, // version
|
|---|
| 155 | WS_AF_NETBIOS, // address family
|
|---|
| 156 | 0, // max sock addr
|
|---|
| 157 | 0, // min sock addr
|
|---|
| 158 | SOCK_DGRAM, // socket type
|
|---|
| 159 | WS_IPPROTO_NETBIOS_MAGIC, // protocol (encoded LANA Number)
|
|---|
| 160 | 0, // protocol max. offset
|
|---|
| 161 | 0, // network byte order
|
|---|
| 162 | 0, // security scheme
|
|---|
| 163 | 64000, // message size
|
|---|
| 164 | 0, // provider reserved
|
|---|
| 165 |
|
|---|
| 166 | // is completed dynamically,
|
|---|
| 167 | // Note: "NetBT" is a signature string, don't change it.
|
|---|
| 168 | 'M','S','A','F','D',' ','N','e','t','B','I','O','S',' ',
|
|---|
| 169 | '[','\\','D','e','v','i','c','e','\\','N','e','t','B','T',
|
|---|
| 170 | '_','T','c','p','i','p','%','l','s',' ','D','A','T','A','G',
|
|---|
| 171 | 'R','A','M',' ','%','d'
|
|---|
| 172 | };
|
|---|
| 173 |
|
|---|
| 174 |
|
|---|
| 175 | /*
|
|---|
| 176 | * descriptor structure for a LAN adapter
|
|---|
| 177 | */
|
|---|
| 178 | typedef struct _LANAdapter
|
|---|
| 179 | {
|
|---|
| 180 | ULONG LANA; // Lan adapter number
|
|---|
| 181 | ULONG encLANA; // Win32 "encoded" LAN Adapter number
|
|---|
| 182 | // LANA encoded LANA
|
|---|
| 183 | // ------ ------------
|
|---|
| 184 | // 0 0x80000000
|
|---|
| 185 | // 1 -1
|
|---|
| 186 | // 2 -2
|
|---|
| 187 | // ... ...
|
|---|
| 188 | LPWSTR lpszGUID; // GUID of adapter driver
|
|---|
| 189 | } LANADAPTER, *PLANADAPTER;
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 | static LANADAPTER LANAdapter_0 =
|
|---|
| 193 | {
|
|---|
| 194 | 0, // LAN adapter number 0
|
|---|
| 195 | 0x80000000, // corresponding to adapter 0:
|
|---|
| 196 | // myDEFINE_GUID(0xe125fc45, 0x8a8c, 0x4aef, 0xad, 0xc2, 0xe2, 0x51, 0xc2, 0x82, 0x7c, 0x8f)
|
|---|
| 197 | // manual specification of GUID saves StringFromCLSID call and OLE32 linkage
|
|---|
| 198 | (LPWSTR)L"{E125FC45-8A8C-4AEF-ADC2-E251C2827C8F}"
|
|---|
| 199 | };
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 | typedef struct _ProtocolBinding
|
|---|
| 203 | {
|
|---|
| 204 | LANADAPTER* pLANA;
|
|---|
| 205 | WSAPROTOCOL_INFOW * pProtocol;
|
|---|
| 206 | } PROTOCOLBINDING, *PPROTOCOLBINDING;
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 | // this is our sample, static binding setup
|
|---|
| 210 | // To do: determine this dynamically in i_WSAEnumInitialize
|
|---|
| 211 | static PROTOCOLBINDING arrBindingInfo[] =
|
|---|
| 212 | {
|
|---|
| 213 | { &LANAdapter_0, &sProtocol_TcpIp },
|
|---|
| 214 | { &LANAdapter_0, &sProtocol_UdpIp },
|
|---|
| 215 | { &LANAdapter_0, &sProtocol_NetBtSeq },
|
|---|
| 216 | { &LANAdapter_0, &sProtocol_NetBtDgram },
|
|---|
| 217 | NULL
|
|---|
| 218 | };
|
|---|
| 219 |
|
|---|
| 220 |
|
|---|
| 221 | /*****************************************************************************
|
|---|
| 222 | * Name : static int i_WSAEnumInitialize
|
|---|
| 223 | * Purpose : access Protocol Manager and obtain binding information,
|
|---|
| 224 | * in case this fails a standard setup is returned
|
|---|
| 225 | * Parameters:
|
|---|
| 226 | * Variables :
|
|---|
| 227 | * Result :
|
|---|
| 228 | * Remark :
|
|---|
| 229 | * Status :
|
|---|
| 230 | *
|
|---|
| 231 | * Author : Patrick Haller [2002-03-04]
|
|---|
| 232 | *****************************************************************************/
|
|---|
| 233 |
|
|---|
| 234 | static int i_WSAEnumInitialize(void)
|
|---|
| 235 | {
|
|---|
| 236 | // 1 - open protman$
|
|---|
| 237 | // 2 - obtain binding information
|
|---|
| 238 | // 3 - close protman$
|
|---|
| 239 | // 4 - parse and analyse binding info
|
|---|
| 240 | // and build ready-to-eat WSAEnumProtocol pieces
|
|---|
| 241 | return 0;
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 | /*****************************************************************************
|
|---|
| 247 | * WSOCK32_WSAEnterSingleProtocol [internal]
|
|---|
| 248 | *
|
|---|
| 249 | * enters the protocol informations of one given protocol into the
|
|---|
| 250 | * given buffer. If the given buffer is too small only the required size for
|
|---|
| 251 | * the protocols are returned.
|
|---|
| 252 | *
|
|---|
| 253 | * RETURNS
|
|---|
| 254 | * The number of protocols entered into the buffer
|
|---|
| 255 | *
|
|---|
| 256 | * BUGS
|
|---|
| 257 | * - only implemented for IPX, SPX, SPXII, TCP, UDP
|
|---|
| 258 | * - there is no check that the operating system supports the returned
|
|---|
| 259 | * protocols
|
|---|
| 260 | */
|
|---|
| 261 |
|
|---|
| 262 | // Note @@@PH 2002-03-04
|
|---|
| 263 | // - we currently do not determine if a specified protocol is really installed,
|
|---|
| 264 | // but return a "standard configuration" for adapter 0 instead.
|
|---|
| 265 | static INT WSOCK32_WSAEnterSingleProtocol(PPROTOCOLBINDING pBinding,
|
|---|
| 266 | DWORD dwCatalogID,
|
|---|
| 267 | WSAPROTOCOL_INFOA* lpBuffer,
|
|---|
| 268 | LPDWORD lpSize,
|
|---|
| 269 | BOOL unicode)
|
|---|
| 270 | {
|
|---|
| 271 | DWORD dwLength = 0;
|
|---|
| 272 | DWORD dwOldSize = *lpSize;
|
|---|
| 273 | INT iAnz = 1;
|
|---|
| 274 | WCHAR *lpProtName = NULL;
|
|---|
| 275 | BOOL flagDoCopy = TRUE;
|
|---|
| 276 | WCHAR szBuf[256];
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | if (FALSE == unicode)
|
|---|
| 280 | *lpSize = sizeof( WSAPROTOCOL_INFOA );
|
|---|
| 281 | else
|
|---|
| 282 | *lpSize = sizeof( WSAPROTOCOL_INFOW );
|
|---|
| 283 |
|
|---|
| 284 | if ( !lpBuffer || !*lpSize || (*lpSize > dwOldSize))
|
|---|
| 285 | flagDoCopy = FALSE;
|
|---|
| 286 |
|
|---|
| 287 | // copy the information
|
|---|
| 288 | if (flagDoCopy)
|
|---|
| 289 | {
|
|---|
| 290 | memcpy(lpBuffer, (const void*)pBinding->pProtocol, *lpSize );
|
|---|
| 291 | lpProtName = pBinding->pProtocol->szProtocol;
|
|---|
| 292 |
|
|---|
| 293 | // for NETBIOS protocols, recalculate the name
|
|---|
| 294 | if( WS_AF_NETBIOS == pBinding->pProtocol->iAddressFamily)
|
|---|
| 295 | {
|
|---|
| 296 | // recalculate LANA -> iProtocol
|
|---|
| 297 | lpBuffer->iProtocol = pBinding->pLANA->encLANA;
|
|---|
| 298 |
|
|---|
| 299 | #ifdef __EMX__
|
|---|
| 300 | snwprintf(szBuf,
|
|---|
| 301 | 256, // sizeof szBuf
|
|---|
| 302 | pBinding->pProtocol->szProtocol,
|
|---|
| 303 | pBinding->pLANA->lpszGUID,
|
|---|
| 304 | pBinding->pLANA->LANA);
|
|---|
| 305 | #else
|
|---|
| 306 | swprintf((wchar_t*)szBuf,
|
|---|
| 307 | 256, // sizeof szBuf
|
|---|
| 308 | (const wchar_t*)pBinding->pProtocol->szProtocol,
|
|---|
| 309 | pBinding->pLANA->lpszGUID,
|
|---|
| 310 | pBinding->pLANA->LANA);
|
|---|
| 311 | #endif
|
|---|
| 312 |
|
|---|
| 313 | lpProtName = szBuf;
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | // set catalog entry ID
|
|---|
| 317 | lpBuffer->dwCatalogEntryId = dwCatalogID;
|
|---|
| 318 |
|
|---|
| 319 | // convert and copy the name
|
|---|
| 320 | if (unicode)
|
|---|
| 321 | strncpyW( (LPWSTR)lpBuffer->szProtocol, lpProtName, WSAPROTOCOL_LEN);
|
|---|
| 322 | else
|
|---|
| 323 | WideCharToMultiByte( CP_ACP, 0, lpProtName, -1, lpBuffer->szProtocol,
|
|---|
| 324 | WSAPROTOCOL_LEN, NULL, NULL);
|
|---|
| 325 | }
|
|---|
| 326 | else
|
|---|
| 327 | iAnz = 0;
|
|---|
| 328 |
|
|---|
| 329 | return iAnz;
|
|---|
| 330 | }
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 | /*****************************************************************************
|
|---|
| 334 | * WSOCK32_EnumProtocol [internal]
|
|---|
| 335 | *
|
|---|
| 336 | * Enters the information about installed protocols into a given buffer
|
|---|
| 337 | *
|
|---|
| 338 | * RETURNS
|
|---|
| 339 | * SOCKET_ERROR if the buffer is to small for the requested protocol infos
|
|---|
| 340 | * on success the number of protocols inside the buffer
|
|---|
| 341 | *
|
|---|
| 342 | * NOTE
|
|---|
| 343 | * NT4SP5 does not return SPX if lpiProtocols == NULL
|
|---|
| 344 | *
|
|---|
| 345 | * BUGS
|
|---|
| 346 | * - NT4SP5 returns in addition these list of NETBIOS protocols
|
|---|
| 347 | * (address family 17), each entry two times one for socket type 2 and 5
|
|---|
| 348 | *
|
|---|
| 349 | * iProtocol lpProtocol
|
|---|
| 350 | * 0x80000000 \Device\NwlnkNb
|
|---|
| 351 | * 0xfffffffa \Device\NetBT_CBENT7
|
|---|
| 352 | * 0xfffffffb \Device\Nbf_CBENT7
|
|---|
| 353 | * 0xfffffffc \Device\NetBT_NdisWan5
|
|---|
| 354 | * 0xfffffffd \Device\NetBT_El9202
|
|---|
| 355 | * 0xfffffffe \Device\Nbf_El9202
|
|---|
| 356 | * 0xffffffff \Device\Nbf_NdisWan4
|
|---|
| 357 | *
|
|---|
| 358 | * - there is no check that the operating system supports the returned
|
|---|
| 359 | * protocols
|
|---|
| 360 | */
|
|---|
| 361 | static INT WSOCK32_EnumProtocol( LPINT lpiProtocols,
|
|---|
| 362 | WSAPROTOCOL_INFOA* lpBuffer,
|
|---|
| 363 | LPDWORD lpdwLength,
|
|---|
| 364 | BOOL unicode)
|
|---|
| 365 | {
|
|---|
| 366 | DWORD dwCurSize,
|
|---|
| 367 | dwOldSize = *lpdwLength;
|
|---|
| 368 | DWORD dwSpaceTaken = 0;
|
|---|
| 369 | INT anz = 0;
|
|---|
| 370 | INT rc;
|
|---|
| 371 | DWORD dwCatalogID = 1;
|
|---|
| 372 |
|
|---|
| 373 | PPROTOCOLBINDING pBinding = arrBindingInfo;
|
|---|
| 374 | LPINT lpIter;
|
|---|
| 375 |
|
|---|
| 376 | *lpdwLength = 0;
|
|---|
| 377 |
|
|---|
| 378 | // iterate over all available protocol bindings
|
|---|
| 379 | for(;
|
|---|
| 380 | pBinding->pLANA != NULL;
|
|---|
| 381 | pBinding++)
|
|---|
| 382 | {
|
|---|
| 383 | // keep identical catalog IDs everywhere
|
|---|
| 384 | dwCatalogID++;
|
|---|
| 385 |
|
|---|
| 386 | // check if the current protocol is in the "selection list"
|
|---|
| 387 | if (lpiProtocols != NULL)
|
|---|
| 388 | {
|
|---|
| 389 | BOOL fFound = FALSE;
|
|---|
| 390 |
|
|---|
| 391 | for (lpIter = lpiProtocols;
|
|---|
| 392 | *lpIter;
|
|---|
| 393 | lpIter++)
|
|---|
| 394 | {
|
|---|
| 395 | if (pBinding->pProtocol->iProtocol == *lpIter)
|
|---|
| 396 | {
|
|---|
| 397 | fFound = TRUE;
|
|---|
| 398 | break;
|
|---|
| 399 | }
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | // don't add this protocol entry
|
|---|
| 403 | if (!fFound)
|
|---|
| 404 | continue;
|
|---|
| 405 | }
|
|---|
| 406 |
|
|---|
| 407 |
|
|---|
| 408 | // ok, add the current protocol to the list
|
|---|
| 409 |
|
|---|
| 410 | // calculate how much space is left
|
|---|
| 411 | dwCurSize = dwOldSize - dwSpaceTaken;
|
|---|
| 412 |
|
|---|
| 413 | // determine how much space this will take up
|
|---|
| 414 | rc = WSOCK32_WSAEnterSingleProtocol( pBinding, dwCatalogID, &lpBuffer[ anz ], &dwCurSize, unicode);
|
|---|
| 415 | if (rc > 0)
|
|---|
| 416 | {
|
|---|
| 417 | // update pointers if protocol was added
|
|---|
| 418 | anz += rc;
|
|---|
| 419 | dwSpaceTaken += dwCurSize;
|
|---|
| 420 | }
|
|---|
| 421 |
|
|---|
| 422 | // deliver the number of bytes required to hold ALL information
|
|---|
| 423 | *lpdwLength += dwCurSize;
|
|---|
| 424 | }
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 | // returncode for signalling "more data"
|
|---|
| 428 | if (dwOldSize < *lpdwLength)
|
|---|
| 429 | anz = SOCKET_ERROR;
|
|---|
| 430 |
|
|---|
| 431 | return anz;
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 |
|
|---|
| 435 |
|
|---|
| 436 | /*****************************************************************************
|
|---|
| 437 | * Name : int WSAEnumProtocolsA
|
|---|
| 438 | * Purpose : retrieves binding information on protocols and adapters
|
|---|
| 439 | * Parameters: lpiProtocols
|
|---|
| 440 | * [in] Null-terminated array of iProtocol values. This
|
|---|
| 441 | * parameter is optional; if lpiProtocols is NULL, information
|
|---|
| 442 | * on all available protocols is returned. Otherwise,
|
|---|
| 443 | * information is retrieved only for those protocols listed in
|
|---|
| 444 | * the array.
|
|---|
| 445 | * lpProtocolBuffer
|
|---|
| 446 | * [out] Buffer that is filled with WSAPROTOCOL_INFOA structures.
|
|---|
| 447 | * lpdwBufferLength
|
|---|
| 448 | * [in, out] On input, the count of bytes in the
|
|---|
| 449 | * lpProtocolBuffer buffer passed to WSAEnumProtocols. On
|
|---|
| 450 | * output, the minimum buffer size that can be passed to
|
|---|
| 451 | * WSAEnumProtocols to retrieve all the requested information.
|
|---|
| 452 | * This routine has no ability to enumerate over multiple calls;
|
|---|
| 453 | * the passed-in buffer must be large enough to hold all entries
|
|---|
| 454 | * in order for the routine to succeed. This reduces the
|
|---|
| 455 | * complexity of the API and should not pose a problem because
|
|---|
| 456 | * the number of protocols loaded on a computer is typically
|
|---|
| 457 | * small.
|
|---|
| 458 | * Variables :
|
|---|
| 459 | * Result : If no error occurs, WSAEnumProtocols returns the number of
|
|---|
| 460 | * protocols to be reported. Otherwise, a value of SOCKET_ERROR
|
|---|
| 461 | * is returned and a specific error code can be retrieved by
|
|---|
| 462 | * calling WSAGetLastError.
|
|---|
| 463 | * Remark :
|
|---|
| 464 | * Status : UNTESTED
|
|---|
| 465 | *
|
|---|
| 466 | * Author : Patrick Haller [2002-03-01]
|
|---|
| 467 | *****************************************************************************/
|
|---|
| 468 |
|
|---|
| 469 | ODINFUNCTION3(int, WSAEnumProtocolsA, LPINT, lpiProtocols,
|
|---|
| 470 | LPWSAPROTOCOL_INFOA, lpProtocolBuffer,
|
|---|
| 471 | LPDWORD, lpdwBufferLength)
|
|---|
| 472 | {
|
|---|
| 473 | dprintf(("NOT COMPLETELY IMPLEMENTED"));
|
|---|
| 474 |
|
|---|
| 475 | return WSOCK32_EnumProtocol(lpiProtocols,
|
|---|
| 476 | lpProtocolBuffer,
|
|---|
| 477 | lpdwBufferLength,
|
|---|
| 478 | FALSE);
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 |
|
|---|
| 482 | /*****************************************************************************
|
|---|
| 483 | * Name : int WSAEnumProtocolsW
|
|---|
| 484 | * Purpose : retrieves binding information on protocols and adapters
|
|---|
| 485 | * Parameters: lpiProtocols
|
|---|
| 486 | * [in] Null-terminated array of iProtocol values. This
|
|---|
| 487 | * parameter is optional; if lpiProtocols is NULL, information
|
|---|
| 488 | * on all available protocols is returned. Otherwise,
|
|---|
| 489 | * information is retrieved only for those protocols listed in
|
|---|
| 490 | * the array.
|
|---|
| 491 | * lpProtocolBuffer
|
|---|
| 492 | * [out] Buffer that is filled with WSAPROTOCOL_INFOW structures.
|
|---|
| 493 | * lpdwBufferLength
|
|---|
| 494 | * [in, out] On input, the count of bytes in the
|
|---|
| 495 | * lpProtocolBuffer buffer passed to WSAEnumProtocols. On
|
|---|
| 496 | * output, the minimum buffer size that can be passed to
|
|---|
| 497 | * WSAEnumProtocols to retrieve all the requested information.
|
|---|
| 498 | * This routine has no ability to enumerate over multiple calls;
|
|---|
| 499 | * the passed-in buffer must be large enough to hold all entries
|
|---|
| 500 | * in order for the routine to succeed. This reduces the
|
|---|
| 501 | * complexity of the API and should not pose a problem because
|
|---|
| 502 | * the number of protocols loaded on a computer is typically
|
|---|
| 503 | * small.
|
|---|
| 504 | * Variables :
|
|---|
| 505 | * Result : If no error occurs, WSAEnumProtocols returns the number of
|
|---|
| 506 | * protocols to be reported. Otherwise, a value of SOCKET_ERROR
|
|---|
| 507 | * is returned and a specific error code can be retrieved by
|
|---|
| 508 | * calling WSAGetLastError.
|
|---|
| 509 | * Remark :
|
|---|
| 510 | * Status : UNTESTED
|
|---|
| 511 | *
|
|---|
| 512 | * Author : Patrick Haller [2002-03-01]
|
|---|
| 513 | *****************************************************************************/
|
|---|
| 514 |
|
|---|
| 515 | ODINFUNCTION3(int, WSAEnumProtocolsW, LPINT, lpiProtocols,
|
|---|
| 516 | LPWSAPROTOCOL_INFOW, lpProtocolBuffer,
|
|---|
| 517 | LPDWORD, lpdwBufferLength)
|
|---|
| 518 | {
|
|---|
| 519 | dprintf(("NOT COMPLETELY IMPLEMENTED"));
|
|---|
| 520 |
|
|---|
| 521 | return WSOCK32_EnumProtocol(lpiProtocols,
|
|---|
| 522 | (LPWSAPROTOCOL_INFOA)lpProtocolBuffer,
|
|---|
| 523 | lpdwBufferLength,
|
|---|
| 524 | TRUE);
|
|---|
| 525 | }
|
|---|
| 526 | //******************************************************************************
|
|---|
| 527 | //******************************************************************************
|
|---|