LCOV - code coverage report
Current view: top level - src - Gnutella.h (source / functions) Hit Total Coverage
Test: app.info Lines: 2 6 33.3 %
Date: 2010-12-13 Functions: 1 5 20.0 %
Branches: 6 16 37.5 %

           Branch data     Line data    Source code
       1                 :            : // $Id: Gnutella.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 gnutella_h
       6                 :            : #define gnutella_h
       7                 :            : 
       8                 :            : #include "TCP.h"
       9                 :            : 
      10                 :            : #define ORIG_OK               0x1
      11                 :            : #define RESP_OK               0x2
      12                 :            : 
      13                 :            : #define GNUTELLA_MSG_SIZE     23
      14                 :            : #define GNUTELLA_MAX_PAYLOAD  1024
      15                 :            : 
      16                 :            : class GnutellaMsgState {
      17                 :            : public:
      18                 :            :         GnutellaMsgState ();
      19                 :            : 
      20                 :            :         string buffer;
      21                 :            :         int current_offset;
      22                 :            :         int got_CR;
      23                 :            :         string headers;
      24                 :            :         char msg[GNUTELLA_MSG_SIZE];
      25                 :            :         u_char msg_hops;
      26                 :            :         unsigned int msg_len;
      27                 :            :         int msg_pos;
      28                 :            :         int msg_sent;
      29                 :            :         u_char msg_type;
      30                 :            :         u_char msg_ttl;
      31                 :            :         char payload[GNUTELLA_MAX_PAYLOAD];
      32                 :            :         int payload_len;
      33                 :            :         unsigned int payload_left;
      34                 :            : };
      35                 :            : 
      36                 :            : 
      37 [ #  # ][ #  # ]:          0 : class Gnutella_Analyzer : public TCP_ApplicationAnalyzer {
      38                 :            : public:
      39                 :            :         Gnutella_Analyzer(Connection* conn);
      40                 :            : 
      41                 :            :         virtual void Done ();
      42                 :            :         virtual void DeliverStream(int len, const u_char* data, bool orig);
      43                 :            : 
      44                 :          0 :         static Analyzer* InstantiateAnalyzer(Connection* conn)
      45                 :          0 :                 { return new Gnutella_Analyzer(conn); }
      46                 :            : 
      47                 :          1 :         static bool Available()
      48                 :            :                 {
      49                 :            :                 return gnutella_text_msg || gnutella_binary_msg ||
      50                 :            :                         gnutella_partial_binary_msg || gnutella_establish ||
      51 [ +  - ][ +  - ]:          1 :                         gnutella_not_establish || gnutella_http_notify;
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
      52                 :            :                 }
      53                 :            : 
      54                 :            : private:
      55                 :            :         int NextLine(const u_char* data, int len);
      56                 :            : 
      57                 :            :         int GnutellaOK(string header);
      58                 :            :         int IsHTTP(string header);
      59                 :            : 
      60                 :          0 :         int Established() const { return state == (ORIG_OK | RESP_OK); }
      61                 :            : 
      62                 :            :         void DeliverLines(int len, const u_char* data, bool orig);
      63                 :            : 
      64                 :            :         void SendEvents(GnutellaMsgState* p, bool is_orig);
      65                 :            : 
      66                 :            :         void DissectMessage(char* msg);
      67                 :            :         void DeliverMessages(int len, const u_char* data, bool orig);
      68                 :            : 
      69                 :            :         int state;
      70                 :            :         int new_state;
      71                 :            :         int sent_establish;
      72                 :            : 
      73                 :            :         GnutellaMsgState* orig_msg_state;
      74                 :            :         GnutellaMsgState* resp_msg_state;
      75                 :            :         GnutellaMsgState* ms;
      76                 :            : };
      77                 :            : 
      78                 :            : #endif

Generated by: LCOV version 1.8