tcp_layer.hh
Go to the documentation of this file.
#pragma once
#include "t_layer.hh"
#include "Abstract_Socket.hh"
class PORT;
class tcp_layer : public SSL_Socket, public layer, public PORT {
Params _params;
int _client_id;
std::string _time_key;
bool _reconnect_on_send;
public:
tcp_layer(const std::string& p_type, const std::string& p_param);
virtual ~tcp_layer();
virtual void send_data(OCTETSTRING& data, Params& params);
virtual void receive_data(OCTETSTRING& data, Params& info);
virtual void message_incoming(const unsigned char* p_buffer, int p_length, int p_client_id = -1);
protected:
void Add_Fd_Read_Handler(int fd) { Handler_Add_Fd_Read(fd); };
void Add_Fd_Write_Handler(int fd) { Handler_Add_Fd_Write(fd); };
void Remove_Fd_Read_Handler(int fd) { Handler_Remove_Fd_Read(fd); };
void Remove_Fd_Write_Handler(int fd) { Handler_Remove_Fd_Write(fd); };
void Remove_Fd_All_Handlers(int fd) { Handler_Remove_Fd(fd); };
void Handler_Uninstall() { Uninstall_Handler(); }
void Timer_Set_Handler(double call_interval, boolean is_timeout = TRUE,
boolean call_anyway = TRUE, boolean is_periodic = TRUE) {
Handler_Set_Timer(call_interval, is_timeout, call_anyway, is_periodic);
};
const char* remote_address_name() { return Params::server.c_str(); };
const char* remote_port_name() { return Params::port.c_str(); };
const char* socket_debugging_name() { return Params::debug.c_str(); };
const char* ssl_use_ssl_name() { return Params::use_ssl.c_str(); };
void client_connection_opened(int p_client_id);
bool add_user_data(int p_client_id);
int send_message_on_fd(int p_client_id, const unsigned char * message_buffer, int length_of_message);
int send_message_on_nonblocking_fd(int client_id, const unsigned char * message_buffer, int length_of_message);
int receive_message_on_fd(int p_client_id);
void peer_disconnected(int p_client_id);
private:
void Handle_Fd_Event(int fd, boolean is_readable, boolean is_writable, boolean is_error);
void Handle_Timeout(double time_since_last_call);
}; // End of class tcp_layer
tcp_layer::message_incoming
virtual void message_incoming(const unsigned char *p_buffer, int p_length, int p_client_id=-1)
Receive bytes formated data from the lower layers.
Definition: tcp_layer.cc:99
tcp_layer::send_message_on_fd
int send_message_on_fd(int p_client_id, const unsigned char *message_buffer, int length_of_message)
Definition: tcp_layer.cc:129
tcp_layer
Forward declaration of TITAN class.
Definition: tcp_layer.hh:23
tcp_layer::remote_port_name
const char * remote_port_name()
Definition: tcp_layer.hh:84
tcp_layer::send_data
virtual void send_data(OCTETSTRING &data, Params &params)
Send bytes formated data to the lower layers.
Definition: tcp_layer.cc:85
tcp_layer::Add_Fd_Read_Handler
void Add_Fd_Read_Handler(int fd)
Definition: tcp_layer.hh:72
tcp_layer::Handle_Timeout
void Handle_Timeout(double time_since_last_call)
Definition: tcp_layer.cc:78
tcp_layer::peer_disconnected
void peer_disconnected(int p_client_id)
Definition: tcp_layer.cc:171
tcp_layer::Remove_Fd_Read_Handler
void Remove_Fd_Read_Handler(int fd)
Definition: tcp_layer.hh:74
layer
Forward declaration of TITAN class.
Definition: layer.hh:29
tcp_layer::client_connection_opened
void client_connection_opened(int p_client_id)
Definition: tcp_layer.cc:112
tcp_layer::Remove_Fd_All_Handlers
void Remove_Fd_All_Handlers(int fd)
Definition: tcp_layer.hh:76
tcp_layer::_reconnect_on_send
bool _reconnect_on_send
Definition: tcp_layer.hh:27
tcp_layer::tcp_layer
tcp_layer(const std::string &p_type, const std::string &p_param)
Set to true if connection shall be done when sending data. Otherwise, connection is established by th...
Definition: tcp_layer.cc:14
tcp_layer::_params
Params _params
Definition: tcp_layer.hh:24
Params::use_ssl
static const std::string & use_ssl
Commsignia HTTP server port. Default: 80.
Definition: Params.hh:78
tcp_layer::ssl_use_ssl_name
const char * ssl_use_ssl_name()
Definition: tcp_layer.hh:86
Params::server
static const std::string & server
Commsignia antenna selector.
Definition: Params.hh:76
tcp_layer::socket_debugging_name
const char * socket_debugging_name()
Definition: tcp_layer.hh:85
tcp_layer::~tcp_layer
virtual ~tcp_layer()
Default destructor.
Definition: tcp_layer.cc:62
tcp_layer::_time_key
std::string _time_key
Connection identifier.
Definition: tcp_layer.hh:26
tcp_layer::Timer_Set_Handler
void Timer_Set_Handler(double call_interval, boolean is_timeout=TRUE, boolean call_anyway=TRUE, boolean is_periodic=TRUE)
Definition: tcp_layer.hh:78
Params
This class provides basic functionalities for an ITS dictionary.
Definition: Params.hh:21
Params::debug
static const std::string & debug
Definition: Params.hh:24
tcp_layer::receive_message_on_fd
int receive_message_on_fd(int p_client_id)
Definition: tcp_layer.cc:157
tcp_layer::add_user_data
bool add_user_data(int p_client_id)
Definition: tcp_layer.cc:118
tcp_layer::send_message_on_nonblocking_fd
int send_message_on_nonblocking_fd(int client_id, const unsigned char *message_buffer, int length_of_message)
Definition: tcp_layer.cc:143
tcp_layer::Remove_Fd_Write_Handler
void Remove_Fd_Write_Handler(int fd)
Definition: tcp_layer.hh:75
tcp_layer::receive_data
virtual void receive_data(OCTETSTRING &data, Params &info)
Receive bytes formated data from the lower layers.
Definition: tcp_layer.cc:93
Params::port
static const std::string & port
HTTP server address (e.g. www.etsi.org)
Definition: Params.hh:77
tcp_layer::_client_id
int _client_id
Layer parameters.
Definition: tcp_layer.hh:25
tcp_layer::Handler_Uninstall
void Handler_Uninstall()
Definition: tcp_layer.hh:77
tcp_layer::Handle_Fd_Event
void Handle_Fd_Event(int fd, boolean is_readable, boolean is_writable, boolean is_error)
Definition: tcp_layer.cc:71
Abstract_Socket.hh
tcp_layer::Add_Fd_Write_Handler
void Add_Fd_Write_Handler(int fd)
Definition: tcp_layer.hh:73
tcp_layer::remote_address_name
const char * remote_address_name()
Definition: tcp_layer.hh:83
t_layer.hh
Header file for ITS abstract protocol layer definition.