LCOV - code coverage report
Current view: top level - src - ICMP.h (source / functions) Hit Total Coverage
Test: app.info Lines: 5 23 21.7 %
Date: 2010-12-13 Functions: 5 23 21.7 %
Branches: 3 26 11.5 %

           Branch data     Line data    Source code
       1                 :            : // $Id: ICMP.h 6219 2008-10-01 05:39:07Z vern $
       2                 :            : //
       3                 :            : // See the file "COPYING" in the main distribution directory for copyright.
       4                 :            : 
       5                 :            : #ifndef icmp_h
       6                 :            : #define icmp_h
       7                 :            : 
       8                 :            : #include "Analyzer.h"
       9                 :            : 
      10                 :            : typedef enum {
      11                 :            :         ICMP_INACTIVE,  // no packet seen
      12                 :            :         ICMP_ACTIVE,    // packets seen
      13                 :            : } ICMP_EndpointState;
      14                 :            : 
      15                 :            : // We do not have an PIA for ICMP (yet) and therefore derive from
      16                 :            : // RuleMatcherState to perform our own matching.
      17 [ +  - ][ #  # ]:          5 : class ICMP_Analyzer : public TransportLayerAnalyzer {
                 [ #  # ]
      18                 :            : public:
      19                 :            :         ICMP_Analyzer(Connection* conn);
      20                 :            : 
      21                 :          0 :         static Analyzer* InstantiateAnalyzer(Connection* conn)
      22                 :          0 :                 { return new ICMP_Analyzer(conn); }
      23                 :            : 
      24                 :          1 :         static bool Available() { return true; }
      25                 :            : 
      26                 :            : protected:
      27                 :            :         ICMP_Analyzer() { }
      28                 :            :         ICMP_Analyzer(AnalyzerTag::Tag tag, Connection* conn);
      29                 :            : 
      30                 :            :         virtual void Done();
      31                 :            :         virtual void DeliverPacket(int len, const u_char* data, bool orig,
      32                 :            :                                         int seq, const IP_Hdr* ip, int caplen);
      33                 :            :         virtual void UpdateEndpointVal(RecordVal* endp, int is_orig);
      34                 :            :         virtual bool IsReuse(double t, const u_char* pkt);
      35                 :            :         virtual unsigned int MemoryAllocation() const;
      36                 :            : 
      37                 :            :         void ICMPEvent(EventHandlerPtr f);
      38                 :            :         void Describe(ODesc* d) const;
      39                 :            : 
      40                 :            :         RecordVal* BuildICMPVal();
      41                 :            : 
      42                 :            :         virtual void NextICMP(double t, const struct icmp* icmpp,
      43                 :            :                                 int len, int caplen, const u_char*& data);
      44                 :            : 
      45                 :            :         RecordVal* ExtractICMPContext(int len, const u_char*& data);
      46                 :            : 
      47                 :            :         RecordVal* icmp_conn_val;
      48                 :            :         int type;
      49                 :            :         int code;
      50                 :            :         int len;
      51                 :            : 
      52                 :            :         int request_len, reply_len;
      53                 :            : 
      54                 :            :         RuleMatcherState matcher_state;
      55                 :            : };
      56                 :            : 
      57 [ #  # ][ #  # ]:          0 : class ICMP_Echo_Analyzer : public ICMP_Analyzer {
      58                 :            : public:
      59                 :            :         ICMP_Echo_Analyzer(Connection* conn);
      60                 :            : 
      61                 :          0 :         static Analyzer* InstantiateAnalyzer(Connection* conn)
      62                 :          0 :                 { return new ICMP_Echo_Analyzer(conn); }
      63                 :            : 
      64 [ +  - ][ -  + ]:          1 :         static bool Available() { return icmp_echo_request || icmp_echo_reply; }
      65                 :            : 
      66                 :            : protected:
      67                 :            :         ICMP_Echo_Analyzer()    { }
      68                 :            : 
      69                 :            :         virtual void NextICMP(double t, const struct icmp* icmpp,
      70                 :            :                               int len, int caplen, const u_char*& data);
      71                 :            : };
      72                 :            : 
      73 [ #  # ][ #  # ]:          0 : class ICMP_Context_Analyzer : public ICMP_Analyzer {
      74                 :            : public:
      75                 :          0 :         ICMP_Context_Analyzer(AnalyzerTag::Tag tag, Connection* conn)
      76                 :          0 :                 : ICMP_Analyzer(tag, conn)      { }
      77                 :            : 
      78                 :            : protected:
      79                 :            :         ICMP_Context_Analyzer() { }
      80                 :            : 
      81                 :            :         virtual void NextICMP(double t, const struct icmp* icmpp,
      82                 :            :                               int len, int caplen, const u_char*& data);
      83                 :            : };
      84                 :            : 
      85 [ #  # ][ #  # ]:          0 : class ICMP_TimeExceeded_Analyzer : public ICMP_Context_Analyzer {
      86                 :            : public:
      87                 :          0 :         ICMP_TimeExceeded_Analyzer(Connection* conn)
      88                 :          0 :                 : ICMP_Context_Analyzer(AnalyzerTag::ICMP_TimeExceeded, conn)   { }
      89                 :            : 
      90                 :          0 :         static Analyzer* InstantiateAnalyzer(Connection* conn)
      91                 :          0 :                 { return new ICMP_TimeExceeded_Analyzer(conn); }
      92                 :            : 
      93                 :          1 :         static bool Available() { return icmp_time_exceeded; }
      94                 :            : 
      95                 :            : protected:
      96                 :            :         ICMP_TimeExceeded_Analyzer()    { }
      97                 :            : };
      98                 :            : 
      99 [ #  # ][ #  # ]:          0 : class ICMP_Unreachable_Analyzer : public ICMP_Context_Analyzer {
     100                 :            : public:
     101                 :          0 :         ICMP_Unreachable_Analyzer(Connection* conn)
     102                 :          0 :                 : ICMP_Context_Analyzer(AnalyzerTag::ICMP_Unreachable, conn)    { }
     103                 :            : 
     104                 :          0 :         static Analyzer* InstantiateAnalyzer(Connection* conn)
     105                 :          0 :                 { return new ICMP_Unreachable_Analyzer(conn); }
     106                 :            : 
     107                 :          6 :         static bool Available() { return icmp_unreachable; }
     108                 :            : 
     109                 :            : protected:
     110                 :            :         ICMP_Unreachable_Analyzer()     { }
     111                 :            : };
     112                 :            : 
     113                 :            : 
     114                 :            : // Returns the counterpart type to the given type (e.g., the counterpart
     115                 :            : // to ICMP_ECHOREPLY is ICMP_ECHO).
     116                 :            : extern int ICMP_counterpart(int icmp_type, int icmp_code, bool& is_one_way);
     117                 :            : 
     118                 :            : #endif

Generated by: LCOV version 1.8