Package org.acplt.oncrpc.apps.jportmap
Class jportmap
java.lang.Object
org.acplt.oncrpc.server.OncRpcServerStub
org.acplt.oncrpc.apps.jportmap.jportmap
- All Implemented Interfaces:
OncRpcDispatchable
- Direct Known Subclasses:
OncRpcEmbeddedPortmap.embeddedjportmap
The class
jportmap
implements a Java-based ONC/RPC port mapper,
speaking the widely deployed protocol version 2.
This class can be either used stand-alone (a static main
is
provided for this purpose) or as part of an application. In this case you
should check first for another portmap already running before starting your
own one.
- Version:
- $Revision: 1.2 $ $Date: 2003/08/14 11:26:50 $ $State: Exp $ $Locker: $
- Author:
- Harald Albrecht
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of IP addresses assigned to this host.static final int
Well-known port where the portmap process can be found on Internet hosts.static final int
Program number of the portmapper as defined in RFC 1832.static final int
Program version number of the portmapper as defined in RFC 1832.The list of registrated servers.Fields inherited from class org.acplt.oncrpc.server.OncRpcServerStub
info, shutdownSignal, transports
-
Constructor Summary
ConstructorsConstructorDescriptionjportmap()
Create a new portmap instance, create the transport registration information and UDP and TCP-based transports, which will be bound later to port 111. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispatchOncRpcCall
(OncRpcCallInformation call, int program, int version, int procedure) Dispatch incomming ONC/RPC calls to the individual handler functions.(package private) OncRpcGetPortResult
getPort
(OncRpcServerIdent params) Lookup port for (program, version, protocol).(package private) boolean
isLocalAddress
(InetAddress addr) Checks whether the address given belongs to one of the local addresses of this host.(package private) OncRpcDumpResult
Return list of registered ONC/RPC servers.static void
Create an instance of an ONC/RPC portmapper and run it.(package private) XdrBoolean
setPort
(OncRpcServerIdent params) Register a port number for a particular (program, version, protocol).(package private) XdrBoolean
unsetPort
(OncRpcServerIdent params) Deregister all port settings for a particular (program, version) for all transports (TCP, UDP, ...).Methods inherited from class org.acplt.oncrpc.server.OncRpcServerStub
close, getCharacterEncoding, register, run, run, setCharacterEncoding, stopRpcProcessing, unregister
-
Field Details
-
locals
List of IP addresses assigned to this host. Will be filled later by constructor. -
servers
The list of registrated servers. -
PMAP_PORT
public static final int PMAP_PORTWell-known port where the portmap process can be found on Internet hosts.- See Also:
-
PMAP_PROGRAM
public static final int PMAP_PROGRAMProgram number of the portmapper as defined in RFC 1832.- See Also:
-
PMAP_VERSION
public static final int PMAP_VERSIONProgram version number of the portmapper as defined in RFC 1832.- See Also:
-
-
Constructor Details
-
jportmap
Create a new portmap instance, create the transport registration information and UDP and TCP-based transports, which will be bound later to port 111. The constructor does not start the dispatcher loop.- Throws:
OncRpcException
IOException
-
-
Method Details
-
getPort
Lookup port for (program, version, protocol). If no suitable registration entry if found and an entry with another version, but the same program and version number is found, this is returned instead. This is compatible with the way Sun's portmap implementation works.- Parameters:
params
- server identification (program, version, protocol) to look up. The port field is not used.- Returns:
- port number where server listens for incomming ONC/RPC calls,
or
0
, if no server is registered for (program, protocol).
-
setPort
Register a port number for a particular (program, version, protocol). Note that a caller can not register the same (program, version, protocol) for another port. In this case we return false. Thus, a caller first needs to deregister any old entries which it whishes to update. Always add new registration entries to the end of the list (vector).- Parameters:
params
- (program, version, protocol, port) to register.- Returns:
true
if registration succeeded.
-
unsetPort
Deregister all port settings for a particular (program, version) for all transports (TCP, UDP, ...). While these are strange semantics, they are compatible with Sun's portmap implementation.- Parameters:
params
- (program, version) to deregister. The protocol and port fields are not used.- Returns:
true
if deregistration succeeded.
-
listServers
OncRpcDumpResult listServers()Return list of registered ONC/RPC servers.- Returns:
- list of ONC/RPC server descriptions (program, version, protocol, port).
-
isLocalAddress
Checks whether the address given belongs to one of the local addresses of this host.- Parameters:
addr
- IP address to check.- Returns:
true
if address specified belongs to one of the local addresses of this host.
-
dispatchOncRpcCall
public void dispatchOncRpcCall(OncRpcCallInformation call, int program, int version, int procedure) throws OncRpcException, IOException Dispatch incomming ONC/RPC calls to the individual handler functions. The CALLIT method is currently unimplemented.- Specified by:
dispatchOncRpcCall
in interfaceOncRpcDispatchable
- Parameters:
call
- The ONC/RPC call, with references to the transport and XDR streams to use for retrieving parameters and sending replies.program
- the portmap's program number, 100000version
- the portmap's protocol version, 2procedure
- the procedure to call.- Throws:
OncRpcException
- if an ONC/RPC error occurs.IOException
- if an I/O error occurs.- See Also:
-
main
Create an instance of an ONC/RPC portmapper and run it. As we have to bootstrap the ONC/RPC port information chain, we do not use the usual overloadedrun()
method without any parameters, but instead supply it the transports to handle. Registration and deregistration is not necessary and not possible.
-