import_text: Allow setting interface name from GUI

Add the ability to set the interface name from the GUI
"Import from Hex Dump" just as with text2pcap. The last
feature for #16724 from the GUI side.
This commit is contained in:
John Thacker 2021-12-30 13:57:45 -05:00
parent 0047ca961f
commit b296db31a4
3 changed files with 32 additions and 2 deletions

View File

@ -400,6 +400,7 @@ int ImportTextDialog::exec() {
gchar *err_info;
wtap_dump_params params;
int file_type_subtype;
QString interface_name;
QDialog::exec();
@ -493,6 +494,12 @@ int ImportTextDialog::exec() {
params.tsprec = WTAP_TSPREC_USEC; /* XXX - support other precisions? */
/* Write a pcapng temporary file */
file_type_subtype = wtap_pcapng_file_type_subtype();
if (ti_ui_->interfaceLineEdit->text().length()) {
interface_name = ti_ui_->interfaceLineEdit->text();
} else {
interface_name = ti_ui_->interfaceLineEdit->placeholderText();
}
text_import_pre_open(&params, file_type_subtype, import_info_.import_text_filename, interface_name.toUtf8().constData());
/* Use a random name for the temporary import buffer */
import_info_.wdh = wtap_dump_open_tempfile(&tmp, "import", file_type_subtype, WTAP_UNCOMPRESSED, &params, &err, &err_info);
capfile_name_.append(tmp ? tmp : "temporary file");
@ -519,6 +526,7 @@ int ImportTextDialog::exec() {
}
cleanup_wtap:
/* g_free checks for null */
g_free(params.idb_inf);
g_free(tmp);
g_free((gpointer) import_info_.payload);
switch (import_info_.mode) {

View File

@ -123,6 +123,7 @@ private slots:
void on_tagLineEdit_textChanged(const QString &tag_str);
void on_ppiLineEdit_textChanged(const QString &ppi_str);
/* Footer input */
void on_maxLengthLineEdit_textChanged(const QString &max_frame_len_str);
void on_buttonBox_helpRequested();
};

View File

@ -765,9 +765,30 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="interfaceLayout">
<item>
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="interfaceLabel">
<property name="text">
<string>Interface name:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="interfaceLineEdit">
<property name="toolTip">
<string>The name of the interface to write to the import capture file</string>
</property>
<property name="placeholderText">
<string>Fake IF, Import from Hex Dump</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="maxLengthLayout">
<item>
<widget class="QLabel" name="maxLengthLabel">
<property name="text">
<string>Maximum frame length:</string>
</property>