protected override void HandleInternal(ChannelHandlerContext ctx, RpcInfo info) { RpcCall rpcCall = (RpcCall)info.Header(); MountInterface.MNTPROC mntproc = MountInterface.MNTPROC.FromValue(rpcCall.GetProcedure ()); int xid = rpcCall.GetXid(); byte[] data = new byte[info.Data().ReadableBytes()]; info.Data().ReadBytes(data); XDR xdr = new XDR(data); XDR @out = new XDR(); IPAddress client = ((IPEndPoint)info.RemoteAddress()).Address; if (mntproc == MountInterface.MNTPROC.Null) { @out = NullOp(@out, xid, client); } else { if (mntproc == MountInterface.MNTPROC.Mnt) { // Only do port monitoring for MNT if (!DoPortMonitoring(info.RemoteAddress())) { @out = MountResponse.WriteMNTResponse(Nfs3Status.Nfs3errAcces, @out, xid, null); } else { @out = Mnt(xdr, @out, xid, client); } } else { if (mntproc == MountInterface.MNTPROC.Dump) { @out = Dump(@out, xid, client); } else { if (mntproc == MountInterface.MNTPROC.Umnt) { @out = Umnt(xdr, @out, xid, client); } else { if (mntproc == MountInterface.MNTPROC.Umntall) { Umntall(@out, xid, client); } else { if (mntproc == MountInterface.MNTPROC.Export) { // Currently only support one NFS export IList <NfsExports> hostsMatchers = new AList <NfsExports>(); if (hostsMatcher != null) { hostsMatchers.AddItem(hostsMatcher); @out = MountResponse.WriteExportList(@out, xid, exports, hostsMatchers); } else { // This means there are no valid exports provided. RpcAcceptedReply.GetInstance(xid, RpcAcceptedReply.AcceptState.ProcUnavail, new VerifierNone ()).Write(@out); } } else { // Invalid procedure RpcAcceptedReply.GetInstance(xid, RpcAcceptedReply.AcceptState.ProcUnavail, new VerifierNone ()).Write(@out); } } } } } } ChannelBuffer buf = ChannelBuffers.WrappedBuffer(@out.AsReadOnlyWrap().Buffer()); RpcResponse rsp = new RpcResponse(buf, info.RemoteAddress()); RpcUtil.SendRpcResponse(ctx, rsp); }
/// <exception cref="System.Exception"/> public override void MessageReceived(ChannelHandlerContext ctx, MessageEvent e) { RpcInfo info = (RpcInfo)e.GetMessage(); RpcCall rpcCall = (RpcCall)info.Header(); int portmapProc = rpcCall.GetProcedure(); int xid = rpcCall.GetXid(); XDR @in = new XDR(info.Data().ToByteBuffer().AsReadOnlyBuffer(), XDR.State.Reading ); XDR @out = new XDR(); if (portmapProc == PmapprocNull) { @out = NullOp(xid, @in, @out); } else { if (portmapProc == PmapprocSet) { @out = Set(xid, @in, @out); } else { if (portmapProc == PmapprocUnset) { @out = Unset(xid, @in, @out); } else { if (portmapProc == PmapprocDump) { @out = Dump(xid, @in, @out); } else { if (portmapProc == PmapprocGetport) { @out = Getport(xid, @in, @out); } else { if (portmapProc == PmapprocGetversaddr) { @out = Getport(xid, @in, @out); } else { Log.Info("PortmapHandler unknown rpc procedure=" + portmapProc); RpcAcceptedReply reply = RpcAcceptedReply.GetInstance(xid, RpcAcceptedReply.AcceptState .ProcUnavail, new VerifierNone()); reply.Write(@out); } } } } } } ChannelBuffer buf = ChannelBuffers.WrappedBuffer(@out.AsReadOnlyWrap().Buffer()); RpcResponse rsp = new RpcResponse(buf, info.RemoteAddress()); RpcUtil.SendRpcResponse(ctx, rsp); }