aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--file.c18
-rw-r--r--file.h10
-rw-r--r--ui/gtk/manual_addr_resolv.c3
-rw-r--r--ui/qt/address_editor_frame.cpp29
-rw-r--r--ui/qt/address_editor_frame.h1
5 files changed, 47 insertions, 14 deletions
diff --git a/file.c b/file.c
index 9ab2854..73eef29 100644
--- a/file.c
+++ b/file.c
@@ -3977,6 +3977,24 @@ cf_comment_types(capture_file *cf)
return comment_types;
}
+/*
+ * Add a resolved address to this file's list of resolved addresses.
+ */
+gboolean
+cf_add_ip_name_from_string(capture_file *cf, const char *addr, const char *name)
+{
+ /*
+ * XXX - support multiple resolved address lists, and add to the one
+ * attached to this file?
+ */
+ if (!add_ip_name_from_string(addr, name))
+ return FALSE;
+
+ /* OK, we have unsaved changes. */
+ cf->unsaved_changes = TRUE;
+ return TRUE;
+}
+
#ifdef WANT_PACKET_EDITOR
static gint
g_direct_compare_func(gconstpointer a, gconstpointer b, gpointer user_data _U_)
diff --git a/file.h b/file.h
index 8a54cde..65354e7 100644
--- a/file.h
+++ b/file.h
@@ -696,6 +696,16 @@ gboolean cf_set_user_packet_comment(capture_file *cf, frame_data *fd, const gcha
*/
guint32 cf_comment_types(capture_file *cf);
+/**
+ * Add a resolved address to this file's list of resolved addresses.
+ *
+ * @param cf the capture file
+ * @param addr a string representing an IPv4 or IPv6 address
+ * @param name a string containing a name corresponding to that address
+ * @return TRUE if it succeeds, FALSE if not
+ */
+gboolean cf_add_ip_name_from_string(capture_file *cf, const char *addr, const char *name);
+
#ifdef WANT_PACKET_EDITOR
/**
* Give a frame new, edited data.
diff --git a/ui/gtk/manual_addr_resolv.c b/ui/gtk/manual_addr_resolv.c
index 0fae93d..085dc06 100644
--- a/ui/gtk/manual_addr_resolv.c
+++ b/ui/gtk/manual_addr_resolv.c
@@ -62,7 +62,7 @@ man_addr_resolv_ok(GtkWidget *w _U_, gpointer data _U_)
name = gtk_entry_get_text(GTK_ENTRY(name_te));
if (strlen(addr) && strlen(name)) {
- if (!add_ip_name_from_string(addr, name)) {
+ if (!cf_add_ip_name_from_string(&cfile, addr, name)) {
GtkWidget *dialog = (GtkWidget *)simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
"Illegal IP address: \"%s\".", addr);
simple_dialog_set_cb(dialog, man_addr_ill_addr_cb, NULL);
@@ -70,6 +70,7 @@ man_addr_resolv_ok(GtkWidget *w _U_, gpointer data _U_)
return;
} else {
redissect = TRUE;
+ main_update_for_unsaved_changes(&cfile);
}
}
g_free(addr);
diff --git a/ui/qt/address_editor_frame.cpp b/ui/qt/address_editor_frame.cpp
index cb27144..49e3fa1 100644
--- a/ui/qt/address_editor_frame.cpp
+++ b/ui/qt/address_editor_frame.cpp
@@ -42,7 +42,8 @@
AddressEditorFrame::AddressEditorFrame(QWidget *parent) :
AccordionFrame(parent),
- ui(new Ui::AddressEditorFrame)
+ ui(new Ui::AddressEditorFrame),
+ cap_file_(NULL)
{
ui->setupUi(this);
@@ -60,12 +61,14 @@ AddressEditorFrame::~AddressEditorFrame()
void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
{
- if (!cf.capFile()->current_frame) {
+ cap_file_ = cf.capFile();
+
+ if (!cap_file_->current_frame) {
on_buttonBox_rejected();
return;
}
- if (!cf_read_record(cf.capFile(), cf.capFile()->current_frame)) {
+ if (!cf_read_record(cap_file_, cap_file_->current_frame)) {
on_buttonBox_rejected();
return; // error reading the frame
}
@@ -75,22 +78,22 @@ void AddressEditorFrame::editAddresses(CaptureFile &cf, int column)
ui->addressComboBox->clear();
- epan_dissect_init(&edt, cf.capFile()->epan, FALSE, FALSE);
- col_custom_prime_edt(&edt, &cf.capFile()->cinfo);
+ epan_dissect_init(&edt, cap_file_->epan, FALSE, FALSE);
+ col_custom_prime_edt(&edt, &cap_file_->cinfo);
- epan_dissect_run(&edt, cf.capFile()->cd_t, &cf.capFile()->phdr,
- frame_tvbuff_new_buffer(cf.capFile()->current_frame, &cf.capFile()->buf), cf.capFile()->current_frame, &cf.capFile()->cinfo);
+ epan_dissect_run(&edt, cap_file_->cd_t, &cap_file_->phdr,
+ frame_tvbuff_new_buffer(cap_file_->current_frame, &cap_file_->buf), cap_file_->current_frame, &cap_file_->cinfo);
epan_dissect_fill_in_columns(&edt, TRUE, TRUE);
/* First check selected column */
- if (isAddressColumn(&cf.capFile()->cinfo, column)) {
- addresses << cf.capFile()->cinfo.col_expr.col_expr_val[column];
+ if (isAddressColumn(&cap_file_->cinfo, column)) {
+ addresses << cap_file_->cinfo.col_expr.col_expr_val[column];
}
- for (int col = 0; col < cf.capFile()->cinfo.num_cols; col++) {
+ for (int col = 0; col < cap_file_->cinfo.num_cols; col++) {
/* Then check all columns except the selected */
- if ((col != column) && (isAddressColumn(&cf.capFile()->cinfo, col))) {
- addresses << cf.capFile()->cinfo.col_expr.col_expr_val[col];
+ if ((col != column) && (isAddressColumn(&cap_file_->cinfo, col))) {
+ addresses << cap_file_->cinfo.col_expr.col_expr_val[col];
}
}
@@ -142,7 +145,7 @@ void AddressEditorFrame::on_buttonBox_accepted()
}
QString addr = ui->addressComboBox->currentText();
QString name = ui->nameLineEdit->text();
- if (!add_ip_name_from_string(addr.toUtf8().constData(), name.toUtf8().constData())) {
+ if (!cf_add_ip_name_from_string(cap_file_, addr.toUtf8().constData(), name.toUtf8().constData())) {
QString error_msg = tr("Can't assign %1 to %2").arg(name).arg(addr);
emit editAddressStatus(error_msg);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
diff --git a/ui/qt/address_editor_frame.h b/ui/qt/address_editor_frame.h
index 0bec30b..eb57263 100644
--- a/ui/qt/address_editor_frame.h
+++ b/ui/qt/address_editor_frame.h
@@ -59,6 +59,7 @@ private slots:
private:
Ui::AddressEditorFrame *ui;
+ capture_file *cap_file_;
bool isAddressColumn(struct epan_column_info *cinfo, int column);
};