ReactOS 0.4.15-dev-7958-gcd0bb1a
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
48typedef struct client_s
49{
51 int socket;
60
61typedef enum
62{
63 NoEcho = 0,
64 Echo = 1,
65 Password = 2
67
68/*
69** Forward function declarations
70*/
71static BOOL WINAPI Cleanup(DWORD dwControlType);
72static void WaitForConnect(void);
74static void CreateSocket(void);
75static void UserLogin(int client_socket);
77static int DoTelnetHandshake(int sock);
78static int ReceiveLine(int sock, char *buffer, int len, EchoMode echo);
79static void RunShell(client_t *client);
80//static BOOL CreateChildProcess(const char *);
86int 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:41
int socket
Definition: telnetd.h:51
BOOLEAN bReadFromPipe
Definition: telnetd.h:53
HANDLE hChildStdinWr
Definition: telnetd.h:57
HANDLE hProcess
Definition: telnetd.h:55
BOOLEAN bTerminate
Definition: telnetd.h:52
HANDLE hChildStdoutRd
Definition: telnetd.h:58
char userID[USERID_SIZE]
Definition: telnetd.h:50
BOOLEAN bWriteToPipe
Definition: telnetd.h:54
DWORD dwProcessId
Definition: telnetd.h:56
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:20
static DWORD WINAPI ReadFromPipeThread(LPVOID)
static int DoTelnetHandshake(int sock)
EchoMode
Definition: telnetd.h:62
@ Password
Definition: telnetd.h:65
@ NoEcho
Definition: telnetd.h:63
@ Echo
Definition: telnetd.h:64
static DWORD WINAPI MonitorChildThread(LPVOID)
#define WINAPI
Definition: msvc.h:6
CHAR * LPTSTR
Definition: xmlstorage.h:192