Пример #1
0
	def configure(self, properties):
		oldCaptureToFile = self.getCaptureToFile()
		oldCaptureViaNet = self.getCaptureViaNet()
		oldCaptureFilter = self.getCaptureFilter()
		#FIXME: validate filter
		if "capture_to_file" in properties:
			self.setCaptureToFile(properties["capture_to_file"])
		if "capture_filter" in properties:
			self.setCaptureFilter(properties["capture_filter"])
		if "capture_via_net" in properties:
			self.setCaptureViaNet(properties["capture_via_net"])
		if "delay" in properties:
			self.setDelay(properties["delay"])
		if "bandwidth" in properties:
			self.setBandwidth(properties["bandwidth"])
		if "lossratio" in properties:
			self.setLossRatio(properties["lossratio"])
		Connection.configure(self, properties)
		if self.connector.state == State.STARTED:
			self._configLink()
			if oldCaptureToFile and (not self.getCaptureToFile() or self.getCaptureFilter() != oldCaptureFilter):
				self._stopCaptureToFile()
			if oldCaptureViaNet and (not self.getCaptureViaNet() or self.getCaptureFilter() != oldCaptureFilter):
				self._stopCaptureViaNet()
			if self.getCaptureToFile() and (not oldCaptureToFile or self.getCaptureFilter() != oldCaptureFilter):
				self._startCaptureToFile()
			if self.getCaptureViaNet() and (not oldCaptureViaNet or self.getCaptureFilter() != oldCaptureFilter):
				self._startCaptureViaNet()
Пример #2
0
 def configure(self, properties):
     oldCaptureToFile = self.getCaptureToFile()
     oldCaptureViaNet = self.getCaptureViaNet()
     oldCaptureFilter = self.getCaptureFilter()
     if "capture_filter" in properties:
         filter = properties["capture_filter"]
         host = self.getHost()
         if host:
             fault.check(tcpdump._checkSyntax(host, filter=filter), "Syntax error in filter")
         self.setCaptureFilter(properties["capture_filter"])
     if "capture_to_file" in properties:
         self.setCaptureToFile(properties["capture_to_file"])
     if "capture_via_net" in properties:
         self.setCaptureViaNet(properties["capture_via_net"])
     for p in netemProperties:
         if p in properties:
             val = properties[p]
             val = netemValueConvert[p](val)
             fault.check(netemValuesChecks[p](val), "Invalid value for %s: %s", (p, val))
             self.setAttribute(p, val)
         if p + "_to" in properties:
             val = properties[p + "_to"]
             val = netemValueConvert[p](val)
             fault.check(netemValuesChecks[p](val), "Invalid value for %s: %s", (p + "_to", val))
             self.setAttribute(p + "_to", val)
         if p + "_from" in properties:
             val = properties[p + "_from"]
             val = netemValueConvert[p](val)
             fault.check(netemValuesChecks[p](val), "Invalid value for %s: %s", (p + "_from", val))
             self.setAttribute(p + "_from", val)
     Connection.configure(self, properties)
     if self.connector.state == State.STARTED:
         self._configLink()
         if oldCaptureToFile and (not self.getCaptureToFile() or self.getCaptureFilter() != oldCaptureFilter):
             self._stopCaptureToFile()
         if oldCaptureViaNet and (not self.getCaptureViaNet() or self.getCaptureFilter() != oldCaptureFilter):
             self._stopCaptureViaNet()
         if self.getCaptureToFile() and (not oldCaptureToFile or self.getCaptureFilter() != oldCaptureFilter):
             self._startCaptureToFile()
         if self.getCaptureViaNet() and (not oldCaptureViaNet or self.getCaptureFilter() != oldCaptureFilter):
             self._startCaptureViaNet()