NCB

typedef struct _NCB { /* ncb */

UCHAR ncb_command; /* command code */

UCHAR ncb_retcode; /* return code */

UCHAR ncb_lsn; /* local session number */

UCHAR ncb_num; /* number of network name */

PUCHAR ncb_buffer; /* address of message buffer */

WORD ncb_length; /* size of message buffer */

UCHAR ncb_callname[NCBNAMSZ]; /* blank-padded name of remote */

UCHAR ncb_name[NCBNAMSZ]; /* blank-padded name of local */

UCHAR ncb_rto; /* receive timeout/retry count */

UCHAR ncb_sto; /* send timeout/system timeout */

void (*ncb_post) (struct _NCB *); /* POST routine address */

UCHAR ncb_lana_num; /* lana (adapter) number */

UCHAR ncb_cmd_cplt; /* 0xff => command pending */

UCHAR ncb_reserve[10]; /* reserved, used by BIOS */

HANDLE ncb_event; /* signaled when ASYNCH completes */

} NCB, *PNCB;

The NCB structure describes a network-control block. A pointer to this structure is passed to the Netbios function.

Members

ncb_command

Contains the command code and a flag that indicates whether the NCB is processed asynchronously. The most significant bit contains the flag. If the ASYNCH constant is combined with this value (using the OR operator), the NCB is processed asynchronously. The following command codes are supported:

Code Meaning

NCBADDGRNAME (0x36) Add a group name to the local name table.
NCBADDNAME (0x30) Add a unique name to the local name table.
NCBASTAT (0x33) Retrieve the status of the adapter. When this value is specified, the ncb_buffer member points to a buffer to be filled with an ADAPTER_STATUS structure followed by an array of NAME_BUFFER structures.
NCBCALL (0x10) Open a session with another name.
NCBCANCEL (0x35) Cancel a previous command.
NCBCHAINSEND (0x17) Send the contents of two data buffers to the specified session partner. For NT, this is equivalent to NCBCHAINSENDNA.
NCBCHAINSENDNA (0x72) Send the contents of two data buffers to the specified session partner and do not wait for acknowledgment. For NT, this is equivalent to NCBCHAINSEND.
NCBDELNAME (0x31) Delete a name from the local name table.
NCBDGRECV (0x21) Receive a datagram from any name.
NCBDGRECVBC (0x23) Receive broadcast datagram from any host.
NCBDGSEND (0x20) Send datagram to a specified name.
NCBDGSENDBC (0x22) Send a broadcast datagram to every host on the LAN.
NCBFINDNAME (0x78) Determine the location of a name on the network.
NCBHANGUP (0x12) Close a specified session.
NCBLISTEN (0x11) Enable a session to be opened with another name.
NCBRECV (0x15) Receive data from the specified session partner.
NCBRECVANY (0x16) Receive data from any session corresponding to a specified name.
NCBRESET (0x32) Reset a LAN adapter. An adapter must be reset before any other NCB command will be accepted that specifies the same number in the ncb_lana_num member.
NCBSEND (0x14) Send data to the specified session partner. For NT, this is equivalent to NCBSENDNA.
NCBSENDNA (0x71) Send data to specified session partner and do not wait for an acknowledgment. For NT, this is equivalent to NCBSEND.
NCBSSTAT (0x34) Retrieve the status of the session. When this value is specified, the buffer pointed to by the ncb_buffer member is filled with a SESSION_HEADER structure followed by one or more SESSION_BUFFER structures.
NCBTRACE (0x79) Activate or deactivate NCB tracing. Support for this command in the system is optional and system-specific.
NCBUNLINK (0x70) Unlink the adapter.
NCBENUM (0x37) Enumerate LAN adapter (LANA) numbers. When this value is specified, the ncb_buffer member contains a pointer to a buffer to be filled with a LANA_ENUM structure.
NCBLANSTALERT (0x73) Notify the user of LAN failures that last for over one minute.

ncb_retcode

Specifies the return code. This value is set to NRC_PENDING while an asynchronous operation is in progress. The following return codes are possible:

Return code Meaning

NRC_GOODRET (0x00) The operation succeeded.
NRC_BUFLEN (0x01) An illegal buffer length was supplied.
NRC_ILLCMD (0x03) An illegal command was supplied.
NRC_CMDTMO (0x05) The command was timed out.
NRC_INCOMP (0x06) The message was incomplete. The application should issue another command.
NRC_BADDR (0x07) The buffer address is illegal.
NRC_SNUMOUT (0x08) The session number is out of range.
NRC_NORES (0x09) No resource was available.
NRC_SCLOSED (0x0A) The session is closed.
NRC_CMDCAN (0x0B) The command is cancelled.
NRC_DUPNAME (0x0D) A duplicate name exists in the local name table.
NRC_NAMTFUL (0x0E) The name table is full.
NRC_ACTSES (0x0F) The command completed; the name has active sessions and is now deregistered.
NRC_LOCTFUL (0x11) The local session table is full.
NRC_REMTFUL (0x12) The remote session table is full. The request to open a session was rejected.
NRC_ILLNN (0x13) An illegal name number was specified.
NRC_NOCALL (0x14) The system cannot find the name that was called.
NRC_NOWILD (0x15) Wildcard characters are not permitted in _name.
NRC_INUSES (0x16) The name was already in use on the remote adapter.
NRC_NAMERR (0x17) The name was deleted.
NRC_SABORT (0x18) The session ended abnormally.
NRC_NAMCONF (0x19) A name conflict was detected.
NRC_IFBUSY (0x21) The interface is busy.
NRC_TOOMANY (0x22) Too many commands are outstanding; the application should retry the command later.
NRC_BRIDGE (0x23) The ncb_lana_num member does not specify a valid network number.
NRC_CANOCCR (0x24) The command was completed while a cancel operation was occurring.
NRC_CANCEL (0x26) It is not valid to cancel the command.
NRC_DUPENV (0x30) The name is defined by another local process.
NRC_ENVNOTDEF (0x34) The environment is not defined. A reset command must be issued.
NRC_OSRESNOTAV (0x35) Operating system resources are exhausted. The application should retry the command later.
NRC_MAXAPPS (0x36) The maximum number of applications was exceeded.
NRC_NOSAPS (0x37) No SAPs available for netbios.
NRC_NORESOURCES (0x38) The requested resources are not available.
NRC_INVADDRESS (0x39) The NCB address is not valid.
  This return code is an extension to IBM Netbios 3.0. This return code is not returned in the NCB; instead, it is returned by the Netbios function.
NRC_INVDDID (0x3B) The NCB DDID was invalid.
NRC_LOCKFAIL (0x3C) The attempt to lock the user area failed.
NRC_OPENERR (0x3F) An error occurred during an open operation being performed by the device driver. (This return code is an extension of IBM Netbios 3.0.)
NRC_SYSTEM (0x40) A system error occurred.
NRC_PENDING (0xFF) An asynchronous operation is not yet finished.

ncb_lsn

Specifies the local session number. This number uniquely identifies a session within an environment.

ncb_num

Specifies the number of the network name. This number uniquely identifies a session within an environment. It can be the following special value:

Number Meaning

0xFF Specifies that any local network name applies.

ncb_buffer

Points to the message buffer.

ncb_length

Specifies the size (in bytes) of the message buffer.

ncb_callname

Specifies the string that contains the remote name. Trailing blanks should be supplied.

ncb_name

Specifies the string that contains the local name. Trailing blanks should be supplied.

ncb_rto

Specifies the receive time-out period (in 500-millisecond units) for the session. A value of 0 implies no time-out. Specified only for NCBRECV commands.

ncb_sto

Specifies the send time-out period (in 500-millisecond units) for the session. A value of 0 implies no time-out. Specified only for NCBSEND and NCBCHAINSEND commands.

ncb_post

Specifies the address of the routine to call when the asynchronous NCB completes. The completion routine is passed a pointer to the completed NCB.

ncb_lana_num

Specifies the LAN adapter number. This zero-based number corresponds to a particular transport provider using a particular LAN adapter board.

ncb_cmd_cplt

Specifies the command-complete flag. This value is the same as the ncb_retcode member.

ncb_reserve

Reserved. This member must be set to zero.

ncb_event

Specifies a handle to a Windows event that will be set to the signaled state when the asynchronous NCB completes. The event will not be signaled if the Netbios function returns a non-zero value.

The ncb_event member must be zero if the ncb_command member does not have the ASYNCH value set or if ncb_post is non-zero. Otherwise, NRC_ILLCMD is returned.

See Also

ADAPTER_STATUS, LANA_ENUM, NAME_BUFFER, Netbios, SESSION_HEADER