Previous | Contents | Index |
Returns the local host's internet address.
#include <rpc/rpc.h>
void get_myaddress(struct sockaddr_in *addr);
addr
A pointer to a sockaddr_in structure that the routine will load with the internet address of the host where the local procedure resides.
Puts the local host's internet address into addr without doing any name translation. The port number is always set to htons (PMAPPORT).
None
Returns the local host's internet address according to a destination address.
#include <rpc/rpc.h>
void get_myaddr_dest(struct sockaddr_in *addr, struct sockaddr_in *dest);
addr
A pointer to a sockaddr_in structure that the routine will load with the local internet address which would provide a connection to the remote address specified in dest.dest
A pointer to a sockaddr_in structure containing an internet address of a remote host.
Since the local host may have multiple network addresses (each on its own interface), this routine is used to select the local address which would provide a connection to the remote address specified in dest.This is an alternative to gethostbyname, which invokes yellow pages. It takes a destination (where we are trying to get to) and finds an exact network match to go to.
None
This chapter describes the routines that allow C programs to access the Portmapper network service.
Table 6-1 indicates the task that each routine performs.
Routine | Task Category |
---|---|
pmap_getmaps | Returns a list of port mappings for the specified remote host. |
pmap_getmaps_vms | Returns a list of port mappings (including OpenVMS process IDs) for the specified remote host. |
pmap_getport | Returns the port number on which the specified service is waiting. |
pmap_rmtcall | Requests the Portmapper on the specified remote host to call the specified procedure on that host. |
pmap_set | Registers a remote server procedure with the host's Portmapper. |
pmap_unset | Unregisters a remote server procedure with the host's Portmapper. |
Returns a copy of the current port mappings on a remote host.
#include <rpc/pmap_clnt.h>
struct pmaplist *pmap_getmaps(struct sockaddr_in *addr);
addr
A pointer to a sockaddr_in structure containing the internet address of the host whose Portmapper you wish to call.
A client interface to the Portmapper, which returns a list of the current ONC RPC program-to-port mappings on the host located at the internet address addr. The SHOW PORTMAPPER management command uses this routine.
struct pmaplist * A pointer to the returned list of server-to-port mappings on host addr. NULL Indicates failure.
Returns a copy of the current port mappings on a remote host running TCP/IP Services software.
#include <rpc/pmap_clnt.h>
struct pmaplist_vms *pmap_getmaps_vms(struct sockaddr_in *addr);
addr
A pointer to a sockaddr_in structure containing the internet address of the host whose Portmapper you wish to call.
This routine is similar to the pmap_getmaps routine. However, pmap_getmaps_vms also returns the process identifiers (PIDs) that are required for mapping requests to TCP/IP Services hosts.
struct pmaplist * A pointer to the returned list of server-to-port mappings on host addr. NULL Indicates failure.
Returns the port number on which the specified service is waiting.
#include <rpc/pmap_clnt.h>
u_short pmap_getport(struct sockaddr_in *addr, u_long prognum, u_long versnum, u_long protocol );
addr
A pointer to a sockaddr_in structure containing the internet address of the host where the remote Portmapper resides.prognum
The program number associated with the remote procedure.versnum
The version number associated with the remote procedure.protocol
The transport protocol that the remote procedure uses. Specify either IPPROTO_UDP or IPPROTO_TCP.
A client interface to the Portmapper. This routine returns the port number on which waits a server that supports program number prognum, version versnum, and speaks the transport protocol associated with protocol (IPPROTO_UDP or IPPROTO_TCP).
Notes
If the requested version is not available, but at least the requested program is registered, the routine returns a port number.The pmap_getport routine returns the port number in host byte order not network byte order. For certain routines you may need to convert this value to network byte order using the htons routine. For example, the sockaddr_in structure requires that the port number be in network byte order.
x The port number of the service on the remote system. 0 No mapping exists or RPC could not contact the remote Portmapper service. In the latter case, the global variable rpc_createerr.cf_error contains the ONC RPC status.
The client interface to the Portmapper service for a remote call and broadcast service. This routine allows a program to do a lookup and call in one step.
#include <rpc/pmap_clnt.h>
enum clnt_stat pmap_rmtcall(struct sockaddr_in *addr, u_long prognum, u_long versnum, u_long procnum, xdrproc_t inproc, char * in xdrproc_t outproc, char * out, struct timeval timeout, u_long *port );
addr
A pointer to a sockaddr_in structure containing the internet address of the host where the remote Portmapper resides.prognum
The program number associated with the remote procedure.versnum
The version number associated with the remote procedure.procnum
The procedure number associated with the remote procedure.inproc
The XDR routine used to encode the remote procedure's arguments.in
A pointer to the remote procedure's arguments.outproc
The XDR routine used to decode the remote procedure's results.out
A pointer to the remote procedure's results.timeout
A timeval structure describing the time allowed for the results to return to the client.port
A pointer to a location for the returned port number. Modified to the remote program's port number if the pmap_rmtcall routine succeeds.
A client interface to the Portmapper, which instructs the Portmapper on the host at the internet address *addr to make a call on your behalf to a procedure on that host. Use this procedure for a ping operation and nothing else. You can use the clnt_perrno routine to print any error message.
Note
If the requested procedure is not registered with the remote Portmapper, the remote Portmapper does not reply to the request. The call to pmap_rmtcall will eventually time out. The pmap_rmtcall does not perform authentication.
enum clnt_stat Returns the buffer containing the status of the operation.
Called by the server procedure to have the Portmapper create a mapping of the procedure's program and version number.
#include <rpc/pmap_clnt.h>
bool_t pmap_set(u_long prognum, u_long versnum, u_long protocol, u_short port);
prognum
The program number associated with the server procedure.versnum
The version number associated with the server procedure.protocol
The transport protocol that the server procedure uses. Specify either IPPROTO_UDP or IPPROTO_TCP.port
The port number associated with the server program.
A server interface to the Portmapper, which establishes a mapping between the triple [prognum,versnum,protocol] and port on the server's Portmapper service. The svc_register routine calls this routine to register the server with the local Portmapper.
TRUE Indicates success. FALSE Indicates failure.
Called by the server procedure to have the Portmapper delete a mapping of the procedure's program and version number.
#include <rpc/pmap_clnt.h>
bool_t pmap_unset(u_long prognum, u_long versnum);
prognum
The program number associated with the server procedure.versnum
The version number associated with the server procedure.
A server interface to the Portmapper, which destroys all mapping between the triple [prognum, versnum, *] and ports on the local host's Portmapper.
TRUE Indicates success. FALSE Indicates failure.
This chapter describes the server routines that allow C programs to receive procedure calls from client programs over the network.
Table 7-1 indicates the task that each routine performs.
Routine | Task Category |
---|---|
registerrpc | Creates a server handle and registers the server program with the Portmapper. |
seterr_reply | Fills in the error field in an RPC reply message with the specified error information. |
svc_destroy | Destroys a server handle (macro). |
svc_freeargs | Frees the memory allocated when RPC decoded the server procedure's arguments (macro). |
svc_getargs | Decodes the server procedure's arguments (macro). |
svc_getcaller | Returns the address of the client that called the server procedure (macro). |
svc_getreqset | Reads data for each server connection. |
svc_register | Registers the server program with the Portmapper. |
svc_run | Waits for incoming RPC requests and dispatches to the appropriate service routine. |
svc_sendreply | Sends the results of an RPC request to the client. |
svc_unregister | Unregisters the server program with the Portmapper. |
svcerr_auth | Sends an error message to the client indicating that the authentication information was not correctly formatted. |
svcerr_decode | Sends an error message to the client indicating that the server could not decode the arguments. |
svcerr_noproc | Sends an error message to the client indicating that the server does not implement the desired procedure. |
svcerr_noprog | Sends an error message to the client indicating that the requested program is not available. |
svcerr_progvers | Sends an error message to the client indicating that the requested version is not available. |
svcerr_systemerr | Sends an error message to the client indicating that a system error occurred. |
svcerr_weakauth | Sends an error message to the client indicating that the authentication information was correctly formatted but was insufficient. |
svcraw_create | Creates a server handle for a client that shares the same program space. |
svcfd_create | Creates a server handle for a specified TCP socket. |
svctcp_create | Creates a server handle using the TCP protocol. |
svcudp_bufcreate | Creates a server handle using buffered UDP transport. |
svcudp_create | Creates a server handle using the UDP transport. |
xprt_register | Adds the UDP or TCP socket associated with the specified server handle to the list of registered sockets. |
xprt_unregister | Removes the UDP or TCP socket associated with the specified server handle from the list of sockets. |
_authenticate | Authenticates an RPC request message. |
Obtains a unique systemwide procedure identification number.
#include <rpc/rpc.h>
int registerrpc(u_long prognum, u_long versnum, u_long procnum, char *(*progname)(), xdrproc_t inproc, xdrproc_t outproc );
prognum
The program number associated with the service procedure.versnum
The version number associated with the service procedure.procnum
The procedure number associated with the service procedure.progname
The address of the service procedure being registered with the ONC RPC service package.inproc
The XDR routine used to decode the service procedure's arguments.outproc
The XDR routine used to encode the service procedure's results.
The registerrpc routine performs the following tasks for a server:
- Creates a UDP server handle. See the svcudp_create routine for restrictions.
- Calls the svc_register routine to register the program with the Portmapper.
- Adds prognum, versnum, and procnum to an internal list of registered procedures. When the server receives a request, it uses this list to determine which routine to call.
A server should call registerrpc for every procedure it implements, except for the NULL procedure. If a request arrives for program prognum, version versnum, and procedure procnum, progname is called with a pointer to its parameters.
0 Indicates success. -1 Indicates failure.
Fills in the error text in a reply message.
#include <rpc/rpc.h>
void seterr_reply(struct rpc_msg *msg, struct rpc_err *error);
msg
A pointer to a reply message buffer.error
A pointer to an rpc_err structure containing the error associated with the reply message.
Given a reply message, seterr_reply fills in the error field.
None
A macro that frees the memory associated with an RPC server handle.
#include <rpc/rpc.h>
void svc_destroy(SVCXPRT *xprt);
xprt
A pointer to an RPC server handle created by any of the server handle creation routines.
The svc_destroy routine returns all the private data structures associated with a server handle. If the server handle creation routine received the value RPC_ANYSOCK as the socket, svc_destroy closes the socket. Otherwise, your program must close the socket.
None
A macro that frees the memory allocated when the procedure's arguments were decoded.
#include <rpc/rpc.h>
bool_t svc_freeargs(SVCXPRT *xprt, xdrproc_t inproc, char *in);
xprt
A pointer to an RPC server handle created by any of the server handle creation routines.inproc
The XDR routine used to decode the service procedure's arguments.in
A pointer to the service procedure's decoded arguments.
The svc_destroy routine returns the memory that the svc_getargs routine allocated to hold the service procedure's decoded arguments. This routine calls the xdr_free routine.
TRUE Success; memory successfully deallocated. FALSE Failure; memory not deallocated.
A macro that decodes the service procedure's arguments.
#include <rpc/rpc.h>
bool_t svc_getargs(SVCXPRT *xprt, xdrproc_t inproc, char *in);
xprt
A pointer to an RPC server handle created by any of the server handle creation routines.inproc
The XDR routine used to decode the service procedure's arguments.in
A pointer to the service procedure's decoded arguments.
This routine calls the specified XDR routine to decode the arguments passed to the service procedure.
TRUE Successfully decoded. FALSE Decoding unsuccessful.
Previous | Next | Contents | Index |