The port mapper program maps RPC program and version numbers to transport-specific port numbers. This program makes dynamic binding of remote programs possible.
This is desirable because the range of reserved port numbers is very small and the number of potential remote programs is very large. By running only the port mapper on a reserved port, the port numbers of other remote programs can be ascertained by querying the port mapper.
The port mapper also aids in broadcast RPC. A given RPC program will usually have different port number bindings on different machines, so there is no way to directly broadcast to all of these programs. The port mapper, however, does have a fixed port number. So, to broadcast to a given program, the client actually sends its message to the port mapper located at the broadcast address. Each port mapper that picks up the broadcast then calls the local service specified by the client. When the port mapper gets the reply from the local service, it sends the reply on back to the client.
const PMAP_PORT = 111; /* portmapper port number */ /* * A mapping of (program, version, protocol) to port number */ struct mapping { unsigned int prog; unsigned int vers; unsigned int prot; unsigned int port; }; /* * Supported values for the "prot" field */ const IPPROTO_TCP = 6; /* protocol number for TCP/IP */ const IPPROTO_UDP = 17; /* protocol number for UDP/IP */ /* * A list of mappings */ struct *pmaplist { mapping map; pmaplist next; };
/* * Arguments to callit */ struct call_args { unsigned int prog; unsigned int vers; unsigned int proc; opaque args<>; }; /* * Results of callit */ struct call_result { unsigned int port; opaque res<>; };
/* * Port mapper procedures */ program PMAP_PROG { version PMAP_VERS { void PMAPPROC_NULL(void) = 0; bool PMAPPROC_SET(mapping) = 1; bool PMAPPROC_UNSET(mapping) = 2; unsigned int PMAPPROC_GETPORT(mapping) = 3; pmaplist PMAPPROC_DUMP(void) = 4; call_result PMAPPROC_CALLIT(call_args) = 5; } = 2; } = 100000;
The portmapper program currently supports two protocols (UDP/IP and TCP/IP). The portmapper is contacted by talking to it on assigned port number 111 (SUNRPC [8]) on either of these protocols. The following is a description of each of the portmapper procedures:
Note:
The procedure returns the remote program's port number, and the bytes of results are the results of the remote procedure.