ReactOS  0.4.12-dev-18-gf469aca
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
37 struct home
38 {
39  char alias[64];
40  char target[256];
41 };
42 
44 {
49  bool loaded;
50  bool ready;
51 };
52 
54 {
57 };
58 
59 struct message
60 {
62  char buffer[514];
63 };
64 
65 struct tftperror
66 {
69  char errormessage[512];
70 };
71 
72 struct packet
73 {
76  char buffer;
77 };
78 
79 struct data12
80 {
83 };
84 
85 struct request
86 {
94  char path[256];
96  char *filename;
97  char *mode;
98  char *alias;
103  int bytesRead[2];
104  packet* pkt[2];
107  union
108  {
112  };
113  union
114  {
118  };
123 };
124 
125 struct data1
126 {
128  MYDWORD allServers[MAX_SERVERS];
129  MYDWORD staticServers[MAX_SERVERS];
130  MYDWORD listenServers[MAX_SERVERS];
131  MYWORD listenPorts[MAX_SERVERS];
133  bool ready;
134  bool busy;
135 };
136 
137 struct data2
138 {
140 #ifdef __REACTOS__
141  home homes[MAX_SERVERS];
142 #else
143  home homes[8];
144 #endif
146  data12 hostRanges[32];
147  char fileRead;
148  char fileWrite;
150  int minport;
151  int maxport;
155 };
156 
157 struct data15
158 {
159  union
160  {
161  //MYDWORD ip;
162  unsigned ip:32;
163  MYBYTE octate[4];
164  };
165 };
166 
167 //Functions
168 bool detectChange();
169 void closeConn();
170 void getInterfaces(data1*);
171 void runProg();
172 void processRequest(LPVOID lpParam);
173 char* myGetToken(char*, MYBYTE);
174 char* myTrim(char*, char*);
175 void init(void*);
176 bool cleanReq(request*);
177 bool addServer(MYDWORD*, MYDWORD);
178 FILE* openSection(const char*, MYBYTE, char*);
179 char* readSection(char*, FILE*);
180 bool getSection(const char*, char*, MYBYTE, char*);
181 bool isIP(char*s);
182 char* myLower(char*);
183 char* myUpper(char*);
184 char* IP2String(char*, MYDWORD);
186 void printWindowsError();
187 void logMess(request*, MYBYTE);
188 void logMess(char*, MYBYTE);
Definition: winsock.h:66
int maxport
Definition: tftpd.h:151
char * filename
Definition: tftpd.h:96
char * myUpper(char *)
Definition: tftpd.cpp:1785
MYBYTE attempt
Definition: tftpd.h:93
Definition: tftpd.h:59
MYWORD tblock
Definition: tftpd.h:122
bool ifspecified
Definition: tftpd.h:154
time_t expiry
Definition: tftpd.h:89
MYWORD timeout
Definition: tftpd.h:120
char * myLower(char *)
Definition: tftpd.cpp:1795
FILE * logfile
Definition: tftpd.h:145
bool loaded
Definition: tftpd.h:49
MYWORD block
Definition: tftpd.h:121
#define MYWORD
Definition: tftpd.h:22
bool busy
Definition: tftpd.h:134
MYWORD opcode
Definition: tftpd.h:74
Definition: tftpd.h:125
GLuint buffer
Definition: glext.h:5915
void printWindowsError()
Definition: tftpd.cpp:323
char * IP2String(char *, MYDWORD)
Definition: tftpd.cpp:1759
MYDWORD * findServer(MYDWORD *, MYDWORD)
Definition: tftpd.cpp:2572
Definition: tftpd.h:79
int bytesRecd
Definition: tftpd.h:102
FILE * openSection(const char *, MYBYTE, char *)
Definition: tftpd.cpp:1581
MYBYTE sockInd
Definition: tftpd.h:92
MYWORD errorcode
Definition: tftpd.h:68
char alias[64]
Definition: tftpd.h:39
MYDWORD tsize
Definition: tftpd.h:99
void closeConn()
Definition: tftpd.cpp:481
socklen_t clientsize
Definition: tftpd.h:106
SOCKET maxFD
Definition: tftpd.h:132
void getInterfaces(data1 *)
Definition: tftpd.cpp:2519
bool isIP(char *s)
Definition: tftpd.cpp:1767
MYWORD block
Definition: tftpd.h:75
message mesout
Definition: tftpd.h:110
SOCKET sock
Definition: tftpd.h:90
void processRequest(LPVOID lpParam)
MYWORD blksize
Definition: tftpd.h:119
acknowledgement acout
Definition: tftpd.h:111
MYDWORD rangeStart
Definition: tftpd.h:81
unsigned ip
Definition: tftpd.h:162
MYWORD opcode
Definition: tftpd.h:55
fd_set readfds
Definition: tftpd.h:88
bool ready
Definition: tftpd.h:133
char * readSection(char *, FILE *)
Definition: tftpd.cpp:1611
void runProg()
Definition: tftpd.cpp:393
tftperror clientError
Definition: tftpd.h:115
bool ready
Definition: tftpd.h:50
MYDWORD rangeEnd
Definition: tftpd.h:82
timeval tv
Definition: tftpd.h:87
char * mode
Definition: tftpd.h:97
Definition: dhcpd.h:135
#define MYBYTE
Definition: tftpd.h:21
Definition: tftpd.h:37
bool getSection(const char *, char *, MYBYTE, char *)
Definition: tftpd.cpp:1533
char * myGetToken(char *, MYBYTE)
Definition: tftpd.cpp:1628
SOCKET knock
Definition: tftpd.h:91
char * myTrim(char *, char *)
Definition: tftpd.cpp:1689
int socklen_t
Definition: tcp.c:35
WSADATA wsaData
Definition: tftpd.h:139
char fileWrite
Definition: tftpd.h:148
sockaddr_in client
Definition: tftpd.h:105
MYDWORD server
Definition: tftpd.h:47
SOCKET sock
Definition: tftpd.h:45
GLdouble s
Definition: gl.h:2039
MYDWORD failureCount
Definition: tftpd.h:152
void init(void *)
Definition: tftpd.cpp:1805
char fileOverwrite
Definition: tftpd.h:149
MYBYTE logLevel
Definition: tftpd.h:153
sockaddr_in addr
Definition: tftpd.h:46
MYWORD block
Definition: tftpd.h:56
MYWORD opcode
Definition: tftpd.h:61
tftperror serverError
Definition: tftpd.h:109
__kernel_time_t time_t
Definition: linux.h:252
#define MAX_SERVERS
Definition: tftpd.h:34
void logMess(request *, MYBYTE)
Definition: tftpd.cpp:2622
Definition: services.c:325
MYWORD port
Definition: tftpd.h:48
MYWORD opcode
Definition: tftpd.h:67
Definition: tftpd.h:85
acknowledgement acin
Definition: tftpd.h:117
FILE * file
Definition: tftpd.h:95
Definition: tftpd.h:157
char fileRead
Definition: tftpd.h:147
UINT_PTR SOCKET
Definition: winsock.h:47
MYDWORD fblock
Definition: tftpd.h:100
char buffer
Definition: tftpd.h:76
bool cleanReq(request *)
Definition: tftpd.cpp:1505
char * alias
Definition: tftpd.h:98
#define MYDWORD
Definition: tftpd.h:23
int minport
Definition: tftpd.h:150
bool addServer(MYDWORD *, MYDWORD)
Definition: tftpd.cpp:2557
bool detectChange()
Definition: tftpd.cpp:2428
message mesin
Definition: tftpd.h:116
int bytesReady
Definition: tftpd.h:101
Definition: tftpd.h:137