1 | /** |
---|
2 | * @file ConnectionController.h |
---|
3 | * This header file defines the TcpipServer class. |
---|
4 | * @author Tomas Urban |
---|
5 | * @version 0.2 |
---|
6 | * @date 23/07/2009 |
---|
7 | */ |
---|
8 | #ifndef CONNECTION_CONTROLLER_H |
---|
9 | #define CONNECTION_CONTROLLER_H |
---|
10 | |
---|
11 | #include "TcpipDefs.h" |
---|
12 | #include "GenericCapture.h" |
---|
13 | #include "Messages/TrafficCaptureMessage.h" |
---|
14 | #include "TcpipDispatch.h" |
---|
15 | #include <boost/thread/mutex.hpp> |
---|
16 | #include <boost/thread/condition.hpp> |
---|
17 | |
---|
18 | /** |
---|
19 | * ConnectionController is class which handles a single client TCP/IP connection. It reads requests from |
---|
20 | * the client, decodes and processes them and replies to them if needed. |
---|
21 | */ |
---|
22 | class ConnectionController |
---|
23 | { |
---|
24 | private: |
---|
25 | SOCKET_TYPE m_hSocket; |
---|
26 | GenericCapture * m_pCapture; |
---|
27 | boost::mutex m_mutex; |
---|
28 | boost::condition m_captureClosed; |
---|
29 | void SendSimpleReply(CommonReplyMessage & reply, bool bRes); |
---|
30 | void ProcessMessage(const struct TMessageHeader & header, const char * pPayload, TcpipDispatch & td); |
---|
31 | public: |
---|
32 | /** |
---|
33 | * Class constructor. |
---|
34 | * @param hSocket Handle to client's socket |
---|
35 | */ |
---|
36 | ConnectionController(SOCKET_TYPE hSocket); |
---|
37 | ~ConnectionController(void); |
---|
38 | /** |
---|
39 | * The method starts waiting for client's requests and processing them. It is a blocking method |
---|
40 | * and it returns only if the connection is interrupted or on client's request to terminate the whole |
---|
41 | * session. |
---|
42 | */ |
---|
43 | void Run(); |
---|
44 | /** |
---|
45 | * The method is used for stopping a running connection controller. |
---|
46 | */ |
---|
47 | void Stop(); |
---|
48 | }; |
---|
49 | |
---|
50 | #endif |
---|