summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2014-10-01build: Make ccache opt-in rather than opt-outTobias Klauser3-18/+4
Using ccache by default for compilation if it is available on the system might confuse people and in rare cases also lead to unexpected results. Thus, from now on the use of ccache for compilation has to explicitely specified by setting the CCACHE make variable to the name/path of the ccache binary, i.e. `make CCACHE=ccache' Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-29built_in: Remove unused macro force_castTobias Klauser1-4/+0
The macro is unused and explicit cast should be used anyway. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-29netsniff-ng: Fix tpacketv2-only capturingTobias Klauser2-1/+8
We need to set up the RX ring depending on whether tpacket v3 is available or not. Otherwise end up setting its structure up for tpacket v3, even though only tpacket v2 is available. This should fix packet capturing for tpacket v2 (i.e. corrupted frames in pcap). Reported-by: Mike Reeves <luke@geekempire.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-29ring_rx: Fix typo in header guard #endifTobias Klauser1-1/+1
It's HAVE_TPACKET3, not HAVE_TPACKETV3. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-29netsniff-ng: Move variable definitionTobias Klauser1-3/+2
Save one #ifdef block by moving the tpacket v3 only variable definition to the block where it is actually used. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-18INSTALL: Fix formattingTobias Klauser1-16/+16
Use spaces for indentation in the INSTALL file so the dependency listing are properly aligned in any case. Also reorder the lists slightly. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-18build: nacl: Propagate nacl specific environment variables to parent shellwilson1-1/+1
Use source command to execute the nacl_build.sh script in order to change parent shell's environment variable needed to find the just built libnacl. wilson says: > As I use "make nacl" to install nacl, the nacl_path.sh would be execute. > Then NACL_INC_DIR env variable will be set and appended to ~/.bashrc. In > nacl_build.sh, it used 'source' command to execute nacl_path.sh, however > the NACL_INC_DIR variable only took effect in this script context, but > not in the shell I was running. > I think we need the 'source' command to execute nacl_build.sh so that we > don't need to restart the shell for further installation. Signed-off-by: wilson <wilson.wen.chn@gmail.com> [tklauser: Reformated commit message] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-12csum: Use ISO C fixed width typesTobias Klauser1-22/+22
Use the ISO C fixed width types from stdint.h instead of the self-defined Linux types. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-11netsniff-ng: Remvoe unnecessary cast to void *Tobias Klauser1-2/+1
The iov_base member of struct iovec is already void *, so there is no need to cast it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-11netsniff-ng: Unindent goto labelTobias Klauser1-2/+1
Stick to the usual style of having goto labels not indented. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-09dissectors: 80211_mac_hdr: Remove remaining binary constantsTobias Klauser1-41/+32
Commit 151fd88f7429 ("dissectors: 80211_mac_hdr: Remove usage of binary constants") removed binary constants in a particular case that was reported to cause a compile error. However, this module uses binary constants in some other places. Replace them by hexadecimal constants, which makes it easier to read and is C99 compatible. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-09dissectors: 80211_mac_hdr: Fix clang warningTobias Klauser1-14/+14
clang gives the following warning about function meas_type(): proto_80211_mac_hdr.c:1704:1: warning: control may reach end of non-void function [-Wreturn-type] } ^ Even though this is a false positive (since we check the entire range of an u8 in the switch/case), fix it by turning the case 13 ... 255 into default. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-09dissector: Don't re-initialize packet_types arrayTobias Klauser1-1/+0
Both sparse and clang warn about the initializers overriding previous initialization of the packet_types array. Since every access of the packet_types array checks the value for NULL (the default value, since the array is static) and prints a "?" if it isNULL, we don't need the prior initialization with "?". Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-09sock: Error out if setting of the system socket memory failsTobias Klauser1-1/+2
Currently we ignore the return value of the write() calls to /proc/sys/net/core/{r,w}mem_{default,max} in set_system_socket_mem(). Better check the return value and notify the user about it. This also fixes a clang compiler warning about a variable explicitely assigned to itself. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-09netsniff-ng: Remove useless check for ctx.device_inTobias Klauser1-2/+1
If ctx.device_in is NULL after option parsing, it is always set to "any", which is before this check. Thus, it serves no purpose and can be removed. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-09build: Don't overwrite CC variableTobias Klauser3-9/+10
Don't reset the variable CC in the Makefile, but set it to gcc by default (can be overriden when e.g. compiling with `make CC=clang'). This way we can also have non-verbose compiles with compilers other than gcc. Furthermore make sure that the CC variable is also respected for LD. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-08flowtop: Use integer conversion to determine PID proc entriesTobias Klauser1-13/+20
Try to convert the directory entry name to an unsigned integer with strtoul() instead of using strspn() to determine if a proc entry is a PID. If it is a valid PID (i.e. strtoul returned a value != 0), we can directly use it to pass into walk_process() and there set flow_entry->proc_num. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-08flowtop: Simplify entry skip logicTobias Klauser1-10/+5
Instead of testing three skip conditions for every entry, make use of the short-circuit evaluation of the boolean OR operator to only test as few conditions as necessary. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-08build: Detect compiler (gcc or clang) and filter out compiler flagsTobias Klauser1-0/+12
Create a make variable $(COMPILER) which is set to either `gcc' or `clang' depending on the compiler used. Use this variable to filter out command line options not supported by clang (for now only -fno-delete-null-pointer-checks). Compiler detection snippet extracted from the Linux kernel Makefile. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-08build: travis: Re-enable clang and also use it for configureTobias Klauser1-1/+2
Make sure we also use clang for the compile tests in the configure script. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-08build: Change return type of main in configure compile test programsTobias Klauser1-12/+12
When running the configure script with `CC=clang ./configure' clang fails all the compile test programs due to the main() function not having return type int. Change it, so we can use clang as a compiler in the configure script. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05bpfc: Don't duplicate copyright/bug report/license stringTobias Klauser1-14/+11
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of bpfc.o slightly smaller: before: text data bss dec hex filename 3594 0 0 3594 e0a bpfc/bpfc.o after: text data bss dec hex filename 3313 0 0 3313 cf1 bpfc/bpfc.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05flowtop: Don't duplicate copyright/bug report/license stringTobias Klauser1-16/+12
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of flowtop.o slightly smaller: before: text data bss dec hex filename 15601 4 48 15653 3d25 flowtop/flowtop.o after: text data bss dec hex filename 15228 4 48 15280 3bb0 flowtop/flowtop.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05astraceroute: Don't duplicate copyright/bug report/license stringTobias Klauser1-14/+11
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of astraceroute.o slightly smaller: before: text data bss dec hex filename 18481 0 4 18485 4835 astraceroute/astraceroute.o after: text data bss dec hex filename 18201 0 4 18205 471d astraceroute/astraceroute.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05ifpps: Don't duplicate copyright/bug report/license stringTobias Klauser1-16/+12
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of ifpps.o slightly smaller: before: text data bss dec hex filename 22146 0 1456 23602 5c32 ifpps/ifpps.o after: text data bss dec hex filename 21807 0 1456 23263 5adf ifpps/ifpps.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05netsniff-ng: Don't duplicate copyright/bug report/license stringTobias Klauser1-18/+13
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of netsniff-ng.o slightly smaller: before: text data bss dec hex filename 26998 8 68 27074 69c2 netsniff-ng/netsniff-ng.o after: text data bss dec hex filename 26582 8 68 26658 6822 netsniff-ng/netsniff-ng.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05trafgen: Don't duplicate copyright/bug report/license stringTobias Klauser1-14/+11
Move the copyright/bug report/license string to an own constant and use it for the output of help() and version() to avoid duplication and prevent the strings from getting out of sync. This makes the text section of trafgen.o slightly smaller: before: text data bss dec hex filename 18512 0 104 18616 48b8 trafgen/trafgen.o after: text data bss dec hex filename 18240 0 104 18344 47a8 trafgen/trafgen.o Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-05trafgen: Consistently use unsigned int for number of CPUsTobias Klauser1-9/+9
The number of CPUs is stored in ctx.cpus which is unsigned int, so use unsigned int consistently when using CPU number. Negative CPU numbers wont occur anyhow. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-03build: travis: Disable clang for nowTobias Klauser1-1/+0
clang doesn't understand all our (GCC-spcific) compiler flags. We need to work around it by filtering them out properly in case clang is used. For now, just disable clang on travis, until I figured this out locally. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-03build: travis: Pass on CC environment variable to makeTobias Klauser1-1/+1
If travis compiles with clang, the environment variable CC is set. Since the netsniff-ng build system doesn't currently pick it up unless explicitly specified as a make variable, pass it on as such. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-03build: travis: Install dependencies before buildTobias Klauser1-0/+4
In order to make sure all tools (except curvetun) are built by Travis CI, install the libraries they depend upon. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-03mausezahn: Fix non-ANSI function declarationsTobias Klauser21-29/+27
ANSI C doesn't allow empty parameter list, thus use void where appropriate. This fixes the corresponding sparse warning. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-03build: Add continuous integration support via travis-ciTobias Klauser2-0/+7
This allows any libnl github repo to link to travis-ci which will result in new commits and pull requests to be automatically built with both gcc and clang. Any build failures including the addition of warnings are reported to the author and committer. Following Thomas Graf's suggestion: https://plus.google.com/103961622207897185587/posts/GaVC6jwcMgp Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-01trafgen: Replace variable length arraysTobias Klauser1-6/+9
Use zmalloc()'ed buffer or statically sized array to replace usage of variable sized arrays. Found by the sparse static checker. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-01netsniff-ng 0.5.9-rc4v0.5.9-rc4Tobias Klauser1-1/+1
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-09-01dissectors: 80211_mac_hdr: Remove usage of binary constantsTobias Klauser1-16/+16
Binary constants are not C99, but a GCC extension. Moreover, Mohan reports compilation errors resulting from these constructs when using a PowerPC cross-compiler. Thus, replace them by the corresponding hexadecimal constants. Reported-by: Mohan Kannekanti <mohan.kannekanti@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-25zsh: trafgen: Add new command line option -A/--no-sock-memTobias Klauser1-0/+1
Commit 76486ece10c6 ("trafgen: add option to not adjust system socket mem during testrun") introduced the new command line option -A/--no-sock-mem for trafgen but didn't add it to the zsh completion. Do it now. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-21trafgen: minor fix to help text for option "--no-sock-mem"Jesper Dangaard Brouer1-1/+1
Pushed last commit a bit too fast. The help text described that the single letter option for "--no-sock-mem" were "-m", which is wrong the right option is "-A" (only help txt, correct in the code and manual). Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2014-08-21trafgen: add option to not adjust system socket mem during testrunJesper Dangaard Brouer2-3/+19
The default behavior of trafgen is to boost the systems default socket memory limits during a testrun. This behaviour does not always result in improved performance, because this will stress the kernels SLAB allocators unnecessary. Introducing an option "--no-sock-mem" that instruct trafgen to not perform any socket memory adjustments. Fixes: #130 Acked-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
2014-08-15dissectors: Include protos.h in some dissectors for protocol ops declarationTobias Klauser9-0/+9
Fixes sparse warnings like the following in some dissectors: proto_arp.c:158:17: warning: symbol 'arp_ops' was not declared. Should it be static? Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-15conf: oui: update oui.confTobias Klauser1-44/+450
Update oui.conf using oui-update.py Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-15geoip: Use NULL instead of integer to initialize pointersTobias Klauser1-2/+2
Fixes the following sparse warnings: geoip.c:76:30: warning: Using plain integer as NULL pointer geoip.c:78:30: warning: Using plain integer as NULL pointer Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-15netsniff-ng: Conditionally define POLLRDNORM where it is usedTobias Klauser2-12/+4
Instead of defining POLLRDNORM in built_in.h if it isn't provided by system/kernel headers, define it in ring.h where its only user is. This way we make sure that <poll.h> is included before checking #ifndef POLLRDNORM. This fixes the following sparse warning: /usr/include/bits/poll.h:32:10: warning: preprocessor token POLLRDNORM redefined built_in.h:378:10: this was the original definition Also remove the defines for POLLWRNORM and POLLRDHUP which are not used anywhere in the code. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-15build: Add build flag to enable sparse checking of C source filesTobias Klauser5-0/+13
Similar to the 'make C=1' for the Linux kernel, wire up the sparse command for our build system in a similar fashion. Use 'make C=1 [tool]' to check the source files using sparse. Of course, the sparse tool needs to be installed and available in your $PATH for this to work. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-15dissectors: Remove unnecessary includes of dissector_eth.hTobias Klauser8-7/+1
dissector_eth.h is only used in dissectors which need to manipulate the eth_lay2 and eth_lay3 hash tables. Remove the include from all dissectors that don't access them. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-14netsniff-ng: Protect all access to tpacket v3 structs and constants (this ↵Tobias Klauser2-12/+45
time for real) Commit 0fab564a98d1 ("netsniff-ng: Properly wrap usage of all tpacket v3 structs") took care of protecting _some_ tpacket v3 structures with compile error when building with !HAVE_TPACKET3 (reported by Mike Reeves): > CC ring_rx.c > ring_rx.c: In function 'setup_rx_ring_layout': > ring_rx.c:124: warning: implicit declaration of function 'set_sockopt_tpacket_v3' > ring_rx.c: In function 'sock_rx_net_stats': > ring_rx.c:194: error: field 'k3' has incomplete type > make: *** [netsniff-ng/ring_rx.o] Error 1 Many thanks to Mike for helping me sort out these problems. Reported-by: Mike Reeves <luke@geekempire.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-14netsniff-ng: Use correct parameters to show_frame_hdr()Tobias Klauser1-1/+2
Commit edca6174b09 ("dissector: Restore paket type if capturing from nlmon device") changed the signature of show_frame_hdr(). The call to this function was not updated in the !HAVE_TPACKET3 part of netsniff-ng introduced in commit 97e6f994785c ("netsniff-ng: Restore tpacket v2 capturing"), causing a compile error. Fix this by providing the correct parameters to show_frame_hdr() also in this case. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-14netsniff-ng: Properly wrap usage of all tpacket v3 structsTobias Klauser1-21/+40
Mike Reeves reports the following compilation error if tpacket v3 is not available: > CC ring_rx.c > ring_rx.c: In function 'alloc_rx_ring_frames': > ring_rx.c:143: error: 'struct ring' has no member named 'layout3' > ring_rx.c:144: error: 'struct ring' has no member named 'layout3' > ring_rx.c: In function 'sock_rx_net_stats': > ring_rx.c:172: error: field 'k3' has incomplete type > make: *** [netsniff-ng/ring_rx.o] Error 1 The layout3 member of struct ring is only available for HAVE_TPACKET3. Thus, wrap all access to it into inline functions defined depending on wheter HAVE_TPACKET3 is defined. Reported-by: Mike Reeves <luke@geekempire.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-14netsniff-ng: Clean up HAVE_TPACKET3 #ifdefsTobias Klauser1-10/+13
Instead of having #ifdef HAVE_TPACKET3 spread all over the code, encapsulate the functionality depending on it inside inline functions: the existing is_tpacket_v3() introduced in commit 5bc19d0b84d0 ("netsniff-ng: Only use TPACKET_V3 if HAVE_TPACKET3 is defined") and the newly introduced get_ring_layout_size() to get the ring layout size depending on the tpacket version available and the version actually in use. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-08-14netsniff-ng: Only use TPACKET_V3 if HAVE_TPACKET3 is definedTobias Klauser1-9/+16
TPACKET_V3 is not defined if tpacket v3 is not available, thus make its use conditional on HAVE_TPACKET3. Wrap the check for TPACKET_V3 in ring_rx in an inline function which always returns false if HAVE_TPACKET3 is not defined. Reported-by: Mike Reeves <luke@geekempire.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>