summaryrefslogtreecommitdiff
path: root/bpf_parser.y
AgeCommit message (Collapse)AuthorFilesLines
2015-12-17bpfc: Add option to pass macro/define for C preprocessorVadim Kochan1-3/+3
Add -D,--define option to pass macro/define for C preprocessor (e.g. to use #ifdef's within bpf file). Option allows to pass multiple -D,--define options. Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
2015-12-17cpp: Allow to pass additional cpp optionsVadim Kochan1-1/+1
Extend cpp_exec function with args parameter to specify additional cpp options (like -D). Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-25bpfc: Check yyin against NULL before calling fclose() on itTobias Klauser1-1/+1
Follow 3f2f363485d3 ("trafgen: Make sure yyin is set before close it") and check the yyin pointer against NULL before attempting to call fclose() with it. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-24bpfc: Invoke C preprocessor from cpp.c moduleVadim Kochan1-12/+6
Use cpp_exec func from cpp.c module to invoke C preprocessor. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-16bpfc: Do not panic if bpf file is not validVadim Kochan1-4/+9
If bpf file is not valid then cpp generated file is not deleted because panic() func is invoked. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> [tk: Move exit label to the correct place] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2015-11-10bpfc, trafgen: Do not close stdin when "-" is specifiedVadim Kochan1-1/+3
Do not perform fclose for stdin fd. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2014-04-22conf: Use configuration file path from Makefile instead of hardcoded pathsTobias Klauser1-2/+2
Currently, the path to the configuration files is hardcoded to $PREFIX/etc/netsniff-ng. If we want to keep the configuration files outside of prefix (e.g. during development), we need to pass the complete path as specified in $ETCDIRE (and $ETCDIR respectively, which could e.g. be overriden on the command line during build install) as a preprocessor define. This way, we can e.g. install the configuration files to /etc while installing the binaries in /usr/local with: $ make PREFIX=/usr/local ETCDIR=/etc $ make PREFIX=/usr/local ETCDIR=/etc install Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-11-25bpfc: Check return value of system()Tobias Klauser1-1/+2
Check the return value of system() when invoking CPP in the BPF parser and bail out in case of an error. This fixes the following compiler warning: bpf_parser.y:754:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result] Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2013-09-06bpfc: add gnu as style %-register prefixDaniel Borkmann1-1/+68
Let a and x register also be addressed as %x and %a. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-09-03bpf: ldi,ldxi: allow for '#' prefix in numbersDaniel Borkmann1-2/+6
For consistency, allow for '#' prefix in numbers, which we currently do not do. So keep old mode as compatibility to not break current programs, and add new one with '#' prefix. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-06-15bpf: use Linux' define of BPF_MAXINSNSDaniel Borkmann1-9/+7
Do not necessarily define our own, only in case the Linux one is not available. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-06-08bpfc: also allow to load skb len into XDaniel Borkmann1-0/+2
This functionality is available in the kernel, so make it also available for use in bpfc. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-06-04xutils: eliminate xutils, move rest to epoll2Daniel Borkmann1-1/+0
Finally eliminate xutils.{c,h} and move the rest to epoll2. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-06-04xutils: break out string handling and lockingDaniel Borkmann1-0/+1
Break out all string handling functions and lockme stuff in order to further eliminate the big code blob in xutils, so that it can be easier maintained. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-05-23bpfc: allow bpf programs to be passed to cppDaniel Borkmann1-2/+28
This patch allows bpf programs to be passed to the C preprocessor before handing over to bpfc. Example: #define ETH_P_IP 0x800 ldh [12] jne #ETH_P_IP, drop ldb [23] jneq #6, drop ldh [20] jset #0x1fff, drop ldxb 4 * ([14] & 0xf) ldh [x + 14] jeq #0x16, pass ldh [x + 16] jne #0x16, drop pass: ret #-1 drop: ret #0 Compile with: bpfc -i foo -p Suggested-by: John Lange <JLange@trendium.com> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-03-19bpfc: filter: add poff ancillary operationDaniel Borkmann1-1/+10
In preparation for [1], add the #poff operation, so that users can dynamically truncate packets on the payload start offset. This is useful for several reasons: privacy, speed, ... Example for bpfc: ld #poff ret a [1] http://thread.gmane.org/gmane.linux.network/262512 Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-03-16bpfc: support different output formatsDaniel Borkmann1-12/+58
Add different bpf opcode pretty printer to support a variety of output formats for netsniff-ng, xt_bpf, tcpdump, C-like and make future integration of formats easier. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
2013-03-15all: import netsniff-ng 0.5.8-rc0 sourceDaniel Borkmann1-0/+673
We decided to get rid of the old Git history and start a new one for several reasons: *) Allow / enforce only high-quality commits (which was not the case for many commits in the history), have a policy that is more close to the one from the Linux kernel. With high quality commits, we mean code that is logically split into commits and commit messages that are signed-off and have a proper subject and message body. We do not allow automatic Github merges anymore, since they are total bullshit. However, we will either cherry-pick your patches or pull them manually. *) The old archive was about ~27MB for no particular good reason. This basically derived from the bad decision that also some PDF files where stored there. From this moment onwards, no binary objects are allowed to be stored in this repository anymore. The old archive is not wiped away from the Internet. You will still be able to find it, e.g. on git.cryptoism.org etc. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>