NetBios Structure in detail (network control block NCB)

Source: Internet
Author: User

The previous network basic programming uses the control block NCB to introduce (supplement):

In the WIN32 environment, the use of vc++6.0 for NetBIOS program development requires the use of nb30.h files and netapi32.lib static link libraries. The former defines all function declarations and constant definitions for NetBIOS, which defines the NetBIOS application.

The structure of the NCB is defined in the Nb30.h file. NCB structure definition: NCB has 64 characters, divided into 14 fields (or fields) and a 10-byte reserved domain, table 2.1 shows the NCB and its domain.

Description of the domain name and byte offset.

Detailed instructions for each command:

1. Command NetBIOS commands are used in two ways, that is, wait and non-wait (or synchronous and asynchronous). If the high order bit of the command code is 0 o'clock is the wait method, the command will block the application that commits the command to continue execution until the NetBIOS command is completed before allowing the application to continue execution. NetBIOS can only process one wait-mode command at a time. If the high-order bit of the command code is binary 1 o'clock, the command is queued internally by NetBIOS and does not prevent the application that submits the command from continuing execution. The application can see the status of the command execution by polling the command End Flag field value (see the Command End field for details). After the command is executed, the final return code is stored in the command End flag field of the NCB structure. NetBIOS can suspend several non-wait mode commands at a time.

2. After the return code command is submitted to the NetBIOS driver, the success of the command is reflected in the field. If the Return Code field value is 00h, the command succeeds. For asynchronous NetBIOS command NetBIOS will return the value FFH in the Return Code field immediately, indicating that the command is queued and is about to be executed. When the command finishes executing, the field is placed into the final return code.

3. Local session number after the session has been established with the remote application processing, the NetBIOS driver sets the field (local session number) accordingly.   In subsequent communications, if you want to communicate with remoting, local processing simply indicates the local session number in the NCB structure and no longer needs to specify the full remoting logical name in the local session number field. In the case of an adapter alone, the workstation and each processing can be up to 254 sessions at a time, as long as the relevant local session number is specified, the purpose of the session can be reached. The system retains the values 0 and 255, and does not use them as local session numbers.

4. Name number each processing on a workstation can add up to 254 logical names to the name table. After successfully adding a logical name to Lana's private name table, NetBIOS resets the name Number field value to the index value of the name in the name table (the index value is known as the moniker), which can be used in future non-connected communication with remoting. Names 0 and 255 are also reserved for the system, where the physical address of the adapter is always in the 1th item in the table.

5. Buffer address the value of the field is the address of the data buffer to be sent, or the address of the buffer in which to hold the received data.

6. Buffer length This field specifies the length of the buffer specified by the Buffer address field. When a piece of data is received, NetBIOS sets the field accordingly.

7. Call (remote) name call (remote) name is a 16-byte domain set by the application whose value is the logical name of remoting. When an application sets up a connection or sends a data sheet package to remoting, the field is set accordingly. NetBIOS fills in the field when the remote driver connection is expecting to receive local processing of the connection call. Therefore, the processing of the receive call can identify the name of the remote caller. The first byte is "*" to represent any remote name.

8. The local name local name is a 16-byte field set by the application (all bytes are useful), and its value is the logical name that is processed locally. When an application sets up a connection or sends a data sheet package to remoting, the field is set accordingly. The first byte of the field cannot be a binary 0 or an asterisk; In addition, IBM retains the first three bytes, so the first three bytes cannot be IBM. Finally, the 16th byte cannot be a value between 00h~1fh. In the LAN Manager environment, the last character (that is, the 16th byte) has a special meaning, as shown in the following table:

9. Receive timeouts when you expect a packet to be received from one or several remoting, the application can specify the maximum number of times to wait in the receive timeout (Receive time limit) field, in the space of the number of seconds. If the package is not received at the specified time, the NetBIOS driver returns an error in the Receive timeout field. If the Receive Timeout field value is 00h, the execution is blocked until a packet is received by the local processing.

10. The Send timeout send timeout (send time limit) field is similar to the Receive Timeout field, but it specifies the time to wait for the NetBIOS connection command to complete. If the specified time is exceeded, an error is returned. If the Send Timeout field value is 00h, the time limit is not specified for the send operation. At this point, the command blocks execution until either a packet is successfully sent or the NetBIOS layer stops retrying.

One. Post routine address when you submit an asynchronous command, the application can set the field. In MS-DOS, the application fills the address of the post-processing routine in the field. The so-called post-processing routine, the routine that the NetBIOS driver will invoke after the command has finished executing.

Lana number there may be more than one Lana card or network protocol (or transport driver) on one workstation, so the Lana number field in the NCB is used to indicate which network protocol on which network adapter the application wants to use. This field is called the LAN adapter number or the Lana number, and the LANA number is between 0~9.

Note: Only programs that are based on the same NetBIOS protocol can communicate with each other. Based on this, the server application should listen for the client connection on each LANA number while the program is being designed, and the application on the client computer will attempt to connect through each LANA number that is installed on the computer.

13. Command end flag The NetBIOS driver uses this field to indicate that the asynchronous command is complete. Initially, when an application submits an asynchronous command, NetBIOS resets the field value to FFH. After the command is finished, fill in the field with the final value. That is, after a non-wait command is submitted, the application can monitor (poll) The value of the field to see if the command is complete until its value is no longer FFH.

14. reserved domain NCB reserved domain is 10 bytes long reserved domain, NetBIOS may use it to return the expanded error information. In addition, NetBIOS uses it as a staging area during the process of processing a request. The application should not use a reserved domain for the NCB, because the behavior of NetBIOS will be unpredictable once it has been destroyed.

15. Event handle When you submit an asynchronous command, the application can set the field.   This field is used to hold the handle of the post-processing routine. Note: When the setting of the command domain uses the Asynch (asynchronous) flag, the setting of the domain is mutually exclusive with the setting of the Post routine address field, where one must have a domain set to 0 and the other a value other than 0.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.