Beispiel #1
0
            protected internal override void HandleInternal(ChannelHandlerContext ctx, RpcInfo
                                                            info)
            {
                // This is just like what's done in RpcProgramMountd#handleInternal and
                // RpcProgramNfs3#handleInternal.
                RpcCall rpcCall   = (RpcCall)info.Header();
                int     procedure = rpcCall.GetProcedure();

                if (procedure != 0)
                {
                    bool portMonitorSuccess = DoPortMonitoring(info.RemoteAddress());
                    if (!portMonitorSuccess)
                    {
                        SendRejectedReply(rpcCall, info.RemoteAddress(), ctx);
                        return;
                    }
                }
                resultSize = info.Data().ReadableBytes();
                RpcAcceptedReply reply = RpcAcceptedReply.GetAcceptInstance(1234, new VerifierNone
                                                                                ());
                XDR @out = new XDR();

                reply.Write(@out);
                ChannelBuffer b   = ChannelBuffers.WrappedBuffer(@out.AsReadOnlyWrap().Buffer());
                RpcResponse   rsp = new RpcResponse(b, info.RemoteAddress());

                RpcUtil.SendRpcResponse(ctx, rsp);
            }
Beispiel #2
0
        /// <exception cref="System.Exception"/>
        public override void MessageReceived(ChannelHandlerContext ctx, MessageEvent e)
        {
            RpcInfo  info          = (RpcInfo)e.GetMessage();
            RpcCall  call          = (RpcCall)info.Header();
            EndPoint remoteAddress = info.RemoteAddress();

            if (Log.IsTraceEnabled())
            {
                Log.Trace(program + " procedure #" + call.GetProcedure());
            }
            if (this.progNumber != call.GetProgram())
            {
                Log.Warn("Invalid RPC call program " + call.GetProgram());
                SendAcceptedReply(call, remoteAddress, RpcAcceptedReply.AcceptState.ProgUnavail,
                                  ctx);
                return;
            }
            int ver = call.GetVersion();

            if (ver < lowProgVersion || ver > highProgVersion)
            {
                Log.Warn("Invalid RPC call version " + ver);
                SendAcceptedReply(call, remoteAddress, RpcAcceptedReply.AcceptState.ProgMismatch,
                                  ctx);
                return;
            }
            HandleInternal(ctx, info);
        }