LCOV - code coverage report
Current view: top level - src - POP3.h (source / functions) Hit Total Coverage
Test: app.info Lines: 4 4 100.0 %
Date: 2010-12-13 Functions: 2 2 100.0 %
Branches: 1 8 12.5 %

           Branch data     Line data    Source code
       1                 :            : // $Id: POP3.h 3526 2006-09-12 07:32:21Z vern $
       2                 :            : 
       3                 :            : // This code contributed to Bro by Florian Schimandl and Hugh Dollman.
       4                 :            : //
       5                 :            : // An analyser for the POP3 protocol.
       6                 :            : 
       7                 :            : #ifndef pop3_h
       8                 :            : #define pop3_h
       9                 :            : 
      10                 :            : #include <vector>
      11                 :            : #include <string>
      12                 :            : #include <algorithm>
      13                 :            : 
      14                 :            : #include "NVT.h"
      15                 :            : #include "TCP.h"
      16                 :            : #include "MIME.h"
      17                 :            : 
      18                 :            : 
      19                 :            : #undef POP3_CMD_DEF
      20                 :            : #define POP3_CMD_DEF(cmd)       POP3_CMD_##cmd,
      21                 :            : 
      22                 :            : typedef enum {
      23                 :            : #include "POP3_cmd.def"
      24                 :            : } POP3_Cmd;
      25                 :            : 
      26                 :            : typedef enum {
      27                 :            :         POP3_START,
      28                 :            :         POP3_AUTHORIZATION,
      29                 :            :         POP3_TRANSACTION,
      30                 :            :         POP3_UPDATE,
      31                 :            :         POP3_FINISHED,
      32                 :            : } POP3_MasterState;
      33                 :            : 
      34                 :            : typedef enum {
      35                 :            :         START,
      36                 :            :         USER,
      37                 :            :         PASS,
      38                 :            :         APOP,
      39                 :            :         AUTH,
      40                 :            :         AUTH_PLAIN,
      41                 :            :         AUTH_LOGIN,
      42                 :            :         AUTH_CRAM_MD5,
      43                 :            :         NOOP,
      44                 :            :         LAST,
      45                 :            :         STAT,
      46                 :            :         LIST,
      47                 :            :         RETR,
      48                 :            :         DELE,
      49                 :            :         UIDL,
      50                 :            :         TOP,
      51                 :            :         QUIT,
      52                 :            :         RSET,
      53                 :            :         CAPA,
      54                 :            :         STLS,
      55                 :            :         XSENDER,
      56                 :            :         MISC,
      57                 :            :         END,
      58                 :            : } POP3_State;
      59                 :            : 
      60                 :            : typedef enum {
      61                 :            :         POP3_OK,
      62                 :            :         POP3_WOK,
      63                 :            : } POP3_SubState;
      64                 :            : 
      65                 :            : class POP3_Analyzer : public TCP_ApplicationAnalyzer {
      66                 :            : public:
      67                 :            :         POP3_Analyzer(Connection* conn);
      68                 :            :         ~POP3_Analyzer();
      69                 :            : 
      70                 :            :         virtual void Done();
      71                 :            :         virtual void DeliverStream(int len, const u_char* data, bool orig);
      72                 :            : 
      73                 :          5 :         static Analyzer* InstantiateAnalyzer(Connection* conn)
      74                 :            :                 {
      75                 :          5 :                 return new POP3_Analyzer(conn);
      76                 :            :                 }
      77                 :            : 
      78                 :          1 :         static bool Available()
      79                 :            :                 {
      80 [ -  + ][ #  # ]:          1 :                 return pop3_request || pop3_reply || pop3_data || pop3_unexpected;
         [ #  # ][ #  # ]
      81                 :            :                 }
      82                 :            : 
      83                 :            : protected:
      84                 :            :         int masterState;
      85                 :            :         int subState;
      86                 :            :         int state;
      87                 :            :         int lastState;
      88                 :            :         bool multiLine;
      89                 :            :         bool guessing;
      90                 :            :         bool requestForMultiLine;
      91                 :            :         bool waitingForAuthentication;
      92                 :            :         int lastRequiredCommand;
      93                 :            :         int authLines;
      94                 :            : 
      95                 :            :         string user;
      96                 :            :         string password;
      97                 :            : 
      98                 :            :         void ProcessRequest(int length, const char* line);
      99                 :            :         void ProcessReply(int length, const char* line);
     100                 :            :         void NotAllowed(const char* cmd, const char* state);
     101                 :            :         void ProcessClientCmd();
     102                 :            :         void FinishClientCmd();
     103                 :            :         void BeginData();
     104                 :            :         void ProcessData(int length, const char* line);
     105                 :            :         void EndData();
     106                 :            : 
     107                 :            :         vector<string> TokenizeLine(const string input, const char split);
     108                 :            :         int ParseCmd(string cmd);
     109                 :            :         void AuthSuccessfull();
     110                 :            :         void POP3Event(EventHandlerPtr event, bool is_orig,
     111                 :            :                         const char* arg1 = 0, const char* arg2 = 0);
     112                 :            : 
     113                 :            :         MIME_Mail* mail;
     114                 :            :         list<string> cmds;
     115                 :            : 
     116                 :            : private:
     117                 :            :         bool backOff;
     118                 :            : };
     119                 :            : 
     120                 :            : #endif

Generated by: LCOV version 1.8