/// <summary> /// Set information needed to send and receive a DTLS connection /// </summary> /// <param name="ssl">structure to set information in</param> /// <param name="udp">UDP object to send and receive</param> /// <param name="ep">End point of connection</param> /// <returns>1 on success</returns> public static int set_dtls_fd(IntPtr ssl, UdpClient udp, IPEndPoint ep) { /* sanity check on inputs */ if (ssl == IntPtr.Zero) { return FAILURE; } try { if (!udp.Equals(null) && !ep.Equals(null)) { IntPtr ptr; DTLS_con con; GCHandle gch = GCHandle.FromIntPtr(ssl); ctx_handles handles = (ctx_handles)gch.Target; GCHandle fd_pin; con = new DTLS_con(); con.udp = udp; con.ep = ep; fd_pin = GCHandle.Alloc(con); handles.set_fd(fd_pin); ptr = GCHandle.ToIntPtr(fd_pin); wolfSSL_SetIOWriteCtx(handles.get_ctx(), ptr); //pass along the socket for writing to wolfSSL_SetIOReadCtx(handles.get_ctx(), ptr); //pass along the socket for reading from return SUCCESS; } return FAILURE; } catch (Exception e) { log(ERROR_LOG, "Error setting up fd!! " + e.ToString()); return FAILURE; } }