Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

TelnetOption Class Reference

#include <NVT.h>

Inheritance diagram for TelnetOption:

Inheritance graph
[legend]
Collaboration diagram for TelnetOption:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TelnetOption (TCP_NVT *endp, unsigned int code)
unsigned int Code () const
int IsActive () const
int SaidWill () const
int SaidWont () const
int SaidDo () const
int SaidDont () const
void SetWill ()
void SetWont ()
void SetDo ()
void SetDont ()
void RecvOption (unsigned int type)
virtual void RecvSubOption (u_char *data, int len)
virtual void SetActive (int is_active)
const TCP_NVTEndpoint () const

Protected Member Functions

virtual void InconsistentOption (unsigned int type)
virtual void BadOption ()

Protected Attributes

TCP_NVTendp
unsigned int code
int flags
int active

Friends

class TCP_NVT

Constructor & Destructor Documentation

TelnetOption::TelnetOption TCP_NVT endp,
unsigned int  code
 

Definition at line 45 of file NVT.cc.

References active.

00046         {
00047         endp = arg_endp;
00048         code = arg_code;
00049         flags = 0;
00050         active = 0;
00051         }


Member Function Documentation

void TelnetOption::BadOption  )  [protected, virtual]
 

Definition at line 120 of file NVT.cc.

References TCP_Contents::Conn(), and Connection::Event().

Referenced by TelnetEnvironmentOption::RecvSubOption(), TelnetAuthenticateOption::RecvSubOption(), TelnetEncryptOption::RecvSubOption(), and TelnetTerminalOption::RecvSubOption().

00121         {
00122         endp->Conn()->Event(bad_option);
00123         }

unsigned int TelnetOption::Code  )  const [inline]
 

Definition at line 48 of file NVT.h.

Referenced by TCP_NVT::FindOption().

00048 { return code; }

const TCP_NVT* TelnetOption::Endpoint  )  const [inline]
 

Definition at line 67 of file NVT.h.

Referenced by TelnetEncryptOption::RecvSubOption().

00067 { return endp; }

void TelnetOption::InconsistentOption unsigned int  type  )  [protected, virtual]
 

Reimplemented in TelnetBinaryOption.

Definition at line 115 of file NVT.cc.

References TCP_Contents::Conn(), and Connection::Event().

Referenced by RecvOption(), TelnetAuthenticateOption::RecvSubOption(), and TelnetEncryptOption::RecvSubOption().

00116         {
00117         endp->Conn()->Event(inconsistent_option);
00118         }

int TelnetOption::IsActive  )  const [inline]
 

Definition at line 50 of file NVT.h.

References active.

Referenced by RecvOption().

00050 { return active; }

void TelnetOption::RecvOption unsigned int  type  ) 
 

Definition at line 53 of file NVT.cc.

References TCP_NVT::FindPeerOption(), InconsistentOption(), internal_error(), IsActive(), SaidDo(), SaidDont(), SaidWill(), SaidWont(), SetActive(), SetDo(), SetDont(), SetWill(), SetWont(), TELNET_OPT_DO, TELNET_OPT_DONT, TELNET_OPT_WILL, and TELNET_OPT_WONT.

Referenced by TCP_NVT::SawOption().

00054         {
00055         TelnetOption* peer = endp->FindPeerOption(code);
00056         if ( ! peer )
00057                 internal_error("option peer missing in TelnetOption::RecvOption");
00058 
00059         // WILL/WONT/DO/DONT are messages we've *received* from our peer.
00060         switch ( type ) {
00061         case TELNET_OPT_WILL:
00062                 if ( SaidDont() || peer->SaidWont() || peer->IsActive() )
00063                         InconsistentOption(type);
00064 
00065                 peer->SetWill();
00066 
00067                 if ( SaidDo() )
00068                         peer->SetActive(1);
00069                 break;
00070 
00071         case TELNET_OPT_WONT:
00072                 if ( peer->SaidWill() && ! SaidDont() )
00073                         InconsistentOption(type);
00074 
00075                 peer->SetWont();
00076 
00077                 if ( SaidDont() )
00078                         peer->SetActive(0);
00079                 break;
00080 
00081         case TELNET_OPT_DO:
00082                 if ( SaidWont() || peer->SaidDont() || IsActive() )
00083                         InconsistentOption(type);
00084 
00085                 peer->SetDo();
00086 
00087                 if ( SaidWill() )
00088                         SetActive(1);
00089                 break;
00090 
00091         case TELNET_OPT_DONT:
00092                 if ( peer->SaidDo() && ! SaidWont() )
00093                         InconsistentOption(type);
00094 
00095                 peer->SetDont();
00096 
00097                 if ( SaidWont() )
00098                         SetActive(0);
00099                 break;
00100 
00101         default:
00102                 internal_error("bad option type in TelnetOption::RecvOption");
00103         }
00104         }

void TelnetOption::RecvSubOption u_char *  data,
int  len
[virtual]
 

Reimplemented in TelnetTerminalOption, TelnetEncryptOption, TelnetAuthenticateOption, and TelnetEnvironmentOption.

Definition at line 106 of file NVT.cc.

Referenced by TCP_NVT::SawSubOption().

00107         {
00108         }

int TelnetOption::SaidDo  )  const [inline]
 

Definition at line 54 of file NVT.h.

References OPT_SAID_DO.

Referenced by RecvOption().

00054 { return flags & OPT_SAID_DO; }

int TelnetOption::SaidDont  )  const [inline]
 

Definition at line 55 of file NVT.h.

References OPT_SAID_DONT.

Referenced by RecvOption().

00055 { return flags & OPT_SAID_DONT; }

int TelnetOption::SaidWill  )  const [inline]
 

Definition at line 52 of file NVT.h.

References OPT_SAID_WILL.

Referenced by RecvOption().

00052 { return flags & OPT_SAID_WILL; }

int TelnetOption::SaidWont  )  const [inline]
 

Definition at line 53 of file NVT.h.

References OPT_SAID_WONT.

Referenced by RecvOption().

00053 { return flags & OPT_SAID_WONT; }

void TelnetOption::SetActive int  is_active  )  [virtual]
 

Reimplemented in TelnetBinaryOption.

Definition at line 110 of file NVT.cc.

References active.

Referenced by RecvOption().

00111         {
00112         active = is_active;
00113         }

void TelnetOption::SetDo  )  [inline]
 

Definition at line 59 of file NVT.h.

References OPT_SAID_DO.

Referenced by RecvOption().

00059 { flags |= OPT_SAID_DO; }

void TelnetOption::SetDont  )  [inline]
 

Definition at line 60 of file NVT.h.

References OPT_SAID_DONT.

Referenced by RecvOption().

00060 { flags |= OPT_SAID_DONT; }

void TelnetOption::SetWill  )  [inline]
 

Definition at line 57 of file NVT.h.

References OPT_SAID_WILL.

Referenced by RecvOption().

00057 { flags |= OPT_SAID_WILL; }

void TelnetOption::SetWont  )  [inline]
 

Definition at line 58 of file NVT.h.

References OPT_SAID_WONT.

Referenced by RecvOption().

00058 { flags |= OPT_SAID_WONT; }


Friends And Related Function Documentation

friend class TCP_NVT [friend]
 

Reimplemented in TelnetEncryptOption, and TelnetAuthenticateOption.

Definition at line 70 of file NVT.h.


Member Data Documentation

int TelnetOption::active [protected]
 

Definition at line 77 of file NVT.h.

Referenced by IsActive(), SetActive(), and TelnetOption().

unsigned int TelnetOption::code [protected]
 

Definition at line 75 of file NVT.h.

TCP_NVT* TelnetOption::endp [protected]
 

Definition at line 74 of file NVT.h.

int TelnetOption::flags [protected]
 

Definition at line 76 of file NVT.h.


The documentation for this class was generated from the following files:
Generated on Sat May 1 15:33:03 2004 for bro_docs.8a82 by doxygen 1.3.6