ThingWorx C SDK
twTunnelManager.h
Go to the documentation of this file.
1 /***************************************
2  * Copyright (C) 2015 ThingWorx 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 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
56 typedef void (*tunnel_cb) (char started, const char * tid, const char * thingName, const char * peerName,
57  const char * host, int16_t port, DATETIME startTime, DATETIME endTime,
58  uint64_t bytesSent, uint64_t bytesRcvd, const char * type, const char * msg, void * userdata);
59 
61 
65 typedef struct twActiveTunnel {
66  char * thingName;
67  char * tid;
68  char * peerName;
69  char * host;
70  uint16_t port;
71  DATETIME startTime;
72  DATETIME endTime;
73  char * type;
75 
86 
95 
105 void twTunnelManager_TaskerFunction(DATETIME now, void * params);
106 
116 int twTunnelManager_StopTunnel(char * id, char * msg) ;
117 
125 
137 int twTunnelManager_UpdateTunnelServerInfo(char * host, uint16_t port, char * appkey);
138 
151 int twTunnelManager_RegisterTunnelCallback(tunnel_cb cb, char * id, void * userdata);
152 
166 int twTunnelManager_UnregisterTunnelCallback(tunnel_cb cb, char * id, void * userdata);
167 
177 twActiveTunnelList * twTunnelManager_ListActiveTunnels();
178 
192 void twTunnelManager_SetProxyInfo(char * proxyHost, uint16_t proxyPort, char * proxyUser, char * proxyPass);
193 
200 void twTunnelManager_SetSelfSignedOk(char state);
201 
208 void twTunnelManager_EnableFipsMode(char state);
209 
220 
228 void twTunnelManager_DisableEncryption(char state);
229 
250 void twTunnelManager_SetX509Fields(char * subject_cn, char * subject_o, char * subject_ou,
251  char * issuer_cn, char * issuer_o, char * issuer_ou);
252 
265 void twTunnelManager_LoadCACert(const char *file, int type);
266 
277 void twTunnelManager_LoadClientCert(char *file);
278 
290 void twTunnelManager_SetClientKey(const char *file, char * passphrase, int type);
291 
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif
twActiveTunnelList * twTunnelManager_ListActiveTunnels()
Return a list of the currently active tunnels.
Definition: twTunnelManager.c:1166
DATETIME startTime
Definition: twTunnelManager.h:71
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:1280
char * host
Definition: twTunnelManager.h:69
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:1047
char * tid
Definition: twTunnelManager.h:67
Wrappers for OS-specific functionality.
Linked list structure definition.
Definition: twList.h:46
void twTunnelManager_DisableEncryption(char state)
Passthru to notify the TLS library to disable encryption.
Definition: twTunnelManager.c:1231
Active tunnel structure definition.
Definition: twTunnelManager.h:65
char * peerName
Definition: twTunnelManager.h:68
void twTunnelManager_SetSelfSignedOk(char state)
Passthru to notify the TLS library to accept self-signed certificates.
Definition: twTunnelManager.c:1216
int twTunnelManager_Delete()
Frees all memory associated with the tunnel manager singleton and all its owned substructures.
Definition: twTunnelManager.c:816
int twTunnelManager_StopTunnel(char *id, char *msg)
Shuts down a tunnel.
Definition: twTunnelManager.c:999
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:1271
DATETIME endTime
Definition: twTunnelManager.h:72
struct twActiveTunnel twActiveTunnel
Active tunnel structure definition.
int twTunnelManager_Create()
Creates the tunnel manager singleton.
Definition: twTunnelManager.c:785
void twTunnelManager_SetProxyInfo(char *proxyHost, uint16_t proxyPort, char *proxyUser, char *proxyPass)
Sets the proxy information to be used when making a connection.
Definition: twTunnelManager.c:1196
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:1092
void twTunnelManager_DisableCertValidation(char state)
Passthru to notify the TLS library to not validate the server certificate.
Definition: twTunnelManager.c:1226
int twTunnelManager_StopAllTunnels()
Shuts down all tunnels.
Definition: twTunnelManager.c:1034
char * type
Definition: twTunnelManager.h:73
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:1236
char * thingName
Definition: twTunnelManager.h:66
uint16_t port
Definition: twTunnelManager.h:70
int twTunnelManager_RegisterTunnelCallback(tunnel_cb cb, char *id, void *userdata)
Registers a function to be called when a tunnel state changes.
Definition: twTunnelManager.c:1071
void twTunnelManager_SetClientKey(const char *file, char *passphrase, int type)
Sets the key of the client.
Definition: twTunnelManager.c:1289
void twTunnelManager_TaskerFunction(DATETIME now, void *params)
Executes all functions required for proper operation of tunnels.
Definition: twTunnelManager.c:820
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:56
void twTunnelManager_EnableFipsMode(char state)
Passthru to enable FIPS mode for TLS providers that support to.
Definition: twTunnelManager.c:1221