ReactOS  0.4.12-dev-57-g7050ac4
telnetd.h
Go to the documentation of this file.
1 #pragma once
2 
3 #define _CRT_SECURE_NO_WARNINGS
4 #define WIN32_NO_STATUS
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <windef.h>
8 #include <winbase.h>
9 #include <wincon.h>
10 #define _INC_WINDOWS
11 #include <winsock2.h>
12 #include <strsafe.h>
13 
14 /*
15 ** macro definitions
16 */
17 #define TELNET_PORT (23)
18 
19 #define BUFSIZE (4096)
20 #define USERID_SIZE (64)
21 #define CTRLC (3)
22 #define BS (8)
23 #define CR (13)
24 #define LF (10)
25 #define DEL (127)
26 
27 #define IAC "\xff"
28 #define DONT "\xfe"
29 #define WONT "\xfc"
30 #define WILL "\xfb"
31 #define DO "\xfd"
32 #define SB "\xfa"
33 #define SE "\xf0"
34 #define ECHO "\x01"
35 #define SUPPRESS_GO_AHEAD "\x03"
36 #define TERMINAL_TYPE "\x18"
37 #define NAWS "\x1f"
38 #define LINEMODE "\x22"
39 #define NEWENVIRON "\x27"
40 #define MODE "\x01"
41 
42 #define HANDSHAKE_TIMEOUT (3)
43 
44 /*
45 ** types
46 */
47 
48 typedef struct client_s
49 {
51  int socket;
59 } client_t;
60 
61 typedef enum
62 {
63  NoEcho = 0,
64  Echo = 1,
66 } EchoMode;
67 
68 /*
69 ** Forward function declarations
70 */
71 static BOOL WINAPI Cleanup(DWORD dwControlType);
72 static void WaitForConnect(void);
73 static BOOLEAN StartSocketInterface(void);
74 static void CreateSocket(void);
75 static void UserLogin(int client_socket);
77 static int DoTelnetHandshake(int sock);
78 static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo);
79 static void RunShell(client_t *client);
80 //static BOOL CreateChildProcess(const char *);
84 static void TerminateShell(client_t *client);
85 static VOID ErrorExit(LPTSTR);
86 int kickoff_telnetd(void);
static void TerminateShell(client_t *client)
HANDLE hChildStdinWr
Definition: telnetd.h:57
HANDLE hProcess
Definition: telnetd.h:55
static DWORD WINAPI MonitorChildThread(LPVOID)
static VOID ErrorExit(LPTSTR)
static void RunShell(client_t *client)
#define USERID_SIZE
Definition: telnetd.h:20
GLuint buffer
Definition: glext.h:5915
static void UserLogin(int client_socket)
BOOLEAN bWriteToPipe
Definition: telnetd.h:54
CHAR * LPTSTR
Definition: xmlstorage.h:192
static DWORD WINAPI WriteToPipeThread(LPVOID)
int kickoff_telnetd(void)
Definition: telnetd.c:48
static BOOLEAN StartSocketInterface(void)
unsigned char BOOLEAN
BOOLEAN bReadFromPipe
Definition: telnetd.h:53
static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo)
unsigned int BOOL
Definition: ntddk_ex.h:94
EchoMode
Definition: telnetd.h:61
BOOLEAN bTerminate
Definition: telnetd.h:52
static FILE * client
Definition: client.c:41
unsigned long DWORD
Definition: ntddk_ex.h:95
static void CreateSocket(void)
GLenum GLsizei len
Definition: glext.h:6722
#define WINAPI
Definition: msvc.h:20
DWORD dwProcessId
Definition: telnetd.h:56
char userID[USERID_SIZE]
Definition: telnetd.h:50
int socket
Definition: telnetd.h:51
static int DoTelnetHandshake(int sock)
static BOOL WINAPI Cleanup(DWORD dwControlType)
Definition: tcpcore.h:1455
static DWORD WINAPI UserLoginThread(LPVOID)
struct client_s client_t
HANDLE hChildStdoutRd
Definition: telnetd.h:58
static void WaitForConnect(void)
Definition: telnetd.h:63
Definition: telnetd.h:64
static DWORD WINAPI ReadFromPipeThread(LPVOID)