Mark the file as having unsaved data if you change address resolution.
That information can, and will, get saved in some file formats, so mark the file as changed so it can and will get saved by "Save". XXX - we need to treat it as a type of data that can be discarded when saving in some file formats, just like comments. Bug: 12629 Change-Id: I1fd69b95f4f7345c339961b4c53c28b98b364e4e Reviewed-on: https://code.wireshark.org/review/16538 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
6df8e83e57
commit
e5fa40ab31
18
file.c
18
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_)
|
||||
|
|
10
file.h
10
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.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -59,6 +59,7 @@ private slots:
|
|||
|
||||
private:
|
||||
Ui::AddressEditorFrame *ui;
|
||||
capture_file *cap_file_;
|
||||
|
||||
bool isAddressColumn(struct epan_column_info *cinfo, int column);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue