DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Developing applications over IPX/SPX using TLI

SAP packets

SAP is implemented using Novell's IPX datagram protocol. The SAP information for querying or broadcasting servers becomes the data portion of the IPX packet.

Some of the fields in the packet are byte-order sensitive, and the data must be sent in high-to-low byte order. See ``Network byte ordering'' for more information.

The structure of a SAP packet is described in ``Fields in a SAP packet''.

Fields in a SAP packet

Offset Field Type* Byte order
0 IPX header uint8[30] N/A
30 SAP operation uint16 high-to-low
32 SAP data varies  

*
A uint8 is an unsigned char.
A uint16 is an unsigned short.


IPX header
is 30 bytes and contains fields for: checksum, length, transport control, packet type, destination network, destination node, destination socket, source network, source node, source socket. For more information about the IPX header, see the Networking Guide or ``Using the IPX protocol''.

SAP operation
determines the format of the rest of the packet. This field supports five query/response types:

SAP data
varies in length and information depending upon the SAP operation. For example, query packets have 2 bytes of SAP data, whereas a response packet can have up to 448 bytes of SAP data.

SAP query packets

SAP query packets are used to determine the identities of servers on the network. Client applications for SCO IPX/SPX use SAP queries to obtain the addresses of available servers. With the address, the client application can establish a session with a server.

Application servers usually do not use SAP queries. However, if the application server needs to establish a session with another server, the application server would use a SAP query to obtain the address of another server.

The structure of a SAP query packet is described in ``SAP query packet structure''.

SAP query packet structure

Offset Field Type* Byte order
0 IPX header uint8[30] N/A
30 SAP query type uint16 high-to-low
32 Server Type uint16 high-to-low

*
A uint8 is an unsigned char.
A uint16 is an unsigned short.


SAP query type
This field is set to 0x0001 for a General Service Query (SAP_GSQ) and to 0x0003 for a Nearest Service Query (SAP_NSQ).

A General Service Query (SAP_GSQ 0x0001) is used to query all local servers and routers. The query can be for any server or for a server of a particular type.

A Nearest Server Query (SAP_NSQ 0x0003) is used to query for the nearest server. The query can be for all servers or for all servers of a particular type.


Server type
This field follows the SAP Query Type field and is used to differentiate the types of servers. Server types are bindery object types and are assigned by Novell. See ``Novell object types'' for more about Novell object types.

SAP response packets

There are two types of SAP responses: a General Service Response and a Nearest Server Response. Each type of response packet has a SAP response type and at least one SAP SIS (Server Information Structure). The packet can have up to seven SISs.

The structure of a SAP response packet is described in ``SAP response packet structure''.

SAP response packet structure

Offset Field Type* Byte order
0 IPX header uint8[30] N/A
30 Response type uint16 high-to-low
32 Server Information Structures SIS[7] high-to-low

*
A uint8 is an unsigned char.
A uint16 is an unsigned short.


Response Type
is set to 0x0002 (SAP_GSR) for a General Service Response or to 0x0004 (SAP_NSR) for a Nearest Server Response.

The General Service Response packet is sent to answer a General Service Query packet. SAPD responds to all General Service Query packets on behalf of all SCO IPX/SPX servers and all application servers that use SAPD.

The Nearest Server Response packet is sent to answer a Nearest Server Query packet. This packet usually contains just one SIS. SAPD finds the nearest server of the requested type. If SAPD determines it is the best source for information about the server, it responds to the query.


Server Information Structure
contains an array of up to seven SISs. The first structure in the packet begins at offset 32. The number of Server Information Structures that are passed can be determined by the length of the IPX packet. Subtract 32 from the length of the packet (30 for the IPX header and 2 for the response type). Then divide the remainder by the size of the Server Information Structure (64).

Each Server Information Structure contains information for a particular advertising server. The structure of an SIS is described in ``The format of a Server Information Structure''.

The format of a Server Information Structure

Offset Field Type* Byte order
0 Server type uint16 high-to-low
2 Server name char[48] N/A
50 Server IPX address uint8[12] high-to-low
62 Intermediate networks uint16 high-to-low

*
A uint8 is an unsigned char.
A uint16 is an unsigned short.


Server type
contains the object type of the advertising server. See ``Novell object types'' for more about Novell object types.

Server name
contains the name of the advertising server (up to a 48-character string)

Server IPX address
is the IPX address of the server and contains three fields: network, node, and socket. See ``IPX addresses'' for more about IPX addresses.

Intermediate networks
indicates the number of routers that exist between the client and the server. This is equivalent to the hop count.

Periodic information broadcast packets

Periodic broadcast packets are used to advertise that a service is available and to remove services that are no longer available. When a server first comes up, it sends out one of these packets to let the SAP agents know that its services are now available. The SAP agents use this first broadcast to add the server to their Server Information tables and to echo the new server information to all their networks.

The server then sends out a periodic broadcast every 60 seconds to let the SAP agents know that its services are still available. SAP agents use these broadcasts to keep their Server Information tables up-to-date. Any server or service that does not send a broadcast for 3 minutes is presumed to be ``down''. That server's information is then removed from the SAP agent's table, and the SAP agent sends out a broadcast indicating that the server is down.

When a server is going down, the server sends a broadcast packet with the ``Intermediate networks'' field set to 16. This value signals SAP agents to remove that server from their tables.

A Periodic Broadcast packet has the same format as a General Service Response packet. See ``SAP response packets'' for more information. The fields in a Periodic Broadcast packet are:


Response type
can be set to either SAP_PIB (0x0002) or SAP_GSR (0x0002).

Server Information Structure
contains the IPX address (network, node, and socket) of the server being advertised. A Periodic Broadcast packet always contains exactly one SIS (Server Information Structure).

Server network
contains the network number of the server. For application servers loaded on SCO IPX/SPX servers, the network number is the file server's internal network number.

Server node
contains the node number of the server. For application servers loaded on SCO IPX/SPX servers, the node number is always 0x000000000001.

Server socket
contains the socket number that the application server has acquired to service clients. Application servers should acquire two socket numbers, one for advertising and one for servicing client connection requests.

``An application server's address'' illustrates such an application server loaded on a SCO IPX/SPX server.

An application server's address


Using the values given in ``An application server's address'', the application server would set the server IPX address in its Periodic Broadcast packets to:

Server network: 0x00D0C000
Server node: 0x000000000001
Server socket: 0x4002


Next topic: Accessing SAP
Previous topic: Configuring and testing SAPD

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003