The following sample C code builds and issues an SIOCTTLSCTL
ioctl that requests initialization of the secure connection and the
return of the partner's certificate in the provided buffer.
...
#include "ezbztlsc.h" /* SIOCTTLSCTL ioctl */
...
struct TTLS_IOCTL ioc; /* ioctl data structure */
char buff[1000]; /* buffer for certificate */
...
/* issue the SIOCTTLSCTL ioctl */
memset(&ioc,0,sizeof(ioc)); /* set all unused fields to zero */
ioc.TTLSi_Ver = TTLS_VERSION1;
ioc.TTLSi_Req_Type = TTLS_INIT_CONNECTION | TTLS_RETURN_CERTIFICATE;
ioc.TTLSi_BufferPtr = &buff
ioc.TTLSi_BufferLen = sizeof(buff);
rc = ioctl(s,SIOCTTLSCTL,(char *)&ioc);
if (rc < 0)
{
/* do failure logic. If the socket is in non- */
/* blocking mode then you may also receive rc */
/* of -1 with an errno of EINPROGRESS. This does */
/* not indicate an error. Wait for the completion */
/* of the handshake with select() for WRITEABLE. */
}