Esempio n. 1
0
            /// <summary>
            /// Deregister all port settings for a particular (program, version) for
            /// all transports (TCP, UDP, ...).
            /// </summary>
            /// <remarks>
            /// Deregister all port settings for a particular (program, version) for
            /// all transports (TCP, UDP, ...). This method basically falls back to
            /// the implementation provided by the <code>jrpcgen</code> superclass,
            /// but checks whether there are other ONC/RPC programs registered. If
            /// not, it signals itself to shut down the portmap service.
            /// </remarks>
            /// <param name="params">
            /// (program, version) to deregister. The protocol and port
            /// fields are not used.
            /// </param>
            /// <returns><code>true</code> if deregistration succeeded.</returns>
            internal override XdrBoolean unsetPort(OncRpcServerIdent @params)
            {
                XdrBoolean ok = base.unsetPort(@params);

                if (ok.booleanValue())
                {
                    //
                    // Check for registered programs other than PMAP_PROGRAM.
                    //
                    bool onlyPmap = true;
                    int  size     = this.servers.Count;
                    for (int idx = 0; idx < size; ++idx)
                    {
                        if (((OncRpcServerIdent)this.servers[idx]).program != jportmap.PMAP_PROGRAM)
                        {
                            onlyPmap = false;
                            break;
                        }
                    }
                    //
                    // If only portmap-related entries are left, then shut down this
                    // portmap service.
                    //
                    if (onlyPmap && (this.serviceThread != null))
                    {
                        this.stopRpcProcessing();
                    }
                }
                return(ok);
            }
			/// <summary>
			/// Deregister all port settings for a particular (program, version) for
			/// all transports (TCP, UDP, ...).
			/// </summary>
			/// <remarks>
			/// Deregister all port settings for a particular (program, version) for
			/// all transports (TCP, UDP, ...). This method basically falls back to
			/// the implementation provided by the <code>jrpcgen</code> superclass,
			/// but checks whether there are other ONC/RPC programs registered. If
			/// not, it signals itself to shut down the portmap service.
			/// </remarks>
			/// <param name="params">
			/// (program, version) to deregister. The protocol and port
			/// fields are not used.
			/// </param>
			/// <returns><code>true</code> if deregistration succeeded.</returns>
			internal override XdrBoolean unsetPort(OncRpcServerIdent @params)
			{
				XdrBoolean ok = base.unsetPort(@params);
				if (ok.booleanValue())
				{
					//
					// Check for registered programs other than PMAP_PROGRAM.
					//
					bool onlyPmap = true;
					int size = this.servers.Count;
					for (int idx = 0; idx < size; ++idx)
					{
						if (((OncRpcServerIdent)this.servers[idx]).program != jportmap.PMAP_PROGRAM)
						{
							onlyPmap = false;
							break;
						}
					}
					//
					// If only portmap-related entries are left, then shut down this
					// portmap service.
					//
					if (onlyPmap && (this.serviceThread != null))
					{
						this.stopRpcProcessing();
					}
				}
				return ok;
			}
Esempio n. 3
0
        /// <summary>Dispatch incomming ONC/RPC calls to the individual handler functions.</summary>
        /// <remarks>
        /// Dispatch incomming ONC/RPC calls to the individual handler functions.
        /// The CALLIT method is currently unimplemented.
        /// </remarks>
        /// <param name="call">
        /// The ONC/RPC call, with references to the transport and
        /// XDR streams to use for retrieving parameters and sending replies.
        /// </param>
        /// <param name="program">the portmap's program number, 100000</param>
        /// <param name="version">the portmap's protocol version, 2</param>
        /// <param name="procedure">the procedure to call.</param>
        /// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
        /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
        public virtual void dispatchOncRpcCall(org.acplt.oncrpc.server.OncRpcCallInformation
			 call, int program, int version, int procedure)
        {
            //
            // Make sure it's the right program and version that we can handle.
            // (defensive programming)
            //
            if (program == PMAP_PROGRAM)
            {
                if (version == PMAP_VERSION)
                {
                    switch (procedure)
                    {
                        case 0:
                        {
                            // handle NULL call.
                            call.retrieveCall(org.acplt.oncrpc.XdrVoid.XDR_VOID);
                            call.reply(org.acplt.oncrpc.XdrVoid.XDR_VOID);
                            break;
                        }

                        case OncRpcPortmapServices.PMAP_GETPORT:
                        {
                            // handle port query
                            org.acplt.oncrpc.OncRpcServerIdent @params = new org.acplt.oncrpc.OncRpcServerIdent
                                ();
                            call.retrieveCall(@params);
                            org.acplt.oncrpc.OncRpcGetPortResult result = getPort(@params);
                            call.reply(result);
                            break;
                        }

                        case OncRpcPortmapServices.PMAP_SET:
                        {
                            // handle port registration
                            //
                            // ensure that no remote client tries to register
                            //
                            OncRpcServerIdent @params = new OncRpcServerIdent
                                ();
                            call.retrieveCall(@params);
                            org.acplt.oncrpc.XdrBoolean result;
                            if (isLocalAddress(call.peerAddress))
                            {
                                result = setPort(@params);
                            }
                            else
                            {
                                result = new XdrBoolean(false);
                            }
                            call.reply(result);
                            break;
                        }

                        case OncRpcPortmapServices.PMAP_UNSET:
                        {
                            // handle port deregistration
                            OncRpcServerIdent @params = new OncRpcServerIdent
                                ();
                            call.retrieveCall(@params);
                            org.acplt.oncrpc.XdrBoolean result;
                            if (isLocalAddress(call.peerAddress))
                            {
                                result = unsetPort(@params);
                            }
                            else
                            {
                                result = new XdrBoolean(false);
                            }
                            call.reply(result);
                            break;
                        }

                        case OncRpcPortmapServices.PMAP_DUMP:
                        {
                            // list all registrations
                            call.retrieveCall(org.acplt.oncrpc.XdrVoid.XDR_VOID);
                            org.acplt.oncrpc.OncRpcDumpResult result = listServers();
                            call.reply(result);
                            break;
                        }

                        default:
                        {
                            // unknown/unimplemented procedure
                            call.failProcedureUnavailable();
                            break;
                        }
                    }
                }
                else
                {
                    call.failProgramMismatch(PMAP_VERSION, PMAP_VERSION);
                }
            }
            else
            {
                call.failProgramUnavailable();
            }
        }
Esempio n. 4
0
        /// <summary>Dispatch incomming ONC/RPC calls to the individual handler functions.</summary>
        /// <remarks>
        /// Dispatch incomming ONC/RPC calls to the individual handler functions.
        /// The CALLIT method is currently unimplemented.
        /// </remarks>
        /// <param name="call">
        /// The ONC/RPC call, with references to the transport and
        /// XDR streams to use for retrieving parameters and sending replies.
        /// </param>
        /// <param name="program">the portmap's program number, 100000</param>
        /// <param name="version">the portmap's protocol version, 2</param>
        /// <param name="procedure">the procedure to call.</param>
        /// <exception cref="org.acplt.oncrpc.OncRpcException">if an ONC/RPC error occurs.</exception>
        /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
        public virtual void dispatchOncRpcCall(org.acplt.oncrpc.server.OncRpcCallInformation
                                               call, int program, int version, int procedure)
        {
            //
            // Make sure it's the right program and version that we can handle.
            // (defensive programming)
            //
            if (program == PMAP_PROGRAM)
            {
                if (version == PMAP_VERSION)
                {
                    switch (procedure)
                    {
                    case 0:
                    {
                        // handle NULL call.
                        call.retrieveCall(org.acplt.oncrpc.XdrVoid.XDR_VOID);
                        call.reply(org.acplt.oncrpc.XdrVoid.XDR_VOID);
                        break;
                    }

                    case OncRpcPortmapServices.PMAP_GETPORT:
                    {
                        // handle port query
                        org.acplt.oncrpc.OncRpcServerIdent @params = new org.acplt.oncrpc.OncRpcServerIdent
                                                                         ();
                        call.retrieveCall(@params);
                        org.acplt.oncrpc.OncRpcGetPortResult result = getPort(@params);
                        call.reply(result);
                        break;
                    }

                    case OncRpcPortmapServices.PMAP_SET:
                    {
                        // handle port registration
                        //
                        // ensure that no remote client tries to register
                        //
                        OncRpcServerIdent @params = new OncRpcServerIdent
                                                        ();
                        call.retrieveCall(@params);
                        org.acplt.oncrpc.XdrBoolean result;
                        if (isLocalAddress(call.peerAddress))
                        {
                            result = setPort(@params);
                        }
                        else
                        {
                            result = new XdrBoolean(false);
                        }
                        call.reply(result);
                        break;
                    }

                    case OncRpcPortmapServices.PMAP_UNSET:
                    {
                        // handle port deregistration
                        OncRpcServerIdent @params = new OncRpcServerIdent
                                                        ();
                        call.retrieveCall(@params);
                        org.acplt.oncrpc.XdrBoolean result;
                        if (isLocalAddress(call.peerAddress))
                        {
                            result = unsetPort(@params);
                        }
                        else
                        {
                            result = new XdrBoolean(false);
                        }
                        call.reply(result);
                        break;
                    }

                    case OncRpcPortmapServices.PMAP_DUMP:
                    {
                        // list all registrations
                        call.retrieveCall(org.acplt.oncrpc.XdrVoid.XDR_VOID);
                        org.acplt.oncrpc.OncRpcDumpResult result = listServers();
                        call.reply(result);
                        break;
                    }

                    default:
                    {
                        // unknown/unimplemented procedure
                        call.failProcedureUnavailable();
                        break;
                    }
                    }
                }
                else
                {
                    call.failProgramMismatch(PMAP_VERSION, PMAP_VERSION);
                }
            }
            else
            {
                call.failProgramUnavailable();
            }
        }