AdvertiseService(3sapd)


AdvertiseService -- advertise service of specific type on internetwork

Synopsis

#include <sap_dos.h> 

int AdvertiseService(uint16 ServerType, char *ServerName, uint8 *Socket);

Description

AdvertiseService is compatible with native NetWare® and it causes the named server to be advertised by the SAP daemon. This call needs to be made only once to start the advertising process.


NOTE: This function is supported only when the SAP daemon is running.

This function does not use mapped memory, but sends a message via the protocol stack to the SAP daemon. The message is acknowledged by the SAP daemon to ensure that it was received.

Only the root user has permission to advertise using the SAP_ADVERTISE_FOREVER flag, and only root can unadvertise a server advertised with this flag.

When a server is advertised with the SAP_ADVERTISE_FOREVER flag, the server description is written to /etc/netware/sapouts. When NetWare services are started, this file is read and the services are automatically readvertised. Servers can be removed from sapouts only via a call to SAPAdvertiseMyServer(3sapd) with the Action flag set to SAP_STOP_ADVERTISING.

To obtain a list of servers that are permanently advertised, use the SAPListPermanentServers(3sapd) function.

The service will be advertised until it is discontinued or until the advertising process terminates.

Parameters

(IN) ServerType
Specifies the type of server for the server's service class.

(IN) ServerName
Pointer to the NULL-terminated name of the server to be advertised (maximum of 48 characters, including NULL).

(IN) Socket
Pointer to a 2-byte array that specifies the socket number at which the advertised service may be accessed.

Usage

If SAP_ADVERTISE is set in Action, the SAP daemon places the PID of the advertising process in the advertise table entry.

If SAP_ADVERTISE_FOREVER is set in Action, the SAP daemon places its own PID in the table.

The SAP daemon places the PID of the advertising process in the advertise table entry. The kill(2) system call with arguments ``(pid, 0)'' is used to determine if the process that made the AdvertiseService call is still active.

As long as the process is active, the services for that process will be advertised. When the process terminates, the services for that process will be marked as HOPS = 16, or down.

The ServerType argument specifies the type of server to be advertised. For some common values, see the table below.

Defined Constants for SAP daemon Value Server Type
FILE_SERVER_TYPE 0x0004 NetWare Server
PRINT_SERVER_TYPE 0x0047 Print Server
BTRIEVE_SERVER_TYPE 0x004B Btrieve Server
ACCESS_SERVER_TYPE 0x0098 NetWare Access Server
OLD_NVT_SERVER_TYPE 0x009E NVT over NVT protocol
I386_SERVER_TYPE 0x0107 386 NetWare (3.x)
SPX_NVT_SERVER_TYPE 0x0247 NVT over SPX/SPXII protocol
TIME_SYNC_SERVER_TYPE 0x026B Time Synchronization
DIRECTORY_SERVER_TYPE 0x0278 Directory Server

 
 ---------------------------------------------------------------------------------- 
| Defined Constants for SAP daemon|  Value          |  Server Type                | 
|---------------------------------|-----------------|-----------------------------| 
| FILE_SERVER_TYPE                |  0x0004         |  NetWare Server             | 
|---------------------------------|-----------------|-----------------------------| 
| PRINT_SERVER_TYPE               |  0x0047         |  Print Server               | 
|---------------------------------|-----------------|-----------------------------| 
| BTRIEVE_SERVER_TYPE             |  0x004B         |  Btrieve Server             | 
|---------------------------------|-----------------|-----------------------------| 
| ACCESS_SERVER_TYPE              |  0x0098         |  NetWare Access Server      | 
|---------------------------------|-----------------|-----------------------------| 
| OLD_NVT_SERVER_TYPE             |  0x009E         |  NVT over NVT protocol      | 
|---------------------------------|-----------------|-----------------------------| 
| I386_SERVER_TYPE                |  0x0107         |  386 NetWare (3.x)          | 
|---------------------------------|-----------------|-----------------------------| 
| SPX_NVT_SERVER_TYPE             |  0x0247         |  NVT over SPX/SPXII protocol| 
|---------------------------------|-----------------|-----------------------------| 
| TIME_SYNC_SERVER_TYPE           |  0x026B         |  Time Synchronization       | 
|---------------------------------|-----------------|-----------------------------| 
| DIRECTORY_SERVER_TYPE           |  0x0278         |  Directory Server           | 
|---------------------------------|-----------------|-----------------------------| 
The ServerName argument specifies the NULL-terminated name of the server to be advertised. If the name contained in ServerName is not less than SAP_MAX_SERVER_NAME_LENGTH, the request to advertise the server will be rejected.

The Socket argument is the socket number to which clients may make service requests. If Socket is zero (0), an invalid socket error will be returned.

Return values

If successful, the function returns a zero (0); otherwise, it returns a negative number which is the negative of the error code.

0
successful

-3
invalid Action flag (see SAPAdvertiseMyServer(3sapd))

-7
unable to obtain NetWare configuration file path

-8
invalid socket

-10
not supported (SAP daemon not running)

-11
service in use; try again

-40
unable to allocate local memory

-42
server to unadvertise not found

-43
no permission to advertise/unadvertise server

Examples

   strcpy (ServerName, "MY_SERVER"); 
   Socket[0] = 0x40; 
   Socket[1] = 0x47; 
   ServerType = PRINT_SERVER_TYPE; 
   ret = AdvertiseService (ServerType, ServerName, Socket); 

References

SAPAdvertiseMyServer(3sapd), ShutdownSAP(3sapd)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.