forked from LaloLoop/TFTPApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tftpcommon.h
executable file
·52 lines (40 loc) · 1.38 KB
/
tftpcommon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Clase Abstracta.
Características similares para el cliente y servidor del protocolo TFTP.
*/
#ifndef TFTPCOMMON_H
#define TFTPCOMMON_H
#include <QObject>
#include "socketudp.h"
// Tipos de envío.
#define NETASCII 9
#define OCTET 8
// Errores.
#define FILE_NOT_FOUND 1
#define ACCES_VIOLATION 2
#define NO_MEMORY 3
#define ILLEGAL_TFTP 4
#define UNKNOWN_ID 5
#define FILE_EXISTS 6
#define NO_SUCH_USER 7
typedef int tid_t; // Identificador de transimisión
enum rqCode {RRQ, WRQ};
enum writerMonede{SERVER, CLIENT};
class TFTPCommon : public QObject{
Q_OBJECT
// protected:
// tid_t tid;
public:
TFTPCommon(QObject *parent);
static int sendACK(SocketUDP sock,unsigned short block,SockAddr &addr);
static int sendData(SocketUDP sock,unsigned short block,void* data,size_t data_size,SockAddr &addr);
static int sendError(SocketUDP sock,int errtype,SockAddr &addr);
static int sendWRQ(SocketUDP sock,const char* filename,int mode,SockAddr &addr);
static int sendRRQ(SocketUDP sock,const char* filename,int mode,SockAddr &addr);
// protected:
// void generateTID(); // Genera un TID aleatorio.
public slots:
virtual void atenderCliente(rqCode, QString, qint16,
QString fileName, QString mode) = 0;
virtual void clienteAtendido(rqCode) = 0;
};
#endif // TFTPCOMMON_H