ReactOS 0.4.15-dev-5666-gc548b97
tftpd.h
Go to the documentation of this file.
1/**************************************************************************
2* Copyright (C) 2005 by Achal Dhir *
3* achaldhir@gmail.com *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 2 of the License, or *
8* (at your option) any later version. *
9* *
10* This program is distributed in the hope that it will be useful, *
11* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13* GNU General Public License for more details. *
14* *
15* You should have received a copy of the GNU General Public License *
16* along with this program; if not, write to the *
17* Free Software Foundation, Inc., *
18* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19***************************************************************************/
20// TFTPServer.cpp
21#define MYBYTE unsigned char
22#define MYWORD unsigned short
23#define MYDWORD unsigned int
24
25#ifdef _MSC_VER
26 #define strcasecmp _stricmp
27 #define _CRT_SECURE_NO_WARNINGS
28 #pragma comment(lib, "ws2_32.lib")
29 #pragma comment(lib, "iphlpapi.lib")
30#endif
31
32//Constants
33#define my_inet_addr inet_addr
34#define MAX_SERVERS 8
35
36//Structs
37struct home
38{
39 char alias[64];
40 char target[256];
41};
42
44{
49 bool loaded;
50 bool ready;
51};
52
54{
57};
58
59struct message
60{
62 char buffer[514];
63};
64
66{
69 char errormessage[512];
70};
71
72struct packet
73{
76 char buffer;
77};
78
79struct data12
80{
83};
84
85struct request
86{
94 char path[256];
96 char *filename;
97 char *mode;
98 char *alias;
103 int bytesRead[2];
107 union
108 {
112 };
113 union
114 {
118 };
123};
124
125struct data1
126{
133 bool ready;
134 bool busy;
135};
136
137struct data2
138{
140#ifdef __REACTOS__
142#else
144#endif
155};
156
157struct data15
158{
159 union
160 {
161 //MYDWORD ip;
162 unsigned ip:32;
164 };
165};
166
167//Functions
168bool detectChange();
169void closeConn();
170void getInterfaces(data1*);
171void runProg();
172void processRequest(LPVOID lpParam);
173char* myGetToken(char*, MYBYTE);
174char* myTrim(char*, char*);
175void init(void*);
176bool cleanReq(request*);
178FILE* openSection(const char*, MYBYTE, char*);
179char* readSection(char*, FILE*);
180bool getSection(const char*, char*, MYBYTE, char*);
181bool isIP(char*s);
182char* myLower(char*);
183char* myUpper(char*);
184char* IP2String(char*, MYDWORD);
186void printWindowsError();
187void logMess(request*, MYBYTE);
188void logMess(char*, MYBYTE);
__kernel_time_t time_t
Definition: linux.h:252
GLdouble s
Definition: gl.h:2039
GLuint buffer
Definition: glext.h:5915
GLenum target
Definition: glext.h:7315
int socklen_t
Definition: tcp.c:35
MYWORD opcode
Definition: tftpd.h:55
MYWORD block
Definition: tftpd.h:56
Definition: tftpd.h:80
MYDWORD rangeEnd
Definition: tftpd.h:82
MYDWORD rangeStart
Definition: tftpd.h:81
Definition: tftpd.h:158
unsigned ip
Definition: tftpd.h:162
MYBYTE octate[4]
Definition: tftpd.h:163
Definition: tftpd.h:126
MYDWORD staticServers[MAX_SERVERS]
Definition: tftpd.h:129
bool busy
Definition: tftpd.h:134
SOCKET maxFD
Definition: tftpd.h:132
tftpConnType tftpConn[MAX_SERVERS]
Definition: tftpd.h:127
MYDWORD allServers[MAX_SERVERS]
Definition: tftpd.h:128
MYDWORD listenServers[MAX_SERVERS]
Definition: tftpd.h:130
MYWORD listenPorts[MAX_SERVERS]
Definition: tftpd.h:131
bool ready
Definition: tftpd.h:133
Definition: tftpd.h:138
data12 hostRanges[32]
Definition: tftpd.h:146
char fileWrite
Definition: tftpd.h:148
bool ifspecified
Definition: tftpd.h:154
MYBYTE logLevel
Definition: tftpd.h:153
char fileOverwrite
Definition: tftpd.h:149
int maxport
Definition: tftpd.h:151
char fileRead
Definition: tftpd.h:147
int minport
Definition: tftpd.h:150
WSADATA wsaData
Definition: tftpd.h:139
MYDWORD failureCount
Definition: tftpd.h:152
home homes[8]
Definition: tftpd.h:143
FILE * logfile
Definition: tftpd.h:145
Definition: winsock.h:66
Definition: tftpd.h:38
char alias[64]
Definition: tftpd.h:39
Definition: tftpd.h:60
MYWORD opcode
Definition: tftpd.h:61
Definition: dhcpd.h:135
char buffer
Definition: tftpd.h:76
MYWORD opcode
Definition: tftpd.h:74
MYWORD block
Definition: tftpd.h:75
Definition: tftpd.h:86
MYBYTE sockInd
Definition: tftpd.h:92
MYDWORD tsize
Definition: tftpd.h:99
char * filename
Definition: tftpd.h:96
FILE * file
Definition: tftpd.h:95
acknowledgement acin
Definition: tftpd.h:117
char * alias
Definition: tftpd.h:98
int bytesReady
Definition: tftpd.h:101
time_t expiry
Definition: tftpd.h:89
MYWORD blksize
Definition: tftpd.h:119
int bytesRecd
Definition: tftpd.h:102
MYBYTE attempt
Definition: tftpd.h:93
SOCKET knock
Definition: tftpd.h:91
char * mode
Definition: tftpd.h:97
tftperror serverError
Definition: tftpd.h:109
int bytesRead[2]
Definition: tftpd.h:103
MYDWORD fblock
Definition: tftpd.h:100
acknowledgement acout
Definition: tftpd.h:111
MYWORD tblock
Definition: tftpd.h:122
MYWORD timeout
Definition: tftpd.h:120
packet * pkt[2]
Definition: tftpd.h:104
fd_set readfds
Definition: tftpd.h:88
SOCKET sock
Definition: tftpd.h:90
tftperror clientError
Definition: tftpd.h:115
message mesin
Definition: tftpd.h:116
socklen_t clientsize
Definition: tftpd.h:106
timeval tv
Definition: tftpd.h:87
message mesout
Definition: tftpd.h:110
sockaddr_in client
Definition: tftpd.h:105
MYWORD block
Definition: tftpd.h:121
MYWORD port
Definition: tftpd.h:48
bool loaded
Definition: tftpd.h:49
SOCKET sock
Definition: tftpd.h:45
MYDWORD server
Definition: tftpd.h:47
bool ready
Definition: tftpd.h:50
sockaddr_in addr
Definition: tftpd.h:46
MYWORD opcode
Definition: tftpd.h:67
MYWORD errorcode
Definition: tftpd.h:68
char errormessage[512]
Definition: tftpd.h:69
bool getSection(const char *, char *, MYBYTE, char *)
Definition: tftpd.cpp:1533
char * myTrim(char *, char *)
Definition: tftpd.cpp:1689
#define MYDWORD
Definition: tftpd.h:23
bool detectChange()
Definition: tftpd.cpp:2428
char * myLower(char *)
Definition: tftpd.cpp:1795
bool addServer(MYDWORD *, MYDWORD)
Definition: tftpd.cpp:2557
void runProg()
Definition: tftpd.cpp:393
#define MYBYTE
Definition: tftpd.h:21
void getInterfaces(data1 *)
Definition: tftpd.cpp:2519
char * myUpper(char *)
Definition: tftpd.cpp:1785
MYDWORD * findServer(MYDWORD *, MYDWORD)
Definition: tftpd.cpp:2572
FILE * openSection(const char *, MYBYTE, char *)
Definition: tftpd.cpp:1581
void closeConn()
Definition: tftpd.cpp:481
#define MAX_SERVERS
Definition: tftpd.h:34
bool cleanReq(request *)
Definition: tftpd.cpp:1505
char * IP2String(char *, MYDWORD)
Definition: tftpd.cpp:1759
char * readSection(char *, FILE *)
Definition: tftpd.cpp:1611
void processRequest(LPVOID lpParam)
bool isIP(char *s)
Definition: tftpd.cpp:1767
void printWindowsError()
Definition: tftpd.cpp:323
char * myGetToken(char *, MYBYTE)
Definition: tftpd.cpp:1628
void logMess(request *, MYBYTE)
Definition: tftpd.cpp:2622
#define MYWORD
Definition: tftpd.h:22
UINT_PTR SOCKET
Definition: winsock.h:47
static int init
Definition: wintirpc.c:33