aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2021-12-21 21:09:27 -0500
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-12-22 02:41:11 +0000
commit3ff0c753a1ddd676cbe2e18fe7a555be6273fbfe (patch)
tree3e3f74ffc3ec6fc773e86dabcc8ecde4a60e5410 /ui
parent2c44afbba3b6f5f01dd87a5c42beaa1186aaa07a (diff)
text_import: Add interface and internals for dummy IPv4 addresses
Add dummy IPv4 addresses to the text_import_info_t struct, and use them if set in the same way text2pcap does. GUI support in "Import from Hex Dump" is not added yet. This is also part of the work for text2pcap to eventually call text_import. Related to #16724.
Diffstat (limited to 'ui')
-rw-r--r--ui/text_import.c20
-rw-r--r--ui/text_import.h2
2 files changed, 17 insertions, 5 deletions
diff --git a/ui/text_import.c b/ui/text_import.c
index 4810bb40aa..2cb2054a0c 100644
--- a/ui/text_import.c
+++ b/ui/text_import.c
@@ -155,6 +155,10 @@ static guint32 hdr_ethernet_proto = 0;
static gboolean hdr_ip = FALSE;
static guint hdr_ip_proto = 0;
+/* Destination and source addresses for IP header */
+static ws_in4_addr hdr_ip_dest_addr = 0;
+static ws_in4_addr hdr_ip_src_addr = 0;
+
/* Dummy UDP header */
static gboolean hdr_udp = FALSE;
static guint32 hdr_dest_port = 0;
@@ -483,11 +487,12 @@ write_current_packet(gboolean cont)
vec_t cksum_vector[1];
if (isOutbound) {
- HDR_IP.src_addr = IP_DST;
- HDR_IP.dest_addr = IP_SRC;
- } else {
- HDR_IP.src_addr = IP_SRC;
- HDR_IP.dest_addr = IP_DST;
+ HDR_IP.src_addr = hdr_ip_dest_addr ? hdr_ip_dest_addr : IP_DST;
+ HDR_IP.dest_addr = hdr_ip_src_addr ? hdr_ip_src_addr : IP_SRC;
+ }
+ else {
+ HDR_IP.src_addr = hdr_ip_src_addr ? hdr_ip_src_addr : IP_SRC;
+ HDR_IP.dest_addr = hdr_ip_dest_addr ? hdr_ip_dest_addr : IP_DST;
}
HDR_IP.packet_length = g_htons(ip_length);
HDR_IP.protocol = (guint8) hdr_ip_proto;
@@ -1490,6 +1495,11 @@ text_import(const text_import_info_t *info)
break;
}
+ if (hdr_ip) {
+ hdr_ip_src_addr = info->ip_src_addr;
+ hdr_ip_dest_addr = info->ip_dest_addr;
+ }
+
max_offset = info->max_frame_length;
if (info->mode == TEXT_IMPORT_HEXDUMP) {
diff --git a/ui/text_import.h b/ui/text_import.h
index 8c2a2488a8..a1a0d288ec 100644
--- a/ui/text_import.h
+++ b/ui/text_import.h
@@ -90,6 +90,8 @@ typedef struct
/* Dummy header info (if encapsulation == 1) */
enum dummy_header_type dummy_header_type;
guint pid;
+ ws_in4_addr ip_src_addr;
+ ws_in4_addr ip_dest_addr;
guint protocol;
guint src_port;
guint dst_port;