RDK Documentation (Open Sourced RDK Components)
Wsproxy

Description

Data Structures

class  AutoLock_
 
class  WebSocketProxy
 
class  PingPongTask
 

Macros

#define AutoLock()   AutoLock_ a()
 
#define DYNAMIC_PASSCODE_UTILITY   "/usr/bin/rdkssacli"
 
#define STATIC_PASSCODE_UTILITY   "/usr/bin/GetConfigFile"
 
#define DYNAMIC_PASSCODE_ARG   "\"{STOR=GET,SRC=kquhqtoczcbx,DST=/dev/stdout}\""
 
#define STATIC_PASSCODE_ARG_FILE   "/tmp/.cfgStaticxpki"
 
#define TRM_USE_RFC   1
 
#define _TRMPRX_OUT_   stdout
 
#define __TIMESTAMP()
 

Typedefs

typedef std::map< void *, int > connection_ct_t
 

Enumerations

enum  MessageType
 
enum  TRM_RFC_PARAM_TYPE
 

Functions

static int get_connection_id (void)
 
static int conn_to_id (void *conn)
 
static void * id_to_conn (int connection_id)
 
static void add_connection (void *conn)
 
static void remove_connection (void *conn)
 
static void remove_all_connections (void)
 
static int connect_to_trm (const char *ip, int port, int *trm_fd)
 
int begin_request_callback (void *)
 
void end_request_callback (void *, int)
 
int websocket_connect_callback (void *)
 
int websocket_disconnect_callback (void *conn)
 
void websocket_ready_callback (void *conn)
 
int log_message_callback (void *, const char *message)
 
int websocket_data_callback_with_clientId (int connection_id, int flags, char *trm_data, size_t trm_data_length)
 
int websocket_data_callback (void *conn, int flags, char *trm_data, size_t trm_data_length)
 
static void * TRM_response_listener (void *)
 
static QString getIPFromInterface (QString interfaceName, bool isLoopback)
 
int main (int argc, char *argv[])
 
int log_message_callback (const void *conn, const char *message)
 
static void onWebsocketMessageReceivedSSL (int clientId, char *message, size_t len)
 
static void onPongSSL (int clientId, long long unsigned int ticks, QByteArray &qmsg)
 
static int exec_sys_command (char *cmd)
 
static bool rfc_get_trmssl_status ()
 
static bool is_TRM_RFC_param_enable (TRM_RFC_PARAM_TYPE type)
 
static void delete_file (QString &fileName)
 
static void executeCommand (std::string command, std::string &output)
 
static bool selectPk12KeyAndPass (std::string dynKeyFilePath, std::string staticKeyFilePath, std::string &outputKeyFilePath, std::string &pass)
 
int mg_websocket_write_ssl (int clientId, char *data, int data_len)
 
int mg_websocket_write (void *conn, const char *data, size_t data_len)
 
int mg_websocket_close_all_ssl ()
 
int mg_websocket_close (void *conn)
 
 PingPongTask::PingPongTask (QWebSocket *wssocket)
 
 PingPongTask::PingPongTask (tcpOpensslProxyServer *sslProxyServer, int clientId)
 
void PingPongTask::start (void)
 
void PingPongTask::stop (void)
 
 WebSocketProxy::WebSocketProxy (const QStringList &boundIPs, quint16 port, QObject *parent=Q_NULLPTR)
 
int WebSocketProxy::onWebsocketHasDataToWriteSSL (int clientId, char *data, int len)
 
void WebSocketProxy::onRemoveAllOpenSslConnections ()
 

Variables

static const int header_length = 16
 
static const char * trm_ip = 0
 
static const char * trm_port = 0
 
static int trm_socket_fd = -1
 
static pthread_mutex_t conn_mutex
 
static connection_ct_t connections
 
const char * localHost ="lo"
 
const char * devicePropertiesPath ="/etc/device.properties"
 
const char * mocaIntTagName = "MOCA_INTERFACE"
 
const char * trmPropertiesPath ="/etc/trmProxySetup.properties"
 
const char * caKeyTagName = "CA_CHAIN_CERTIFICATE"
 
const char * privateKeyTagName = "CA_SERVER_PRIVATE_KEY"
 
const char * publicKeyTagName = "CA_SERVER_PUBLIC_CERTIFICATE"
 
const char * xpkiDynamicCertificate = "CA_SERVER_XPKI_DYNAMIC_CERTIFICATE"
 
const char * xpkiStaticCertificate = "CA_SERVER_XPKI_STATIC_CERTIFICATE"
 
static WebSocketProxym_proxy = NULL
 

Public Slots

void PingPongTask::onTimeout (void)
 
void PingPongTask::onPong (quint64 elapsedTime, QByteArray)
 

Private Slots

void WebSocketProxy::onNewConnectionSSl (int clientId, tcpOpensslProxyServer *ss)
 
void WebSocketProxy::onNewConnection (void)
 
void WebSocketProxy::onWebsocketConnect (void)
 
void WebSocketProxy::onWebsocketBinaryMessageReceived (QByteArray byteArray)
 
void WebSocketProxy::onWebsocketTextMessageReceived (QString)
 
void WebSocketProxy::onWebsocketBytesWritten (qint64)
 
void WebSocketProxy::onWebsocketDisconnected (void)
 
void WebSocketProxy::onWebsocketStateChanged (QAbstractSocket::SocketState)
 
void WebSocketProxy::onWebSocketAboutClose (void)
 
void WebSocketProxy::onWebsocketError (QAbstractSocket::SocketError)
 
void WebSocketProxy::onWebsocketHasDataToWrite (void *, void *)
 
void WebSocketProxy::onRemoveConnection (void *)
 

Data Structure Documentation

◆ AutoLock_

class AutoLock_

Definition at line 77 of file main.cpp.

Collaboration diagram for AutoLock_:
Collaboration graph

◆ WebSocketProxy

class WebSocketProxy

Definition at line 56 of file qt_websocketproxy.h.

Inheritance diagram for WebSocketProxy:
Inheritance graph
Collaboration diagram for WebSocketProxy:
Collaboration graph

Public Member Functions

 WebSocketProxy (const QStringList &boundIPs, quint16 port, QObject *parent=Q_NULLPTR)
 
int onWebsocketHasDataToWriteSSL (int clientId, char *data, int len)
 
void onRemoveAllOpenSslConnections ()
 

Data Fields

std::unordered_map< int, PingPongTask * > sslProxyPingPongTasks
 

Private Slots

void onNewConnection (void)
 
void onWebsocketConnect (void)
 
void onWebsocketBinaryMessageReceived (QByteArray byteArray)
 
void onWebsocketTextMessageReceived (QString)
 
void onWebsocketBytesWritten (qint64)
 
void onWebsocketDisconnected (void)
 
void onWebsocketStateChanged (QAbstractSocket::SocketState)
 
void onWebSocketAboutClose (void)
 
void onWebsocketError (QAbstractSocket::SocketError)
 
void onWebsocketHasDataToWrite (void *, void *)
 
void onRemoveConnection (void *)
 
void onNewConnectionSSl (int clientId, tcpOpensslProxyServer *ss)
 
void onWebsocketConnectSSL (int clientId, QString msg)
 
void onSslErrorsSSL (QString err)
 
void onAcceptErrorSSL (QString err)
 
void onPeerVerifyErrorSSL (QString err)
 
void onWebsocketDisconnectedSSL (int clientId)
 
void onWebsocketErrorSSL (QString err)
 

Private Attributes

QMap< QString, QWebSocketServer * > proxyServers
 
QMap< QString, tcpOpensslProxyServer * > sslProxyServers
 
std::unordered_map< int, tcpOpensslProxyServer * > sslProxyMap
 
QList< QWebSocket * > connections
 
QMap< QWebSocket *, PingPongTask * > pingPongTasks
 

◆ PingPongTask

class PingPongTask

Definition at line 103 of file qt_websocketproxy.h.

Inheritance diagram for PingPongTask:
Inheritance graph
Collaboration diagram for PingPongTask:
Collaboration graph

Public Slots

void onTimeout (void)
 
void onPong (quint64 elapsedTime, QByteArray)
 

Public Member Functions

 PingPongTask (QWebSocket *wssocket)
 
 PingPongTask (tcpOpensslProxyServer *sslProxyServer, int clientId)
 
void start (void)
 
void stop (void)
 

Private Attributes

QWebSocket * wssocket
 
QTimer timer
 
int retry
 
bool stopped
 
int m_clientId
 
tcpOpensslProxyServerm_sslProxyServer
 

Macro Definition Documentation

◆ __TIMESTAMP

#define __TIMESTAMP ( )
Value:
do { /*YYMMDD-HH:MM:SS:usec*/ \
struct tm __tm; \
struct timeval __tv; \
gettimeofday(&__tv, NULL); \
localtime_r(&__tv.tv_sec, &__tm); \
fprintf(_TRMPRX_OUT_, "\r\n[tid=%ld]: %02d%02d%02d-%02d:%02d:%02d:%06d ", \
syscall(SYS_gettid), \
__tm.tm_year+1900-2000, \
__tm.tm_mon+1, \
__tm.tm_mday, \
__tm.tm_hour, \
__tm.tm_min, \
__tm.tm_sec, \
(int)__tv.tv_usec); \
} while(0)

Definition at line 127 of file qt_websocketproxy.h.