This chapter is for RPC programmers. It documents the port mapper routines in the RPC Run-Time Library (RTL). These routines are the programming interface to RPC.
Port Mapper routines provide a simple callable interface to the Port Mapper. They allow you to request Port Mapper services and information about port mappings. The table below summarizes the purpose of each Port Mapper routine.
Routine |
Purpose |
pmap_getmaps |
Returns a list of Port Mappings for the specified host. |
pmap_getport |
Returns the port number on which a specified service is waiting. |
pmap_rmtcall |
Requests the Port Mapper on a remote host to call a procedure on that host. |
pmap_set |
Registers a remote service with a remote port. |
pmap_unset |
Unregisters a service so it is no longer mapped to a port. |
Port Mapper routines use many of the same arguments as client routines. See Table 9-1 in the RPC RTL Client Routines chapter for a list of these arguments.
The following sections describe each Port
Mapper routine in detail.
Returns a list of Port Mappings for the specified host.
Format
struct pmaplist *pmap_getmaps (struct sockaddr_in *addr);
Argument
addr
Address of a structure containing the internet address of the host whose Port Mapper is being called.
Description
The pmap_getmaps routine returns a list of current RPC server-to-Port Mappings on the host at addr. The list structure is defined in the PMAP_PROT.H file.
The MULTINET SHOW /RPC_PORTMAP command uses this routine.
Diagnostics
If an error occurs (for example, pmap_getmaps cannot get a list of Port Mappings, the internet address is invalid, or the remote Port Mapper does not exist), the routine returns either NULL or the address of the list.
See Also
pmap_getport,
pmap_set, pmap_unset
Returns the port number on which a specified service is waiting.
Format
u_short pmap_getport (struct
sockaddr_in *addr,
u_long prognum, u_long versnum, u_long protocol);
Arguments
addr
Address of a structure containing the internet address of the remote host on which the server resides.
prognum, versnum, protocol
See Table 9-1 in the RPC RTL Client Routines chapter for a list of these arguments.
Diagnostics
If the requested mapping does not exist or the routine fails to contact the remote Port Mapper, the routine returns either the port number or zero.
The pmap_getport routine uses the global variable rpc_createerr. rpc_createerr is a structure that contains the most recent service creation error. Use rpc_createerr if you want the service program to handle the error. The value of rpc_createerr is set by any RPC server creation routine that does not succeed.
The rpc_createerr variable is defined in the CLNT.H file.
See Also
pmap_getmaps,
pmap_set, pmap_unset
Requests the Port Mapper on a remote host to call a procedure on that host.
Format
enum clnt_stat pmap_rmtcall
(struct sockaddr_in *addr,
u_long prognum, u_long versnum, u_long procnum,
xdrproc_t inproc, u_char *in, xdrproc_t outproc, u_char *out,
struct
timeval tout, u_long *portp);
Arguments
addr
Address of a structure containing the internet address of the remote host on which the server resides.
prognum, versnum, procnum, inproc, in, outproc, out
See Table 9-1 in the RPC RTL Client Routines chapter for a list of these arguments.
tout
Time allowed for the results to return to the client, in seconds and microseconds.
portp
Address where pmap_rmtcall will write the port number of the remote service.
Description
The pmap_rmtcall routine allows you to get a port number and call a remote procedure in one call. The routine requests a remote Port Mapper to call a prognum, versnum, and procnum on the Port Mapper's host. The remote procedure call uses the UDP transport.
If pmap_rmtcall succeeds, it changes portp to contain the port number of the remote service.
After calling the pmap_rmtcall routine, you may call the clnt_perrno / clnt_sperrno routine.
Diagnostics
This routine returns diagnostic values defined in the CLNT.H file for enum clnt_stat.
See Also
clnt_broadcast, clnt_perrno /
clnt_sperrno
Registers a remote service with a remote port.
Format
bool_t pmap_set (u_long prognum,
u_long versnum,
u_long protocol, u_short port);
Arguments
prognum, versnum, protocol
See Table 9-1 in the RPC RTL Client Routines chapter for a list of these arguments.
port
Remote port number.
Description
The pmap_set routine calls the local Port Mapper to tell it which port and protocol the prognum, versnum is using.
You are not likely to use pmap_set, because svc_register calls it.
Diagnostics
The pmap_set routine returns TRUE if it succeeds, and FALSE if it fails.
See Also
pmap_getport,
pmap_getmaps, pmap_unset, svc_register
Unregisters a service so it is no longer mapped it to a port.
Format
bool_t pmap_unset (u_long prognum, u_long versnum);
Arguments
prognum, versnum
See Table 9-1 in the RPC RTL Client Routines chapter for a list of these arguments.
Description
The pmap_unset routine calls the local Port Mapper and, for all protocols, removes the prognum and versnum from the list that maps servers to ports.
You are not likely to use pmap_unset, because svc_unregister calls it.
Diagnostics
The pmap_unset routine returns TRUE if it succeeds, FALSE if it fails.
See Also
pmap_getport, pmap_getmaps, pmap_set, svc_unregister