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

           Branch data     Line data    Source code
       1                 :            : // $Id: NVT.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 nvt_h
       6                 :            : #define nvt_h
       7                 :            : 
       8                 :            : #include "ContentLine.h"
       9                 :            : 
      10                 :            : 
      11                 :            : #define TELNET_OPTION_BINARY 0
      12                 :            : #define TELNET_OPTION_TERMINAL 24
      13                 :            : #define TELNET_OPTION_AUTHENTICATE 37
      14                 :            : #define TELNET_OPTION_ENCRYPT 38
      15                 :            : #define TELNET_OPTION_ENVIRON 39
      16                 :            : #define NUM_TELNET_OPTIONS 5
      17                 :            : 
      18                 :            : class NVT_Analyzer;
      19                 :            : 
      20                 :            : 
      21                 :            : class TelnetOption {
      22                 :            : public:
      23                 :            :         TelnetOption(NVT_Analyzer* endp, unsigned int code);
      24 [ #  # ][ #  # ]:          0 :         virtual ~TelnetOption() { }
      25                 :            : 
      26                 :            : // Whether we told the other side WILL/WONT/DO/DONT.
      27                 :            : #define OPT_SAID_WILL 0x1
      28                 :            : #define OPT_SAID_WONT 0x2
      29                 :            : #define OPT_SAID_DO 0x4
      30                 :            : #define OPT_SAID_DONT 0x8
      31                 :            : 
      32                 :          0 :         unsigned int Code() const       { return code; }
      33                 :            : 
      34                 :          0 :         int IsActive() const            { return active; }
      35                 :            : 
      36                 :          0 :         int SaidWill() const    { return flags & OPT_SAID_WILL; }
      37                 :          0 :         int SaidWont() const    { return flags & OPT_SAID_WONT; }
      38                 :          0 :         int SaidDo() const      { return flags & OPT_SAID_DO; }
      39                 :          0 :         int SaidDont() const    { return flags & OPT_SAID_DONT; }
      40                 :            : 
      41                 :          0 :         void SetWill()  { flags |= OPT_SAID_WILL; }
      42                 :          0 :         void SetWont()  { flags |= OPT_SAID_WONT; }
      43                 :          0 :         void SetDo()    { flags |= OPT_SAID_DO; }
      44                 :          0 :         void SetDont()  { flags |= OPT_SAID_DONT; }
      45                 :            : 
      46                 :            :         void RecvOption(unsigned int type);
      47                 :            :         virtual void RecvSubOption(u_char* data, int len);
      48                 :            : 
      49                 :            :         virtual void SetActive(int is_active);
      50                 :            : 
      51                 :          0 :         const NVT_Analyzer* Endpoint() const    { return endp; }
      52                 :            : 
      53                 :            : protected:
      54                 :            :         friend class NVT_Analyzer;
      55                 :            :         virtual void InconsistentOption(unsigned int type);
      56                 :            :         virtual void BadOption();
      57                 :            : 
      58                 :            :         NVT_Analyzer* endp;
      59                 :            :         unsigned int code;
      60                 :            :         int flags;
      61                 :            :         int active;
      62                 :            : };
      63                 :            : 
      64 [ #  # ][ #  # ]:          0 : class TelnetTerminalOption : public TelnetOption {
      65                 :            : public:
      66                 :          0 :         TelnetTerminalOption(NVT_Analyzer* arg_endp)
      67                 :          0 :                 : TelnetOption(arg_endp, TELNET_OPTION_TERMINAL)        { }
      68                 :            : 
      69                 :            :         void RecvSubOption(u_char* data, int len);
      70                 :            : };
      71                 :            : 
      72 [ #  # ][ #  # ]:          0 : class TelnetEncryptOption : public TelnetOption {
      73                 :            : public:
      74                 :          0 :         TelnetEncryptOption(NVT_Analyzer* arg_endp)
      75                 :          0 :                 : TelnetOption(arg_endp, TELNET_OPTION_ENCRYPT)
      76                 :          0 :                         { did_encrypt_request = doing_encryption = 0; }
      77                 :            : 
      78                 :            :         void RecvSubOption(u_char* data, int len);
      79                 :            : 
      80                 :          0 :         int DidRequest() const          { return did_encrypt_request; }
      81                 :          0 :         int DoingEncryption() const     { return doing_encryption; }
      82                 :            : 
      83                 :            : protected:
      84                 :            :         friend class NVT_Analyzer;
      85                 :            :         int did_encrypt_request, doing_encryption;
      86                 :            : };
      87                 :            : 
      88 [ #  # ][ #  # ]:          0 : class TelnetAuthenticateOption : public TelnetOption {
      89                 :            : public:
      90                 :          0 :         TelnetAuthenticateOption(NVT_Analyzer* arg_endp)
      91                 :          0 :                 : TelnetOption(arg_endp, TELNET_OPTION_AUTHENTICATE)
      92                 :          0 :                         { authentication_requested = 0; }
      93                 :            : 
      94                 :            :         void RecvSubOption(u_char* data, int len);
      95                 :            : 
      96                 :          0 :         int DidRequestAuthentication() const
      97                 :          0 :                 { return authentication_requested; }
      98                 :            : 
      99                 :            : protected:
     100                 :            :         friend class NVT_Analyzer;
     101                 :            :         int authentication_requested;
     102                 :            : };
     103                 :            : 
     104 [ #  # ][ #  # ]:          0 : class TelnetEnvironmentOption : public TelnetOption {
     105                 :            : public:
     106                 :          0 :         TelnetEnvironmentOption(NVT_Analyzer* arg_endp)
     107                 :          0 :                 : TelnetOption(arg_endp, TELNET_OPTION_ENVIRON)
     108                 :          0 :                         { }
     109                 :            : 
     110                 :            :         void RecvSubOption(u_char* data, int len);
     111                 :            : 
     112                 :            : protected:
     113                 :            :         char* ExtractEnv(u_char*& data, int& len, int& code);
     114                 :            : };
     115                 :            : 
     116 [ #  # ][ #  # ]:          0 : class TelnetBinaryOption : public TelnetOption {
     117                 :            : public:
     118                 :          0 :         TelnetBinaryOption(NVT_Analyzer* arg_endp)
     119                 :          0 :                 : TelnetOption(arg_endp, TELNET_OPTION_BINARY)
     120                 :          0 :                         { }
     121                 :            : 
     122                 :            :         void SetActive(int is_active);
     123                 :            : 
     124                 :            : protected:
     125                 :            :         void InconsistentOption(unsigned int type);
     126                 :            : };
     127                 :            : 
     128                 :            : class NVT_Analyzer : public ContentLine_Analyzer {
     129                 :            : public:
     130                 :            :         NVT_Analyzer(Connection* conn, bool orig);
     131                 :            :         ~NVT_Analyzer();
     132                 :            : 
     133                 :            :         TelnetOption* FindOption(unsigned int code);
     134                 :            :         TelnetOption* FindPeerOption(unsigned int code);
     135                 :            : 
     136                 :          0 :         void SetPeer(NVT_Analyzer* arg_peer)    { peer = arg_peer; }
     137                 :            : 
     138                 :            :         void AuthenticationAccepted();
     139                 :            :         void AuthenticationRejected();
     140                 :            : 
     141                 :            :         void SetTerminal(const u_char* terminal, int len);
     142                 :          0 :         void SetBinaryMode(int mode)    { binary_mode = mode; }
     143                 :            :         void SetEncrypting(int mode);
     144                 :          0 :         void SetAuthName(char* arg_auth_name)   { auth_name = arg_auth_name; }
     145                 :            : 
     146                 :          0 :         const char* AuthName() const    { return auth_name; }
     147                 :          0 :         int AuthenticationHasBeenAccepted() const
     148                 :          0 :                 { return authentication_has_been_accepted; }
     149                 :            : 
     150                 :            : protected:
     151                 :            :         void DoDeliver(int len, const u_char* data);
     152                 :            : 
     153                 :            :         void ScanOption(int seq, int len, const u_char* data);
     154                 :            :         virtual void SawOption(unsigned int code);
     155                 :            :         virtual void SawOption(unsigned int code, unsigned int subcode);
     156                 :            :         virtual void SawSubOption(const char* opt, int len);
     157                 :            :         virtual void BadOptionTermination(unsigned int code);
     158                 :            :         const char* PeerAuthName() const;
     159                 :            : 
     160                 :            :         NVT_Analyzer* peer;
     161                 :            : 
     162                 :            :         int pending_IAC;        // true if we're working on an option/IAC
     163                 :            :         int IAC_pos;            // where the IAC was seen
     164                 :            :         int is_suboption;       // true if current option is suboption
     165                 :            :         int last_was_IAC;       // for scanning suboptions
     166                 :            : 
     167                 :            :         int binary_mode, encrypting_mode;
     168                 :            :         int authentication_has_been_accepted;   // if true, we accepted peer's authentication
     169                 :            :         char* auth_name;
     170                 :            : 
     171                 :            :         TelnetOption* options[NUM_TELNET_OPTIONS];
     172                 :            :         int num_options;
     173                 :            : };
     174                 :            : 
     175                 :            : #endif

Generated by: LCOV version 1.8