[gssdp] sniffer: Make it possible to enter V6 filter
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp] sniffer: Make it possible to enter V6 filter
- Date: Sun, 4 Nov 2018 11:59:58 +0000 (UTC)
commit 621f39fda27985086cb1c76d2c6b4bc7d4a59d6b
Author: Jens Georg <mail jensge org>
Date: Sun Nov 4 11:57:41 2018 +0100
sniffer: Make it possible to enter V6 filter
Remove hardced V4 lengths and entries
tools/gssdp-device-sniffer.c | 31 ++---
tools/gssdp-device-sniffer.ui | 304 +++++++++++++++---------------------------
2 files changed, 121 insertions(+), 214 deletions(-)
---
diff --git a/tools/gssdp-device-sniffer.c b/tools/gssdp-device-sniffer.c
index 552eb44..59e1d8f 100644
--- a/tools/gssdp-device-sniffer.c
+++ b/tools/gssdp-device-sniffer.c
@@ -26,7 +26,6 @@
#define UI_RESOURCE "/org/gupnp/GSSDP/DeviceSniffer.ui"
#define MENU_RESOURCE "/org/gupnp/GSSDP/WindowMenu.ui"
-#define MAX_IP_LEN 16
static char *interface = NULL;
@@ -416,7 +415,7 @@ on_use_filter_radiobutton_toggled (GtkToggleButton *togglebutton,
GtkWidget *filter_hbox;
gboolean use_filter;
- filter_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "address-filter-hbox"));
+ filter_hbox = GTK_WIDGET(gtk_builder_get_object (builder, "address-entry0"));
g_assert (filter_hbox != NULL);
use_filter = gtk_toggle_button_get_active (togglebutton);
@@ -426,26 +425,20 @@ on_use_filter_radiobutton_toggled (GtkToggleButton *togglebutton,
static char *
get_ip_filter (void)
{
- int i;
- char *ip;
- guint8 quad[4];
+ GtkEntry *entry;
+ GInetAddress *addr;
- ip = g_malloc (MAX_IP_LEN);
- for (i=0; i<4; i++) {
- GtkWidget *entry;
- char entry_name[16];
- gint val;
+ entry = GTK_ENTRY (gtk_builder_get_object (builder, "address-entry0"));
+ addr = g_inet_address_new_from_string (gtk_entry_get_text (entry));
- sprintf (entry_name, "address-entry%d", i);
- entry = GTK_WIDGET(gtk_builder_get_object (builder, entry_name));
- g_assert (entry != NULL);
+ if (addr == NULL) {
+ g_warning ("Filter not a valid IP address");
- val = atoi (gtk_entry_get_text (GTK_ENTRY (entry)));
- quad[i] = CLAMP (val, 0, 255);
+ return NULL;
}
- sprintf (ip, "%u.%u.%u.%u", quad[0], quad[1], quad[2], quad[3]);
-
- return ip;
+ g_object_unref (addr);
+
+ return g_strdup (gtk_entry_get_text (entry));
}
G_MODULE_EXPORT
@@ -629,6 +622,8 @@ on_set_address_filter (GSimpleAction *action,
g_free (ip_filter);
gtk_tree_model_get (model, &iter,
1, &ip_filter, -1);
+ gtk_entry_set_text (GTK_ENTRY (gtk_builder_get_object (builder, "address-entry0")),
+ ip_filter);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (use_filter_radio), TRUE);
}
diff --git a/tools/gssdp-device-sniffer.ui b/tools/gssdp-device-sniffer.ui
index 5a48cd5..f1acc7c 100644
--- a/tools/gssdp-device-sniffer.ui
+++ b/tools/gssdp-device-sniffer.ui
@@ -1,99 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.0 -->
+<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow" id="main-window">
<property name="can_focus">False</property>
<signal name="delete-event" handler="on_delete_event" swapped="no"/>
- <child>
- <object class="GtkStack" id="stack1">
+ <child type="titlebar">
+ <object class="GtkHeaderBar">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="show_close_button">True</property>
<child>
- <object class="GtkBox" id="vbox">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">6</property>
- <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkScrolledWindow" id="packet-scrolledwindow">
+ <object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="shadow_type">in</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Clear packet capture</property>
+ <signal name="clicked" handler="on_clear_packet_capture_activate" swapped="no"/>
<child>
- <object class="GtkTreeView" id="packet-treeview">
+ <object class="GtkImage">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
- </child>
+ <property name="can_focus">False</property>
+ <property name="icon_name">edit-clear-all-symbolic</property>
</object>
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="packet-details-scrolledwindow">
+ <object class="GtkToggleButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="shadow_type">in</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Toggle packet capture</property>
+ <property name="active">True</property>
+ <signal name="toggled" handler="on_enable_packet_capture_activate" object="capture-image"
swapped="no"/>
<child>
- <object class="GtkTextView" id="packet-details-textview">
+ <object class="GtkImage" id="capture-image">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="monospace">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">media-playback-stop-symbolic</property>
</object>
</child>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
- </object>
- <packing>
- <property name="name">page0</property>
- <property name="title" translatable="yes">Packets</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="device-details-scrolledwindow">
- <property name="name">Bar</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="margin_top">6</property>
- <property name="margin_bottom">6</property>
- <property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="device-details-treeview">
+ <object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection"/>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Trigger a rescan of the network</property>
+ <property name="action_name">win.trigger-rescan</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">view-refresh-symbolic</property>
+ </object>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
</child>
</object>
<packing>
- <property name="name">page1</property>
- <property name="title" translatable="yes">Device history</property>
<property name="position">1</property>
</packing>
</child>
- </object>
- </child>
- <child type="titlebar">
- <object class="GtkHeaderBar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="show_close_button">True</property>
<child type="title">
<object class="GtkStackSwitcher">
<property name="visible">True</property>
@@ -104,94 +94,104 @@
</object>
</child>
<child>
- <object class="GtkBox">
+ <object class="GtkMenuButton" id="window-menu">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">6</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
<child>
- <object class="GtkButton">
+ <object class="GtkImage">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Clear packet capture</property>
- <signal name="clicked" handler="on_clear_packet_capture_activate" swapped="no"/>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">edit-clear-all-symbolic</property>
- </object>
- </child>
+ <property name="can_focus">False</property>
+ <property name="icon_name">open-menu-symbolic</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkStack" id="stack1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
<child>
- <object class="GtkToggleButton">
+ <object class="GtkScrolledWindow" id="packet-scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Toggle packet capture</property>
- <property name="active">True</property>
- <signal name="toggled" handler="on_enable_packet_capture_activate" object="capture-image"
swapped="no"/>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkImage" id="capture-image">
+ <object class="GtkTreeView" id="packet-treeview">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">media-playback-stop-symbolic</property>
+ <property name="can_focus">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
</object>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButton">
+ <object class="GtkScrolledWindow" id="packet-details-scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="tooltip_text" translatable="yes">Trigger a rescan of the network</property>
- <property name="action_name">win.trigger-rescan</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkImage">
+ <object class="GtkTextView" id="packet-details-textview">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">view-refresh-symbolic</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="monospace">True</property>
</object>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="name">page0</property>
+ <property name="title" translatable="yes">Packets</property>
</packing>
</child>
<child>
- <object class="GtkMenuButton" id="window-menu">
+ <object class="GtkScrolledWindow" id="device-details-scrolledwindow">
+ <property name="name">Bar</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">6</property>
+ <property name="shadow_type">in</property>
<child>
- <object class="GtkImage">
+ <object class="GtkTreeView" id="device-details-treeview">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">open-menu-symbolic</property>
+ <property name="can_focus">True</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
</object>
</child>
</object>
<packing>
- <property name="pack_type">end</property>
+ <property name="name">page1</property>
+ <property name="title" translatable="yes">Device history</property>
<property name="position">1</property>
</packing>
</child>
@@ -212,6 +212,9 @@ Inspired by Intel Tools for UPnP.</property>
<property name="license_type">lgpl-2-1</property>
<signal name="delete-event" handler="gtk_widget_hide" object="about-dialog" swapped="yes"/>
<signal name="response" handler="gtk_widget_hide" object="about-dialog" swapped="yes"/>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="aboutdialog-vbox1">
<property name="can_focus">False</property>
@@ -229,9 +232,6 @@ Inspired by Intel Tools for UPnP.</property>
</child>
</object>
</child>
- <child type="titlebar">
- <placeholder/>
- </child>
</object>
<object class="GtkDialog" id="address-filter-dialog">
<property name="can_focus">False</property>
@@ -241,6 +241,9 @@ Inspired by Intel Tools for UPnP.</property>
<property name="transient_for">main-window</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" swapped="no"/>
<signal name="response" handler="on_address_filter_dialog_response" swapped="no"/>
+ <child type="titlebar">
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
@@ -318,107 +321,19 @@ Inspired by Intel Tools for UPnP.</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="address-filter-hbox">
+ <object class="GtkEntry" id="address-entry0">
<property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <child>
- <object class="GtkEntry" id="address-entry0">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">3</property>
- <property name="activates_default">True</property>
- <property name="width_chars">4</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="address-label0">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">.</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="address-entry1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">3</property>
- <property name="activates_default">True</property>
- <property name="width_chars">4</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="address-label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">.</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="address-entry2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">3</property>
- <property name="activates_default">True</property>
- <property name="width_chars">4</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="address-label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">.</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="address-entry3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="max_length">3</property>
- <property name="activates_default">True</property>
- <property name="width_chars">4</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">6</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="margin_left">23</property>
+ <property name="max_length">46</property>
+ <property name="activates_default">True</property>
+ <property name="width_chars">47</property>
+ <property name="caps_lock_warning">False</property>
+ <property name="placeholder_text" translatable="yes">IP address for filter</property>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
@@ -434,8 +349,5 @@ Inspired by Intel Tools for UPnP.</property>
<action-widgets>
<action-widget response="-5">closebutton1</action-widget>
</action-widgets>
- <child type="titlebar">
- <placeholder/>
- </child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]