Browse Source

Improves PacketCaptureController - work in progress

Andreas T. Meyer-Berg 5 years ago
parent
commit
c0f598506a

+ 42 - 0
src/main/java/de/tu_darmstadt/tk/SmartHomeNetworkSim/control/PacketCaptureController.java

@@ -2,10 +2,12 @@ package de.tu_darmstadt.tk.SmartHomeNetworkSim.control;
 
 import java.util.LinkedList;
 
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketCollectionManager;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketCollector;
 import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.PacketSniffer;
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
 
 /**
  * Controller which controls access to the {@link PacketCollector} and {@link PacketSniffer}
@@ -107,4 +109,44 @@ public class PacketCaptureController {
 	public void removePacketCollector(PacketCollector collector){
 		packetCollectionManager.removePacketCollector(collector);
 	}
+	
+	/**
+	 * Adds a link to a collector, it will collect all packets send via this link
+	 * @param collector Collector which should collect packet of the link
+	 * @param link Link which should be captured
+	 */
+	public void addLinkToCollector(PacketCollector collector, Link link){
+		if(collector!=null && link != null)
+			collector.addLink(link);
+	}
+	
+	/**
+	 * Removes a link from a collector, it will no longer collect all packets send via this link
+	 * @param collector Collector which should no longer collect the packets of the link
+	 * @param link Link which should no longer be captured
+	 */
+	public void removeLinkFromCollector(PacketCollector collector, Link link){
+		if(collector!=null && link != null)
+			collector.removeLink(link);
+	}
+	
+	/**
+	 * Adds a SmartDevice to a collector, it will collect all packets send via this SmartDevice
+	 * @param collector Collector which should collect packets of the Device
+	 * @param device Device which packets should be captured
+	 */
+	public void addDeviceToCollector(PacketCollector collector, SmartDevice device){
+		if(collector!=null && device != null)
+			collector.addDevice(device);
+	}
+	
+	/**
+	 * Removes a link from a collector, it will no longer collect all packets send via this SmartDevice
+	 * @param collector Collector which should no longer collect the packets of the Device
+	 * @param device SmartDevice which should no longer be captured
+	 */
+	public void removeDeviceFromCollector(PacketCollector collector, SmartDevice device){
+		if(collector!=null && device != null)
+			collector.removeDevice(device);
+	}
 }