import text: add IPv6 option, custom IPv6 addresses
Add the option to use IPv6 instead of IPv4 for dummy headers, including custom source and destination address, to the "Import from Hex Dump" GUI box. Related to #16724
This commit is contained in:
parent
756cc28592
commit
a42723359e
|
@ -261,6 +261,7 @@ void ImportTextDialog::applyDialogSettings()
|
|||
ti_ui_->noDummyButton->setChecked(true);
|
||||
}
|
||||
|
||||
ti_ui_->ipv6CheckBox->setChecked(settings["ipv6"].toBool());
|
||||
ti_ui_->ethertypeLineEdit->setText(settings["ethertype"].toString());
|
||||
ti_ui_->protocolLineEdit->setText(settings["ipProtocol"].toString());
|
||||
ti_ui_->sourceAddressLineEdit->setText(settings["sourceAddress"].toString());
|
||||
|
@ -361,6 +362,7 @@ void ImportTextDialog::storeDialogSettings()
|
|||
settings["dummyHeader"] = "none";
|
||||
}
|
||||
|
||||
settings["ipv6"] = ti_ui_->ipv6CheckBox->isChecked();
|
||||
settings["ethertype"] = ti_ui_->ethertypeLineEdit->text();
|
||||
settings["ipProtocol"] = ti_ui_->protocolLineEdit->text();
|
||||
settings["sourceAddress"] = ti_ui_->sourceAddressLineEdit->text();
|
||||
|
@ -897,6 +899,13 @@ void ImportTextDialog::on_ipv4Button_toggled(bool checked)
|
|||
on_noDummyButton_toggled(checked);
|
||||
}
|
||||
|
||||
void ImportTextDialog::on_ipv6CheckBox_toggled(bool checked)
|
||||
{
|
||||
import_info_.ipv6 = checked;
|
||||
on_sourceAddressLineEdit_textChanged(ti_ui_->sourceAddressLineEdit->text());
|
||||
on_destinationAddressLineEdit_textChanged(ti_ui_->destinationAddressLineEdit->text());
|
||||
}
|
||||
|
||||
void ImportTextDialog::on_udpButton_toggled(bool checked)
|
||||
{
|
||||
on_noDummyButton_toggled(checked);
|
||||
|
@ -972,6 +981,29 @@ void ImportTextDialog::checkAddress(SyntaxLineEdit *le, bool &ok_enabled, const
|
|||
updateImportButtonState();
|
||||
}
|
||||
|
||||
void ImportTextDialog::checkIPv6Address(SyntaxLineEdit *le, bool &ok_enabled, const QString &addr_str, ws_in6_addr *val_ptr) {
|
||||
bool conv_ok;
|
||||
SyntaxLineEdit::SyntaxState syntax_state = SyntaxLineEdit::Empty;
|
||||
|
||||
if (!le || !val_ptr)
|
||||
return;
|
||||
|
||||
ok_enabled = true;
|
||||
if (addr_str.length() < 1) {
|
||||
*val_ptr = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
|
||||
} else {
|
||||
conv_ok = ws_inet_pton6(addr_str.toLocal8Bit().data(), (ws_in6_addr*)val_ptr);
|
||||
if (conv_ok) {
|
||||
syntax_state= SyntaxLineEdit::Valid;
|
||||
} else {
|
||||
syntax_state = SyntaxLineEdit::Invalid;
|
||||
ok_enabled = false;
|
||||
}
|
||||
}
|
||||
le->setSyntaxState(syntax_state);
|
||||
updateImportButtonState();
|
||||
}
|
||||
|
||||
void ImportTextDialog::on_ethertypeLineEdit_textChanged(const QString ðertype_str)
|
||||
{
|
||||
check_line_edit(ti_ui_->ethertypeLineEdit, ether_type_ok_, ethertype_str, 16, 0xffff, true, &import_info_.pid);
|
||||
|
@ -984,12 +1016,20 @@ void ImportTextDialog::on_protocolLineEdit_textChanged(const QString &protocol_s
|
|||
|
||||
void ImportTextDialog::on_sourceAddressLineEdit_textChanged(const QString &source_addr_str)
|
||||
{
|
||||
checkAddress(ti_ui_->sourceAddressLineEdit, source_addr_ok_, source_addr_str, &import_info_.ip_src_addr.ipv4);
|
||||
if (ti_ui_->ipv6CheckBox->isChecked()) {
|
||||
checkIPv6Address(ti_ui_->sourceAddressLineEdit, source_addr_ok_, source_addr_str, &import_info_.ip_src_addr.ipv6);
|
||||
} else {
|
||||
checkAddress(ti_ui_->sourceAddressLineEdit, source_addr_ok_, source_addr_str, &import_info_.ip_src_addr.ipv4);
|
||||
}
|
||||
}
|
||||
|
||||
void ImportTextDialog::on_destinationAddressLineEdit_textChanged(const QString &destination_addr_str)
|
||||
{
|
||||
checkAddress(ti_ui_->destinationAddressLineEdit, dest_addr_ok_, destination_addr_str, &import_info_.ip_dest_addr.ipv4);
|
||||
if (ti_ui_->ipv6CheckBox->isChecked()) {
|
||||
checkIPv6Address(ti_ui_->destinationAddressLineEdit, dest_addr_ok_, destination_addr_str, &import_info_.ip_dest_addr.ipv6);
|
||||
} else {
|
||||
checkAddress(ti_ui_->destinationAddressLineEdit, dest_addr_ok_, destination_addr_str, &import_info_.ip_dest_addr.ipv4);
|
||||
}
|
||||
}
|
||||
|
||||
void ImportTextDialog::on_sourcePortLineEdit_textChanged(const QString &source_port_str)
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
|
||||
void check_line_edit(SyntaxLineEdit *le, bool &ok_enable, const QString &num_str, int base, guint max_val, bool is_short, guint *val_ptr);
|
||||
void checkAddress(SyntaxLineEdit *le, bool &ok_enable, const QString &addr_str, ws_in4_addr *val_ptr);
|
||||
void checkIPv6Address(SyntaxLineEdit *le, bool &ok_enable, const QString &addr_str, ws_in6_addr *val_ptr);
|
||||
bool checkDateTimeFormat(const QString &time_format);
|
||||
|
||||
void loadSettingsFile();
|
||||
|
@ -107,6 +108,7 @@ private slots:
|
|||
void on_noDummyButton_toggled(bool checked);
|
||||
void on_ethernetButton_toggled(bool checked);
|
||||
void on_ipv4Button_toggled(bool checked);
|
||||
void on_ipv6CheckBox_toggled(bool checked);
|
||||
void on_udpButton_toggled(bool checked);
|
||||
void on_tcpButton_toggled(bool checked);
|
||||
void on_sctpButton_toggled(bool checked);
|
||||
|
|
|
@ -562,17 +562,27 @@
|
|||
<item row="2" column="0">
|
||||
<widget class="QRadioButton" name="ipv4Button">
|
||||
<property name="toolTip">
|
||||
<string>Prefix each frame with an Ethernet and IPv4 header</string>
|
||||
<string>Prefix each frame with an Ethernet and IP header</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IPv4</string>
|
||||
<string>IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="ipv6CheckBox">
|
||||
<property name="toolTip">
|
||||
<string>Prefix with IPv6 instead of IPv4</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>IPv6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QRadioButton" name="udpButton">
|
||||
<property name="toolTip">
|
||||
<string>Prefix each frame with an Ethernet, IPv4 and UDP header</string>
|
||||
<string>Prefix each frame with an Ethernet, IP and UDP header</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>UDP</string>
|
||||
|
@ -582,7 +592,7 @@
|
|||
<item row="6" column="0">
|
||||
<widget class="QRadioButton" name="tcpButton">
|
||||
<property name="toolTip">
|
||||
<string>Prefix each frame with an Ethernet, IPv4 and TCP header</string>
|
||||
<string>Prefix each frame with an Ethernet, IP and TCP header</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TCP</string>
|
||||
|
@ -592,7 +602,7 @@
|
|||
<item row="7" column="0">
|
||||
<widget class="QRadioButton" name="sctpButton">
|
||||
<property name="toolTip">
|
||||
<string>Prefix each frame with an Ethernet, IPv4 and SCTP header</string>
|
||||
<string>Prefix each frame with an Ethernet, IP and SCTP header</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SCTP</string>
|
||||
|
@ -602,7 +612,7 @@
|
|||
<item row="8" column="0">
|
||||
<widget class="QRadioButton" name="sctpDataButton">
|
||||
<property name="toolTip">
|
||||
<string>Prefix each frame with an Ethernet, IPv4 and SCTP (DATA) header</string>
|
||||
<string>Prefix each frame with an Ethernet, IP and SCTP (DATA) header</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SCTP (Data)</string>
|
||||
|
@ -692,7 +702,7 @@
|
|||
<item row="2" column="2">
|
||||
<widget class="SyntaxLineEdit" name="protocolLineEdit">
|
||||
<property name="toolTip">
|
||||
<string>The IPv4 protocol ID for each frame</string>
|
||||
<string>The IP protocol ID for each frame</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
Loading…
Reference in New Issue