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
        protected internal static void SendRejectedReply(RpcCall call, EndPoint remoteAddress
                                                         , ChannelHandlerContext ctx)
        {
            XDR            @out  = new XDR();
            RpcDeniedReply reply = new RpcDeniedReply(call.GetXid(), RpcReply.ReplyState.MsgDenied
                                                      , RpcDeniedReply.RejectState.AuthError, new VerifierNone());

            reply.Write(@out);
            ChannelBuffer buf = ChannelBuffers.WrappedBuffer(@out.AsReadOnlyWrap().Buffer());
            RpcResponse   rsp = new RpcResponse(buf, remoteAddress);

            RpcUtil.SendRpcResponse(ctx, rsp);
        }
Beispiel #3
0
        private void SerializeInt(int times)
        {
            XDR w = new XDR();

            for (int i = 0; i < times; ++i)
            {
                w.WriteInt(WriteValue);
            }
            XDR r = w.AsReadOnlyWrap();

            for (int i_1 = 0; i_1 < times; ++i_1)
            {
                Assert.Equal(WriteValue, r.ReadInt());
            }
        }
Beispiel #4
0
        private void SendAcceptedReply(RpcCall call, EndPoint remoteAddress, RpcAcceptedReply.AcceptState
                                       acceptState, ChannelHandlerContext ctx)
        {
            RpcAcceptedReply reply = RpcAcceptedReply.GetInstance(call.GetXid(), acceptState,
                                                                  Verifier.VerifierNone);
            XDR @out = new XDR();

            reply.Write(@out);
            if (acceptState == RpcAcceptedReply.AcceptState.ProgMismatch)
            {
                @out.WriteInt(lowProgVersion);
                @out.WriteInt(highProgVersion);
            }
            ChannelBuffer b   = ChannelBuffers.WrappedBuffer(@out.AsReadOnlyWrap().Buffer());
            RpcResponse   rsp = new RpcResponse(b, remoteAddress);

            RpcUtil.SendRpcResponse(ctx, rsp);
        }