aboutsummaryrefslogtreecommitdiffstats
path: root/text2pcap.c
diff options
context:
space:
mode:
authorJaap Keuter <jaap.keuter@xs4all.nl>2018-11-18 12:01:06 +0100
committerAnders Broman <a.broman58@gmail.com>2018-11-19 06:18:21 +0000
commit9aa29213f0923b3f4a55a8645ae2026af56c1683 (patch)
treec2af1c686bb14969f0281a643086e0766ad51859 /text2pcap.c
parentbf9286e554c8d2b9e506b62dc7c0ed8f6e830160 (diff)
text2pcap: consolidate ethernet header protocol determination
With the addition of the IPv6 dummy header the logic to set the correct ethernet protocol has become scattered across the code and also poured into the actual packet writing code. Once command line parsing is completed a consistent set of frame generating parameters should be established. This change consolidates the ethernet header protocol determination to one point, with the added benefit of resolving a possible duplicate IPv4 / IPv6 paramter setting in the same manner as is done for other conflicting parameters. Change-Id: I2c0d3ee8ad5a28b216a374dad807406113200fa2 Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/30691 Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'text2pcap.c')
-rw-r--r--text2pcap.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/text2pcap.c b/text2pcap.c
index 14fd6c7fff..de070ae335 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -626,12 +626,6 @@ write_current_packet (gboolean cont)
/* Is direction indication on with an inbound packet? */
gboolean isInbound = has_direction && (direction == 2);
- /* if defined IPv6 we should rewrite hdr_ethernet_proto anyways */
- if (hdr_ipv6) {
- hdr_ethernet_proto = 0x86DD;
- hdr_ip = FALSE;
- }
-
/* Compute packet length */
length = curr_offset;
if (hdr_sctp) {
@@ -1522,7 +1516,6 @@ parse_options (int argc, char *argv[])
return EXIT_FAILURE;
}
hdr_ethernet = TRUE;
- hdr_ethernet_proto = 0x800;
break;
case 's':
@@ -1565,7 +1558,6 @@ parse_options (int argc, char *argv[])
hdr_ip_proto = 132;
hdr_ethernet = TRUE;
- hdr_ethernet_proto = 0x800;
break;
case 'S':
hdr_sctp = TRUE;
@@ -1607,7 +1599,6 @@ parse_options (int argc, char *argv[])
hdr_ip_proto = 132;
hdr_ethernet = TRUE;
- hdr_ethernet_proto = 0x800;
break;
case 't':
@@ -1640,7 +1631,6 @@ parse_options (int argc, char *argv[])
}
hdr_ip_proto = 17;
hdr_ethernet = TRUE;
- hdr_ethernet_proto = 0x800;
break;
case 'T':
@@ -1669,7 +1659,6 @@ parse_options (int argc, char *argv[])
}
hdr_ip_proto = 6;
hdr_ethernet = TRUE;
- hdr_ethernet_proto = 0x800;
break;
case 'a':
@@ -1699,12 +1688,12 @@ parse_options (int argc, char *argv[])
if (c == '6')
{
hdr_ipv6 = TRUE;
- hdr_ethernet_proto = 0x86DD;
+ hdr_ip = FALSE;
}
else
{
hdr_ip = TRUE;
- hdr_ethernet_proto = 0x800;
+ hdr_ipv6 = FALSE;
}
hdr_ethernet = TRUE;
@@ -1850,6 +1839,14 @@ parse_options (int argc, char *argv[])
hdr_ip = TRUE;
}
+ if (hdr_ip)
+ {
+ hdr_ethernet_proto = 0x0800;
+ } else if (hdr_ipv6)
+ {
+ hdr_ethernet_proto = 0x86DD;
+ }
+
/* Display summary of our state */
if (!quiet) {
fprintf(stderr, "Input from: %s\n", input_filename);