move tcpsvcs from the /apps directory to the /services directory
[reactos.git] / reactos / services / tcpsvcs / tcpsvcs.h
1 /*
2 * ReactOS Services
3 * Copyright (C) 2005 ReactOS Team
4 *
5 * LICENCE: GPL - See COPYING in the top level directory
6 * PROJECT: ReactOS simple TCP/IP services
7 * FILE: apps/utils/net/tcpsvcs/tcpsvcs.h
8 * PURPOSE: Provide CharGen, Daytime, Discard, Echo, and Qotd services
9 * PROGRAMMERS: Ged Murphy (gedmurphy@gmail.com)
10 * REVISIONS:
11 * GM 04/10/05 Created
12 *
13 */
14
15 /* default port numbers */
16 #define ECHO_PORT 7
17 #define DISCARD_PORT 9
18 #define DAYTIME_PORT 13
19 #define QOTD_PORT 17
20 #define CHARGEN_PORT 19
21
22 #define NUM_SERVICES 5
23 #define BUF_SIZE 255
24 #define BUF 1024
25 #define CS_TIMEOUT 1000
26
27 /* RFC865 states no more than 512 chars per line */
28 #define MAX_QUOTE_BUF 512
29
30 /* printable ASCII's characters for chargen */
31 #define START 32
32 #define END 126
33
34 /* number of chars to put on a line */
35 #define LINESIZ 74 // 72 + /r and /n
36
37 /* data structure to pass to threads */
38 typedef struct _Services {
39 INT Port;
40 TCHAR *Name;
41 LPTHREAD_START_ROUTINE Service;
42 } SERVICES, *PSERVICES;
43
44
45 /* tcpsvcs functions */
46 //static VOID WINAPI ServiceMain(DWORD argc, LPTSTR argv[]);
47 VOID WINAPI ServerCtrlHandler(DWORD control);
48 INT CreateServers(VOID);
49 VOID LogEvent (LPCTSTR UserMessage, DWORD ExitCode, BOOL PrintErrorMsg);
50 void UpdateStatus (int NewStatus, int Check);
51
52
53 /* skelserver functions */
54 DWORD WINAPI StartServer(LPVOID lpParam);
55 SOCKET SetUpListener(const char* ServAddr, int Port);
56 VOID AcceptConnections(SOCKET ListeningSocket,
57 LPTHREAD_START_ROUTINE Service, TCHAR *Name);
58 BOOL EchoIncomingPackets(SOCKET sd);
59 BOOL ShutdownConnection(SOCKET Sock, BOOL bRec);
60
61 /* chargen functions */
62 DWORD WINAPI ChargenHandler(VOID* Sock_);
63 BOOL GenerateChars(SOCKET Sock);
64 BOOL SendLine(SOCKET Sock, TCHAR* Line);
65
66 /* daytime functions */
67 DWORD WINAPI DaytimeHandler(VOID* Sock_);
68 BOOL SendTime(SOCKET Sock, TCHAR *time);
69
70 /* echo functions */
71 DWORD WINAPI EchoHandler(VOID* Sock_);
72 BOOL EchoIncomingPackets(SOCKET Sock);
73
74 /* discard functions */
75 DWORD WINAPI DiscardHandler(VOID* Sock_);
76 BOOL RecieveIncomingPackets(SOCKET Sock);
77
78 /* qotd functions */
79 DWORD WINAPI QotdHandler(VOID* Sock_);
80 BOOL SendQuote(SOCKET Sock, TCHAR* Quote);