Azure IoT common library

Fork of azure_c_shared_utility by Azure IoT

Revision:
10:1be0bc9a9deb
Parent:
6:c55b013dfc2a
Child:
15:956c6d205aa7
--- a/tlsio_wolfssl.c	Fri Aug 12 13:49:58 2016 -0700
+++ b/tlsio_wolfssl.c	Fri Aug 26 12:59:40 2016 -0700
@@ -50,8 +50,75 @@
     int port;
 } TLS_IO_INSTANCE;
 
+/*this function will clone an option given by name and value*/
+static void* tlsio_wolfssl_CloneOption(const char* name, const void* value)
+{
+    void* result;
+    if (
+        (name == NULL) || (value == NULL)
+        )
+    {
+        result = NULL;
+    }
+    else
+    {
+        if (strcmp(name, "TrustedCerts") == 0)
+        {
+            if (mallocAndStrcpy_s((char**)&result, value) != 0)
+            {
+                result = NULL;
+            }
+            else
+            {
+                /*return as is*/
+            }
+        }
+        else
+        {
+            /*option is not handled*/
+            result = NULL;
+        }
+    }
+    return result;
+}
+
+/*this function destroys an option previously created*/
+static void tlsio_wolfssl_DestroyOption(const char* name, const void* value)
+{
+    /*since all options for this layer are actually string copies., disposing of one is just calling free*/
+    if ((name != NULL) && (value != NULL))
+    {
+        if (strcmp(name, "TrustedCerts") == 0)
+        {
+            free((void*)value);
+        }
+        else
+        {
+            /*option is not handled*/
+        }
+    }
+}
+
+static OPTIONHANDLER_HANDLE tlsio_wolfssl_retrieveoptions(CONCRETE_IO_HANDLE tls_io)
+{
+    OPTIONHANDLER_HANDLE result;
+    (void)tls_io;
+
+    result = OptionHandler_Create(tlsio_wolfssl_CloneOption, tlsio_wolfssl_DestroyOption, tlsio_wolfssl_setoption);
+    if (result == NULL)
+    {
+        /*return as is*/
+    }
+    else
+    {
+        /*insert here work to add the options to "result" handle*/
+    }
+    return result;
+}
+
 static const IO_INTERFACE_DESCRIPTION tlsio_wolfssl_interface_description =
 {
+    tlsio_wolfssl_retrieveoptions,
     tlsio_wolfssl_create,
     tlsio_wolfssl_destroy,
     tlsio_wolfssl_open,
@@ -649,4 +716,4 @@
     }
 
     return result;
-}
\ No newline at end of file
+}