My Project
 All Classes Functions Variables Pages
TFTP.h
1 /*
2  * TFTP.h
3  *
4  * Created on: May 21, 2017
5  * Author: kolban
6  */
7 
8 #ifndef COMPONENTS_CPP_UTILS_TFTP_H_
9 #define COMPONENTS_CPP_UTILS_TFTP_H_
10 #define TFTP_DEFAULT_PORT (69)
11 #include <string>
12 #include <Socket.h>
35 class TFTP {
36 public:
37  TFTP();
38  virtual ~TFTP();
39  void start(uint16_t port = TFTP_DEFAULT_PORT);
40  void setBaseDir(std::string baseDir);
45  public:
47  void processWRQ();
48  void processRRQ();
49  void sendAck(uint16_t blockNumber);
50  void sendError(uint16_t code, std::string message);
51  void setBaseDir(std::string baseDir);
52  void waitForAck(uint16_t blockNumber);
53  uint16_t waitForRequest(Socket* pServerSocket);
54 
55  private:
59  Socket m_partnerSocket;
60  struct sockaddr m_partnerAddress;
61  uint16_t m_opCode; // The last op code received.
62  std::string m_filename; // The name of the file.
63  std::string m_mode;
64  std::string m_baseDir; // The base directory.
65 
66  };
67 
68 private:
69  std::string m_baseDir;
70 
71 };
72 
73 #endif /* COMPONENTS_CPP_UTILS_TFTP_H_ */
void setBaseDir(std::string baseDir)
Set the base dir for file access. If we are asked to put a file to the file system, this is the base relative directory.
Definition: TFTP.cpp:281
void waitForAck(uint16_t blockNumber)
Wait for an acknowledgment from the client. After having sent data to the client, we expect an acknow...
Definition: TFTP.cpp:291
Encapsulate a socket.
Definition: Socket.h:62
void start(uint16_t port=TFTP_DEFAULT_PORT)
Start being a TFTP server.
Definition: TFTP.cpp:228
void sendError(uint16_t code, std::string message)
Send an error indication to the client.
Definition: TFTP.cpp:382
A TFTP server.
Definition: TFTP.h:35
void sendAck(uint16_t blockNumber)
Send an acknowledgment back to the partner. A TFTP acknowledgment packet contains an opcode (4) and a...
Definition: TFTP.cpp:206
void processWRQ()
Process a client write request.
Definition: TFTP.cpp:151
uint16_t waitForRequest(Socket *pServerSocket)
Wait for a client request. A TFTP server waits for requests to send or receive files. A request can be either WRQ (write request) which is a request from the client to write a new local file or it can be a RRQ (read request) which is a request from the client to read a local file.
Definition: TFTP.cpp:337
void setBaseDir(std::string baseDir)
Set the base dir for file access. If we are asked to put a file to the file system, this is the base relative directory.
Definition: TFTP.cpp:270
TFTP_Transaction()
Start a TFTP transaction.
Definition: TFTP.cpp:73
void processRRQ()
Process a client read request.
Definition: TFTP.cpp:86
Internal class for TFTP processing.
Definition: TFTP.h:44