diff --git a/README.md b/README.md index fc018f7..84d60ad 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,17 @@ epcap includes a small example program called sniff. The Packet is a binary holding the captured data. +## PF_RING + + In case you want to compile epcap with PF_RING support, + just specify the path to the libpfring and modified libpcap libraries + via shell variable PFRING. + + PFRING=/home/user/pfring make + + As a result epcap binary will be linked with the following flags: -static -lpfring -lpthread + + ## SCREENSHOT =INFO REPORT==== 6-Jan-2010::20:35:18 === diff --git a/rebar.config b/rebar.config index 7a1ac27..690e219 100644 --- a/rebar.config +++ b/rebar.config @@ -2,10 +2,12 @@ {"EXE_LDFLAGS", "-lpcap $ERL_LDFLAGS"}, {"linux", "EXE_CFLAGS", "$EXE_CFLAGS -DEPCAP_RLIMIT_NOFILES=1"}, {"solaris", "EXE_CFLAGS", "$EXE_CFLAGS -DEPCAP_RLIMIT_NOFILES=1"} - ]}. +]}. + {port_specs, [ {"priv/epcap", ["c_src/epcap.c", "c_src/epcap_priv.c"]} - ]}. +]}. + {deps, [ {pkt, ".*", {git, "https://github.com/msantos/pkt.git", "master"}} - ]}. +]}. diff --git a/rebar.config.script b/rebar.config.script new file mode 100644 index 0000000..277c9ef --- /dev/null +++ b/rebar.config.script @@ -0,0 +1,17 @@ +case os:getenv("PFRING") of + false -> + CONFIG; + Value -> + case filelib:is_dir(Value) of + true -> + case lists:keysearch(port_env, 1, CONFIG) of + {value, {port_env, Flags}} -> + {"EXE_LDFLAGS", LDFLAGS} = hd(Flags), + NewFlags = LDFLAGS ++ " -static -L " ++ Value ++ " -lpfring -lpthread", + NewLDFLAGS = lists:keyreplace("EXE_LDFLAGS", 1, Flags, {"EXE_LDFLAGS", NewFlags}), + lists:keyreplace(port_env, 1, CONFIG, {port_env, NewLDFLAGS}); + _ -> CONFIG + end; + _ -> CONFIG + end +end.