00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _USER_AGENT_H
00021 #define _USER_AGENT_H
00022
00023 #include <string>
00024 #include <pthread.h>
00025 #include "shared_ptr.h"
00026 #include "hsms_cnx.h"
00027 #include "async_reception.h"
00028 #include "hsmsd_interface.h"
00029
00030 namespace freesecs
00031 {
00035 class ua_req_handler_t
00036 {
00037 public:
00038 ua_req_handler_t();
00039 virtual ~ua_req_handler_t(){};
00040 void process_ctl(hsmsd_client_req_t&, size_t);
00041 void process_data(hsmsd_client_req_t&, size_t);
00042
00043 protected:
00044 virtual void rcv_from_ctl(void *buf, size_t count) = 0;
00045 virtual void rcv_from_data(void *buf, size_t count) = 0;
00046
00047 virtual void send_msg(hsms_cnx_t::pdata_t) = 0;
00048 virtual void start_cnx() = 0;
00049 virtual void stop_cnx() = 0;
00050 virtual void get_cnx_state() = 0;
00051
00052 private:
00053 hsms_cnx_t::pdata_t _pmsg;
00054 int _msg_len;
00055 int _nb_received;
00056 int _data_state;
00057 };
00058
00059
00066 class user_agent_t : public ua_req_handler_t
00067 {
00068 public:
00069 typedef shared_ptr_t<hsms_cnx_t> pcnx_t;
00070
00071 public:
00072 user_agent_t( const char *ctl_in_fifo_name,
00073 const char *ctl_out_fifo_name,
00074 const char *data_in_fifo_name,
00075 const char *data_out_fifo_name,
00076 pcnx_t pcnx);
00077 virtual ~user_agent_t();
00078
00079 public:
00080
00081 int user_ctl_handler(const size_t&);
00082 int user_data_handler(const size_t&);
00083 int user_error_handler(const int&);
00084
00085 int cnx_ctl_handler(const hsms_socket_t::pdata_t&);
00086 int cnx_data_handler(const hsms_socket_t::pdata_t&);
00087 int cnx_state_handler(const hsms_state_et&);
00088
00089 protected:
00090
00091 virtual void rcv_from_ctl(void *buf, size_t count);
00092 virtual void rcv_from_data(void *buf, size_t count);
00093 virtual void send_msg(hsms_cnx_t::pdata_t);
00094 virtual void start_cnx();
00095 virtual void stop_cnx();
00096 virtual void get_cnx_state();
00097
00098 private:
00099 pcnx_t _pcnx;
00100 private:
00101 int _fd_ctl_in;
00102 int _fd_ctl_out;
00103 int _fd_data_in;
00104 int _fd_data_out;
00105 shared_ptr_t<async_reception_t> _ar_ctl;
00106 shared_ptr_t<async_reception_t> _ar_data;
00107
00108 private:
00109 hsmsd_client_req_t _client_ctl_req;
00110 hsmsd_client_req_t _client_data_req;
00111 };
00112 }
00113 #endif