mirror of https://github.com/wolfSSL/wolfssl.git
Clean ups
parent
168985ed9f
commit
52e661df05
|
@ -24,23 +24,16 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/settings.h>
|
#include <cyassl/ctaocrypt/settings.h>
|
||||||
|
|
||||||
#if defined(CYASSL_MDK_ARM)
|
#if defined(HAVE_LWIP_NATIVE)
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <rtl.h>
|
|
||||||
#include "cyassl_MDK_ARM.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CYASSL_IAR_ARM)
|
#if defined(CYASSL_IAR_ARM)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CYASSL_LWIP)
|
|
||||||
#include "lwip/tcp.h"
|
#include "lwip/tcp.h"
|
||||||
#include "lwip/sockets.h"
|
#include "lwip/sockets.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cyassl/ctaocrypt/settings.h>
|
#include <cyassl/ctaocrypt/settings.h>
|
||||||
#include <cyassl/ssl.h>
|
#include <cyassl/ssl.h>
|
||||||
|
@ -52,14 +45,14 @@
|
||||||
/*Enable debug*/
|
/*Enable debug*/
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#define DBG_PRINTF(x, ...) printf("[HTTPSClient : DBG]"x"\r\n", ##__VA_ARGS__);
|
#define DBG_PRINTF(x, ...) printf("[HTTPSClient : DBG]"x"\r\n", ##__VA_ARGS__);
|
||||||
|
#define ERR_PRINTF(x, ...) printf("[HTTPSClient:ERROR]"x"\r\n", ##__VA_ARGS__);
|
||||||
#else
|
#else
|
||||||
/*Disable debug*/
|
/*Disable debug*/
|
||||||
#define DBG_PRINTF(x, ...)
|
#define DBG_PRINTF(x, ...)
|
||||||
|
#define ERR_PRINTF(x, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERR_PRINTF(x, ...) printf("[HTTPSClient:ERROR]"x"\r\n", ##__VA_ARGS__);
|
static int LwIP_cb_mutex = 0 ;
|
||||||
|
|
||||||
static int CyaSSL_cb_mutex = 0 ;
|
|
||||||
|
|
||||||
static unsigned long localPort = 0 ;
|
static unsigned long localPort = 0 ;
|
||||||
static unsigned long getPort(void) {
|
static unsigned long getPort(void) {
|
||||||
|
@ -73,6 +66,7 @@ static err_t DataConnectedCallback (void *arg, struct tcp_pcb *pcb, s8_t err)
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static err_t DataSentCallback (void *arg, struct tcp_pcb *pcb, u16_t err)
|
static err_t DataSentCallback (void *arg, struct tcp_pcb *pcb, u16_t err)
|
||||||
{
|
{
|
||||||
DBG_PRINTF("LwIPtest: Data Sent(SentCallBack1)\n") ;
|
DBG_PRINTF("LwIPtest: Data Sent(SentCallBack1)\n") ;
|
||||||
|
@ -119,6 +113,7 @@ static err_t DataReceiveCallback(void *arg, struct tcp_pcb *pcb, struct pbuf *p,
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int count = 0 ;
|
static int count = 0 ;
|
||||||
|
|
||||||
void CyaSSL_HTTPS_Client_NB_init(void *nb,
|
void CyaSSL_HTTPS_Client_NB_init(void *nb,
|
||||||
|
@ -146,12 +141,6 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
switch(https_nb->stat) {
|
switch(https_nb->stat) {
|
||||||
case BEGIN:
|
case BEGIN:
|
||||||
printf("======= LwIP: HTTPS Client Test(%x): %d =========\n", nb, count ++) ;
|
printf("======= LwIP: HTTPS Client Test(%x): %d =========\n", nb, count ++) ;
|
||||||
{
|
|
||||||
void * p ;
|
|
||||||
p = (void *)malloc(1) ;
|
|
||||||
printf("Watermark=%x\n", p) ;
|
|
||||||
free(p) ;
|
|
||||||
}
|
|
||||||
/*** Assuming LwIP has been initialized ***/
|
/*** Assuming LwIP has been initialized ***/
|
||||||
https_nb->stat = INITIALIZED ;
|
https_nb->stat = INITIALIZED ;
|
||||||
case INITIALIZED:
|
case INITIALIZED:
|
||||||
|
@ -181,8 +170,8 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
}
|
}
|
||||||
|
|
||||||
case TCP_CONNECT:
|
case TCP_CONNECT:
|
||||||
if(CyaSSL_cb_mutex)return ERR_OK ;
|
if(LwIP_cb_mutex)return ERR_OK ;
|
||||||
else CyaSSL_cb_mutex = 1 ;
|
else LwIP_cb_mutex = 1 ;
|
||||||
DBG_PRINTF("LwIPtest: TCP_CONNECT(%x)\n", https_nb) ;
|
DBG_PRINTF("LwIPtest: TCP_CONNECT(%x)\n", https_nb) ;
|
||||||
DBG_PRINTF("LwIPtest: Server IP Addrress(%d.%d.%d.%d)\n",
|
DBG_PRINTF("LwIPtest: Server IP Addrress(%d.%d.%d.%d)\n",
|
||||||
(*(unsigned long *)&https_nb->serverIP_em&0xff),
|
(*(unsigned long *)&https_nb->serverIP_em&0xff),
|
||||||
|
@ -203,7 +192,7 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
|
|
||||||
case TCP_CONNECTED:
|
case TCP_CONNECTED:
|
||||||
printf("LwIPtest: TCP CONNECTED(%x)\n", https_nb) ;
|
printf("LwIPtest: TCP CONNECTED(%x)\n", https_nb) ;
|
||||||
CyaSSL_cb_mutex = 0 ;
|
LwIP_cb_mutex = 0 ;
|
||||||
|
|
||||||
/*CyaSSLv3_client_method()
|
/*CyaSSLv3_client_method()
|
||||||
CyaTLSv1_client_method()
|
CyaTLSv1_client_method()
|
||||||
|
@ -229,7 +218,7 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
|
|
||||||
case SSL_CONN: /* handshaking */
|
case SSL_CONN: /* handshaking */
|
||||||
|
|
||||||
if(CyaSSL_cb_mutex) return ERR_OK ;
|
if(LwIP_cb_mutex) return ERR_OK ;
|
||||||
ret = CyaSSL_connect(https_nb->ssl);
|
ret = CyaSSL_connect(https_nb->ssl);
|
||||||
DBG_PRINTF("LwIPtest: SSL Connecting(CyaSSL_connect), ret = %d\n", ret) ;
|
DBG_PRINTF("LwIPtest: SSL Connecting(CyaSSL_connect), ret = %d\n", ret) ;
|
||||||
if(ret == SSL_SUCCESS) {
|
if(ret == SSL_SUCCESS) {
|
||||||
|
@ -253,7 +242,7 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
if(https_nb->ssl->lwipCtx.wait-- == 0) { /* counting down after the callback
|
if(https_nb->ssl->lwipCtx.wait-- == 0) { /* counting down after the callback
|
||||||
for multiple callbacks */
|
for multiple callbacks */
|
||||||
https_nb->stat = SSL_CONN ;
|
https_nb->stat = SSL_CONN ;
|
||||||
CyaSSL_cb_mutex = 0 ;
|
LwIP_cb_mutex = 0 ;
|
||||||
}
|
}
|
||||||
return ERR_OK ;
|
return ERR_OK ;
|
||||||
|
|
||||||
|
@ -262,8 +251,8 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
#define SEND_BUFF_SIZE 100
|
#define SEND_BUFF_SIZE 100
|
||||||
char sendBuff[SEND_BUFF_SIZE] ;
|
char sendBuff[SEND_BUFF_SIZE] ;
|
||||||
int size ;
|
int size ;
|
||||||
if(CyaSSL_cb_mutex)return ERR_OK ;
|
if(LwIP_cb_mutex)return ERR_OK ;
|
||||||
else CyaSSL_cb_mutex = 1 ; /* lock */
|
else LwIP_cb_mutex = 1 ; /* lock */
|
||||||
printf("LwIPtest: SSL CONNECTED(%x)\n", https_nb) ;
|
printf("LwIPtest: SSL CONNECTED(%x)\n", https_nb) ;
|
||||||
CyaSSL_NB_setCallbackArg(https_nb->ssl, &(https_nb->stat)) ;
|
CyaSSL_NB_setCallbackArg(https_nb->ssl, &(https_nb->stat)) ;
|
||||||
tcp_sent(https_nb->pcb, DataSentCallback);
|
tcp_sent(https_nb->pcb, DataSentCallback);
|
||||||
|
@ -286,7 +275,7 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
#define HTTP_BUFF_SIZE 2048
|
#define HTTP_BUFF_SIZE 2048
|
||||||
char httpbuff[HTTP_BUFF_SIZE] ;
|
char httpbuff[HTTP_BUFF_SIZE] ;
|
||||||
|
|
||||||
CyaSSL_cb_mutex = 0 ;
|
LwIP_cb_mutex = 0 ;
|
||||||
memset(httpbuff, '\0', HTTP_BUFF_SIZE) ;
|
memset(httpbuff, '\0', HTTP_BUFF_SIZE) ;
|
||||||
ret = CyaSSL_read(https_nb->ssl, httpbuff, HTTP_BUFF_SIZE) ;
|
ret = CyaSSL_read(https_nb->ssl, httpbuff, HTTP_BUFF_SIZE) ;
|
||||||
printf("LwIPtest: HTTPS GET(%x), Received(%d)\n",https_nb, strlen(httpbuff)) ;
|
printf("LwIPtest: HTTPS GET(%x), Received(%d)\n",https_nb, strlen(httpbuff)) ;
|
||||||
|
@ -327,6 +316,7 @@ int CyaSSL_HTTPS_Client_NB(void *nb)
|
||||||
CyaSSL_HTTPS_Client_NB
|
CyaSSL_HTTPS_Client_NB
|
||||||
*/
|
*/
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
#ifndef NO_MAIN_DRIVER
|
||||||
|
|
||||||
CYASSL_HTTPS_NB CyaSSL_HTTPS_Client_1 ;
|
CYASSL_HTTPS_NB CyaSSL_HTTPS_Client_1 ;
|
||||||
void *CyaSSL_HTTPS_ClientP_1 = (void *)&CyaSSL_HTTPS_Client_1 ;
|
void *CyaSSL_HTTPS_ClientP_1 = (void *)&CyaSSL_HTTPS_Client_1 ;
|
||||||
|
@ -344,7 +334,6 @@ void *CyaSSL_HTTPS_ClientP_5 = (void *)&CyaSSL_HTTPS_Client_5 ;
|
||||||
#define IP_ADDR(a,b,c,d) (((a)|((b)<<8)|((c)<<16)|(d)<<24))
|
#define IP_ADDR(a,b,c,d) (((a)|((b)<<8)|((c)<<16)|(d)<<24))
|
||||||
static struct ip_addr server_em = { IP_ADDR(192,168,11,9) } ;
|
static struct ip_addr server_em = { IP_ADDR(192,168,11,9) } ;
|
||||||
|
|
||||||
|
|
||||||
void HTTPSClient_main_init() {
|
void HTTPSClient_main_init() {
|
||||||
|
|
||||||
CyaSSL_HTTPS_Client_NB_init(CyaSSL_HTTPS_ClientP_1,
|
CyaSSL_HTTPS_Client_NB_init(CyaSSL_HTTPS_ClientP_1,
|
||||||
|
@ -361,7 +350,6 @@ void HTTPSClient_main_init() {
|
||||||
|
|
||||||
void HTTPSClient_main(int i)
|
void HTTPSClient_main(int i)
|
||||||
{
|
{
|
||||||
|
|
||||||
if((i % 1) == 0) { /* wait for initializing TCP/IP, DHCP */
|
if((i % 1) == 0) { /* wait for initializing TCP/IP, DHCP */
|
||||||
CyaSSL_HTTPS_Client_NB(CyaSSL_HTTPS_ClientP_1) ;
|
CyaSSL_HTTPS_Client_NB(CyaSSL_HTTPS_ClientP_1) ;
|
||||||
}
|
}
|
||||||
|
@ -382,4 +370,7 @@ void HTTPSClient_main(int i)
|
||||||
CyaSSL_HTTPS_Client_NB(CyaSSL_HTTPS_ClientP_5) ;
|
CyaSSL_HTTPS_Client_NB(CyaSSL_HTTPS_ClientP_5) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* NO_MAIN_DRIVER */
|
||||||
|
#endif /* HAVE_LWIP_NATIVE */
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef HTTPS_NB_H
|
||||||
|
#define HTTPS_NB_H
|
||||||
|
|
||||||
extern int CyaSSL_GetDataFromPbuf(char *buff, struct pbuf *p, int size) ;
|
extern int CyaSSL_GetDataFromPbuf(char *buff, struct pbuf *p, int size) ;
|
||||||
|
|
||||||
|
@ -68,4 +71,6 @@ typedef struct {
|
||||||
|
|
||||||
extern void CyaSSL_HTTPS_Client_NB_init(void *nb,
|
extern void CyaSSL_HTTPS_Client_NB_init(void *nb,
|
||||||
struct ip_addr svIP, unsigned long svPort, char *host, char *path) ;
|
struct ip_addr svIP, unsigned long svPort, char *host, char *path) ;
|
||||||
extern int CyaSSL_HTTPS_Client_NB(void *nb) ;
|
extern int CyaSSL_HTTPS_Client_NB(void *nb) ;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1874,9 +1874,6 @@
|
||||||
</configuration>
|
</configuration>
|
||||||
<group>
|
<group>
|
||||||
<name>Apps</name>
|
<name>Apps</name>
|
||||||
<file>
|
|
||||||
<name>$PROJ_DIR$\..\..\CyaSSL\https-maic.c</name>
|
|
||||||
</file>
|
|
||||||
<file>
|
<file>
|
||||||
<name>$PROJ_DIR$\..\..\CyaSSL\https-nb.c</name>
|
<name>$PROJ_DIR$\..\..\CyaSSL\https-nb.c</name>
|
||||||
</file>
|
</file>
|
||||||
|
|
4
src/io.c
4
src/io.c
|
@ -1055,9 +1055,11 @@ void CyaSSL_SetIO_NetX(CYASSL* ssl, NX_TCP_SOCKET* nxSocket, ULONG waitOption)
|
||||||
/*Enable debug*/
|
/*Enable debug*/
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#define DBG_PRINTF(x, ...) printf("[SSLClient : DBG]"x"\r\n", ##__VA_ARGS__);
|
#define DBG_PRINTF(x, ...) printf("[SSLClient : DBG]"x"\r\n", ##__VA_ARGS__);
|
||||||
|
#define ERR_PRINTF(x, ...) printf("[SSLClient:ERROR]"x"\r\n", ##__VA_ARGS__);
|
||||||
#else
|
#else
|
||||||
/*Disable debug*/
|
/*Disable debug*/
|
||||||
#define DBG_PRINTF(x, ...)
|
#define DBG_PRINTF(x, ...)
|
||||||
|
#define ERR_PRINTF(x, ...) err_sys(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -1068,8 +1070,6 @@ void CyaSSL_SetIO_NetX(CYASSL* ssl, NX_TCP_SOCKET* nxSocket, ULONG waitOption)
|
||||||
#define DBG_PRINTF_CB(x, ...)
|
#define DBG_PRINTF_CB(x, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ERR_PRINTF(x, ...) printf("[SSLClient:ERROR]"x"\r\n", ##__VA_ARGS__);
|
|
||||||
|
|
||||||
void CyaSSL_PbufFree(void *vp)
|
void CyaSSL_PbufFree(void *vp)
|
||||||
{
|
{
|
||||||
struct pbuf *p ;
|
struct pbuf *p ;
|
||||||
|
|
Loading…
Reference in New Issue