10. RPC RTL Port Mapper Routines

Introduction

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

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 Arguments

Port Mapper routines use many of the same arguments as client routines. See the Common Arguments table in the RPC RTL Client Routines chapter for a list of these arguments.

The following sections describe each Port Mapper routine in detail.

 

 

 

 


 

pmap_getmaps

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.

 

Returns

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.

 

 

 

 

 


 

pmap_getport

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 the Common Arguments table in the RPC RTL Client Routines chapter for a list of these arguments.

 

Returns

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.

 

 

 

 

 


 

pmap_rmtcall

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 the Common Arguments table 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.

 

Returns

This routine returns diagnostic values defined in the CLNT.H file for enum clnt_stat.

 

 

 

 

 


 

pmap_set

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 the Common Arguments table 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.

 

Returns

The pmap_set routine returns TRUE if it succeeds, and FALSE if it fails.

 

 

 

 

 


 

pmap_unset

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 the Common Arguments table 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.

 

Returns

The pmap_unset routine returns TRUE if it succeeds, FALSE if it fails.