You are not connected. Please login or register

View previous topic View next topic Go down  Message [Page 1 of 1]

1 The NetBIOS on Fri Apr 01, 2011 6:00 pm

mwambe

avatar
Moderator
Moderator
Purpose
A Windows-based application can use the Network Basic Input/Output System (NetBIOS) interface to communicate with applications on other computers in a network. The NetBIOS interface provides commands and support for the following services:

* Network name registration and verification
* Session establishment and termination
* Reliable connection-oriented data transfer
* Unreliable connectionless data transfer (datagram)
* Protocol and adapter monitoring and management

The NetBIOS interface exposes an explicit set of commands that are submitted through a structure known as the network control block (NCB). An application can issue NetBIOS commands over any protocol that supports the NetBIOS interface.

Using the NetBIOS Interface:
The following examples illustrate using the NetBIOS interface.

* Listing All NetBIOS Names on a LANA
* Getting the MAC Address for an Ethernet Adapter

-You can use the Netbios function to get the Media Access Control (MAC) address for an ethernet adapter if your card is bound to NetBIOS. The following example uses the NCBASTAT command, providing an asterisk (*) as the name in the ncb_callname member of the NCB structure.
CODE:

#include
#include
#include
#include
#include

#pragma comment(lib, "netapi32.lib")

typedef struct _ASTAT_
{
ADAPTER_STATUS adapt;
NAME_BUFFER NameBuff [30];
}ASTAT, * PASTAT;

ASTAT Adapter;

void main (void)
{
NCB ncb;
UCHAR uRetCode;
memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBRESET;
ncb.ncb_lana_num = 0;

uRetCode = Netbios( &ncb );
printf( "The NCBRESET return code is: 0x%x \n", uRetCode );

memset( &ncb, 0, sizeof(ncb) );
ncb.ncb_command = NCBASTAT;
ncb.ncb_lana_num = 0;

memcpy( &ncb.ncb_callname, "* ", 16 );
ncb.ncb_buffer = (UCHAR*) &Adapter;
ncb.ncb_length = sizeof(Adapter);

uRetCode = Netbios( &ncb );
printf( "The NCBASTAT return code is: 0x%x \n", uRetCode );
if ( uRetCode == 0 )
{
printf( "The Ethernet Number is: %02x%02x%02x%02x%02x%02x\n",
Adapter.adapt.adapter_address[0],
Adapter.adapt.adapter_address[1],
Adapter.adapt.adapter_address[2],
Adapter.adapt.adapter_address[3],
Adapter.adapt.adapter_address[4],
Adapter.adapt.adapter_address[5] );
}
}



Netbios Function

The Netbios function interprets and executes the specified network control block (NCB).
The Netbios function is provided primarily for applications that were written for the NetBIOS interface and need to be ported to Windows. Applications not requiring compatibility with NetBIOS should use other interfaces, such as Windows Sockets, mailslots, named pipes, RPC, or distributed COM to accomplish tasks similar to those supported by NetBIOS. These other interfaces are more flexible and portable.

Syntax

UCHAR Netbios(
PNCB pcnb
);

Reference:http://demwambe.blogspot.com/

http://demwambe.blogspot.com/

View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

 
ReedzSolution © 2011 | StaffList | Powered by: Forumotion

Free forum | © PunBB | Free forum support | Contact | Report an abuse | Free forum