Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Interrupts & Ports - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

        Net Bios interface

        Calling the Net Bios is accomplished by building a Net Bios
        Control Block (NCB), and execute an INT 5Ch with registers ES:BX
        containing the address of the NCB. When control is returned,
        only AX is changed.

        The NCB is 64 bytes long and is shown in Table 2. The COMMAND
        field describes the basic function of the command. All commands
        are listed in Table 1. On selected commands, the high order bit
        of the COMMAND field can be set to indicate the "no-wait" mode.
        This feature, coupled with the value contained in the POST field,
        results in three distinct ways that the Net Bios can signal
        command completion:

             1.   No-wait bit not set. In this case, the post address is
                  ignored and control will not be returned from INT 5Ch
                  until after the command has completed. The RETCODE
                  field and the AL register will contain the result of
                  the operation (see Table 4 for error codes).

             2.   No-wait bit set and POST contains 0:0. The Net Bios
                  will (after minimum processing) return immediately,
                  even though the command may not have completed. On
                  return, the AL register will contain an "immediate
                  error" code or 0. If AL is not 0, then the command
                  could not be queued (e.g., invalid COMMAND code). If
                  AL is 0, then the process should poll the CMD_DONE
                  field of the NCB, waiting for some value other than
                  0FFh. When CMD_DONE is not equal to 0FFh, the command
                  has completed and all other NCB fields are valid.

             3.   No-wait bit set and POST contains the address of a user
                  routine. The Net Bios will return immediately, even
                  though the command may not have completed. On return,
                  the AL register will contain an "immediate error" code
                  or 0. If AL is not 0, then the command could not be
                  queued (e.g., invalid COMMAND code). If AL is 0, then
                  the user's POST routine will be called after the
                  command is completed. When the POST routine is called,
                  interrupts are off, the stack is set for an IRET, and
                  ES:BX contains the address of the completed NCB.

        Table 1 shows NCB COMMAND field codes, Table 3 shows field usage
        by command, and Table 4 shows error codes returned in AL and
        RETCODE.

        Typically, a POST routine can issue another Net Bios command.
        However, some implementations may return an immediate error 21h
        (interface busy) on nested interrupt conditions. If the user is
        issuing commands from either the POST routine or other hardware
        routines, then the user must be prepared to queue NCBs that need
        starting and start them from, say, a timer tick whenever an
        interface busy error is encountered. This same logic can also
        cover the case where the Net Bios is temporarily out of resources
        (immediate error 09h). Normally, do not always queue the NCBs
        for later starting (may dramatically reduce throughput), only do
        it when the errors 21h or 09h are encountered.

        The user POST routine should be as short as possible and no
        registers should be changed. Interrupts may be enabled in the
        POST routine.

        In some cases, the user's POST routine will be called before
        control is returned from the INT 5Ch that started the command.

        A typical sequence of Net Bios commands is listed below.

             1. ADD NAME
             2. CALL
             3. SEND
             4. RECEIVE
             5. Repeat 3,4 as needed
             6. HANG UP
             7. DELETE NAME

        Depending on the design of the application, the process doing the
        above may send a specific message to the other end informing it
        of the intention to HANG UP. This would not be necessary if the
        other end was executing the following sequence.

             1. ADD NAME
             2. LISTEN
             3. RECEIVE
             4. If time-out goto 3
             5. If session lost goto 2
             6. SEND
             7. Goto 3

        Entry:
          ES:BX -> pointer to Network Control Block
        Return:
          AL = Error Code (0 if none)

        Functions:
        10   Call                 Attempt to open session with another name
        11   Listen               Listen for a `Call' to come in
        12   Hang up              End a session
        14   Send                 Send data as a message within specific
                                  session
        15   Receive              Receive a message
        16   Receive any          Receive a message from any open session
        17   Chain send           Concatenate two buffers and send as a
                                  message

        20   Send datagram        Send a datagram (wow!)
        21   Receive datagram     Receive a datagram
        22   Send broadcast       Send a broadcast datagram
             datagram
        23   Receive broadcast    Receive a broadcast datagram
             datagram

        30   Add name             Add a unique name to the local name table
        31   Delete name          Delete a name from the local name table
        32   Reset                Reset the LAN adapter, clear name and
                                  sessions tables. Use with GREAT care!
        33   Adapter status       Get information about the LAN adapter,
                                  names.
        34   Session status       Get information about all sessions
                                  associated with a specific name or all
                                  names.
        35   Cancel               Cancel a pending command
        36   Add group name       Add a group name to the local name table

        70   Unlink               Terminate a remote boot operation (end
                                  INT 13h redirection)



        ---1---|--2-|---3---|7
        0124567|0123|0123456|0
        -------+----+-------+-------------------------------------------
        IIIIIII|IIII|IIIIIII|I   00      Command
        OOOOOOO|OOOO|OOOOOOO|O   01      Return code
        OOIIIOI|    |  I    |    02      Local session number
             I |IIII|O I   O|    03      Number of a local name
           IIII|IIII|   III |    04-07   Pointer to message buffer
           IBBI|IBIB|   BB  |    08-09   Message buffer length
        IB    I|IO O|   I   |    0A-19   Callname (see below)
        II     |    |II  I I|    1A-29   Source (local) name
        II     |    |       |    2A      Receive timeout in half seconds
        II     |    |       |    2B      Send timeout in helf seconds
        IIIIIII|IIII|II II I|    2C-2F   Interrupt completion routine address
        IIIIIII|IIII|IIIIIII|I   30      Number of LAN adapter (0 or 1)
        OOOOOOO|OOOO|OOOOOOO|O   31      Command complete flag
               |    |       |    32-3F   14d bytes reserved (Internal use only)

        Callname
          Normal use:
            0A-19   Network name
          Chain send:
            0A-0B   Length of next buffer in chain
            0C-0F   Pointer to next buffer in chain

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson