text2pcap: make ethernet dummy header direction aware
When giving the command line option '-D' and having 'I' and 'O' markers in the hexdump to import the IP addresses are adjusted, transport layer ports are adjusted, the TCP window information is adjusted, but still the frames originate from the same interface and go to the other interface. This changes makes it so that the Ethernet destination and source address is also adjusted with the direction indicated, to match the other adjusted addressing used. Bug: 15287 Change-Id: I762f195ece206ed14e6bca1c1160055df7c4dac1 Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl> Reviewed-on: https://code.wireshark.org/review/30767 Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
d45adf3479
commit
802d4c0121
15
text2pcap.c
15
text2pcap.c
|
@ -147,6 +147,8 @@ static int quiet = FALSE;
|
|||
|
||||
/* Dummy Ethernet header */
|
||||
static int hdr_ethernet = FALSE;
|
||||
static guint8 hdr_eth_dest_addr[6] = {0x0a, 0x02, 0x02, 0x02, 0x02, 0x02};
|
||||
static guint8 hdr_eth_src_addr[6] = {0x0a, 0x02, 0x02, 0x02, 0x02, 0x01};
|
||||
static guint32 hdr_ethernet_proto = 0;
|
||||
|
||||
/* Dummy IP header */
|
||||
|
@ -271,10 +273,7 @@ typedef struct {
|
|||
guint16 l3pid;
|
||||
} hdr_ethernet_t;
|
||||
|
||||
static hdr_ethernet_t HDR_ETHERNET = {
|
||||
{0x0a, 0x02, 0x02, 0x02, 0x02, 0x02},
|
||||
{0x0a, 0x01, 0x01, 0x01, 0x01, 0x01},
|
||||
0};
|
||||
static hdr_ethernet_t HDR_ETHERNET;
|
||||
|
||||
typedef struct {
|
||||
guint8 ver_hdrlen;
|
||||
|
@ -638,6 +637,14 @@ write_current_packet (gboolean cont)
|
|||
|
||||
/* Write Ethernet header */
|
||||
if (hdr_ethernet) {
|
||||
if (isInbound)
|
||||
{
|
||||
memcpy(HDR_ETHERNET.dest_addr, hdr_eth_src_addr, 6);
|
||||
memcpy(HDR_ETHERNET.src_addr, hdr_eth_dest_addr, 6);
|
||||
} else {
|
||||
memcpy(HDR_ETHERNET.dest_addr, hdr_eth_dest_addr, 6);
|
||||
memcpy(HDR_ETHERNET.src_addr, hdr_eth_src_addr, 6);
|
||||
}
|
||||
HDR_ETHERNET.l3pid = g_htons(hdr_ethernet_proto);
|
||||
write_bytes((const char *)&HDR_ETHERNET, sizeof(HDR_ETHERNET));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue