Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove trailing whitespace

  • Loading branch information...
commit 589f60620de129d36be09f6051a29d28186a78dd 1 parent 080f4ef
@msantos authored
View
18 README.md
@@ -1,5 +1,5 @@
epcap\_compile is an Erlang library for compiling PCAP filters to BPF
-programs (see pcap-filter(7)).
+programs (see pcap-filter(7)).
epcap\_compile uses the NIF interface to wrap pcap\_compile(3PCAP)
from libpcap.
@@ -45,7 +45,7 @@ These libraries are not required but can be used with epcap\_compile:
compile(Filter) -> {ok, Fcode} | {error, Error}
compile(Filter, Options) -> {ok, Fcode} | {error, Error}
-
+
Types Filter = string() | binary()
Fcode = [ Insn ]
Insn = binary()
@@ -97,18 +97,18 @@ The same BPF program can be generated from Erlang by using the bpf module in pro
ip({A,B,C,D}) ->
IP = (A bsl 24) bor (B bsl 16) bor (C bsl 8) bor D,
-
+
[
% Ethernet
?BPF_STMT(?BPF_LD+?BPF_H+?BPF_ABS, 12), % offset = Ethernet Type
?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, ?ETHERTYPE_IP, 0, 5), % type = IP
-
+
% IP
?BPF_STMT(?BPF_LD+?BPF_W+?BPF_ABS, 26), % offset = Source IP address
?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, IP, 2, 0), % source = {A,B,C,D}
?BPF_STMT(?BPF_LD+?BPF_W+?BPF_ABS, 30), % offset = Destination IP address
?BPF_JUMP(?BPF_JMP+?BPF_JEQ+?BPF_K, IP, 0, 1), % destination = {A,B,C,D}
-
+
% Amount of packet to return
?BPF_STMT(?BPF_RET+?BPF_K, 16#FFFFFFFF), % Return up to 2^32-1 bytes
?BPF_STMT(?BPF_RET+?BPF_K, 0) % Return 0 bytes: drop packet
@@ -119,17 +119,17 @@ The same BPF program can be generated from Erlang by using the bpf module in pro
-module(lsf).
-export([f/0, f/1]).
-
+
f() ->
{ok, Fcode} = epcap_compile:compile("tcp and ( port 80 or port 443 )"),
f(Fcode).
-
+
f(Fcode) when is_list(Fcode) ->
{ok, S} = packet:socket(),
{ok, _} = packet:filter(S, Fcode),
-
+
loop(S).
-
+
loop(S) ->
case procket:recv(S, 1500) of
{ok, Data} ->
View
12 c_src/epcap_compile.c
@@ -1,21 +1,21 @@
/* Copyright (c) 2012-2013, Michael Santos <michael.santos@gmail.com>
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of the author nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
@@ -118,7 +118,7 @@ nif_pcap_compile(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
}
insns = enif_make_list(env, 0);
-
+
/* Build the list from the end of the buffer, so the list does
* not need to be reversed. */
for (i = fp.bf_len-1; i >= 0; i--) {
View
10 examples/bpf_ex.erl
@@ -1,21 +1,21 @@
%% Copyright (c) 2012-2013, Michael Santos <michael.santos@gmail.com>
%% All rights reserved.
-%%
+%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
-%%
+%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
-%%
+%%
%% Redistributions in binary form must reproduce the above copyright
%% notice, this list of conditions and the following disclaimer in the
%% documentation and/or other materials provided with the distribution.
-%%
+%%
%% Neither the name of the author nor the names of its contributors
%% may be used to endorse or promote products derived from this software
%% without specific prior written permission.
-%%
+%%
%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
%% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
%% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
View
10 examples/lsf.erl
@@ -1,21 +1,21 @@
%% Copyright (c) 2012-2013, Michael Santos <michael.santos@gmail.com>
%% All rights reserved.
-%%
+%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
-%%
+%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
-%%
+%%
%% Redistributions in binary form must reproduce the above copyright
%% notice, this list of conditions and the following disclaimer in the
%% documentation and/or other materials provided with the distribution.
-%%
+%%
%% Neither the name of the author nor the names of its contributors
%% may be used to endorse or promote products derived from this software
%% without specific prior written permission.
-%%
+%%
%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
%% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
%% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
View
10 examples/lsf_inet.erl
@@ -1,21 +1,21 @@
%% Copyright (c) 2012-2013, Michael Santos <michael.santos@gmail.com>
%% All rights reserved.
-%%
+%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
-%%
+%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
-%%
+%%
%% Redistributions in binary form must reproduce the above copyright
%% notice, this list of conditions and the following disclaimer in the
%% documentation and/or other materials provided with the distribution.
-%%
+%%
%% Neither the name of the author nor the names of its contributors
%% may be used to endorse or promote products derived from this software
%% without specific prior written permission.
-%%
+%%
%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
%% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
%% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
View
10 src/epcap_compile.erl
@@ -1,21 +1,21 @@
%% Copyright (c) 2012-2013, Michael Santos <michael.santos@gmail.com>
%% All rights reserved.
-%%
+%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
-%%
+%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
-%%
+%%
%% Redistributions in binary form must reproduce the above copyright
%% notice, this list of conditions and the following disclaimer in the
%% documentation and/or other materials provided with the distribution.
-%%
+%%
%% Neither the name of the author nor the names of its contributors
%% may be used to endorse or promote products derived from this software
%% without specific prior written permission.
-%%
+%%
%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
%% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
%% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
View
10 test/epcap_compile_tests.erl
@@ -1,21 +1,21 @@
%% Copyright (c) 2012-2013, Michael Santos <michael.santos@gmail.com>
%% All rights reserved.
-%%
+%%
%% Redistribution and use in source and binary forms, with or without
%% modification, are permitted provided that the following conditions
%% are met:
-%%
+%%
%% Redistributions of source code must retain the above copyright
%% notice, this list of conditions and the following disclaimer.
-%%
+%%
%% Redistributions in binary form must reproduce the above copyright
%% notice, this list of conditions and the following disclaimer in the
%% documentation and/or other materials provided with the distribution.
-%%
+%%
%% Neither the name of the author nor the names of its contributors
%% may be used to endorse or promote products derived from this software
%% without specific prior written permission.
-%%
+%%
%% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
%% "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
%% LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
Please sign in to comment.
Something went wrong with that request. Please try again.