public void dispatchOncRpcCall(OncRpcCallInformation call, int program, int version, int procedure) { if ( version == 1 ) { switch ( procedure ) { case 0: { call.retrieveCall(XdrVoid.XDR_VOID); CB_NULL_1(); call.reply(XdrVoid.XDR_VOID); break; } case 1: { CB_COMPOUND4args args_ = new CB_COMPOUND4args(); call.retrieveCall(args_); CB_COMPOUND4res result_ = CB_COMPOUND_1(args_); call.reply(result_); break; } default: call.failProcedureUnavailable(); break; } } else { call.failProgramUnavailable(); } }
/// <summary>Send back an ONC/RPC reply to the original caller.</summary> /// <remarks> /// Send back an ONC/RPC reply to the original caller. This is rather a /// low-level method, typically not used by applications. Dispatcher handling /// ONC/RPC calls have to use the /// <see cref="OncRpcCallInformation.reply(org.acplt.oncrpc.XdrAble)">OncRpcCallInformation.reply(org.acplt.oncrpc.XdrAble) /// </see> /// method instead on the /// call object supplied to the handler. /// </remarks> /// <param name="callInfo"> /// information about the original call, which are necessary /// to send back the reply to the appropriate caller. /// </param> /// <param name="state"> /// ONC/RPC reply message header indicating success or failure /// and containing associated state information. /// </param> /// <param name="reply"> /// If not <code>null</code>, then this parameter references /// the reply to be serialized after the reply message header. /// </param> /// <exception cref="org.acplt.oncrpc.OncRpcException"> /// if an ONC/RPC exception occurs, like the data /// could not be successfully serialized. /// </exception> /// <exception cref="System.IO.IOException"> /// if an I/O exception occurs, like transmission /// failures over the network, etc. /// </exception> /// <seealso cref="OncRpcCallInformation">OncRpcCallInformation</seealso> /// <seealso cref="OncRpcDispatchable">OncRpcDispatchable</seealso> internal override void reply(OncRpcCallInformation callInfo , OncRpcServerReplyMessage state, XdrAble reply) { beginEncoding(callInfo, state); if (reply != null) { reply.xdrEncode(sendingXdr); } endEncoding(); }
/// <summary>Begins the sending phase for ONC/RPC replies.</summary> /// <remarks> /// Begins the sending phase for ONC/RPC replies. /// This method belongs to the lower-level access pattern when handling /// ONC/RPC calls. /// </remarks> /// <param name="callInfo"> /// Information about ONC/RPC call for which we are about /// to send back the reply. /// </param> /// <param name="state">ONC/RPC reply header indicating success or failure.</param> /// <exception cref="org.acplt.oncrpc.OncRpcException"> /// if an ONC/RPC exception occurs, like the data /// could not be successfully serialized. /// </exception> /// <exception cref="System.IO.IOException">if an I/O exception occurs, like transmission /// </exception> internal override void beginEncoding(OncRpcCallInformation callInfo, OncRpcServerReplyMessage state) { // // In case decoding has not been properly finished, do it now to // free up pending resources, etc. // if (pendingDecoding) { pendingDecoding = false; receivingXdr.endDecoding(); } // // Now start encoding using the reply message header first... // sendingXdr.beginEncoding(callInfo.peerAddress, callInfo.peerPort); state.xdrEncode(sendingXdr); }
public void dispatchOncRpcCall(OncRpcCallInformation call, int program, int version, int procedure) { if (version == 3) { switch (procedure) { case 0: { call.retrieveCall(XdrVoid.XDR_VOID); MOUNTPROC3_NULL(); call.reply(XdrVoid.XDR_VOID); break; } case 1: { Name args_ = new Name(); call.retrieveCall(args_); MountStatus result_ = MOUNTPROC3_MNT(args_); call.reply(result_); break; } case 2: { call.retrieveCall(XdrVoid.XDR_VOID); MountList result_ = MOUNTPROC3_DUMP(); call.reply(result_); break; } case 3: { Name args_ = new Name(); call.retrieveCall(args_); MOUNTPROC3_UMNT(args_); call.reply(XdrVoid.XDR_VOID); break; } case 4: { call.retrieveCall(XdrVoid.XDR_VOID); MOUNTPROC3_UMNTALL(); call.reply(XdrVoid.XDR_VOID); break; } case 5: { call.retrieveCall(XdrVoid.XDR_VOID); Exports result_ = MOUNTPROC3_EXPORT(); call.reply(result_); break; } default: { call.failProcedureUnavailable(); break; } } } else { call.failProgramUnavailable(); } }
public void dispatchOncRpcCall(OncRpcCallInformation call, int program, int version, int procedure) { if (version == 2) { switch (procedure) { case 0: { call.retrieveCall(XdrVoid.XDR_VOID); NFSPROC_NULL(); call.reply(XdrVoid.XDR_VOID); break; } case 1: { NFSHandle args_ = new NFSHandle(); args_.Version = V2.RPC.NFSv2Protocol.NFS_VERSION; call.retrieveCall(args_); FileStatus result_ = NFSPROC_GETATTR(args_); call.reply(result_); break; } case 2: { CreateArguments args_ = new CreateArguments(); call.retrieveCall(args_); FileStatus result_ = NFSPROC_SETATTR(args_); call.reply(result_); break; } case 3: { call.retrieveCall(XdrVoid.XDR_VOID); NFSPROC_ROOT(); call.reply(XdrVoid.XDR_VOID); break; } case 4: { ItemOperationArguments args_ = new ItemOperationArguments(); call.retrieveCall(args_); ItemOperationStatus result_ = NFSPROC_LOOKUP(args_); call.reply(result_); break; } case 5: { NFSHandle args_ = new NFSHandle(); args_.Version = V2.RPC.NFSv2Protocol.NFS_VERSION; call.retrieveCall(args_); LinkStatus result_ = NFSPROC_READLINK(args_); call.reply(result_); break; } case 6: { ReadArguments args_ = new ReadArguments(); call.retrieveCall(args_); ReadStatus result_ = NFSPROC_READ(args_); call.reply(result_); break; } case 7: { call.retrieveCall(XdrVoid.XDR_VOID); NFSPROC_WRITECACHE(); call.reply(XdrVoid.XDR_VOID); break; } case 8: { WriteArguments args_ = new WriteArguments(); call.retrieveCall(args_); FileStatus result_ = NFSPROC_WRITE(args_); call.reply(result_); break; } case 9: { CreateArguments args_ = new CreateArguments(); call.retrieveCall(args_); ItemOperationStatus result_ = NFSPROC_CREATE(args_); call.reply(result_); break; } case 10: { ItemOperationArguments args_ = new ItemOperationArguments(); call.retrieveCall(args_); XdrInt result_ = new XdrInt(NFSPROC_REMOVE(args_)); call.reply(result_); break; } case 11: { RenameArguments args_ = new RenameArguments(); call.retrieveCall(args_); XdrInt result_ = new XdrInt(NFSPROC_RENAME(args_)); call.reply(result_); break; } case 12: { LinkArguments args_ = new LinkArguments(); call.retrieveCall(args_); XdrInt result_ = new XdrInt(NFSPROC_LINK(args_)); call.reply(result_); break; } case 13: { SymlinkArguments args_ = new SymlinkArguments(); call.retrieveCall(args_); XdrInt result_ = new XdrInt(NFSPROC_SYMLINK(args_)); call.reply(result_); break; } case 14: { CreateArguments args_ = new CreateArguments(); call.retrieveCall(args_); ItemOperationStatus result_ = NFSPROC_MKDIR(args_); call.reply(result_); break; } case 15: { ItemOperationArguments args_ = new ItemOperationArguments(); call.retrieveCall(args_); XdrInt result_ = new XdrInt(NFSPROC_RMDIR(args_)); call.reply(result_); break; } case 16: { ItemArguments args_ = new ItemArguments(); call.retrieveCall(args_); ItemStatus result_ = NFSPROC_READDIR(args_); call.reply(result_); break; } case 17: { NFSHandle args_ = new NFSHandle(); args_.Version = V2.RPC.NFSv2Protocol.NFS_VERSION; call.retrieveCall(args_); FSStatStatus result_ = NFSPROC_STATFS(args_); call.reply(result_); break; } default: { call.failProcedureUnavailable(); break; } } } else { call.failProgramUnavailable(); } }
/// <summary> /// The real workhorse handling incoming requests, dispatching them and /// sending back replies. /// </summary> /// <remarks> /// The real workhorse handling incoming requests, dispatching them and /// sending back replies. /// </remarks> public virtual void _listen() { OncRpcCallInformation callInfo = new OncRpcCallInformation (this); for (; ; ) { // // Start decoding the incomming call. This involves remembering // from whom we received the call so we can later send back the // appropriate reply message. // Note that for UDP-based communication we don't need to deal // with timeouts. // try { pendingDecoding = true; receivingXdr.beginDecoding(); callInfo.peerAddress = receivingXdr.getSenderAddress(); callInfo.peerPort = receivingXdr.getSenderPort(); } catch (SocketException) { // // In case of I/O Exceptions (especially socket exceptions) // close the file and leave the stage. There's nothing we can // do anymore. // Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { // // In case of ONC/RPC exceptions at this stage we're silently // ignoring that there was some data coming in... // continue; } try { // // Pull off the ONC/RPC call header of the XDR stream. // callInfo.callMessage.xdrDecode(receivingXdr); } catch (System.IO.IOException) { // // In case of I/O Exceptions (especially socket exceptions) // close the file and leave the stage. There's nothing we can // do anymore. // Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { // // In case of ONC/RPC exceptions at this stage we're silently // ignoring that there was some data coming in, as we're not // sure we got enough information to send a matching reply // message back to the caller. // if (pendingDecoding) { pendingDecoding = false; try { receivingXdr.endDecoding(); } catch (System.IO.IOException) { Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { } } continue; } try { // // Let the dispatcher retrieve the call parameters, work on // it and send back the reply. // To make it once again clear: the dispatch called has to // pull off the parameters of the stream! // dispatcher.dispatchOncRpcCall(callInfo, callInfo.callMessage.program, callInfo.callMessage .version, callInfo.callMessage.procedure); } catch (System.Exception e) { // // In case of some other runtime exception, we report back to // the caller a system error. // // In case of UDP-bases transports we can do so, because we // know that we can reset the buffer and serialize another // reply message even in case we caught some OncRpcException. // // Note that we "kill" the transport by closing it when we // got stuck with an I/O exception when trying to send back // an error reply. // if (pendingDecoding) { pendingDecoding = false; try { receivingXdr.endDecoding(); } catch (System.IO.IOException) { Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { } } // // Check for authentication exceptions, which are reported back // as is. Otherwise, just report a system error // -- very generic, indeed. // try { if (e is OncRpcAuthenticationException) { callInfo.failAuthenticationFailed(((OncRpcAuthenticationException )e).getAuthStatus()); } else { callInfo.failSystemError(); } } catch (SocketException) { Close(); return; } catch (NullReferenceException) { // Until I have a better way to clean up the threads on the sockets, // we need to catch this here and SocketException all over the place Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { } } } }
public void dispatchOncRpcCall(OncRpcCallInformation call, int program, int version, int procedure) { if (version == 3) { switch (procedure) { case 0: { call.retrieveCall(XdrVoid.XDR_VOID); NFSPROC3_NULL(); call.reply(XdrVoid.XDR_VOID); break; } case 1: { GetAttributeArguments args_ = new GetAttributeArguments(); call.retrieveCall(args_); ResultObject<GetAttributeAccessOK, GetAttributeAccessOK> result_ = NFSPROC3_GETATTR(args_); call.reply(result_); break; } case 2: { SetAttributeArguments args_ = new SetAttributeArguments(); call.retrieveCall(args_); ResultObject<SetAttributeAccessOK, SetAttributeAccessFAIL> result_ = NFSPROC3_SETATTR(args_); call.reply(result_); break; } case 3: { ItemOperationArguments args_ = new ItemOperationArguments(); call.retrieveCall(args_); ResultObject<ItemOperationAccessResultOK, ItemOperationAccessResultFAIL> result_ = NFSPROC3_LOOKUP(args_); call.reply(result_); break; } case 4: { AccessArguments args_ = new AccessArguments(); call.retrieveCall(args_); ResultObject<AccessAccessOK, AccessAccessFAIL> result_ = NFSPROC3_ACCESS(args_); call.reply(result_); break; } case 5: { ReadLinkArguments args_ = new ReadLinkArguments(); call.retrieveCall(args_); ResultObject<ReadLinkAccessOK, ReadLinkAccessFAIL> result_ = NFSPROC3_READLINK(args_); call.reply(result_); break; } case 6: { ReadArguments args_ = new ReadArguments(); call.retrieveCall(args_); ResultObject<ReadAccessOK, ReadAccessFAIL> result_ = NFSPROC3_READ(args_); call.reply(result_); break; } case 7: { WriteArguments args_ = new WriteArguments(); call.retrieveCall(args_); ResultObject<WriteAccessOK, WriteAccessFAIL> result_ = NFSPROC3_WRITE(args_); call.reply(result_); break; } case 8: { MakeFileArguments args_ = new MakeFileArguments(); call.retrieveCall(args_); ResultObject<MakeFileAccessOK, MakeFileAccessFAIL> result_ = NFSPROC3_CREATE(args_); call.reply(result_); break; } case 9: { MakeFolderArguments args_ = new MakeFolderArguments(); call.retrieveCall(args_); ResultObject<MakeFolderAccessOK, MakeFolderAccessFAIL> result_ = NFSPROC3_MKDIR(args_); call.reply(result_); break; } case 10: { SymlinkArguments args_ = new SymlinkArguments(); call.retrieveCall(args_); ResultObject<SymlinkAccessOK, SymlinkAccessFAIL> result_ = NFSPROC3_SYMLINK(args_); call.reply(result_); break; } case 11: { MakeNodeArguments args_ = new MakeNodeArguments(); call.retrieveCall(args_); ResultObject<MakeNodeAccessOK, MakeNodeAccessFAIL> result_ = NFSPROC3_MKNOD(args_); call.reply(result_); break; } case 12: { ItemOperationArguments args_ = new ItemOperationArguments(); call.retrieveCall(args_); ResultObject<RemoveAccessOK, RemoveAccessFAIL> result_ = NFSPROC3_REMOVE(args_); call.reply(result_); break; } case 13: { ItemOperationArguments args_ = new ItemOperationArguments(); call.retrieveCall(args_); ResultObject<RemoveAccessOK, RemoveAccessFAIL> result_ = NFSPROC3_RMDIR(args_); call.reply(result_); break; } case 14: { RenameArguments args_ = new RenameArguments(); call.retrieveCall(args_); ResultObject<RenameAccessOK, RenameAccessFAIL> result_ = NFSPROC3_RENAME(args_); call.reply(result_); break; } case 15: { LinkArguments args_ = new LinkArguments(); call.retrieveCall(args_); ResultObject<LinkAccessOK, LinkAccessFAIL> result_ = NFSPROC3_LINK(args_); call.reply(result_); break; } case 16: { ReadFolderArguments args_ = new ReadFolderArguments(); call.retrieveCall(args_); ResultObject<ReadFolderAccessResultOK, ReadFolderAccessResultFAIL> result_ = NFSPROC3_READDIR(args_); call.reply(result_); break; } case 17: { ExtendedReadFolderArguments args_ = new ExtendedReadFolderArguments(); call.retrieveCall(args_); ResultObject<ExtendedReadFolderAccessOK, ExtendedReadFolderAccessFAIL> result_ = NFSPROC3_READDIRPLUS(args_); call.reply(result_); break; } case 18: { FSStatisticsArguments args_ = new FSStatisticsArguments(); call.retrieveCall(args_); ResultObject<FSStatisticsAccessOK, FSStatisticsAccessFAIL> result_ = NFSPROC3_FSSTAT(args_); call.reply(result_); break; } case 19: { FSInfoArguments args_ = new FSInfoArguments(); call.retrieveCall(args_); ResultObject<FSInfoAccessOK, FSInfoAccessFAIL> result_ = NFSPROC3_FSINFO(args_); call.reply(result_); break; } case 20: { PathConfigurationArguments args_ = new PathConfigurationArguments(); call.retrieveCall(args_); ResultObject<PathConfigurationAccessOK, PathConfigurationAccessFAIL> result_ = NFSPROC3_PATHCONF(args_); call.reply(result_); break; } case 21: { CommitArguments args_ = new CommitArguments(); call.retrieveCall(args_); ResultObject<CommitAccessOK, CommitAccessFAIL> result_ = NFSPROC3_COMMIT(args_); call.reply(result_); break; } default: call.failProcedureUnavailable(); break; } } else { call.failProgramUnavailable(); } }
/// <summary> /// The real workhorse handling incoming requests, dispatching them and /// sending back replies. /// </summary> /// <remarks> /// The real workhorse handling incoming requests, dispatching them and /// sending back replies. /// </remarks> public virtual void _listen() { OncRpcCallInformation callInfo = new OncRpcCallInformation (this); for (; ;) { // // Start decoding the incomming call. This involves remembering // from whom we received the call so we can later send back the // appropriate reply message. // Note that for UDP-based communication we don't need to deal // with timeouts. // try { pendingDecoding = true; receivingXdr.beginDecoding(); callInfo.peerAddress = receivingXdr.getSenderAddress(); callInfo.peerPort = receivingXdr.getSenderPort(); } catch (SocketException) { // // In case of I/O Exceptions (especially socket exceptions) // close the file and leave the stage. There's nothing we can // do anymore. // Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { // // In case of ONC/RPC exceptions at this stage we're silently // ignoring that there was some data coming in... // continue; } try { // // Pull off the ONC/RPC call header of the XDR stream. // callInfo.callMessage.xdrDecode(receivingXdr); } catch (System.IO.IOException) { // // In case of I/O Exceptions (especially socket exceptions) // close the file and leave the stage. There's nothing we can // do anymore. // Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { // // In case of ONC/RPC exceptions at this stage we're silently // ignoring that there was some data coming in, as we're not // sure we got enough information to send a matching reply // message back to the caller. // if (pendingDecoding) { pendingDecoding = false; try { receivingXdr.endDecoding(); } catch (System.IO.IOException) { Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { } } continue; } try { // // Let the dispatcher retrieve the call parameters, work on // it and send back the reply. // To make it once again clear: the dispatch called has to // pull off the parameters of the stream! // dispatcher.dispatchOncRpcCall(callInfo, callInfo.callMessage.program, callInfo.callMessage .version, callInfo.callMessage.procedure); } catch (System.Exception e) { // // In case of some other runtime exception, we report back to // the caller a system error. // // In case of UDP-bases transports we can do so, because we // know that we can reset the buffer and serialize another // reply message even in case we caught some OncRpcException. // // Note that we "kill" the transport by closing it when we // got stuck with an I/O exception when trying to send back // an error reply. // if (pendingDecoding) { pendingDecoding = false; try { receivingXdr.endDecoding(); } catch (System.IO.IOException) { Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { } } // // Check for authentication exceptions, which are reported back // as is. Otherwise, just report a system error // -- very generic, indeed. // try { if (e is OncRpcAuthenticationException) { callInfo.failAuthenticationFailed(((OncRpcAuthenticationException )e).getAuthStatus()); } else { callInfo.failSystemError(); } } catch (SocketException) { Close(); return; } catch (NullReferenceException) { // Until I have a better way to clean up the threads on the sockets, // we need to catch this here and SocketException all over the place Close(); return; } catch (org.acplt.oncrpc.OncRpcException) { } } } }
/// <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(); } }