forked from osmocom/wireshark
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>
This commit is contained in:
parent
bf9286e554
commit
9aa29213f0
23
text2pcap.c
23
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);
|
||||
|
|
Loading…
Reference in New Issue