ThingWorx C SDK
twTunnelManager.h
Go to the documentation of this file.
1 /***************************************
2  * Copyright 2017, PTC, Inc.
3  ***************************************/
4 
13 #ifndef TUNNELMANAGER_H /* Prevent multiple inclusions. */
14 #define TUNNELMANAGER_H
15 
16 #include "twOSPort.h"
17 #include "twDefinitions.h"
18 #include "twDefaultSettings.h"
19 #include "twList.h"
20 #include "twInfoTable.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
57 typedef void (*tunnel_cb) (char started, const char * tid, const char * thingName, const char * peerName,
58  const char * host, int16_t port, DATETIME startTime, DATETIME endTime,
59  uint64_t bytesSent, uint64_t bytesRcvd, const char * type, const char * msg, void * userdata);
60 
62 
66 typedef struct twActiveTunnel {
67  char * thingName;
68  char * tid;
69  char * peerName;
70  char * host;
71  uint16_t port;
72  DATETIME startTime;
73  DATETIME endTime;
74  char * type;
76 
87 
96 
107 void twTunnelManager_TaskerFunction(DATETIME now, void * params);
108 
119 void twTunnelManager_ThreadFunction(DATETIME now, void * params);
120 
128 
140 int twTunnelManager_UpdateTunnelServerInfo(char * host, uint16_t port, char * appkey);
141 
154 int twTunnelManager_RegisterTunnelCallback(tunnel_cb cb, char * id, void * userdata);
155 
169 int twTunnelManager_UnregisterTunnelCallback(tunnel_cb cb, char * id, void * userdata);
170 
180 twActiveTunnelList * twTunnelManager_ListActiveTunnels();
181 
195 void twTunnelManager_SetProxyInfo(char * proxyHost, uint16_t proxyPort, char * proxyUser, twPasswdCallbackFunction proxyPassCallback);
196 
214 
235 
254 
275 void twTunnelManager_SetX509Fields(char * subject_cn, char * subject_o, char * subject_ou,
276  char * issuer_cn, char * issuer_o, char * issuer_ou);
277 
300 void twTunnelManager_LoadCACert(const char *file, int type);
301 
323 
345 void twTunnelManager_SetClientKey(const char *file, twPasswdCallbackFunction passphraseCallback, int type);
346 
347 
348 /* Tunnel callback for handling all tunneling services. */
349 enum msgCodeEnum tunnelServiceCallback(const char * entityName, const char * serviceName, twInfoTable * params, twInfoTable ** content) ;
350 
351 #ifdef __cplusplus
352 }
353 #endif
354 
355 #endif
twActiveTunnelList * twTunnelManager_ListActiveTunnels()
Return a list of the currently active tunnels.
Definition: twTunnelManager.c:1507
DATETIME startTime
Definition: twTunnelManager.h:72
void twTunnelManager_ThreadFunction(DATETIME now, void *params)
Executes all functions required for proper operation of tunnels. optimized for threads to provide saf...
Definition: twTunnelManager.c:1207
void twTunnelManager_LoadClientCert(char *file)
Loads the local PEM or DER formatted certificate file used to validate the client to the server...
Definition: twTunnelManager.c:1643
ThingWorx twInfoTable and twDataShape definitions and functions.
void twTunnelManager_SetClientKey(const char *file, twPasswdCallbackFunction passphraseCallback, int type)
Sets the key of the client.
Definition: twTunnelManager.c:1652
char * host
Definition: twTunnelManager.h:70
int twTunnelManager_UpdateTunnelServerInfo(char *host, uint16_t port, char *appkey)
Updates the host, port, and appkey of the tunnels related to connecting to the server.
Definition: twTunnelManager.c:1378
char * tid
Definition: twTunnelManager.h:68
Wrappers for OS-specific functionality.
Linked list structure definition.
Definition: twList.h:59
void twTunnelManager_DisableEncryption(char state)
Passthru to notify the TLS library to disable encryption.
Definition: twTunnelManager.c:1564
Active tunnel structure definition.
Definition: twTunnelManager.h:66
char * peerName
Definition: twTunnelManager.h:69
void twTunnelManager_SetSelfSignedOk(char state)
Passthru to notify the TLS library to accept self-signed certificates.
Definition: twTunnelManager.c:1554
int twTunnelManager_Delete()
Frees all memory associated with the twTunnelManager singleton and all its owned substructures.
Definition: twTunnelManager.c:969
void twTunnelManager_LoadCACert(const char *file, int type)
Loads the local PEM or DER formatted certificate file used to validate the server.
Definition: twTunnelManager.c:1634
void twTunnelManager_SetProxyInfo(char *proxyHost, uint16_t proxyPort, char *proxyUser, twPasswdCallbackFunction proxyPassCallback)
Sets the proxy information to be used when making a connection.
Definition: twTunnelManager.c:1538
DATETIME endTime
Definition: twTunnelManager.h:73
struct twActiveTunnel twActiveTunnel
Active tunnel structure definition.
msgCodeEnum
Enumeration of HTTP message codes.
Definition: twDefinitions.h:74
int twTunnelManager_Create()
Creates the twTunnelManager singleton.
Definition: twTunnelManager.c:935
Default settings for ThingWorx C SDK.
Common definitions for C SDK.
int twTunnelManager_UnregisterTunnelCallback(tunnel_cb cb, char *id, void *userdata)
Unregisters a tunnel callback function that was registered via twTunnelManager_RegisterTunnelCallback...
Definition: twTunnelManager.c:1424
void twTunnelManager_DisableCertValidation(char state)
Passthru to notify the TLS library to not validate the server certificate.
Definition: twTunnelManager.c:1559
int twTunnelManager_StopAllTunnels()
Shuts down all tunnels.
Definition: twTunnelManager.c:1364
Definition: blast.c:41
char * type
Definition: twTunnelManager.h:74
void twTunnelManager_SetX509Fields(char *subject_cn, char *subject_o, char *subject_ou, char *issuer_cn, char *issuer_o, char *issuer_ou)
Defines which fields of an X509 certificate will be validated. NULL parameteres will not be checked a...
Definition: twTunnelManager.c:1569
char * thingName
Definition: twTunnelManager.h:67
uint16_t port
Definition: twTunnelManager.h:71
Info table base structure.
Definition: twInfoTable.h:418
int twTunnelManager_RegisterTunnelCallback(tunnel_cb cb, char *id, void *userdata)
Registers a function to be called when a tunnel state changes.
Definition: twTunnelManager.c:1401
void twTunnelManager_TaskerFunction(DATETIME now, void *params)
Executes all functions required for proper operation of tunnels. optimized for the tasker to provide ...
Definition: twTunnelManager.c:1180
void(* tunnel_cb)(char started, const char *tid, const char *thingName, const char *peerName, const char *host, int16_t port, DATETIME startTime, DATETIME endTime, uint64_t bytesSent, uint64_t bytesRcvd, const char *type, const char *msg, void *userdata)
Signature of a callback function that is registered to be called when a tunnel state changes...
Definition: twTunnelManager.h:57
Definition: gzappend.c:170