Skip to content
Open
1 change: 1 addition & 0 deletions .wolfssl_known_macro_extras
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,7 @@ WOLFSSL_MONT_RED_CT
WOLFSSL_MP_COND_COPY
WOLFSSL_MP_INVMOD_CONSTANT_TIME
WOLFSSL_MULTICIRCULATE_ALTNAMELIST
WOLFSSL_NETX_DUO
WOLFSSL_NEW_PRIME_CHECK
WOLFSSL_NONBLOCK_OCSP
WOLFSSL_NOSHA3_384
Expand Down
48 changes: 41 additions & 7 deletions doc/dox_comments/header_files-ja/wolfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,22 +404,22 @@ void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
/*!
\ingroup IO

\brief この関数は、WOLFSSL構造体内のnxCtx構造体のnxSocketおよびnxWaitメンバーを設定します
\brief この関数は、WOLFSSL構造体内のnxCtx構造体のnxTcpSocketおよびnxWaitメンバーを設定します

\return none 戻り値なし。

\param ssl wolfSSL_new()を使用して作成されたWOLFSSL構造体へのポインタ。
\param nxSocket nxCTX構造体のnxSocketメンバーに設定されるNX_TCP_SOCKET型へのポインタ
\param waitOption nxCtx構造体のnxWaitメンバーに設定されるULONG型。
\param nxsocket nxCtx構造体のnxTcpSocketメンバーに設定されるNX_TCP_SOCKET型へのポインタ
\param waitoption nxCtx構造体のnxWaitメンバーに設定されるULONG型。

_Example_
\code
WOLFSSL* ssl = wolfSSL_new(ctx);
NX_TCP_SOCKET* nxSocket;
ULONG waitOption;
NX_TCP_SOCKET* nxsocket;
ULONG waitoption;
if(ssl != NULL || nxSocket != NULL || waitOption <= 0){
wolfSSL_SetIO_NetX(ssl, nxSocket, waitOption);
if(ssl != NULL || nxsocket != NULL || waitoption <= 0){
wolfSSL_SetIO_NetX(ssl, nxsocket, waitoption);
} else {
// 適切なパラメータを渡す必要があります。
}
Expand All @@ -432,6 +432,40 @@ void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxsocket,
ULONG waitoption);

/*!
\ingroup IO

\brief この関数は、DTLSセッション用のNetX Duo UDPコンテキストを設定します。
UDPソケット、送信先IPアドレス(値渡し)、送信先ポート、待機オプションを
WOLFSSL nxCtx構造体に格納します。WOLFSSL_NETX_DUOの定義が必要です(ThreadX NetX Duo SDK)。

\return none 戻り値なし。

\param ssl wolfSSL_new()を使用して作成されたWOLFSSL構造体へのポインタ。
\param nxsocket 作成・バインド済みのNX_UDP_SOCKETへのポインタ。
\param nxdip 送信先NXD_ADDRESS(値渡し;IPv4またはIPv6)。
\param nxport 送信先UDPポート番号。
\param waitoption NetX待機オプション(例:NX_WAIT_FOREVERまたはティック数)。

_Example_
\code
WOLFSSL* ssl = wolfSSL_new(ctx);
NX_UDP_SOCKET udpsocket;
NXD_ADDRESS peeraddr;
USHORT peerport = 4433;
ULONG wait = NX_WAIT_FOREVER;
// … udpsocketとpeeraddrを初期化 …
wolfSSL_SetIO_NetX_Dtls(ssl, &udpsocket, peeraddr, peerport, wait);
\endcode

\sa wolfSSL_SetIO_NetX
\sa NetX_SendTo
\sa NetX_ReceiveFrom
*/
void wolfSSL_SetIO_NetX_Dtls(WOLFSSL* ssl, NX_UDP_SOCKET* nxsocket,
NXD_ADDRESS nxdip, USHORT nxport,
ULONG waitoption);

/*!
\brief この関数は、WOLFSSL_CTX構造体のCBIOCookieメンバーのコールバックを設定します。
CallbackGenCookie型は関数ポインタで、次のシグネチャを持ちます:
Expand Down
51 changes: 43 additions & 8 deletions doc/dox_comments/header_files/wolfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,25 +450,25 @@ void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
/*!
\ingroup IO

\brief This function sets the nxSocket and nxWait members of the nxCtx
\brief This function sets the nxTcpSocket and nxWait members of the nxCtx
struct within the WOLFSSL structure.

\return none No returns.

\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
\param nxSocket a pointer to type NX_TCP_SOCKET that is set to the
nxSocket member of the nxCTX structure.
\param waitOption a ULONG type that is set to the nxWait member of
\param nxsocket a pointer to type NX_TCP_SOCKET that is set to the
nxTcpSocket member of the nxCtx structure.
\param waitoption a ULONG type that is set to the nxWait member of
the nxCtx structure.
Comment thread
dgarske marked this conversation as resolved.

_Example_
\code
WOLFSSL* ssl = wolfSSL_new(ctx);
NX_TCP_SOCKET* nxSocket;
ULONG waitOption;
NX_TCP_SOCKET* nxsocket;
ULONG waitoption;
if(ssl != NULL || nxSocket != NULL || waitOption <= 0){
wolfSSL_SetIO_NetX(ssl, nxSocket, waitOption);
if(ssl != NULL || nxsocket != NULL || waitoption <= 0){
wolfSSL_SetIO_NetX(ssl, nxsocket, waitoption);
} else {
// You need to pass in good parameters.
}
Expand All @@ -481,6 +481,41 @@ void wolfSSL_SetIOWriteFlags(WOLFSSL* ssl, int flags);
void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxsocket,
ULONG waitoption);

/*!
\ingroup IO

\brief This function configures the NetX Duo UDP context for a DTLS
session. It stores the UDP socket, destination IP address (by value),
destination port, and wait option into the WOLFSSL nxCtx structure.
Requires WOLFSSL_NETX_DUO to be defined (ThreadX NetX Duo SDK).

\return none No returns.

\param ssl a pointer to a WOLFSSL structure, created using wolfSSL_new().
\param nxsocket a pointer to an NX_UDP_SOCKET already created and bound.
\param nxdip the destination NXD_ADDRESS (passed by value; IPv4 or IPv6).
\param nxport the destination UDP port number.
\param waitoption a ULONG NetX wait option (e.g. NX_WAIT_FOREVER or ticks).

_Example_
\code
WOLFSSL* ssl = wolfSSL_new(ctx);
NX_UDP_SOCKET udpsocket;
NXD_ADDRESS peeraddr;
USHORT peerport = 4433;
ULONG wait = NX_WAIT_FOREVER;
// … initialise udpsocket and peeraddr …
wolfSSL_SetIO_NetX_Dtls(ssl, &udpsocket, peeraddr, peerport, wait);
\endcode

\sa wolfSSL_SetIO_NetX
\sa NetX_SendTo
\sa NetX_ReceiveFrom
*/
void wolfSSL_SetIO_NetX_Dtls(WOLFSSL* ssl, NX_UDP_SOCKET* nxsocket,
NXD_ADDRESS nxdip, USHORT nxport,
ULONG waitoption);
Comment thread
dgarske marked this conversation as resolved.

/*!
\brief This function sets the callback for the CBIOCookie member of the
WOLFSSL_CTX structure. The CallbackGenCookie type is a function pointer
Expand Down
12 changes: 11 additions & 1 deletion src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,12 @@ int InitSSL_Ctx(WOLFSSL_CTX* ctx, WOLFSSL_METHOD* method, void* heap)
#ifdef HAVE_NETX
ctx->CBIORecv = NetX_Receive;
ctx->CBIOSend = NetX_Send;
#if defined(WOLFSSL_DTLS) && defined(WOLFSSL_NETX_DUO)
if (method->version.major == DTLS_MAJOR) {
ctx->CBIORecv = NetX_ReceiveFrom;
ctx->CBIOSend = NetX_SendTo;
}
#endif /* WOLFSSL_DTLS && WOLFSSL_NETX_DUO */
#elif defined(WOLFSSL_APACHE_MYNEWT) && !defined(WOLFSSL_LWIP)
ctx->CBIORecv = Mynewt_Receive;
ctx->CBIOSend = Mynewt_Send;
Expand Down Expand Up @@ -7954,9 +7960,13 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
if (wc_InitRwLock(&ssl->buffers.dtlsCtx.peerLock) != 0)
return BAD_MUTEX_E;
#endif

#ifdef HAVE_NETX
ssl->IOCB_ReadCtx = &ssl->nxCtx; /* default NetX IO ctx, same for read */
ssl->IOCB_WriteCtx = &ssl->nxCtx; /* and write */
#else
ssl->IOCB_ReadCtx = &ssl->buffers.dtlsCtx; /* prevent invalid pointer access if not */
ssl->IOCB_WriteCtx = &ssl->buffers.dtlsCtx; /* correctly set */
#endif
#else
#ifdef HAVE_NETX
ssl->IOCB_ReadCtx = &ssl->nxCtx; /* default NetX IO ctx, same for read */
Expand Down
Loading