public void ReceivePUP(PUP pup) { // // Filter out packets not destined for us. // Even though we use pcap in non-promiscuous mode, if // something else has set the interface to promiscuous mode, that // setting may be overridden. // if (pup.DestinationPort.Host != 0 && // Not broadcast. pup.DestinationPort.Host != DirectoryServices.Instance.LocalHost) // Not our address. { // Do nothing with this PUP. Log.Write(LogType.Verbose, LogComponent.PUP, "PUP is neither broadcast nor for us. Discarding."); return; } // // Forward PUP on to registered endpoints. // if (_dispatchMap.ContainsKey(pup.DestinationPort.Socket)) { PUPProtocolEntry entry = _dispatchMap[pup.DestinationPort.Socket]; if (entry.ConnectionType == ConnectionType.Connectionless) { Log.Write(LogType.Verbose, LogComponent.PUP, "Dispatching PUP (source {0}, dest {1}) to {2} handler.", pup.SourcePort, pup.DestinationPort, entry.FriendlyName); // Connectionless; just pass the PUP directly to the protocol entry.ProtocolImplementation.RecvData(pup); } else { // RTP / BSP protocol. Pass this to the BSP handler to set up a channel. Log.Write(LogType.Verbose, LogComponent.PUP, "Dispatching PUP (source {0}, dest {1}) to BSP protocol for {0}.", pup.SourcePort, pup.DestinationPort, entry.FriendlyName); BSPManager.EstablishRendezvous(pup, entry.WorkerType); } } else if (BSPManager.ChannelExistsForSocket(pup)) { // An established BSP channel, send data to it. BSPManager.RecvData(pup); } else if (EFTPManager.ChannelExistsForSocket(pup)) { EFTPManager.RecvData(pup); } else { // Not a protocol we handle; log it. Log.Write(LogType.Normal, LogComponent.PUP, "Unhandled PUP protocol, source {0}, destination {1}, type {2}, dropped packet.", pup.SourcePort, pup.DestinationPort, pup.Type); } }
private void SendBootFile(PUP p) { // // The request PUP contains the file number in the lower-order 16-bits of the pup ID. // Assuming the number is a valid bootfile, we start sending it to the client's port via EFTP. // ushort fileNumber = (ushort)p.ID; Log.Write(LogType.Verbose, LogComponent.MiscServices, "Boot file request is for file {0}.", fileNumber); FileStream bootFile = BootServer.GetStreamForNumber(fileNumber); if (bootFile == null) { Log.Write(LogType.Warning, LogComponent.MiscServices, "Boot file {0} does not exist or could not be opened.", fileNumber); } else { // Send the file. EFTPManager.SendFile(p.SourcePort, bootFile); } }