LCOV - code coverage report
Current view: top level - src - PacketFilter.h (source / functions) Hit Total Coverage
Test: app.info Lines: 0 2 0.0 %
Date: 2010-12-13 Functions: 0 2 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // $Id: PacketFilter.h 80 2004-07-14 20:15:50Z jason $
       2                 :            : //
       3                 :            : // Provides some very limited but fast packet filter mechanisms
       4                 :            : 
       5                 :            : #ifndef PACKETFILTER_H
       6                 :            : #define PACKETFILTER_H
       7                 :            : 
       8                 :            : #include "IP.h"
       9                 :            : #include "PrefixTable.h"
      10                 :            : 
      11                 :            : class PacketFilter {
      12                 :            : public:
      13                 :          0 :         PacketFilter(bool arg_default)  { default_match = arg_default; }
      14                 :          0 :         ~PacketFilter() {}
      15                 :            : 
      16                 :            :         // Drops all packets from a particular source (which may be given
      17                 :            :         // as an AddrVal or a SubnetVal) which hasn't any of TCP flags set
      18                 :            :         // (TH_*) with the given probability (from 0..MAX_PROB).
      19                 :            :         void AddSrc(addr_type src, uint32 tcp_flags, double probability);
      20                 :            :         void AddSrc(Val* src, uint32 tcp_flags, double probability);
      21                 :            :         void AddDst(addr_type src, uint32 tcp_flags, double probability);
      22                 :            :         void AddDst(Val* src, uint32 tcp_flags, double probability);
      23                 :            : 
      24                 :            :         // Removes the filter entry for the given src/dst
      25                 :            :         // Returns false if filter doesn not exist.
      26                 :            :         bool RemoveSrc(addr_type src);
      27                 :            :         bool RemoveSrc(Val* dst);
      28                 :            :         bool RemoveDst(addr_type dst);
      29                 :            :         bool RemoveDst(Val* dst);
      30                 :            : 
      31                 :            :         // Returns true if packet matches a drop filter
      32                 :            :         bool Match(const IP_Hdr* ip, int len, int caplen);
      33                 :            : 
      34                 :            : private:
      35                 :            :         struct Filter {
      36                 :            :                 uint32 tcp_flags;
      37                 :            :                 uint32 probability;
      38                 :            :         };
      39                 :            : 
      40                 :            :         bool MatchFilter(const Filter& f, const IP_Hdr& ip, int len, int caplen);
      41                 :            : 
      42                 :            :         bool default_match;
      43                 :            :         PrefixTable src_filter;
      44                 :            :         PrefixTable dst_filter;
      45                 :            : };
      46                 :            : 
      47                 :            : #endif

Generated by: LCOV version 1.8