public GetPortReply GETPORT(UInt32 program, UInt32 programVersion, UInt32 transportProtocol) { GetPortReply getPortReply = new GetPortReply(0); String matchingProgramName = null; Boolean foundMatchingProgramVersion = false; for (int i = 0; i < namedMappings.Length; i++) { NamedMapping namedMapping = namedMappings[i]; Mapping mapping = namedMapping.mapping; if (program == mapping.program) { matchingProgramName = namedMapping.programName; if (programVersion == mapping.version) { foundMatchingProgramVersion = true; if (transportProtocol == mapping.protocol) { getPortReply.port = mapping.port; } } } } if (getPortReply.port == 0 && NfsServerLog.warningLogger != null) { if (matchingProgramName == null) { NfsServerLog.warningLogger.WriteLine("[{0}] [Warning] Client requested port for Program {1} but it was not found", serviceName, program); } else if (!foundMatchingProgramVersion) { NfsServerLog.warningLogger.WriteLine("[{0}] [Warning] Client requested port for Program '{1}' ({2}) but version {3} was not found in the mapping list", serviceName, matchingProgramName, program, programVersion); } else { NfsServerLog.warningLogger.WriteLine("[{0}] [Warning] Client requested port for Program '{1}' ({2}) Version {3}, but ip protocol {4} is not supported", serviceName, matchingProgramName, program, programVersion, transportProtocol); } } return(getPortReply); }
public DumpReply DUMP() { MappingEntry previousEntry = null; for (int i = 0; i < namedMappings.Length; i++) { NamedMapping namedMapping = namedMappings[i]; Mapping mapping = namedMapping.mapping; MappingEntry entry = new MappingEntry(mapping); entry.SetNextMapping(previousEntry); previousEntry = entry; } return(new DumpReply(previousEntry)); }
public void Run(TextWriter selectServerEventLog, IPEndPoint debugServerEndPoint, IPEndPoint npcServerEndPoint, IPAddress listenIPAddress, Int32 backlog, SharedFileSystem sharedFileSystem, Int32 portmapPort, Int32 mountPort, Int32 nfsPort, UInt32 readSizeMax, UInt32 suggestedReadSizeMultiple) { Buf sendBuffer = new Buf(4096); Buf recvBuffer = new Buf(4096); // // Create Mappings List // NamedMapping[] namedMappings = new NamedMapping[] { new NamedMapping(PortMap.Name, new Mapping(PortMap.ProgramNumber, PortMap2.ProgramVersion, PortMap.IPProtocolTcp, (UInt32)portmapPort)), new NamedMapping(PortMap.Name, new Mapping(PortMap.ProgramNumber, PortMap2.ProgramVersion, PortMap.IPProtocolUdp, (UInt32)portmapPort)), new NamedMapping(Mount.Name, new Mapping(Mount.ProgramNumber, Mount1.ProgramVersion, PortMap.IPProtocolTcp, (UInt32)mountPort)), new NamedMapping(Mount.Name, new Mapping(Mount.ProgramNumber, Mount1.ProgramVersion, PortMap.IPProtocolUdp, (UInt32)mountPort)), new NamedMapping(Mount.Name, new Mapping(Mount.ProgramNumber, Mount3.ProgramVersion, PortMap.IPProtocolTcp, (UInt32)mountPort)), new NamedMapping(Mount.Name, new Mapping(Mount.ProgramNumber, Mount3.ProgramVersion, PortMap.IPProtocolUdp, (UInt32)mountPort)), new NamedMapping(Nfs.Name, new Mapping(Nfs.ProgramNumber, Nfs3.ProgramVersion, PortMap.IPProtocolTcp, (UInt32)nfsPort)), new NamedMapping(Nfs.Name, new Mapping(Nfs.ProgramNumber, Nfs3.ProgramVersion, PortMap.IPProtocolUdp, (UInt32)nfsPort)), }; PortMap2Server portMapServer = new PortMap2Server(this, namedMappings, sendBuffer); Mount1And3Server mountServer = new Mount1And3Server(this, sharedFileSystem, sendBuffer); Nfs3Server nfsServer = new Nfs3Server(this, sharedFileSystem, sendBuffer, readSizeMax, suggestedReadSizeMultiple); // // Create Endpoints // if (listenIPAddress == null) { listenIPAddress = IPAddress.Any; } IPEndPoint portMapEndPoint = new IPEndPoint(listenIPAddress, portmapPort); IPEndPoint mountEndPoint = new IPEndPoint(listenIPAddress, mountPort); IPEndPoint nfsEndPoint = new IPEndPoint(listenIPAddress, nfsPort); selectServer = new SelectServer(false, recvBuffer); AddRpcServer(selectServer, portMapEndPoint, portMapServer, backlog); AddRpcServer(selectServer, mountEndPoint, mountServer, backlog); AddRpcServer(selectServer, nfsEndPoint, nfsServer, backlog); if (debugServerEndPoint != null) { Socket tcpAcceptSocket = new Socket(debugServerEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); tcpAcceptSocket.Bind(debugServerEndPoint); tcpAcceptSocket.Listen(4); selectServer.control.AddListenSocket(tcpAcceptSocket, new ControlServer().AcceptCallback); } if (npcServerEndPoint != null) { #if !WindowsCE NpcSelectServerHandler npcServerHandler; { Nfs3Server.NfsServerManager nfsServerManager = new Nfs3Server.NfsServerManager(nfsServer); NpcReflector reflector = new NpcReflector( new NpcExecutionObject(nfsServerManager, "Nfs3ServerManager", null, null), new NpcExecutionObject(nfsServer, "Nfs3Server", null, null), new NpcExecutionObject(portMapServer, "Portmap2Server", null, null), new NpcExecutionObject(mountServer, "Mount1And3Server", null, null) ); npcServerHandler = new NpcSelectServerHandler(NpcCallback.Instance, reflector, new DefaultNpcHtmlGenerator("NfsServer", reflector)); } Socket tcpAcceptSocket = new Socket(npcServerEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp); tcpAcceptSocket.Bind(npcServerEndPoint); tcpAcceptSocket.Listen(4); selectServer.control.AddListenSocket(tcpAcceptSocket, npcServerHandler.AcceptCallback); #endif } this.serverStartTimeStopwatchTicks = Stopwatch.GetTimestamp(); /* * selectServer.Run(selectServerEventLog, new byte[1024], tcpListeners.ToArray(), * new UdpSelectListener[]{ * new UdpSelectListener(portMapEndPoint, portMapServer), * new UdpSelectListener(mountEndPoint , mountServer), * new UdpSelectListener(nfsEndPoint , nfsServer), * } * ); */ selectServer.Run(); }