ReactOS 0.4.16-dev-1946-g52006dd
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#define STATUS_PENDING ((DWORD)0x00000103)
15
16/*
17** macro definitions
18*/
19#define TELNET_PORT (23)
20
21#define BUFSIZE (4096)
22#define USERID_SIZE (64)
23#define CTRLC (3)
24#define BS (8)
25#define CR (13)
26#define LF (10)
27#define DEL (127)
28
29#define IAC "\xff"
30#define DONT "\xfe"
31#define WONT "\xfc"
32#define WILL "\xfb"
33#define DO "\xfd"
34#define SB "\xfa"
35#define SE "\xf0"
36#define ECHO "\x01"
37#define SUPPRESS_GO_AHEAD "\x03"
38#define TERMINAL_TYPE "\x18"
39#define NAWS "\x1f"
40#define LINEMODE "\x22"
41#define NEWENVIRON "\x27"
42#define MODE "\x01"
43
44#define HANDSHAKE_TIMEOUT (3)
45
46/*
47** types
48*/
49
50typedef struct client_s
51{
53 int socket;
62
63typedef enum
64{
65 NoEcho = 0,
66 Echo = 1,
67 Password = 2
69
70/*
71** Forward function declarations
72*/
73static BOOL WINAPI Cleanup(DWORD dwControlType);
74static void WaitForConnect(void);
76static void CreateSocket(void);
77static void UserLogin(int client_socket);
79static int DoTelnetHandshake(int sock);
80static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo);
81static void RunShell(client_t *client);
82//static BOOL CreateChildProcess(const char *);
88int kickoff_telnetd(void);
unsigned char BOOLEAN
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
static FILE * client
Definition: client.c:37
int socket
Definition: telnetd.h:53
BOOLEAN bReadFromPipe
Definition: telnetd.h:55
HANDLE hChildStdinWr
Definition: telnetd.h:59
HANDLE hProcess
Definition: telnetd.h:57
BOOLEAN bTerminate
Definition: telnetd.h:54
HANDLE hChildStdoutRd
Definition: telnetd.h:60
char userID[USERID_SIZE]
Definition: telnetd.h:52
BOOLEAN bWriteToPipe
Definition: telnetd.h:56
DWORD dwProcessId
Definition: telnetd.h:58
Definition: tcpcore.h:1455
static VOID ErrorExit(LPTSTR)
static BOOLEAN StartSocketInterface(void)
static void UserLogin(int client_socket)
static DWORD WINAPI UserLoginThread(LPVOID)
static DWORD WINAPI WriteToPipeThread(LPVOID)
static void TerminateShell(client_t *client)
struct client_s client_t
int kickoff_telnetd(void)
Definition: telnetd.c:48
static void RunShell(client_t *client)
static void CreateSocket(void)
static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo)
static void WaitForConnect(void)
#define USERID_SIZE
Definition: telnetd.h:22
static DWORD WINAPI ReadFromPipeThread(LPVOID)
static int DoTelnetHandshake(int sock)
EchoMode
Definition: telnetd.h:64
@ Password
Definition: telnetd.h:67
@ NoEcho
Definition: telnetd.h:65
@ Echo
Definition: telnetd.h:66
static DWORD WINAPI MonitorChildThread(LPVOID)
#define WINAPI
Definition: msvc.h:6
CHAR * LPTSTR
Definition: xmlstorage.h:192