C Porting Layer API Reference for Oracle Internet of Things Cloud Service Client Software Library. Release 21.1.1.0.0-3. E80003-19
iotcs_port_ssl.h File Reference

The file contains porting layer for ssl functionality. More...

#include "iotcs.h"

Go to the source code of this file.

Defines

#define IOTCS_RESULT_SSL_WANT_READ   IOTCS_RESULT_CANNOT_AUTHORIZE

Functions

iotcs_result iotcs_port_ssl_init (const char *addr, unsigned short port)
 Initializes ssl related resources.
void iotcs_port_ssl_finalize (void)
 Finalizes ssl related resources.
iotcs_result iotcs_port_ssl_connect (void)
 Establishes ssl connection with the server.
iotcs_result iotcs_port_ssl_disconnect (void)
 Closes connection with the server.
iotcs_result iotcs_port_ssl_write (char *request, size_t length)
 Sends content to the server host using ssl connection.
iotcs_result iotcs_port_ssl_read (char *buffer, int len, int *bytes_read)
 Reads all bytes from the ssl connection into the buffer Do blocking read of all the bytes from established connection until given buffer is full or the connection is closed by peer.
iotcs_result iotcs_port_ssl_connect_lp (int32_t timeout_ms)
 Establishes ssl connection with the server for long polling.
iotcs_result iotcs_port_ssl_disconnect_lp (void)
 Closes long polling connection with the server.
iotcs_result iotcs_port_ssl_write_lp (char *request, size_t length)
 Sends content to the server host using long polling ssl connection.
iotcs_result iotcs_port_ssl_read_lp (char *buffer, int len, int *bytes_read)
 Reads all bytes from the long polling ssl connection into the buffer Do blocking read of all the bytes from established connection until given buffer is full or the connection is closed by peer or the receive timeout (given in iotcs_port_ssl_connect_lp call) has expired.
iotcs_result iotcs_port_storage_ssl_init (const char *addr, unsigned short port, iotcs_bool is_ssl)
 Initializes ssl related resources.
void iotcs_port_storage_ssl_finalize (void)
 Finalizes ssl related resources.
iotcs_result iotcs_port_storage_ssl_connect (void)
 Establishes ssl connection with the storage cloud server.
iotcs_result iotcs_port_storage_ssl_disconnect (void)
 Closes the connection with the storage cloud server.
iotcs_result iotcs_port_storage_ssl_read (char *buffer, int len, int *bytes_read)
 Reads all bytes from the storage cloud server ssl connection into the buffer Do blocking read of all the bytes from established connection until given buffer is full or the connection is closed by peer.
iotcs_result iotcs_port_storage_ssl_write (char *request, size_t length)
 Sends content to the storage cloud server.

Detailed Description

The file contains porting layer for ssl functionality.

Methods for SSL/TLS protocol Library always calls iotcs_port_ssl_init before start using port SSL API and iotcs_port_ssl_finalize when has stopped using port SSL API.

Port SSL API always shall support at least one SSL connection. Library works with this connection by calling blocking methods iotcs_port_ssl_connect, iotcs_port_ssl_write, iotcs_port_ssl_read, iotcs_port_ssl_disconnect. This is the order in which library calls those methods. The whole connect/write/read/disconnect sequence is invoked from one thread and always exclusively. It means that implementation does not require thread safety.

Library could be built with long polling support by defining IOTCS_LONG_POLLING. Without long polling support library use just one SSL connection at a time. Long polling support adds another connection. Methods that work with this long polling connection have _lp suffix, e.g. iotcs_port_ssl_connect_lp. The whole connect/write/read/disconnect sequence for long polling connection is invoked from one thread and always exclusively. But usual connection and long polling connection could be used by library at same time from different threads.


Function Documentation

iotcs_result iotcs_port_ssl_connect ( void  )

Establishes ssl connection with the server.

Note:
Mandatory API. Called by the Library in any configuration.
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
iotcs_result iotcs_port_ssl_connect_lp ( int32_t  timeout_ms)

Establishes ssl connection with the server for long polling.

Note:
Optional API. Called by the Library if IOTCS_LONG_POLLING option is defined.
Parameters:
timeouta receive timeout in milliseconds
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
iotcs_result iotcs_port_ssl_disconnect ( void  )

Closes connection with the server.

Note:
Mandatory API. Called by the Library in any configuration.
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
iotcs_result iotcs_port_ssl_disconnect_lp ( void  )

Closes long polling connection with the server.

Note:
Optional API. Called by the Library if IOTCS_LONG_POLLING option is defined.
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
void iotcs_port_ssl_finalize ( void  )

Finalizes ssl related resources.

Note:
Mandatory API. Called by the Library in any configuration.
iotcs_result iotcs_port_ssl_init ( const char *  addr,
unsigned short  port 
)

Initializes ssl related resources.

Note:
Mandatory API. Called by the Library in any configuration.
Parameters:
addrserver address
portserver port
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
iotcs_result iotcs_port_ssl_read ( char *  buffer,
int  len,
int *  bytes_read 
)

Reads all bytes from the ssl connection into the buffer Do blocking read of all the bytes from established connection until given buffer is full or the connection is closed by peer.

Note:
Mandatory API. Called by the Library in any configuration.
Parameters:
buffera buffer address
lena buffer size in bytes
bytes_readread bytes
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned.
iotcs_result iotcs_port_ssl_read_lp ( char *  buffer,
int  len,
int *  bytes_read 
)

Reads all bytes from the long polling ssl connection into the buffer Do blocking read of all the bytes from established connection until given buffer is full or the connection is closed by peer or the receive timeout (given in iotcs_port_ssl_connect_lp call) has expired.

Note:
Optional API. Called by the Library if IOTCS_LONG_POLLING option is defined.
Parameters:
buffera buffer address
lena buffer size in bytes
bytes_readread bytes
Returns:
IOTCS_RESULT_OK if socket closed by peer or buffer is full. IOTCS_RESULT_SSL_WANT_READ if timeout has expired. IOTCS_RESULT_FAIL in case of error.
iotcs_result iotcs_port_ssl_write ( char *  request,
size_t  length 
)

Sends content to the server host using ssl connection.

Note:
Mandatory API. Called by the Library in any configuration.
Parameters:
requesta buffer address
lengtha buffer size in bytes
Returns:
IOTCS_RESULT_OK when the complete contents of request with current length has been written.
iotcs_result iotcs_port_ssl_write_lp ( char *  request,
size_t  length 
)

Sends content to the server host using long polling ssl connection.

Note:
Optional API. Called by the Library if IOTCS_LONG_POLLING option is defined.
Parameters:
requesta buffer address
lengtha buffer size in bytes
Returns:
IOTCS_RESULT_OK when the complete contents of request with current length has been written.
iotcs_result iotcs_port_storage_ssl_connect ( void  )

Establishes ssl connection with the storage cloud server.

Note:
Optional API. Called by the Library when STORAGE_SUPPORT enabled.
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
iotcs_result iotcs_port_storage_ssl_disconnect ( void  )

Closes the connection with the storage cloud server.

Note:
Optional API. Called by the Library when STORAGE_SUPPORT enabled.
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
void iotcs_port_storage_ssl_finalize ( void  )

Finalizes ssl related resources.

Note:
Optional API. Called by the Library when STORAGE_SUPPORT enabled.
iotcs_result iotcs_port_storage_ssl_init ( const char *  addr,
unsigned short  port,
iotcs_bool  is_ssl 
)

Initializes ssl related resources.

Note:
Optional API. Called by the Library when STORAGE_SUPPORT enabled.
Parameters:
addrscs server address
portscs server port
is_sslshows which type of server is using (https or http)
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned
iotcs_result iotcs_port_storage_ssl_read ( char *  buffer,
int  len,
int *  bytes_read 
)

Reads all bytes from the storage cloud server ssl connection into the buffer Do blocking read of all the bytes from established connection until given buffer is full or the connection is closed by peer.

Note:
Optional API. Called by the Library when STORAGE_SUPPORT enabled.
Parameters:
buffera buffer address
lena buffer size in bytes
bytes_readread bytes
Returns:
IOTCS_RESULT_OK on success; otherwise error result code will be returned.
iotcs_result iotcs_port_storage_ssl_write ( char *  request,
size_t  length 
)

Sends content to the storage cloud server.

Note:
Optional API. Called by the Library when STORAGE_SUPPORT enabled.
Parameters:
requesta buffer address
lengtha buffer size in bytes
Returns:
IOTCS_RESULT_OK when the complete contents of request with current length has been written.