Indention of code
[netsniff-ng.git] / src / misc.c
blob6bda112328344b68d032fec40549d61bc4a7ba51
1 /*
2 * Copyright (C) 2009, 2010 Daniel Borkmann <daniel@netsniff-ng.org> and
3 * Emmanuel Roullit <emmanuel@netsniff-ng.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <unistd.h>
24 #include <sys/types.h>
25 #include <sys/socket.h>
27 #include "macros.h"
28 #include "version.h"
29 #include "system.h"
30 #include "misc.h"
31 #include "netdev.h"
32 #include "tx_ring.h"
34 /**
35 * help - Prints help
37 void help(void)
39 info("\n%s %s, the packet sniffing beast\n", PROGNAME_STRING,
40 VERSION_STRING);
41 info("http://www.netsniff-ng.org\n\n");
42 info("Usage: netsniff-ng [options]\n");
43 info("\n");
44 info("Options for net dev:\n");
45 info(" -d|--dev <netdev> Use device for capturing packets\n");
46 info(" -I|--info Print network device information\n");
47 info(" -M|--no-promisc No promiscuous mode for device\n");
48 info("\n");
49 info("Options for packet dumping/replaying:\n");
50 info(" -p|--dump <file> Dump packets in a pcap file\n");
51 info(" for a better performance combine\n");
52 info(" with -s|--silent\n");
53 info(" -r|--replay <file> Replay all packets from a pcap file\n");
54 info(" -i|--read <file> Display packets from a pcap file\n");
55 info("\n");
56 info("Options for packet filtering:\n");
57 info(" -f|--filter <file> Use BPF filter from file\n");
58 info(" -t|--type <type> Only show packets of defined type\n");
59 info(" this is slower than BPF, types are\n");
60 info(" host|broadcast|multicast|others|outgoing\n");
61 #if 0 /* Next time */
62 info(" -g|--generate <filter> Generate BPF code for expression\n");
63 #endif
64 info("\n");
65 info("Options for system scheduler/process:\n");
66 info(" -b|--bind-cpu <cpu> Bind to specific CPU/CPU-range,\n");
67 info(" for a better performance bind to a\n");
68 info(" single CPU reserved for netsniff-ng\n");
69 info(" -B|--unbind-cpu <cpu> Forbid to use specific CPU/CPU-range\n");
70 info(" -H|--prio-norm Do not high priorize process\n");
71 info(" -Q|--notouch-irq Do not touch IRQ CPU affinity of NIC\n");
72 info(" -n|--non-block Non-blocking packet capturing mode\n");
73 info("\n");
74 info("Options for receive and transmit ring:\n");
75 info(" -S|--ring-size <size> Manually set ring size to <arg>,\n");
76 info(" mmap space in KB/MB/GB, e.g. `10MB`\n");
77 info("\n");
78 info("Options for packet printing:\n");
79 info(" -s|--silent Do not print captured packets\n");
80 info(" -q|--less Print less-verbose packet information\n");
81 info(" -l|--payload Only print human-readable payload\n");
82 info(" -x|--payload-hex Only print payload in hex format\n");
83 info(" -C|--c-style Print full packet in C style hex format\n");
84 info(" -X|--all-hex Print packets in hex format\n");
85 info(" -N|--no-payload Only print packet header\n");
86 info(" -e|--regex <expr> Only print package that matches regex\n");
87 info("\n");
88 info("Options, misc:\n");
89 info(" -v|--version Print version\n");
90 info(" -h|--help Print this help\n");
91 info("\n");
92 info("Note:\n");
93 info(" - For more help try \'man netsniff-ng\'\n");
94 info(" - Binding netsniff-ng to a specific CPU increases performance\n");
95 info(" since NIC RX/TX interrupts will be bound to that CPU, too\n");
96 info("\n");
97 info("Examples:\n");
98 info(" netsniff-ng --dev eth0 --dump out.pcap --silent --bind-cpu 0\n");
99 info(" netsniff-ng --dev eth0 --replay out.pcap --bind-cpu 0\n");
100 info(" netsniff-ng --read out.pcap --no-payload\n");
101 info(" netsniff-ng --filter /etc/netsniff-ng/rules/icq.bpf\n");
102 info(" netsniff-ng --regex \"user.*pass\"\n");
103 info(" netsniff-ng --prio-norm --dev wlan0 --all-hex --type outgoing\n");
104 info("\n");
105 info("Please report bugs to <bugs@netsniff-ng.org>\n");
106 info("Copyright (C) 2009, 2010 Daniel Borkmann and Emmanuel Roullit\n");
107 info("License: GNU GPL version 2\n");
108 info("This is free software: you are free to change and redistribute it.\n");
109 info("There is NO WARRANTY, to the extent permitted by law.\n\n");
111 exit(EXIT_SUCCESS);
115 * version - Prints version
117 void version(void)
119 info("\n%s %s, the packet sniffing beast\n", PROGNAME_STRING,
120 VERSION_STRING);
121 info("http://www.netsniff-ng.org\n\n");
122 #ifdef __HAVE_TX_RING__
123 info("Compiled with transmit ring functionality :)\n\n");
124 #endif
125 info("Please report bugs to <bugs@netsniff-ng.org>\n");
126 info("Copyright (C) 2009, 2010 Daniel Borkmann and Emmanuel Roullit\n");
127 info("License: GNU GPL version 2\n");
128 info("This is free software: you are free to change and redistribute it.\n");
129 info("There is NO WARRANTY, to the extent permitted by law.\n\n");
131 exit(EXIT_SUCCESS);