From 78c13b71e196a107eaa4ec00bb40b062929a6a88 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Wed, 7 Jun 2017 22:24:52 +0300 Subject: trafgen: Allow to generate packets to output pcap file Add trafgen_dev.c module which provides generic way of reading and writing packets to/from networking device or a pcap file. Also allow to handle output pcap file via '-o, --out, --dev' option. It might be useful in future for testing some link protocols which is not easy to capture (e.g. wlan packets) w/o having some special setup. Signed-off-by: Vadim Kochan [tklauser: fix whitespace issues] Signed-off-by: Tobias Klauser --- trafgen_l3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'trafgen_l3.c') diff --git a/trafgen_l3.c b/trafgen_l3.c index 7c8a786..7199b89 100644 --- a/trafgen_l3.c +++ b/trafgen_l3.c @@ -35,10 +35,10 @@ static struct proto_field ipv4_fields[] = { static void ipv4_header_init(struct proto_hdr *hdr) { - const char *dev = proto_dev_get(); + struct dev_io *dev = proto_dev_get(); /* In case of tun interface we do not need to create Ethernet header */ - if (dev && device_mtu(dev) && device_type(dev) != ARPHRD_NONE) + if (dev_io_is_pcap(dev) || device_type(dev_io_name_get(dev)) != ARPHRD_NONE) proto_lower_default_add(hdr, PROTO_ETH); proto_header_fields_add(hdr, ipv4_fields, array_size(ipv4_fields)); @@ -140,10 +140,10 @@ static struct proto_field ipv6_fields[] = { static void ipv6_header_init(struct proto_hdr *hdr) { - const char *dev = proto_dev_get(); + struct dev_io *dev = proto_dev_get(); /* In case of tun interface we do not need to create Ethernet header */ - if (dev && device_mtu(dev) && device_type(dev) != ARPHRD_NONE) + if (dev_io_is_netdev(dev) && device_type(dev_io_name_get(dev)) != ARPHRD_NONE) proto_lower_default_add(hdr, PROTO_ETH); proto_header_fields_add(hdr, ipv6_fields, array_size(ipv6_fields)); -- cgit v1.2.3-54-g00ecf