Article ID: 129316
Article Last Modified on 10/17/1999
SOCKET hSock0 = socket( AF_NETBIOS, SOCK_DGRAM, 0 ); // lana 0; SOCKET hSock1 = socket( AF_NETBIOS, SOCK_DGRAM, -1 ); // lana 1;The lana numbers are basically indices to the list of transports supported by the NetBIOS implementation. A given host has one unique lana number for every installed transport that supports NetBIOS. For example, listed below are some possible lana numbers for a typical Windows NT configuration:
Lana Transport ---------------------------------------------------------- 0 TCP/IP // lana 0 is the default NetBIOS transport 1 IPX/SPX w/NetBIOS 3 NetBEUIIn the case of a multi-homed host (a computer with multiple network adapters), the number of unique lana numbers equals the number of network transports that support NetBIOS times the number of network adapters. For example, if the computer depicted above contained two network adapters, it would have a total of 3 * 2 = 6 lana numbers.
0x00, 0x03, 0x06, 0x1f, 0x20, 0x21, 0xbe, 0xbf, 0x1b, 0x1c, 0x1d, 0x1eIssue 5:
Host A (Client) Host B (Server)
--------------- ---------------
lana Transport lana Transport
---- --------- ---- ---------
0 NetBEUI 0 TCP/IP
3 IPX/SPX <==========> 1 IPX/SPX
3 NetBEUI
This diagram illustrates several other important points about lanas. First,
a transport that has a certain lana number on one host does not necessarily
have the same lana number on other machines. Second, lana numbers do not
have to be sequential.
#include <windows.h>
#include <assert.h>
#include <nspapi.h>
#include <stdio.h>
void main()
{
DWORD cb = 0;
PROTOCOL_INFO *pPI;
BOOL pfLanas[100];
int iRes,
nLanas = sizeof(pfLanas) / sizeof(BOOL);
// Specify NULL for lpiProtocols to enumerate all protocols.
// First, determine the output buffer size.
iRes = EnumProtocols( NULL, NULL, &cb );
// Verify the expected error was received.
assert( iRes == -1 && GetLastError() == ERROR_INSUFFICIENT_BUFFER );
if (!cb)
{
printf( "No available NetBIOS transports.\n");
return;
}
// Allocate a buffer of the specified size.
pPI = (PROTOCOL_INFO*) malloc( cb );
// Enumerate all protocols.
iRes = EnumProtocols( NULL, pPI, &cb );
// EnumProtocols() lists each lana number twice, once for
// SOCK_DGRAM and once for SOCK_SEQPACKET. Set a flag in pfLanas
// so unique lanas can be identified.
memset( pfLanas, 0, sizeof( pfLanas ));
while (iRes > 0)
{
// Scan protocols looking for AF_NETBIOS.
if ( pPI[--iRes].iAddressFamily == AF_NETBIOS )
// found one
pfLanas[ abs(pPI[iRes].iProtocol) ] = TRUE;
}
printf( "Available NetBIOS lana numbers: " );
while( nLanas-- )
if ( pfLanas[nLanas] )
printf( "%d ", nLanas );
printf( "\n" );
free( pPI );
return;
}
Issue 6:
Keywords: kbinfo kbwinsock kbapi kbnetbios kbnetwork KB129316