Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

LAN Programming

Applies to: v10

Novell/IPX programming is DOS-era. v10 still ships IPX.H, but nothing in the sources states that the IPX channel support described here works in v10: unverified.

Socket Numbers from Novell

The sixteen socket numbers 80BB through 80C2 and 86D0 through 86D7 (hexadecimal) are registered with Novell by Galacticomm for use in Worldgroup software. Novell assigns “well-known” socket numbers for released software out of the range 8000 to FFFF. Alternatively, socket numbers 4000 through 7FFF are available for dynamic or experimental usage. Socket numbers 0000 through 3FFF are reserved by Novell, and may be used in accordance with Novell’s instructions (e.g. such as for socket 0452, Service Advertising Protocol).

A value of zero for the socket parameter of btusdf() means pick an available dynamic socket number (4000 to 7FFF). In this case, the actual socket number assigned is available in the global integer lansop (page 27).

Byte Order

You will encounter a socket number with reversed byte order when you are dealing with the IPX headers yourself on IPX Virtual channels in raw-packet mode (page 195).

...

This simply swaps the two bytes of a 16-bit int or unsigned variable.

Multiple Channels on the Same Local Socket

You can define several channels or several channel groups on the same local socket number if you follow a few rules.

...

You can have several SPX connections on one network/node/socket talking one-to-one with several SPX connections on another network/node/socket. You cannot do this with IPX, however. The only way IPX has of distinguishing what channel an incoming IPX packet is for is the local socket (of course) and the network/node/socket that the packet originated from. SPX has connection ID’s to distinguish who’s talking to who, and there can be several on one socket. To have multiple IPX connections between two nodes using GSBL, either the local end, the remote end, or both, must use separate sockets.

LAN Channel State-Machines

IPX Direct Circuit Call

Terminating:

bturst(chan); (direct circuit address is subsequently undefined)

...

IPX direct channels are always in the “communicating” state.

IPX Virtual Circuit Call

Terminating:

bturst(chan); (channel reverts to raw-packet mode)

...

raw-packet mode

communicating

SPX Call

Terminating when in session:

...

connection established

terminating

The SPX Channel State-Machine

Each SPX channel is always in one of these five states:

...

If either party abruptly aborts the connection with bturst(), the other party will eventually get a status 39. The aborting party will get no special status code.

Idle SPX Channel

All SPX channels become idle immediately after any of the following:

...

Definition by btusdf() (only allowed once per program load)Reset by bturst() (may be done at any time)Status 31: connection explicitly terminated by the remote partyStatus 39: watchdog termination, meaning the other party has just disappeared, or some other transmit or connection error (see page 141)When a channel is idle, and only when a channel is idle, you can issue dial-out or listen commands.

Listening SPX Channel

After issuing the listen command (e.g. btucmd(chan,"L")), the channel is in the listening state, and ready to receive an incoming call from another network party (using SPX). Status 34 indicates when such a call has come in and been completed. In that case, the channel moves to the connected state.

The listening state has no timeout, and a channel may remain in the listening state indefinitely. To give up waiting for an incoming call, and return a channel to the idle state, call bturst().

Outdialing SPX Channel

After issuing the dial-out command (e.g. btucmd(chan,"W...M")), the channel is in the outdialing state, and trying to make connection with the network address specified in the dial-out command. Status 35 indicates when the call has gone through and the channel is in the connected state.

The dial-out command may timeout, in which case a status 39 indicates that the call is aborted and the channel is reverting to the idle state. To give up waiting for an outgoing call to complete, and return a channel to the idle state, call bturst().

Connected SPX Channel

After an SPX channel has established a connection with another party on the network, you can transmit to the party (btuxmt(), btuxct()) and receive from it (btuinp(), btuict(), btuica()). Now most of the hardware specifics vanish, and the channel acts much like any other channel on the GSBL.

SPX connections that have been completed (via status 34 or 35) can end in one of four ways:

    Explicitly, by issuing the T command and then waiting for status 36Remotely, by receiving a status 31 (other side terminated — see page 139)Abortively, by resetting the channel (bturst())Unexpectedly, by receiving a status 39 (watchdog abort)Terminating SPX Channel

    When you issue the terminate command (e.g. btucmd(chan,"T")), the channel moves to the terminating state. This is the polite way to end a connection, because the SPX system tries to make sure the other party knows the connection is ending. To end a connection quickly, with no muss and no fuss, just call bturst(), and the channel moves immediately to the idle state.

    ...

    On the other hand, a status 39 indicates that the termination notice was not acknowledged, and we can’t be sure what the other party thinks. After a status 39, the channel ends up in the idle state.

    IPX Virtual Circuits in Raw Packet Mode

                          ___________                                                       /      /     0|  chksum   |  (set by IPX)
            |      |      |___________|
            |      |     2|  length   |  Total number of bytes, incl header
            |      |      |___________|  Range 30-576, WARNING: MSB FIRST!
            |      |     4|  trnspt   |  (set by IPX)
            |      |     5|  paktyp   |  Packet type, 4=IPX packets
            |      |     6|           |
            |      |      |  dstnet   |  Destination network, 4 binary                      |      |      |  bytes,   |  right-justified, and zero-
            |      |      |___________|  filled
            |      |    10|           |
            |      |      |           |
            |      |      |  dstnod   |  Destination node, 6 binary bytes,
            |      |      |           |  right-justified, and zero-filled
            |     30      |           |
            |   bytes     |___________|                                             |      |    16|  dstsoc   |  Destination socket                                 |      |      |___________|  WARNING: MOST SIGNIFICANT BYTE FIRST!                      |      |    18|           |
            30     |      |  srcnet   |  Source network, 4 binary bytes,                    to     |      |           |  right-justified, and zero-filled           576    |      |___________|
            bytes  |    22|           |
            |      |      |           |
            |      |      |  srcnod   |  Source node, 6 binary bytes,
            |      |      |           |  right-justified, and zero-filled
            |      |      |           |
            |      |      |___________|
            |      |    28|  srcsoc   |  Source socket
            |      \      |___________|  WARNING: MOST SIGNIFICANT BYTE FIRST!
            |           30|           |
            |             |           |
            |             |           |
            |             |  datbuf   |  Data buffer, containing 0 to 546
            |             |           |  bytes
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            |             |           |
            \             |___________|
    Figure 6-1: IPX Virtual Raw Packet Format

    Before transmitting a raw IPX packet, (that is, before transmitting a packet on an IPX Virtual channel in raw-packet mode), you must set the following fields of the packet:

    ...

    srcnod Source node

    srcsoc Source socket

    Incomplete Packets Under Raw-Packet Mode

    WARNING: You can only transmit complete packets in raw-packet mode. Fill the length field (in hi-lo byte order) with the total number of bytes in the packet, including the IPX header. The GSBL will use this field to determine packet boundaries. If you return to btuscn() in your main loop with a partial packet in the output buffer, the packet may be lost.

    ...

    This code is an excerpt only (btusiz(), btuitz(), btusdf(), btuend() calls are all essential but they are not shown above). And the while-loop should really have a timeout. And you would rarely call btuscn() only inside a loop like that. But this should give you an idea of what’s involved in this little trick to detect total completion of raw packet transmission.

    IPX Raw-Packet Transmit Example

    For example, let’s say you wanted to transmit the alphabet on an IPX Virtual channel in raw-packet mode to socket 4007 hex on node 2 of network 1. Assume you are using local socket 5008 hex. Here is code that would do this:

    ...

    The call to btusdf() defines one IPX Virtual channel using socket 5008 hex, with 2 ECBs. Note that the specification of the socket number here uses natural (Intel) byte order.

    Galacticomm Terminal Configuration (GTC) Protocol

    GTC enables one GSBL-based program to tell another that it is willing to preprocess the other’s ASCII input.

    ...

    These input modes are also the status codes that will eventually appear to the terminal application program when it calls btusts(). When the status code is 43 or 44, another status byte follows immediately, which is the input line length, where 0 is unlimited. See starting on page 137 for more details on these status codes.

    ctrl+S Pause with GTC

    Also we recommend that a terminal program locally process the ctrl+S pause of server output. This function cannot be handled by the server due to packetization: by the time the server would get a ctrl+S, it may have already shipped out several huge packets.