ReactOS  0.4.12-dev-57-g7050ac4
telnetd.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <wincon.h>
#include <winsock2.h>
#include <strsafe.h>
Include dependency graph for telnetd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  client_s
 

Macros

#define _CRT_SECURE_NO_WARNINGS
 
#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define TELNET_PORT   (23)
 
#define BUFSIZE   (4096)
 
#define USERID_SIZE   (64)
 
#define CTRLC   (3)
 
#define BS   (8)
 
#define CR   (13)
 
#define LF   (10)
 
#define DEL   (127)
 
#define IAC   "\xff"
 
#define DONT   "\xfe"
 
#define WONT   "\xfc"
 
#define WILL   "\xfb"
 
#define DO   "\xfd"
 
#define SB   "\xfa"
 
#define SE   "\xf0"
 
#define ECHO   "\x01"
 
#define SUPPRESS_GO_AHEAD   "\x03"
 
#define TERMINAL_TYPE   "\x18"
 
#define NAWS   "\x1f"
 
#define LINEMODE   "\x22"
 
#define NEWENVIRON   "\x27"
 
#define MODE   "\x01"
 
#define HANDSHAKE_TIMEOUT   (3)
 

Typedefs

typedef struct client_s client_t
 

Enumerations

enum  EchoMode { NoEcho = 0, Echo = 1, Password = 2 }
 

Functions

static BOOL WINAPI Cleanup (DWORD dwControlType)
 
static void WaitForConnect (void)
 
static BOOLEAN StartSocketInterface (void)
 
static void CreateSocket (void)
 
static void UserLogin (int client_socket)
 
static DWORD WINAPI UserLoginThread (LPVOID)
 
static int DoTelnetHandshake (int sock)
 
static int ReceiveLine (int sock, char *buffer, int len, EchoMode echo)
 
static void RunShell (client_t *client)
 
static DWORD WINAPI MonitorChildThread (LPVOID)
 
static DWORD WINAPI WriteToPipeThread (LPVOID)
 
static DWORD WINAPI ReadFromPipeThread (LPVOID)
 
static void TerminateShell (client_t *client)
 
static VOID ErrorExit (LPTSTR)
 
int kickoff_telnetd (void)
 

Macro Definition Documentation

◆ _CRT_SECURE_NO_WARNINGS

#define _CRT_SECURE_NO_WARNINGS

Definition at line 3 of file telnetd.h.

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 10 of file telnetd.h.

◆ BS

#define BS   (8)

Definition at line 22 of file telnetd.h.

◆ BUFSIZE

#define BUFSIZE   (4096)

Definition at line 19 of file telnetd.h.

◆ CR

#define CR   (13)

Definition at line 23 of file telnetd.h.

Referenced by ReceiveLine(), and UserLoginThread().

◆ CTRLC

#define CTRLC   (3)

Definition at line 21 of file telnetd.h.

Referenced by WriteToPipeThread().

◆ DEL

#define DEL   (127)

Definition at line 25 of file telnetd.h.

Referenced by ReceiveLine().

◆ DO

#define DO   "\xfd"

Definition at line 31 of file telnetd.h.

◆ DONT

#define DONT   "\xfe"

Definition at line 28 of file telnetd.h.

◆ ECHO

#define ECHO   "\x01"

Definition at line 34 of file telnetd.h.

◆ HANDSHAKE_TIMEOUT

#define HANDSHAKE_TIMEOUT   (3)

Definition at line 42 of file telnetd.h.

Referenced by DoTelnetHandshake().

◆ IAC

#define IAC   "\xff"

Definition at line 27 of file telnetd.h.

◆ LF

#define LF   (10)

Definition at line 24 of file telnetd.h.

Referenced by ReceiveLine().

◆ LINEMODE

#define LINEMODE   "\x22"

Definition at line 38 of file telnetd.h.

Referenced by DoTelnetHandshake().

◆ MODE

#define MODE   "\x01"

Definition at line 40 of file telnetd.h.

◆ NAWS

#define NAWS   "\x1f"

Definition at line 37 of file telnetd.h.

Referenced by DoTelnetHandshake().

◆ NEWENVIRON

#define NEWENVIRON   "\x27"

Definition at line 39 of file telnetd.h.

Referenced by DoTelnetHandshake().

◆ SB

#define SB   "\xfa"

Definition at line 32 of file telnetd.h.

◆ SE

#define SE   "\xf0"

Definition at line 33 of file telnetd.h.

◆ SUPPRESS_GO_AHEAD

#define SUPPRESS_GO_AHEAD   "\x03"

Definition at line 35 of file telnetd.h.

Referenced by DoTelnetHandshake().

◆ TELNET_PORT

#define TELNET_PORT   (23)

Definition at line 17 of file telnetd.h.

Referenced by CreateSocket().

◆ TERMINAL_TYPE

#define TERMINAL_TYPE   "\x18"

Definition at line 36 of file telnetd.h.

Referenced by DoTelnetHandshake().

◆ USERID_SIZE

#define USERID_SIZE   (64)

Definition at line 20 of file telnetd.h.

Referenced by UserLoginThread().

◆ WILL

#define WILL   "\xfb"

Definition at line 30 of file telnetd.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 4 of file telnetd.h.

◆ WONT

#define WONT   "\xfc"

Definition at line 29 of file telnetd.h.

Typedef Documentation

◆ client_t

Enumeration Type Documentation

◆ EchoMode

Enumerator
NoEcho 
Echo 
Password 

Definition at line 61 of file telnetd.h.

62 {
63  NoEcho = 0,
64  Echo = 1,
65  Password = 2
66 } EchoMode;
EchoMode
Definition: telnetd.h:61
Definition: telnetd.h:63
Definition: telnetd.h:64

Function Documentation

◆ Cleanup()

static BOOL WINAPI Cleanup ( DWORD  dwControlType)
static

◆ CreateSocket()

static void CreateSocket ( void  )
static

◆ DoTelnetHandshake()

static int DoTelnetHandshake ( int  sock)
static

◆ ErrorExit()

static VOID ErrorExit ( LPTSTR  )
static

◆ kickoff_telnetd()

int kickoff_telnetd ( void  )

Definition at line 48 of file telnetd.c.

49 {
50  printf("Attempting to start Simple TelnetD\n");
51 
52 // DetectPlatform();
54 
55  if (!StartSocketInterface())
56  ErrorExit("Unable to start socket interface\n");
57 
58  CreateSocket();
59 
60  while(!bShutdown) {
62  }
63 
64  WSACleanup();
65  return 0;
66 }
INT WSAAPI WSACleanup(VOID)
Definition: startup.c:60
static BOOLEAN StartSocketInterface(void)
Definition: telnetd.c:79
static BOOL WINAPI Cleanup(DWORD dwControlType)
Definition: telnetd.c:69
BOOL WINAPI DECLSPEC_HOTPATCH SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add)
Definition: console.c:2111
static BOOLEAN bShutdown
Definition: telnetd.c:36
static void CreateSocket(void)
Definition: telnetd.c:102
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
static void WaitForConnect(void)
Definition: telnetd.c:120
#define printf
Definition: config.h:203

◆ MonitorChildThread()

static DWORD WINAPI MonitorChildThread ( LPVOID  )
static

◆ ReadFromPipeThread()

static DWORD WINAPI ReadFromPipeThread ( LPVOID  )
static

◆ ReceiveLine()

static int ReceiveLine ( int  sock,
char buffer,
int  len,
EchoMode  echo 
)
static

◆ RunShell()

static void RunShell ( client_t client)
static

◆ StartSocketInterface()

static BOOLEAN StartSocketInterface ( void  )
static

◆ TerminateShell()

static void TerminateShell ( client_t client)
static

◆ UserLogin()

static void UserLogin ( int  client_socket)
static

◆ UserLoginThread()

static DWORD WINAPI UserLoginThread ( LPVOID  )
static

◆ WaitForConnect()

static void WaitForConnect ( void  )
static

◆ WriteToPipeThread()

static DWORD WINAPI WriteToPipeThread ( LPVOID  )
static