9#ifndef telnet_telnetConn_hpp 
   10#define telnet_telnetConn_hpp 
   31#include <mx/sys/timeUtils.hpp> 
   33#include "../../libs/libtelnet/libtelnet.h" 
   42#ifndef TELNET_BUFFSIZE 
   43   #define TELNET_BUFFSIZE (1024) 
   50            { TELNET_TELOPT_ECHO,       TELNET_WONT, TELNET_DO   },
 
   51            { TELNET_TELOPT_TTYPE,      TELNET_WILL, TELNET_DONT },
 
   52            { TELNET_TELOPT_COMPRESS2,  TELNET_WONT, TELNET_DO   },
 
   53            { TELNET_TELOPT_MSSP,       TELNET_WONT, TELNET_DO   },
 
 
   56#define TELNET_WAITING_USER (0) 
   57#define TELNET_GOT_USER (1) 
   58#define TELNET_WAITING_PASS (2) 
   59#define TELNET_GOT_PASS (3) 
   60#define TELNET_WAITING_PROMPT (4) 
   61#define TELNET_LOGGED_IN (5) 
  119   int connect( 
const std::string & host, 
 
  120                const std::string & port  
 
  124   int login( 
const std::string & username, 
 
  125              const std::string & password  
 
  140   int write( 
const std::string & buffWrite, 
 
  152   int read( 
const std::string & eot, 
 
  165   int read( 
int timeoutRead, 
 
  183   int writeRead( 
const std::string & strWrite, 
 
  190   static int send( 
int sock,
 
 
static const telnet_telopt_t telopts[]
libtelnet option table.
A Telnet connection manager, wrapping libtelnet.
int m_EHError
Used to indicate an error occurred in the event handler callback.
int login(const std::string &username, const std::string &password)
Manage the login process on this device.
std::string m_usernamePrompt
The device's username entry prompt, used for managing login.
int write(const std::string &buffWrite, int timeoutWrite)
Write to a telnet connection.
telnet_t * m_telnet
libtelnet telnet_t structure
~telnetConn()
D'tor, conducts connection cleanup.
static int send(int sock, const char *buffer, size_t size)
Internal send for use by event_handler.
std::string m_strRead
The accumulated string read from the device.
static void event_handler(telnet_t *telnet, telnet_event_t *ev, void *user_data)
Event handler callback for libtelnet processing.
int m_loggedin
Flag denoting the login state.
int m_sock
The socket file descriptor.
int noLogin()
Set flags as if we're logged in, used when device doesn't require it.
std::string m_passwordPrompt
The device's password entry prompt, used for managing login.
std::string m_prompt
The device's prompt, used for detecting end of transmission.
int writeRead(const std::string &strWrite, bool swallowEcho, int timeoutWrite, int timeoutRead)
Write to a telnet connection, then get the reply.
int read(const std::string &eot, int timeoutRead, bool clear=true)
Read from a telnet connection, until end-of-transmission string is read.
int connect(const std::string &host, const std::string &port)
Connect to the device.
Error numbers for the tty utilities.
Utilities for i/o on a file descriptor pointing to a tty device.