public void RemoveProvider(DataLinkProvider d) { // // Remove the specified DLP // lock (dataLinkProviderList) { dataLinkProviderList.Remove(d); } }
// // Procesing thread for incoming packets from the TNC. The TNC places a buffer // containing the incoming data into the channel's receive queue. This routine pulls // these frames from the queue for processing. // // Processing steps: // - Parse the raw incoming frame into an HDLC buffer. This process // removes the byte stuffing and verifies the packet CRC. // - Find the Data Link Provider handling incoming data for the Station ID // specified in the incoming address field of the packet. If no matching // dlp is registered, then we simply drop the packet. (Future: we add in support // for multi-cast packets, which will forward to all registered DLPs) // - Place the frame, source, and buffer type into a packet object and place it into the // receive queue of the target DLP. // void RecvFromPort() { Byte[] buf; while (runState.Equals(RunState.Running)) { try { buf = channel.Recv(); } catch { continue; } if (buf == null) { continue; } // // Parse raw buffer // AX25Frame.ParsedFrame pFrame = new AX25Frame.ParsedFrame(HDLCFramer.ParseHDLCFrame(buf)); AX25Frame.Packet pkt = new AX25Frame.Packet( AX25Frame.Packet.PacketType.ParsedFrame, AX25Frame.Packet.Source.Remote, pFrame); // // Look for the DLP handling this packet destination // DataLinkProvider dlp = GetProvider(pFrame.frameInfo.staLink.destinationAddr.stationIDString); if (dlp == null) { // // Ignore the packet and Loop if we cannot find a provider for the incoming frame // TODO - Add support for multi-cast // continue; } // // Send up to the data link provider handling the specified StationID // dlp.dataLinkProviderQ.Enqueue(pkt); } }
DataLinkProvider AddProvider(DataLinkProvider d) { // // Add a DLP to the list if it is not already there. // lock (dataLinkProviderList) { foreach (DataLinkProvider dlp in dataLinkProviderList) { if (dlp.localStationAddress.stationIDString.Equals(d.localStationAddress.stationIDString)) { return(dlp); //Connection already exists, so return it instead } } dataLinkProviderList.Add(d); return(d); } }
public Connection GetConnectionByACKModeID(DataLinkProvider dlp, Int16 AckModeID) { // // Routine to seach for either an incoming or outgoing Connection handling a specific StationLink. // Returns null if no connection is found. // Connection retCon = null; lock (dlp.connectionList) { foreach (Connection con in dlp.connectionList) { if (con.AckModeID == AckModeID) { retCon = con; break; } } } return(retCon); }
//#endregion DataLinkProvider GetProvider(String StationID) { // // Routine to seach for the DLP handling a given station callsign. Returns null if // no provider is found. // DataLinkProvider retDlp = null; lock (dataLinkProviderList) { foreach (DataLinkProvider dlp in dataLinkProviderList) { if (dlp.localStationAddress.stationIDString.Equals(StationID)) { retDlp = dlp; break; } } } return(retDlp); }
void DigipeatCheckAndProcess(Frame.Packet packet) { DataLinkProvider dlp = null; Int32 relayNum = 0; Int32 relayCount = 0; if (packet.receivedFrame != null) { if (packet.receivedFrame.decodeOK) { // // Packet looks OK // Station sta = packet.receivedFrame.staLink; if (sta.relayStation1.stationIDString.Length > 0) { relayCount++; } if (sta.relayStation2.stationIDString.Length > 0) { relayCount++; } if ((relayCount >= 1) && (sta.relayStation1.chBit == 0)) { // // Relay address 1 has not been repeated, so see if we have a DLP for it. // dlp = GetProvider(sta.relayStation1.stationIDString); relayNum = 1; } else if ((relayCount >= 2) && (sta.relayStation2.chBit == 0)) { // // Relay address 2 has not been repeated, so see if we have a DLP for it. // dlp = GetProvider(sta.relayStation2.stationIDString); relayNum = 2; } else { dlp = GetProvider(sta.destinationStation.stationIDString); } } if (dlp != null) { // // We have a provider, check whether this is a digi or if packet is at its final destination // if (relayNum == 0) { // // All digipeating complete (if any) so send it up for processing // dlp.Send(packet); } else { // // Need to digipeat it, so send it up for digipeating // dlp.Digipeat(packet, relayNum); } } } }