예제 #1
0
    def __init__(self, netzob, plugin):
        """Constructor of NetworkCapturerController:

                @type netzob: netzob.NetzobGUI.NetzobGUI
                @param netzob: the main netzob project.
        """
        view = NetworkCapturerView(plugin, self)
        super(NetworkCapturerController, self).__init__(netzob, plugin, view)
        self.model = NetworkCapturer(netzob)
        for device in self.model.getNetworkDevices():
            self.view.deviceCombo.append_text(str(device))
    def __init__(self, netzob, plugin):
        """Constructor of NetworkCapturerController:

                @type netzob: netzob.NetzobGUI.NetzobGUI
                @param netzob: the main netzob project.
        """
        view = NetworkCapturerView(plugin, self)
        super(NetworkCapturerController, self).__init__(netzob, plugin, view)
        self.model = NetworkCapturer(netzob)
        for device in self.model.getNetworkDevices():
            self.view.deviceCombo.append_text(str(device))
예제 #3
0
class NetworkCapturerController(AbstractCapturerController):
    """NetworkCapturerController:
            A controller liking the network capturer and its view in the netzob GUI.
    """

    COLUMN_ID = 0
    COLUMN_SELECTED = 1

    def __init__(self, netzob, plugin):
        """Constructor of NetworkCapturerController:

                @type netzob: netzob.NetzobGUI.NetzobGUI
                @param netzob: the main netzob project.
        """
        super(NetworkCapturerController, self).__init__(netzob, plugin)
        self.netzob = netzob
        self.model = NetworkCapturer(netzob)
        self.view = NetworkCapturerView(plugin, self)
        for device in self.model.getNetworkDevices():
            self.view.deviceCombo.append_text(str(device))

    def getImportLayer(self):
        return self.model.importLayer

    def setImportLayer(self, importLayer):
        self.model.setImportLayer(importLayer)

    importLayer = property(getImportLayer, setImportLayer)

    def clearFilterButton_clicked_cb(self, widget):
        self.view.filterEntry.set_text("")

    def layerRadioButton_toggled_cb(self, widget):
        if self.view.layerRadioButton1.get_active():
            self.importLayer = 1
            self.view.makeL1ImportTreeView()
        elif self.view.layerRadioButton2.get_active():
            self.importLayer = 2
            self.view.makeL2ImportTreeView()
        elif self.view.layerRadioButton3.get_active():
            self.importLayer = 3
            self.view.makeL3ImportTreeView()
        else:
            self.importLayer = 4
            self.view.makeL4ImportTreeView()

    def doReadMessages(self):
        # Sanity checks
        device = self.view.deviceCombo.get_active_text()
        if device is None:
            NetzobErrorMessage(_("Incorrect device"))
            return
        count = self.view.countEntry.get_text()
        try:
            count = int(count)
        except ValueError:
            NetzobErrorMessage(_("Incorrect count"))
            return
        if count < 1:
            NetzobErrorMessage(_("Incorrect count"))
        time = self.view.timeEntry.get_text()
        try:
            time = int(time)
        except ValueError:
            NetzobErrorMessage(_("Incorrect time"))
            return
        if time < 1:
            NetzobErrorMessage(_("Incorrect time"))

        # Launch packets capturing
        try:
            self.model.setBPFFilter(self.view.filterEntry.get_text().strip())
            self.model.readMessages(self.callback_readMessage, device, count, time)
        except NetzobImportException, importEx:
            if importEx.statusCode == WARNING:
                self.view.showWarning(importEx.message)
            else:
                NetzobErrorMessage(importEx.message)
예제 #4
0
class NetworkCapturerController(AbstractCapturerController):
    """NetworkCapturerController:
            A controller liking the network capturer and its view in the netzob GUI.
    """

    COLUMN_ID = 0
    COLUMN_SELECTED = 1

    def __init__(self, netzob, plugin):
        """Constructor of NetworkCapturerController:

                @type netzob: netzob.NetzobGUI.NetzobGUI
                @param netzob: the main netzob project.
        """
        view = NetworkCapturerView(plugin, self)
        super(NetworkCapturerController, self).__init__(netzob, plugin, view)
        self.model = NetworkCapturer(netzob)
        for device in self.model.getNetworkDevices():
            self.view.deviceCombo.append_text(str(device))

    def getImportLayer(self):
        return self.model.importLayer

    def setImportLayer(self, importLayer):
        self.model.setImportLayer(importLayer)

    importLayer = property(getImportLayer, setImportLayer)

    def clearFilterButton_clicked_cb(self, widget):
        self.view.filterEntry.set_text("")

    def layerRadioButton_toggled_cb(self, widget):
        if self.view.layerRadioButton1.get_active():
            self.importLayer = 1
            self.view.makeL1ImportTreeView()
        elif self.view.layerRadioButton2.get_active():
            self.importLayer = 2
            self.view.makeL2ImportTreeView()
        elif self.view.layerRadioButton3.get_active():
            self.importLayer = 3
            self.view.makeL3ImportTreeView()
        else:
            self.importLayer = 4
            self.view.makeL4ImportTreeView()

    def doReadMessages(self):
        # Sanity checks
        device = self.view.deviceCombo.get_active_text()
        if device is None:
            NetzobErrorMessage(_("Incorrect device"))
            return
        count = self.view.countEntry.get_text()
        try:
            count = int(count)
        except ValueError:
            NetzobErrorMessage(_("Incorrect count"))
            return
        if count < 1:
            NetzobErrorMessage(_("Incorrect count"))
        time = self.view.timeEntry.get_text()
        try:
            time = int(time)
        except ValueError:
            NetzobErrorMessage(_("Incorrect time"))
            return
        if time < 1:
            NetzobErrorMessage(_("Incorrect time"))

        # Launch packets capturing
        try:
            self.model.setBPFFilter(self.view.filterEntry.get_text().strip())
            self.model.readMessages(self.callback_readMessage, device, count,
                                    time)
        except NetzobImportException, importEx:
            if importEx.statusCode == WARNING:
                self.view.showWarning(importEx.message)
            else:
                NetzobErrorMessage(importEx.message)