Beispiel #1
0
		public BaseHandler(int port, int programId) : base() {

			this.ProgramID = programId;

			NfsHandlerManager.RegisterHandler(this);

			_listener = NfsListenerManager.GetListener(port, programId);
			_listener.PacketReceived += OnPacketReceived;
		}
Beispiel #2
0
        private void GetPort(NfsPacket sourcePacket, IPEndPoint receivedFrom)
        {
            // skip past the authentication records
            sourcePacket.ReadAuthentication();
            sourcePacket.ReadAuthentication();

            // Collect the arguments to the procedure
            uint programId = sourcePacket.GetUInt();
            uint version   = sourcePacket.GetUInt();
            uint protocol  = sourcePacket.GetUInt();

            // Put together an XDR reply packet
            NfsPacket packet = new NfsPacket(128);

            packet.SetUInt(sourcePacket.XID);
            packet.SetUInt((uint)RpcSignalType.Reply);
            packet.SetUInt((uint)RpcMessageResult.Accepted);

            packet.AddNullAuthentication();

            if (!NfsHandlerManager.IsProgramRegistered((int)programId))
            {
                packet.SetUInt((uint)RpcProcedure.ProgramUnavailable);
            }
            else
            {
                // TODO: add version checking. we're only doing v2 right now.
                // version mismatch gets the ProgMismatch value.
                //			result.AddLong(RPCConsts.RPCProgMismatch);
                //			result.AddLong(versmin);
                //			result.AddLong(versmax);
                int port = NfsHandlerManager.GetPort((int)programId);

                if (port == 0)
                {
                    packet.SetUInt((uint)RpcProcedure.ProgramMismatch);
                }
                else
                {
                    packet.SetUInt((uint)RpcProcedure.Success);
                    packet.SetUInt((uint)port);
                }
            }

            Send(packet, receivedFrom);
        }