LCOV - code coverage report
Current view: top level - src - FlowSrc.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: FlowSrc.h 4618 2007-07-09 18:12:32Z bager $
       2                 :            : //
       3                 :            : // See the file "COPYING" in the main distribution directory for copyright.
       4                 :            : //
       5                 :            : // Written by Bernhard Ager, TU Berlin (2006/2007).
       6                 :            : 
       7                 :            : #ifndef flowsrc_h
       8                 :            : #define flowsrc_h
       9                 :            : 
      10                 :            : #include "IOSource.h"
      11                 :            : #include "NetVar.h"
      12                 :            : #include "binpac.h"
      13                 :            : 
      14                 :            : #define BRO_FLOW_ERRBUF_SIZE 512
      15                 :            : 
      16                 :            : // TODO: 1500 is enough for v5 - how about the others?
      17                 :            : // 65536 would be enough for any UDP packet.
      18                 :            : #define NF_MAX_PKT_SIZE 8192
      19                 :            : 
      20                 :            : struct FlowFileSrcPDUHeader {
      21                 :            :         double network_time;
      22                 :            :         int pdu_length;
      23                 :            :         uint32 ipaddr;
      24                 :            : };
      25                 :            : 
      26                 :            : // Avoid including netflow_pac.h by explicitly declaring the NetFlow_Analyzer.
      27                 :            : namespace binpac {
      28                 :            :         namespace NetFlow {
      29                 :            :                 class NetFlow_Analyzer;
      30                 :            :         }
      31                 :            : }
      32                 :            : 
      33                 :            : class FlowSrc : public IOSource {
      34                 :            : public:
      35                 :            :         virtual ~FlowSrc();
      36                 :            : 
      37                 :            :         // IOSource interface:
      38                 :            :         bool IsReady();
      39                 :            :         void GetFds(int* read, int* write, int* except);
      40                 :            :         double NextTimestamp(double* network_time);
      41                 :            :         void Process();
      42                 :            : 
      43                 :          0 :         const char* Tag()               { return "FlowSrc"; }
      44                 :          0 :         const char* ErrorMsg() const    { return errbuf; }
      45                 :            : 
      46                 :            : protected:
      47                 :            :         FlowSrc();
      48                 :            : 
      49                 :            :         virtual int ExtractNextPDU() = 0;
      50                 :            :         virtual void Close();
      51                 :            : 
      52                 :            :         int selectable_fd;
      53                 :            : 
      54                 :            :         double current_timestamp;
      55                 :            :         double next_timestamp;
      56                 :            :         binpac::NetFlow::NetFlow_Analyzer* netflow_analyzer;
      57                 :            : 
      58                 :            :         u_char buffer[NF_MAX_PKT_SIZE];
      59                 :            :         u_char* data;
      60                 :            :         int pdu_len;
      61                 :            :         uint32 exporter_ip;     // in network byte order
      62                 :            : 
      63                 :            :         char errbuf[BRO_FLOW_ERRBUF_SIZE];
      64                 :            : };
      65                 :            : 
      66                 :            : class FlowSocketSrc : public FlowSrc {
      67                 :            : public:
      68                 :            :         FlowSocketSrc(const char* listen_parms);
      69                 :            :         virtual ~FlowSocketSrc();
      70                 :            : 
      71                 :            :         int ExtractNextPDU();
      72                 :            : 
      73                 :            : protected:
      74                 :            :         char* listenparms;
      75                 :            : };
      76                 :            : 
      77                 :            : class FlowFileSrc : public FlowSrc {
      78                 :            : public:
      79                 :            :         FlowFileSrc(const char* readfile);
      80                 :            :         ~FlowFileSrc();
      81                 :            : 
      82                 :            :         int ExtractNextPDU();
      83                 :            : 
      84                 :            : protected:
      85                 :            :         int Error(int errlvl, const char* errmsg);
      86                 :            :         char* readfile;
      87                 :            : };
      88                 :            : 
      89                 :            : #endif

Generated by: LCOV version 1.8