summaryrefslogtreecommitdiff
path: root/netsniff-ng.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2015-06-13 15:30:46 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2015-06-18 00:41:20 +0200
commitda8fcdd7d8ce59ea334ec24cdaddcc02eb611f04 (patch)
treefc38360ff15125e052d81d74c49972f3f85dd645 /netsniff-ng.c
parent41ce2d49645c6eb87f751c4df0b554f4388e73c3 (diff)
netsniff-ng: Add cooked cmdline option.
Add a --cooked option that we later on use for capturing in cooked header. For now, this only captures with a dgram packet socket, but the remaining logic will follow up. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [ dbkm: split out patch ] Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'netsniff-ng.c')
-rw-r--r--netsniff-ng.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c
index d3e9a13..0a9c620 100644
--- a/netsniff-ng.c
+++ b/netsniff-ng.c
@@ -69,7 +69,8 @@ struct ctx {
static volatile sig_atomic_t sigint = 0, sighup = 0;
static volatile bool next_dump = false;
-static const char *short_options = "d:i:o:rf:MNJt:S:k:n:b:HQmcsqXlvhF:RGAP:Vu:g:T:DBUC:K:L:";
+static const char *short_options =
+ "d:i:o:rf:MNJt:S:k:n:b:HQmcsqXlvhF:RGAP:Vu:g:T:DBUC:K:L:w";
static const struct option long_options[] = {
{"dev", required_argument, NULL, 'd'},
{"in", required_argument, NULL, 'i'},
@@ -106,6 +107,7 @@ static const struct option long_options[] = {
{"ascii", no_argument, NULL, 'l'},
{"no-sock-mem", no_argument, NULL, 'A'},
{"update", no_argument, NULL, 'U'},
+ {"cooked", no_argument, NULL, 'w'},
{"verbose", no_argument, NULL, 'V'},
{"version", no_argument, NULL, 'v'},
{"help", no_argument, NULL, 'h'},
@@ -956,10 +958,9 @@ static void recv_only_or_dump(struct ctx *ctx)
struct timeval start, end, diff;
unsigned long frame_count = 0;
- sock = pf_socket();
+ sock = pf_socket_type(ctx->link_type);
ifindex = device_ifindex(ctx->device_in);
-
size = ring_size(ctx->device_in, ctx->reserve_size);
enable_kernel_bpf_jit_compiler();
@@ -1174,6 +1175,7 @@ static void __noreturn help(void)
" -n|--num <0|uint> Number of packets until exit (def: 0)\n"
" -P|--prefix <name> Prefix for pcaps stored in directory\n"
" -T|--magic <pcap-magic> Pcap magic number/pcap format to store, see -D\n"
+ " -w|--cooked Use Linux \"cooked\" header instead of link header\n"
" -D|--dump-pcap-types Dump pcap types and magic numbers and quit\n"
" -B|--dump-bpf Dump generated BPF assembly\n"
" -r|--rand Randomize packet forwarding order (dev->dev)\n"
@@ -1441,6 +1443,9 @@ int main(int argc, char **argv)
update_geoip();
die();
break;
+ case 'w':
+ ctx.link_type = LINKTYPE_LINUX_SLL;
+ break;
case 'v':
version();
break;
@@ -1512,7 +1517,8 @@ int main(int argc, char **argv)
if (ctx.rfraw)
setup_rfmon_mac80211_dev(&ctx, &ctx.device_in);
- ctx.link_type = pcap_devtype_to_linktype(ctx.device_in);
+ if (!ctx.link_type)
+ ctx.link_type = pcap_dev_to_linktype(ctx.device_in);
if (!ctx.device_out) {
ctx.dump = 0;