lspcommon.h File Reference#include <winsock2.h> #include <ws2spi.h>
Include dependency graph for lspcommon.h:
![]()
This graph shows which files directly or indirectly include this file:
![]() Go to the source code of this file.
Define Documentation
Definition at line 25 of file lspcommon.h.
Definition at line 352 of file lspcommon.h.
Definition at line 353 of file lspcommon.h.
Definition at line 29 of file lspcommon.h.
Typedef Documentation
Definition at line 48 of file lspcommon.h.
Enumeration Type Documentation
Definition at line 51 of file lspcommon.h. 00052 { 00053 LspCatalogBoth = 0, 00054 LspCatalog32Only, 00055 LspCatalog64Only 00056 } WINSOCK_CATALOG;
Function Documentation
Definition at line 87 of file provider.cpp. 00091 { 00092 LPWSAPROTOCOL_INFOW ProtocolInfo = NULL; 00093 DWORD ProtocolInfoSize = 0; 00094 INT ErrorCode = NO_ERROR, 00095 rc; 00096 00097 if ( NULL == TotalProtocols ) 00098 goto cleanup; 00099 00100 *TotalProtocols = 0; 00101 00102 #ifdef _WIN64 00103 // Find out how many entries we need to enumerate 00104 if ( LspCatalog64Only == Catalog ) 00105 { 00106 // Find the size of the buffer 00107 rc = WSCEnumProtocols( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00108 if ( SOCKET_ERROR == rc ) 00109 { 00110 if ( WSAENOBUFS != ErrorCode ) 00111 goto cleanup; 00112 ErrorCode = NO_ERROR; 00113 } 00114 00115 // Allocate the buffer 00116 ProtocolInfo = (LPWSAPROTOCOL_INFOW) LspAlloc( 00117 ProtocolInfoSize, 00118 &ErrorCode 00119 ); 00120 if (ProtocolInfo == NULL) 00121 goto cleanup; 00122 00123 // Enumerate the catalog for real 00124 rc = WSCEnumProtocols( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00125 if ( SOCKET_ERROR == rc ) 00126 goto cleanup; 00127 00128 // Update the count 00129 *TotalProtocols = rc; 00130 } 00131 else if ( LspCatalog32Only == Catalog ) 00132 { 00133 HMODULE hModule; 00134 LPWSCENUMPROTOCOLS fnWscEnumProtocols32 = NULL; 00135 00136 // Load ws2_32.dll 00137 hModule = LoadLibrary( TEXT( "ws2_32.dll" ) ); 00138 if ( NULL == hModule ) 00139 goto cleanup; 00140 00141 // Find the 32-bit catalog enumerator 00142 fnWscEnumProtocols32 = (LPWSCENUMPROTOCOLS) GetProcAddress( 00143 hModule, 00144 TEXT( "WSCEnumProtocols32" ) 00145 ); 00146 if ( NULL == fnWscEnumProtocols32 ) 00147 goto cleanup; 00148 00149 // Find the required buffer size 00150 rc = fnWscEnumProtocols32(NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode); 00151 if ( SOCKET_ERROR == rc ) 00152 { 00153 if ( WSAENOBUFS != ErrorCode ) 00154 goto cleanup; 00155 ErrorCode = NO_ERROR; 00156 } 00157 00158 // Allocate the buffer 00159 ProtocolInfo = (LPWSAPROTOCOL_INFOW) LspAlloc( 00160 ProtocolInfoSize, 00161 &ErrorCode 00162 ); 00163 if ( NULL == ProtocolInfo ) 00164 goto cleanup; 00165 00166 // Enumrate the catalog for real this time 00167 rc = fnWscEnumProtocols32( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00168 if ( SOCKET_ERROR == rc ) 00169 goto cleanup; 00170 00171 // Update the count 00172 *TotalProtocols = rc; 00173 00174 FreeLibrary( hModule ); 00175 } 00176 #else 00177 if ( LspCatalog32Only == Catalog ) 00178 { 00179 // Find the size of the buffer 00180 rc = WSCEnumProtocols( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00181 if ( SOCKET_ERROR == rc ) 00182 { 00183 if ( WSAENOBUFS != ErrorCode ) 00184 goto cleanup; 00185 ErrorCode = NO_ERROR; 00186 } 00187 00188 // Allocate the buffer 00189 ProtocolInfo = (LPWSAPROTOCOL_INFOW) LspAlloc( 00190 ProtocolInfoSize, 00191 &ErrorCode 00192 ); 00193 if ( NULL == ProtocolInfo ) 00194 goto cleanup; 00195 00196 // Enumerate the catalog for real 00197 rc = WSCEnumProtocols( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00198 if ( SOCKET_ERROR == rc ) 00199 goto cleanup; 00200 00201 // Update the count 00202 *TotalProtocols = rc; 00203 } 00204 else if ( LspCatalog64Only == Catalog ) 00205 { 00206 dbgprint( "Unable to enumerate 64-bit Winsock catalog from 32-bit process!"); 00207 } 00208 #endif 00209 else 00210 { 00211 // Find the size of the buffer 00212 rc = WSCEnumProtocols( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00213 if ( SOCKET_ERROR == rc ) 00214 { 00215 if ( WSAENOBUFS != ErrorCode ) 00216 goto cleanup; 00217 ErrorCode = NO_ERROR; 00218 } 00219 00220 // Allocate the buffer 00221 ProtocolInfo = (LPWSAPROTOCOL_INFOW) LspAlloc( 00222 ProtocolInfoSize, 00223 &ErrorCode 00224 ); 00225 if ( NULL == ProtocolInfo ) 00226 goto cleanup; 00227 00228 // Enumerate the catalog for real 00229 rc = WSCEnumProtocols( NULL, ProtocolInfo, &ProtocolInfoSize, &ErrorCode ); 00230 if ( SOCKET_ERROR == rc ) 00231 goto cleanup; 00232 00233 // Update the count 00234 *TotalProtocols = rc; 00235 } 00236 00237 cleanup: 00238 00239 if ( ( NO_ERROR != ErrorCode ) && ( NULL != ProtocolInfo ) ) 00240 { 00241 LspFree( ProtocolInfo ); 00242 ProtocolInfo = NULL; 00243 } 00244 00245 return ProtocolInfo; 00246 }
Definition at line 255 of file provider.cpp. 00260 { 00261 INT ErrorCode = NO_ERROR, 00262 rc = NO_ERROR; 00263 00264 #ifdef _WIN64 00265 if ( LspCatalog64Only == Catalog ) 00266 { 00267 rc = WSCEnumProtocols( NULL, ProtocolInfo, ProtocolInfoSize, &ErrorCode ); 00268 } 00269 else if ( LspCatalog32Only == Catalog ) 00270 { 00271 rc = WSCEnumProtocols32( NULL, ProtocolInfo, ProtocolInfoSize, &ErrorCode ); 00272 } 00273 #else 00274 if ( LspCatalog32Only == Catalog ) 00275 { 00276 rc = WSCEnumProtocols( NULL, ProtocolInfo, ProtocolInfoSize, &ErrorCode ); 00277 } 00278 else if ( LspCatalog64Only == Catalog ) 00279 { 00280 dbgprint( "Unable to enumerate 64-bit Winsock catalog from 32-bit process!" ); 00281 } 00282 #endif 00283 if ( SOCKET_ERROR == rc ) 00284 { 00285 dbgprint( "EnumerateProvidersExisting: WSCEnumProviders failed: %d", 00286 GetLastError() ); 00287 } 00288 00289 return rc; 00290 }
Definition at line 397 of file provider.cpp. 00402 { 00403 PROVIDER *Providers = NULL; 00404 LPWSAPROTOCOL_INFOW ProtocolInfo = NULL; 00405 DWORD DummyLspId = 0; 00406 int ProtocolCount = 0, 00407 LayerCount = 0, 00408 idx, 00409 i, j; 00410 00411 *lspProviderCount = 0; 00412 *lspProviders = NULL; 00413 00414 // Enumerate the catalog 00415 ProtocolInfo = EnumerateProviders( LspCatalogBoth, &ProtocolCount ); 00416 if ( NULL == ProtocolInfo ) 00417 { 00418 dbgprint("FindLspEntries; EnumerateProviders failed!"); 00419 goto cleanup; 00420 } 00421 00422 // Find our dummy LSP entry ID 00423 DummyLspId = 0; 00424 for(i=0; i < ProtocolCount ;i++) 00425 { 00426 if ( 0 == memcmp( &ProtocolInfo[ i ].ProviderId, &gProviderGuid, sizeof( gProviderGuid ) ) ) 00427 { 00428 DummyLspId = ProtocolInfo[ i ].dwCatalogEntryId; 00429 break; 00430 } 00431 } 00432 00433 ASSERT( 0 != DummyLspId ); 00434 00435 // Count how many LSP layered entries are present 00436 LayerCount = 0; 00437 for(i=0; i < ProtocolCount ;i++) 00438 { 00439 if ( ( ProtocolInfo[ i ].ProtocolChain.ChainLen > 1 ) && 00440 ( DummyLspId == ProtocolInfo[ i ].ProtocolChain.ChainEntries[ 0 ] ) 00441 ) 00442 { 00443 LayerCount++; 00444 } 00445 } 00446 00447 ASSERT( 0 != LayerCount ); 00448 00449 // Allocate space for the layered providers 00450 Providers = (PROVIDER *) LspAlloc( sizeof(PROVIDER) * LayerCount, lpErrno ); 00451 if ( NULL == Providers ) 00452 { 00453 dbgprint("FindLspEntries: LspAlloc failed: %d", *lpErrno ); 00454 goto cleanup; 00455 } 00456 00457 idx = 0; 00458 00459 // Save the LSP layered entries 00460 for(i=0; i < ProtocolCount ;i++) 00461 { 00462 // The layered protocol entries for this LSP will always reference the 00463 // dummy entry ID as its first entry in the chain array. Also make 00464 // sure to check only LSP entries (since a base provider's chain length 00465 // is 1 but the chain array entries can be garbage) 00466 if ( ( ProtocolInfo[ i ].ProtocolChain.ChainLen > 1 ) && 00467 ( DummyLspId == ProtocolInfo[ i ].ProtocolChain.ChainEntries[ 0 ] ) 00468 ) 00469 { 00470 // Copy the new entry to the head 00471 memcpy( &Providers[ idx ].LayerProvider, &ProtocolInfo[ i ], sizeof(WSAPROTOCOL_INFOW) ); 00472 Providers[ idx ].LayerProvider.szProtocol[ WSAPROTOCOL_LEN ] = '\0'; 00473 00474 // Copy the provider underneath this entry 00475 for(j=0; j < ProtocolCount ;j++) 00476 { 00477 // The next provider can either be a base, a dummy, or another layered 00478 // protocol chain. If a dummy or layer then both providers will have 00479 // the same DLL to load. 00480 if ( ProtocolInfo[ i ].ProtocolChain.ChainEntries[ 1 ] == 00481 ProtocolInfo[ j ].dwCatalogEntryId ) 00482 { 00483 memcpy( &Providers[ idx ].NextProvider, &ProtocolInfo[ j ], 00484 sizeof( WSAPROTOCOL_INFOW ) ); 00485 Providers[ idx ].NextProvider.szProtocol[ WSAPROTOCOL_LEN ] = '\0'; 00486 break; 00487 } 00488 } 00489 00490 // Verify we copied the lower layer 00491 ASSERT( j < ProtocolCount ); 00492 00493 InitializeCriticalSection( &Providers[ idx ].ProviderCritSec ); 00494 InitializeListHead( &Providers[ idx ].SocketList ); 00495 00496 Providers[ idx ].LspDummyId = DummyLspId; 00497 00498 idx++; 00499 } 00500 } 00501 00502 ASSERT( idx == LayerCount ); 00503 00504 if ( NULL != ProtocolInfo ) 00505 FreeProviders( ProtocolInfo ); 00506 00507 *lspProviders = Providers; 00508 *lspProviderCount = LayerCount; 00509 00510 return TRUE; 00511 00512 cleanup: 00513 00514 if ( NULL != ProtocolInfo ) 00515 FreeProviders( ProtocolInfo ); 00516 00517 if ( NULL != Providers ) 00518 LspFree( Providers ); 00519 00520 return FALSE; 00521 }
Definition at line 534 of file provider.cpp. 00540 { 00541 WSAPROTOCOL_INFOW *ProtocolInfo = NULL; 00542 DWORD hiddenEntryId; 00543 int ProtocolCount, 00544 i, j, k; 00545 00546 // Two possibilites - this inInfo belongs to our LSP or its a layer over our LSP 00547 00548 // First see if the inInfo is one of the LSPs entry 00549 for(i=0; i < lspCount ;i++) 00550 { 00551 if ( inInfo->dwCatalogEntryId == lspProviders[ i ].LayerProvider.dwCatalogEntryId ) 00552 { 00553 return &lspProviders[ i ]; 00554 } 00555 } 00556 00557 ASSERT( inInfo->ProtocolChain.ChainLen > 1 ); 00558 00559 // Next check the inInfo's protocol chains for a reference to our LSP 00560 for(i=0; i < lspCount ;i++) 00561 { 00562 for(j=1; j < inInfo->ProtocolChain.ChainLen ;j++) 00563 { 00564 if ( inInfo->ProtocolChain.ChainEntries[ j ] == lspProviders[ i ].LspDummyId ) 00565 { 00566 // Bad news, the entry passed to us references our dummy entry so we 00567 // need to do some heuristic work to find the "correct" LSP entry 00568 // that corresponds to the input provider 00569 goto next_match; 00570 } 00571 else if ( inInfo->ProtocolChain.ChainEntries[ j ] == lspProviders[ i ].LayerProvider.dwCatalogEntryId ) 00572 { 00573 return &lspProviders[ i ]; 00574 } 00575 } 00576 } 00577 00578 next_match: 00579 00580 // If we didn't find an explicit match we'll have to guess - first try to 00581 // match address family, socket type, protocol and provider flags 00582 for(i=0; i < lspCount ;i++) 00583 { 00584 if ( ( inInfo->iAddressFamily == lspProviders[ i ].LayerProvider.iAddressFamily ) && 00585 ( inInfo->iSocketType == lspProviders[ i ].LayerProvider.iSocketType ) && 00586 ( inInfo->iProtocol == lspProviders[ i ].LayerProvider.iProtocol ) && 00587 ( ( ( inInfo->dwServiceFlags1 & ~XP1_IFS_HANDLES ) == 00588 ( lspProviders[ i ].LayerProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES ) 00589 ) 00590 ) 00591 ) 00592 { 00593 return &lspProviders[ i ]; 00594 } 00595 } 00596 00597 // If this routine was called from WSPSocket and we can't find a match yet, we're 00598 // in bad shape since the protocol info passed in matches no entries of this 00599 // LSPs ... 00600 00601 ASSERT( fromStartup ); 00602 00603 #ifndef DBG 00604 UNREFERENCED_PARAMETER( fromStartup ); 00605 #endif 00606 00607 // 00608 // Still no match. See if the protocol info passed in belongs to another LSP. 00609 // Enumerate all its protocol entries and see if we reside in any of those 00610 // chains. This typically will happen when an LSP is layered over us and it 00611 // bulk loads all of the providers beneath its entries upon its first WSPStartup 00612 // call. 00613 // 00614 // For example consider the following catalog (where this LSP is LSP1): 00615 // 00616 // _____________ _____________ 00617 // | LSP 2 TCP | | LSP 2 UDP | 00618 // _____________ 00619 // | LSP 1 TCP | 00620 // _____________ _____________ 00621 // | BASE TCP | | BASE UDP | 00622 // 00623 // When LSP 2 is started, its WSPStartup is invoked with its UDP entry (since 00624 // the application created a UDP socket). Because LSP2 initializes all its layers 00625 // upon first WSPStartup it will load all the layers beneath it. So LSP2 will 00626 // load LSP1 and invoke its WSPStartup but will pass the UDP protocol info which 00627 // it was passed. At this point LSP1 won't know what to do since it was passed a 00628 // UDP entry and its not layered over any UDP entry. LSP1 cannot return any 00629 // entry if its an IFS LSP which implements only a subset of the Winsock 00630 // functions (i.e. LSP1 will return a mix of function pointers from BASE TCP 00631 // and its own LSP DLL). Because of this, LSP1 will try to "match" which 00632 // chain from LSP2 it actually resides in such that when LSP2 creates a TCP 00633 // socket later, it will have the correct function pointers. 00634 // 00635 // The heuristic is: 00636 // 1. Find all layered protocol entries belonging to the WSAPROTOCOL_INFOW passed. 00637 // In the above example it would find LSP2 TCP and LSP2 UDP. 00638 // 2. Iterate through each provider found and walk the protocol chain in each 00639 // provider, looking for a reference to LSP1's entry. 00640 // 3. If found check LSP1 entry to see if it has already been loaded. If not 00641 // then this is the match, if so then LSP2 could be layered over another TCP 00642 // entry which is also layered over LSP1 so keep looking. 00643 // 00644 00645 // Should never receive a base or dummy entry 00646 ASSERT( inInfo->ProtocolChain.ChainLen > 1 ); 00647 00648 ProtocolInfo = EnumerateProviders( LspCatalogBoth, &ProtocolCount ); 00649 if ( NULL == ProtocolInfo ) 00650 { 00651 dbgprint("FindMatchingLspEntryForProtocolInfo: EnumerateProviders failed!\n"); 00652 goto cleanup; 00653 } 00654 00655 hiddenEntryId = 0; 00656 for(i=0; i < ProtocolCount ;i++) 00657 { 00658 if ( inInfo->ProtocolChain.ChainEntries[ 0 ] == ProtocolInfo[ i ].dwCatalogEntryId ) 00659 { 00660 hiddenEntryId = ProtocolInfo[ i ].dwCatalogEntryId; 00661 break; 00662 } 00663 } 00664 00665 ASSERT( hiddenEntryId ); 00666 00667 for(i=0; i < ProtocolCount ;i++) 00668 { 00669 if ( ProtocolInfo[ i ].ProtocolChain.ChainEntries[ 0 ] == hiddenEntryId ) 00670 { 00671 // This entry belongs to the LSP layered over us - walk its chains to 00672 // see if it references our LSP 00673 for(j=1; j < ProtocolInfo[ i ].ProtocolChain.ChainLen ;j++) 00674 { 00675 for(k=0; k < lspCount ;k++) 00676 { 00677 if ( ProtocolInfo[ i ].ProtocolChain.ChainEntries[ j ] == 00678 lspProviders[ k ].LayerProvider.ProtocolChain.ChainEntries[ 0 ] 00679 ) 00680 { 00681 // Bad news again, the protocol chain of the LSP above us 00682 // references our dummy LSP entry so we'll have to try 00683 // to match according to the protocol triplet and provider 00684 // flags 00685 if ( ( ProtocolInfo[ i ].iAddressFamily == 00686 lspProviders[ k ].LayerProvider.iAddressFamily ) && 00687 ( ProtocolInfo[ i ].iSocketType == 00688 lspProviders[ k ].LayerProvider.iSocketType ) && 00689 ( ProtocolInfo[ i ].iProtocol == 00690 lspProviders[ k ].LayerProvider.iProtocol ) && 00691 ( ( ProtocolInfo[ i ].dwServiceFlags1 & ~XP1_IFS_HANDLES ) == 00692 ( lspProviders[ k ].LayerProvider.dwServiceFlags1 & ~XP1_IFS_HANDLES ) ) 00693 ) 00694 { 00695 return &lspProviders[ i ]; 00696 } 00697 } 00698 00699 if ( ( ProtocolInfo[ i ].ProtocolChain.ChainEntries[ j ] == 00700 lspProviders[ k ].LayerProvider.dwCatalogEntryId ) && 00701 ( lspProviders[ k ].StartupCount == 0 ) 00702 ) 00703 { 00704 return &lspProviders[ i ]; 00705 } 00706 } 00707 } 00708 } 00709 } 00710 00711 cleanup: 00712 00713 ASSERT( FALSE ); 00714 00715 return NULL; 00716 }
Definition at line 825 of file provider.cpp. 00832 { 00833 WSAPROTOCOL_INFOW *ProviderInfo = NULL; 00834 int rc; 00835 00836 rc = LoadProviderPath( provider, Error ); 00837 if ( FALSE == rc ) 00838 { 00839 dbgprint("WSPStartup: LoadProviderPath failed: %d", *Error ); 00840 goto cleanup; 00841 } 00842 00843 // Determine which protocol structure to pass to the lower layer - 00844 // if the next layer is a base provider, pass the base provider's 00845 // structure; otherwise, pass whatever was given to us 00846 if ( BASE_PROTOCOL == provider->NextProvider.ProtocolChain.ChainLen ) 00847 ProviderInfo = &provider->NextProvider; 00848 else 00849 ProviderInfo = lpProtocolInfo; 00850 00851 rc = provider->fnWSPStartup( 00852 wVersion, 00853 &provider->WinsockVersion, 00854 ProviderInfo, 00855 UpCallTable, 00856 &provider->NextProcTable 00857 ); 00858 if ( 0 != rc ) 00859 { 00860 dbgprint("%ws::WSPStartup failed: %d", provider->NextProvider.szProtocol, 00861 rc ); 00862 *Error = rc; 00863 goto cleanup; 00864 } 00865 00866 // Make sure the proc table returned is valid 00867 rc = VerifyProcTable( &provider->NextProcTable ); 00868 if ( SOCKET_ERROR == rc ) 00869 { 00870 *Error = WSAEINVALIDPROCTABLE; 00871 goto cleanup; 00872 } 00873 00874 ASSERT( NO_ERROR == rc ); 00875 00876 // Increment a startup count per-provider as well as an overall counter 00877 // e.g. The sum of all the individual provider's startup should equal 00878 // the global counter, that is, until the process starts calling 00879 // WSPCleanup 00880 provider->StartupCount++; 00881 00882 cleanup: 00883 00884 return rc; 00885 }
Definition at line 728 of file provider.cpp. 00732 { 00733 int rc; 00734 00735 *lpErrno = 0; 00736 00737 // Retrieve the provider path of the lower layer 00738 loadProvider->ProviderPathLen = MAX_PATH - 1; 00739 rc = WSCGetProviderPath( 00740 &loadProvider->NextProvider.ProviderId, 00741 loadProvider->ProviderPathW, 00742 &loadProvider->ProviderPathLen, 00743 lpErrno 00744 ); 00745 if ( SOCKET_ERROR == rc ) 00746 { 00747 dbgprint("LoadProviderPath: WSCGetProviderPath failed: %d", *lpErrno ); 00748 goto cleanup; 00749 } 00750 00751 rc = ExpandEnvironmentStringsW( 00752 loadProvider->ProviderPathW, 00753 loadProvider->LibraryPathW, 00754 MAX_PATH - 1 00755 ); 00756 if ( ( 0 != rc ) && ( MAX_PATH-1 >= rc ) ) 00757 { 00758 loadProvider->Module = LoadLibraryW( loadProvider->LibraryPathW ); 00759 if ( NULL == loadProvider->Module ) 00760 { 00761 dbgprint("LoadProviderPath: LoadLibraryW failed: %d", GetLastError() ); 00762 goto cleanup; 00763 } 00764 } 00765 else if ( 0 == rc ) 00766 { 00767 char ProviderPathA[ MAX_PATH ], 00768 LibraryPathA[ MAX_PATH ]; 00769 00770 // No UNICODE so we must be on Win9x 00771 rc = WideCharToMultiByte( CP_ACP, 0, 00772 loadProvider->ProviderPathW, 00773 loadProvider->ProviderPathLen, 00774 ProviderPathA, 00775 MAX_PATH, 00776 NULL, 00777 NULL 00778 ); 00779 if ( 0 == rc ) 00780 { 00781 dbgprint("LoadProviderPath: WideCharToMultiByte failed: %d", GetLastError() ); 00782 goto cleanup; 00783 } 00784 00785 rc = ExpandEnvironmentStringsA( 00786 ProviderPathA, 00787 LibraryPathA, 00788 MAX_PATH - 1 00789 ); 00790 if ( ( 0 == rc ) || ( MAX_PATH - 1 < rc ) ) 00791 { 00792 dbgprint("LoadProviderPath: ExpandEnvironmentStringsA failed: %d", GetLastError() ); 00793 goto cleanup; 00794 } 00795 00796 loadProvider->Module = LoadLibraryA( LibraryPathA ); 00797 if ( NULL == loadProvider->Module ) 00798 { 00799 dbgprint("LoadProviderPath: LoadLibraryA failed: %d", GetLastError() ); 00800 goto cleanup; 00801 } 00802 } 00803 00804 // Retrieve the next provider's WSPSTartup function 00805 loadProvider->fnWSPStartup = (LPWSPSTARTUP) GetProcAddress( 00806 loadProvider->Module, 00807 "WSPStartup" 00808 ); 00809 if ( NULL == loadProvider->fnWSPStartup ) 00810 { 00811 dbgprint("LoadProviderPath: GetProcAddress failed: %d", GetLastError() ); 00812 goto cleanup; 00813 } 00814 00815 return TRUE; 00816 00817 cleanup: 00818 00819 if ( *lpErrno == 0 ) 00820 *lpErrno = GetLastError(); 00821 return FALSE; 00822 }
Definition at line 314 of file provider.cpp. 00318 { 00319 void *mem = NULL; 00320 mem = HeapAlloc( 00321 gLspHeap, 00322 HEAP_ZERO_MEMORY, 00323 size 00324 ); 00325 if ( NULL == mem ) 00326 { 00327 *lpErrno = WSAENOBUFS; 00328 } 00329 00330 return mem; 00331 }
Definition at line 354 of file provider.cpp. 00357 { 00358 gLspHeap = HeapCreate( 0, 128000, 0 ); 00359 if ( NULL == gLspHeap ) 00360 { 00361 *lpErrno = WSAEPROVIDERFAILEDINIT; 00362 return SOCKET_ERROR; 00363 } 00364 return NO_ERROR; 00365 }
Definition at line 374 of file provider.cpp. 00376 { 00377 if ( NULL != gLspHeap ) 00378 { 00379 HeapDestroy( gLspHeap ); 00380 gLspHeap = NULL; 00381 } 00382 }
Definition at line 47 of file prnpinfo.cpp. 00050 { 00051 WCHAR szGuidString[MAX_PATH], 00052 wszProviderPath[MAX_PATH]; 00053 INT dwProviderPathLen=MAX_PATH-1; 00054 int rc, error, i; 00055 00056 rc = WSCGetProviderPath( 00057 &wsapi->ProviderId, 00058 wszProviderPath, 00059 &dwProviderPathLen, 00060 &error 00061 ); 00062 if ( 0 != rc ) 00063 { 00064 fprintf(stderr, "WSCGetProviderPath failed: %d\n", error); 00065 lstrcpyW(wszProviderPath, L"(error)"); 00066 } 00067 00068 // 00069 // Display address family and protocol information 00070 // 00071 00072 printf("\nProtocol: %S\n", wsapi->szProtocol); 00073 printf("\n Path: %S\n", wszProviderPath); 00074 printf(" Address Family: "); 00075 switch ( wsapi->iAddressFamily ) 00076 { 00077 case AF_INET: 00078 case AF_INET6: 00079 printf("%s\n", (wsapi->iAddressFamily == AF_INET ? "AF_INET" : "AF_INET6")); 00080 printf(" Protocol: "); 00081 switch (wsapi->iProtocol) 00082 { 00083 case IPPROTO_IP: 00084 printf("IPROTO_IP\n"); 00085 break; 00086 case IPPROTO_ICMP: 00087 printf("IPROTO_ICMP\n"); 00088 break; 00089 case IPPROTO_IGMP: 00090 printf("IPROTO_IGMP\n"); 00091 break; 00092 case IPPROTO_GGP: 00093 printf("IPROTO_GGP\n"); 00094 break; 00095 case IPPROTO_TCP: 00096 printf("IPROTO_TCP\n"); 00097 break; 00098 case IPPROTO_PUP: 00099 printf("IPROTO_PUP\n"); 00100 break; 00101 case IPPROTO_UDP: 00102 printf("IPROTO_UDP\n"); 00103 break; 00104 case IPPROTO_IDP: 00105 printf("IPROTO_IDP\n"); 00106 break; 00107 case IPPROTO_ND: 00108 printf("IPROTO_ND\n"); 00109 break; 00110 case IPPROTO_RM: 00111 printf("IPPROTO_RM\n"); 00112 break; 00113 case IPPROTO_RAW: 00114 printf("IPROTO_RAW\n"); 00115 break; 00116 } 00117 break; 00118 00119 case AF_UNSPEC: 00120 printf("AF_UNSPEC\n"); 00121 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00122 break; 00123 00124 case AF_UNIX: 00125 printf("AF_UNIX\n"); 00126 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00127 break; 00128 00129 case AF_IMPLINK: 00130 printf("AF_IMPLINK\n"); 00131 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00132 break; 00133 00134 case AF_PUP: 00135 printf("AF_PUP\n"); 00136 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00137 break; 00138 00139 case AF_CHAOS: 00140 printf("AF_CHAOS\n"); 00141 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00142 break; 00143 00144 case AF_NS: 00145 printf("AF_NS or AF_IPX\n"); 00146 printf(" Protocol: "); 00147 00148 switch ( wsapi->iProtocol ) 00149 { 00150 case NSPROTO_IPX: 00151 printf("NSPROTO_IPX\n"); 00152 break; 00153 case NSPROTO_SPX: 00154 printf("NSPROTO_SPX\n"); 00155 break; 00156 case NSPROTO_SPXII: 00157 printf("NSPROTO_SPXII\n"); 00158 break; 00159 } 00160 break; 00161 00162 case AF_ISO: 00163 printf("AF_ISO or AF_OSI\n"); 00164 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00165 break; 00166 00167 case AF_ECMA: 00168 printf("AF_ECMA\n"); 00169 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00170 break; 00171 00172 case AF_DATAKIT: 00173 printf("AF_DATAKIT\n"); 00174 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00175 break; 00176 00177 case AF_CCITT: 00178 printf("AF_CCITT\n"); 00179 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00180 break; 00181 00182 case AF_SNA: 00183 printf("AF_SNA\n"); 00184 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00185 break; 00186 00187 case AF_DECnet: 00188 printf("AF_DECnet\n"); 00189 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00190 break; 00191 00192 case AF_DLI: 00193 printf("AF_DLI\n"); 00194 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00195 break; 00196 00197 case AF_LAT: 00198 printf("AF_LAT\n"); 00199 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00200 break; 00201 00202 case AF_HYLINK: 00203 printf("AF_HYLINK\n"); 00204 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00205 break; 00206 00207 case AF_APPLETALK: 00208 printf("AF_APPLETALK\n"); 00209 printf(" Protocol: "); 00210 00211 switch ( wsapi->iProtocol ) 00212 { 00213 case DDPPROTO_RTMP: 00214 printf("DDPPROTO_RTMP\n"); 00215 break; 00216 case DDPPROTO_NBP: 00217 printf("DDPPROTO_NBP\n"); 00218 break; 00219 case DDPPROTO_ATP: 00220 printf("DDPROTO_ATP\n"); 00221 break; 00222 case DDPPROTO_AEP: 00223 printf("DDPPROTO_AEP\n"); 00224 break; 00225 case DDPPROTO_RTMPRQ: 00226 printf("DDPPROTO_RTMPRQ\n"); 00227 break; 00228 case DDPPROTO_ZIP: 00229 printf("DDPPROTO_ZIP\n"); 00230 break; 00231 case DDPPROTO_ADSP: 00232 printf("DDPPROTO_ADSP\n"); 00233 break; 00234 case ATPROTO_ADSP: 00235 printf("ATPROTO_ADSP\n"); 00236 break; 00237 case ATPROTO_ATP: 00238 printf("ATPROTO_ATP\n"); 00239 break; 00240 case ATPROTO_ASP: 00241 printf("ATPROTO_ASP\n"); 00242 break; 00243 case ATPROTO_PAP: 00244 printf("ATPROTO_PAP\n"); 00245 break; 00246 } 00247 break; 00248 00249 case AF_NETBIOS: 00250 printf("AF_NETBIOS\n"); 00251 printf(" Protocol: "); 00252 printf("NetBIOS LANA %d\n", ((wsapi->iProtocol == 0x80000000) ? 0: abs(wsapi->iProtocol))); 00253 break; 00254 00255 case AF_VOICEVIEW: 00256 printf("AF_VOICEVIEW\n"); 00257 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00258 break; 00259 00260 case AF_FIREFOX: 00261 printf("AF_FIREFOX\n"); 00262 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00263 break; 00264 00265 case AF_UNKNOWN1: 00266 printf("AF_UNKNOWN1\n"); 00267 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00268 break; 00269 00270 case AF_BAN: 00271 printf("AF_BAN\n"); 00272 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00273 break; 00274 00275 case AF_ATM: 00276 printf("AF_ATM\n"); 00277 printf(" Protocol: "); 00278 00279 switch ( wsapi->iProtocol ) 00280 { 00281 case ATMPROTO_AALUSER: 00282 printf("ATMPROTO_AALUSER\n"); 00283 break; 00284 case ATMPROTO_AAL1: 00285 printf("ATMPROTO_AAL1\n"); 00286 break; 00287 case ATMPROTO_AAL2: 00288 printf("ATMPROTO_AAL2\n"); 00289 break; 00290 case ATMPROTO_AAL34: 00291 printf("ATMPROTO_AAL34\n"); 00292 break; 00293 case ATMPROTO_AAL5: 00294 printf("ATMPROTO_AAL5\n"); 00295 break; 00296 } 00297 break; 00298 00299 case AF_CLUSTER: 00300 printf("AF_CLUSTER\n"); 00301 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00302 break; 00303 case AF_12844: 00304 printf("AF_12844\n"); 00305 printf(" Protocol: UNKNOWN: %d", wsapi->iProtocol); 00306 break; 00307 case AF_IRDA: 00308 printf("AF_IRDA\n"); 00309 printf(" Protocol: "); 00310 00311 switch (wsapi->iProtocol) 00312 { 00313 case IRDA_PROTO_SOCK_STREAM: 00314 printf("IRDA_PROTO_SOCK_STREAM\n"); 00315 break; 00316 } 00317 break; 00318 00319 default: 00320 printf("Unknown: %d\n", wsapi->iAddressFamily); 00321 } 00322 00323 // 00324 // Display socket type information 00325 // 00326 00327 printf(" Socket Type: "); 00328 switch (wsapi->iSocketType) 00329 { 00330 case SOCK_STREAM: 00331 printf("SOCK_STREAM\n"); 00332 break; 00333 case SOCK_DGRAM: 00334 printf("SOCK_DGRAM\n"); 00335 break; 00336 case SOCK_RAW: 00337 printf("SOCK_RAW\n"); 00338 break; 00339 case SOCK_RDM: 00340 printf("SOCK_RDM\n"); 00341 break; 00342 case SOCK_SEQPACKET: 00343 printf("SOCK_SEQPACKET\n"); 00344 break; 00345 } 00346 00347 // 00348 // Display the various provider flags for this entry 00349 // 00350 00351 printf(" Connectionless: "); 00352 if (wsapi->dwServiceFlags1 & XP1_CONNECTIONLESS) 00353 printf("YES\n"); 00354 else 00355 printf("NO\n"); 00356 printf(" Guaranteed Delivery: "); 00357 if (wsapi->dwServiceFlags1 & XP1_GUARANTEED_DELIVERY) 00358 printf("YES\n"); 00359 else 00360 printf("NO\n"); 00361 printf(" Guaranteed Order: "); 00362 if (wsapi->dwServiceFlags1 & XP1_GUARANTEED_ORDER) 00363 printf("YES\n"); 00364 else 00365 printf("NO\n"); 00366 printf(" Message Oriented: "); 00367 if (wsapi->dwServiceFlags1 & XP1_MESSAGE_ORIENTED) 00368 printf("YES\n"); 00369 else 00370 printf("NO\n"); 00371 printf(" Pseudo Stream: "); 00372 if (wsapi->dwServiceFlags1 & XP1_PSEUDO_STREAM) 00373 printf("YES\n"); 00374 else 00375 printf("NO\n"); 00376 printf(" Graceful Close: "); 00377 if (wsapi->dwServiceFlags1 & XP1_GRACEFUL_CLOSE) 00378 printf("YES\n"); 00379 else 00380 printf("NO\n"); 00381 printf(" Expedited Data: "); 00382 if (wsapi->dwServiceFlags1 & XP1_EXPEDITED_DATA) 00383 printf("YES\n"); 00384 else 00385 printf("NO\n"); 00386 printf(" Connect Data: "); 00387 if (wsapi->dwServiceFlags1 & XP1_CONNECT_DATA) 00388 printf("YES\n"); 00389 else 00390 printf("NO\n"); 00391 printf(" Disconnect Data: "); 00392 if (wsapi->dwServiceFlags1 & XP1_DISCONNECT_DATA) 00393 printf("YES\n"); 00394 else 00395 printf("NO\n"); 00396 printf(" Supports Broadcast: "); 00397 if (wsapi->dwServiceFlags1 & XP1_SUPPORT_BROADCAST) 00398 printf("YES\n"); 00399 else 00400 printf("NO\n"); 00401 printf(" Supports Multipoint: "); 00402 if (wsapi->dwServiceFlags1 & XP1_SUPPORT_MULTIPOINT) 00403 printf("YES\n"); 00404 else 00405 printf("NO\n"); 00406 printf(" Multipoint Control Plane: "); 00407 if (wsapi->dwServiceFlags1 & XP1_MULTIPOINT_CONTROL_PLANE) 00408 printf("ROOTED\n"); 00409 else 00410 printf("NON-ROOTED\n"); 00411 printf(" Multipoint Data Plane: "); 00412 if (wsapi->dwServiceFlags1 & XP1_MULTIPOINT_DATA_PLANE) 00413 printf("ROOTED\n"); 00414 else 00415 printf("NON-ROOTED\n"); 00416 printf(" QoS Supported: "); 00417 if (wsapi->dwServiceFlags1 & XP1_QOS_SUPPORTED) 00418 printf("YES\n"); 00419 else 00420 printf("NO\n"); 00421 printf(" Unidirectional Sends: "); 00422 if (wsapi->dwServiceFlags1 & XP1_UNI_SEND) 00423 printf("YES\n"); 00424 else 00425 printf("NO\n"); 00426 printf(" Unidirection Receives: "); 00427 if (wsapi->dwServiceFlags1 & XP1_UNI_RECV) 00428 printf("YES\n"); 00429 else 00430 printf("NO\n"); 00431 printf(" IFS Handles: "); 00432 if (wsapi->dwServiceFlags1 & XP1_IFS_HANDLES) 00433 printf("YES\n"); 00434 else 00435 printf("NO\n"); 00436 printf(" Partial Messages: "); 00437 if (wsapi->dwServiceFlags1 & XP1_PARTIAL_MESSAGE) 00438 printf("YES\n"); 00439 else 00440 printf("NO\n"); 00441 printf(" Provider Flags: "); 00442 if (wsapi->dwProviderFlags & PFL_MULTIPLE_PROTO_ENTRIES) 00443 { 00444 printf("PFL_MULTIPLE_PROTO_ENTRIES "); 00445 } 00446 if (wsapi->dwProviderFlags & PFL_RECOMMENDED_PROTO_ENTRY) 00447 { 00448 printf("PFL_RECOMMENDED_PROT_ENTRY "); 00449 } 00450 if (wsapi->dwProviderFlags & PFL_HIDDEN) 00451 { 00452 printf("PFL_HIDDEN "); 00453 } 00454 if (wsapi->dwProviderFlags & PFL_MATCHES_PROTOCOL_ZERO) 00455 { 00456 printf("PFL_MATCHES_PROTOCOL_ZERO "); 00457 } 00458 if (wsapi->dwProviderFlags == 0) 00459 { 00460 printf("NONE"); 00461 } 00462 printf("\n"); 00463 00464 // 00465 // Display provider ID and catalog ID as well as LSP chain information 00466 // 00467 00468 StringFromGUID2( wsapi->ProviderId, szGuidString, MAX_PATH-1 ); 00469 00470 printf(" Provider Id: %S\n", szGuidString); 00471 printf(" Catalog Entry Id: %ld\n", wsapi->dwCatalogEntryId); 00472 printf(" Number of Chain Entries: %d {", 00473 wsapi->ProtocolChain.ChainLen); 00474 00475 for(i=0; i < wsapi->ProtocolChain.ChainLen ;i++) 00476 printf("%ld ", wsapi->ProtocolChain.ChainEntries[i]); 00477 00478 printf("}\n"); 00479 00480 // 00481 // Display the remaining information 00482 // 00483 00484 printf(" Version: %d\n", wsapi->iVersion); 00485 printf("Max Socket Address Length: %d\n", wsapi->iMaxSockAddr); 00486 printf("Min Socket Address Length: %d\n", wsapi->iMinSockAddr); 00487 printf(" Protocol Max Offset: %d\n", wsapi->iProtocolMaxOffset); 00488 00489 printf(" Network Byte Order: "); 00490 if (wsapi->iNetworkByteOrder == 0) 00491 printf("BIG-ENDIAN\n"); 00492 else 00493 printf("LITLE-ENDIAN\n"); 00494 00495 printf(" Security Scheme: "); 00496 if (wsapi->iSecurityScheme == SECURITY_PROTOCOL_NONE) 00497 printf("NONE\n"); 00498 else 00499 printf("%d\n", wsapi->iSecurityScheme); 00500 00501 printf(" Message Size: "); 00502 if (wsapi->dwMessageSize == 0) 00503 printf("N/A (Stream Oriented)\n"); 00504 else if (wsapi->dwMessageSize == 1) 00505 printf("Depended on underlying MTU\n"); 00506 else if (wsapi->dwMessageSize == 0xFFFFFFFF) 00507 printf("No limit\n"); 00508 else 00509 printf("%ld\n", wsapi->dwMessageSize); 00510 00511 printf(" Provider Reserved: %d\n", wsapi->dwProviderReserved); 00512 }
Definition at line 895 of file provider.cpp. 00898 { 00899 if ( lpProcTable->lpWSPAccept && 00900 lpProcTable->lpWSPAddressToString && 00901 lpProcTable->lpWSPAsyncSelect && 00902 lpProcTable->lpWSPBind && 00903 lpProcTable->lpWSPCancelBlockingCall && 00904 lpProcTable->lpWSPCleanup && 00905 lpProcTable->lpWSPCloseSocket && 00906 lpProcTable->lpWSPConnect && 00907 lpProcTable->lpWSPDuplicateSocket && 00908 lpProcTable->lpWSPEnumNetworkEvents && 00909 lpProcTable->lpWSPEventSelect && 00910 lpProcTable->lpWSPGetOverlappedResult && 00911 lpProcTable->lpWSPGetPeerName && 00912 lpProcTable->lpWSPGetSockOpt && 00913 lpProcTable->lpWSPGetSockName && 00914 lpProcTable->lpWSPGetQOSByName && 00915 lpProcTable->lpWSPIoctl && 00916 lpProcTable->lpWSPJoinLeaf && 00917 lpProcTable->lpWSPListen && 00918 lpProcTable->lpWSPRecv && 00919 lpProcTable->lpWSPRecvDisconnect && 00920 lpProcTable->lpWSPRecvFrom && 00921 lpProcTable->lpWSPSelect && 00922 lpProcTable->lpWSPSend && 00923 lpProcTable->lpWSPSendDisconnect && 00924 lpProcTable->lpWSPSendTo && 00925 lpProcTable->lpWSPSetSockOpt && 00926 lpProcTable->lpWSPShutdown && 00927 lpProcTable->lpWSPSocket && 00928 lpProcTable->lpWSPStringToAddress ) 00929 { 00930 return NO_ERROR; 00931 } 00932 return SOCKET_ERROR; 00933 }
Variable Documentation
Definition at line 39 of file provider.cpp.
Definition at line 42 of file provider.cpp.
Definition at line 99 of file instlsp.cpp.
|