Merge pull request #48 from JacobBarthelmeh/pic32

initial port to pic32
pull/50/merge
John Safranek 2018-04-05 13:59:39 -07:00 committed by GitHub
commit ed37ae9fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 374 additions and 29 deletions

View File

@ -2051,7 +2051,7 @@ static int DoKexDhInit(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
{
byte* pubKey;
byte* pubKey = NULL;
word32 pubKeySz;
byte* f;
word32 fSz;
@ -4542,9 +4542,9 @@ static int PreparePacket(WOLFSSH* ssh, word32 payloadSz)
static int BundlePacket(WOLFSSH* ssh)
{
byte* output;
word32 idx;
byte paddingSz;
byte* output = NULL;
word32 idx = 0;
byte paddingSz = 0;
int ret = WS_SUCCESS;
if (ssh == NULL)

View File

@ -124,6 +124,10 @@ void* wolfSSH_GetIOWriteCtx(WOLFSSH* ssh)
#define RNG CyaSSL_RNG
/* for avoiding name conflict in "stm32f2xx.h" */
static int errno;
#elif defined(MICROCHIP_MPLAB_HARMONY)
#include "tcpip/tcpip.h"
#include "sys/errno.h"
#include <errno.h>
#else
#include <sys/types.h>
#include <errno.h>
@ -224,6 +228,11 @@ void* wolfSSH_GetIOWriteCtx(WOLFSSH* ssh)
#elif defined(WOLFSSH_LWIP)
#define SEND_FUNCTION lwip_send
#define RECV_FUNCTION lwip_recv
#elif defined(MICROCHIP_MPLAB_HARMONY)
#define SEND_FUNCTION(socket,buf,sz,flags) \
TCPIP_TCP_ArrayPut((socket),(uint8_t*)(buf),(sz))
#define RECV_FUNCTION(socket,buf,sz,flags) \
TCPIP_TCP_ArrayGet((socket),(uint8_t*)(buf),(sz))
#else
#define SEND_FUNCTION send
#define RECV_FUNCTION recv
@ -250,6 +259,18 @@ static INLINE int TranslateReturnCode(int old, int sd)
}
#endif
#ifdef MICROCHIP_MPLAB_HARMONY
if (old == 0) {
/* check is still connected */
if (!TCPIP_TCP_IsConnected(sd))
{
return 0;
}
errno = SOCKET_EWOULDBLOCK;
return -1;
}
#endif
return old;
}
@ -329,6 +350,23 @@ int wsEmbedSend(WOLFSSH* ssh, void* data, word32 sz, void* ctx)
WLOG(WS_LOG_DEBUG,"Embed Send trying to send %d", sz);
#ifdef MICROCHIP_MPLAB_HARMONY
/* check is still connected */
if (!TCPIP_TCP_IsConnected(sd))
{
return WS_CBIO_ERR_CONN_CLOSE;
}
/* not enough space to send */
if ((sent = TCPIP_TCP_PutIsReady(sd)) < sz) {
sz = sent;
}
if (sent == 0) {
/* In the case that 0 is returned the main TCP loop needs to be called */
return WS_CBIO_ERR_WANT_WRITE;
}
#endif /* MICROCHIP_MPLAB_HARMONY */
sent = (int)SEND_FUNCTION(sd, buf, sz, ssh->wflags);
WLOG(WS_LOG_DEBUG,"Embed Send sent %d", sent);
@ -358,7 +396,6 @@ int wsEmbedSend(WOLFSSH* ssh, void* data, word32 sz, void* ctx)
return WS_CBIO_ERR_GENERAL;
}
}
return sent;
}

View File

@ -126,7 +126,7 @@ void DefaultLoggingCb(enum wolfSSH_LogLevel level, const char *const msgStr)
time_t current;
struct tm local;
current = time(NULL);
current = WTIME(NULL);
if (WLOCALTIME(&current, &local)) {
/* make pretty */
strftime(timeStr, sizeof(timeStr), "%b %d %T %Y: ", &local);

View File

@ -35,6 +35,7 @@
#include <wolfssh/port.h>
#ifndef NO_FILESYSTEM
int wfopen(WFILE** f, const char* filename, const char* mode)
{
#ifdef USE_WINDOWS_API
@ -47,7 +48,7 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
return 1;
#endif
}
#endif /* !NO_FILESYSTEM */
#ifndef WSTRING_USER

View File

@ -113,8 +113,6 @@ WOLFSSH* wolfSSH_new(WOLFSSH_CTX* ctx)
return NULL;
}
WLOG(WS_LOG_DEBUG, "Entering wolfSSH_new()");
ssh = (WOLFSSH*)WMALLOC(sizeof(WOLFSSH), heap, DYNTYPE_SSH);
ssh = SshInit(ssh, ctx);

View File

@ -0,0 +1,226 @@
/* certs_test.h
*
* Copyright (C) 2014-2018 wolfSSL Inc.
*
* This file is part of wolfSSH.
*
* wolfSSH is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* wolfSSH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wolfSSH. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef WOLFSSL_CERTS_TEST_H
#define WOLFSSL_CERTS_TEST_H
#ifdef NO_FILESYSTEM
/* ./keys/server-key-rsa.der, 2048-bit */
static const unsigned char rsa_key_der_2048[] =
{
0x30, 0x82, 0x04, 0xA3, 0x02, 0x01, 0x00, 0x02, 0x82, 0x01,
0x01, 0x00, 0xDA, 0x5D, 0xAD, 0x25, 0x14, 0x76, 0x15, 0x59,
0xF3, 0x40, 0xFD, 0x3C, 0xB8, 0x62, 0x30, 0xB3, 0x6D, 0xC0,
0xF9, 0xEC, 0xEC, 0x8B, 0x83, 0x1E, 0x9E, 0x42, 0x9C, 0xCA,
0x41, 0x6A, 0xD3, 0x8A, 0xE1, 0x52, 0x34, 0xE0, 0x0D, 0x13,
0x62, 0x7E, 0xD4, 0x0F, 0xAE, 0x5C, 0x4D, 0x04, 0xF1, 0x8D,
0xFA, 0xC5, 0xAD, 0x77, 0xAA, 0x5A, 0x05, 0xCA, 0xEF, 0xF8,
0x8D, 0xAB, 0xFF, 0x8A, 0x29, 0x09, 0x4C, 0x04, 0xC2, 0xF5,
0x19, 0xCB, 0xED, 0x1F, 0xB1, 0xB4, 0x29, 0xD3, 0xC3, 0x6C,
0xA9, 0x23, 0xDF, 0xA3, 0xA0, 0xE5, 0x08, 0xDE, 0xAD, 0x8C,
0x71, 0xF9, 0x34, 0x88, 0x6C, 0xED, 0x3B, 0xF0, 0x6F, 0xA5,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A, 0xFC, 0xC1, 0x4C, 0x96, 0xAE,
0xD5, 0x26, 0x3C, 0x04, 0x2D, 0x88, 0x48, 0x3D, 0x2C, 0x27,
0x73, 0xF5, 0xCD, 0x3E, 0x80, 0xE3, 0xFE, 0xBC, 0x33, 0x4F,
0x12, 0x8D, 0x29, 0xBA, 0xFD, 0x39, 0xDE, 0x63, 0xF9, 0x02,
0x81, 0x81, 0x00, 0x8B, 0x1F, 0x47, 0xA2, 0x90, 0x4B, 0x82,
0x3B, 0x89, 0x2D, 0xE9, 0x6B, 0xE1, 0x28, 0xE5, 0x22, 0x87,
0x83, 0xD0, 0xDE, 0x1E, 0x0D, 0x8C, 0xCC, 0x84, 0x43, 0x3D,
0x23, 0x8D, 0x9D, 0x6C, 0xBC, 0xC4, 0xC6, 0xDA, 0x44, 0x44,
0x79, 0x20, 0xB6, 0x3E, 0xEF, 0xCF, 0x8A, 0xC4, 0x38, 0xB0,
0xE5, 0xDA, 0x45, 0xAC, 0x5A, 0xCC, 0x7B, 0x62, 0xBA, 0xA9,
0x73, 0x1F, 0xBA, 0x27, 0x5C, 0x82, 0xF8, 0xAD, 0x31, 0x1E,
0xDE, 0xF3, 0x37, 0x72, 0xCB, 0x47, 0xD2, 0xCD, 0xF7, 0xF8,
0x7F, 0x00, 0x39, 0xDB, 0x8D, 0x2A, 0xCA, 0x4E, 0xC1, 0xCE,
0xE2, 0x15, 0x89, 0xD6, 0x3A, 0x61, 0xAE, 0x9D, 0xA2, 0x30,
0xA5, 0x85, 0xAE, 0x38, 0xEA, 0x46, 0x74, 0xDC, 0x02, 0x3A,
0xAC, 0xE9, 0x5F, 0xA3, 0xC6, 0x73, 0x4F, 0x73, 0x81, 0x90,
0x56, 0xC3, 0xCE, 0x77, 0x5F, 0x5B, 0xBA, 0x6C, 0x42, 0xF1,
0x21
};
static const int sizeof_rsa_key_der_2048 = sizeof(rsa_key_der_2048);
/* ./keys/server-key-ecc.der, ECC */
static const unsigned char ecc_key_der_256[] =
{
0x30, 0x77, 0x02, 0x01, 0x01, 0x04, 0x20, 0x61, 0x09, 0x99,
0x0B, 0x79, 0xD2, 0x5F, 0x28, 0x5A, 0x0F, 0x5D, 0x15, 0xCC,
0xA1, 0x56, 0x54, 0xF9, 0x2B, 0x39, 0x87, 0x21, 0x2D, 0xA7,
0x7D, 0x85, 0x7B, 0xB8, 0x7F, 0x38, 0xC6, 0x6D, 0xD5, 0xA0,
0x0A, 0x06, 0x08, 0x2A, 0x86, 0x48, 0xCE, 0x3D, 0x03, 0x01,
0x07, 0xA1, 0x44, 0x03, 0x42, 0x00, 0x04, 0x81, 0x13, 0xFF,
0xA4, 0x2B, 0xB7, 0x9C, 0x45, 0x74, 0x7A, 0x83, 0x4C, 0x61,
0xF3, 0x3F, 0xAD, 0x26, 0xCF, 0x22, 0xCD, 0xA9, 0xA3, 0xBC,
0xA5, 0x61, 0xB4, 0x7C, 0xE6, 0x62, 0xD4, 0xC2, 0xF7, 0x55,
0x43, 0x9A, 0x31, 0xFB, 0x80, 0x11, 0x20, 0xB5, 0x12, 0x4B,
0x24, 0xF5, 0x78, 0xD7, 0xFD, 0x22, 0xEF, 0x46, 0x35, 0xF0,
0x05, 0x58, 0x6B, 0x5F, 0x63, 0xC8, 0xDA, 0x1B, 0xC4, 0xF5,
0x69
};
static const int sizeof_ecc_key_der_256 = sizeof(ecc_key_der_256);
/* ./keys/server-key-ecc-384.der, ECC */
static const unsigned char ecc_key_der_384[] =
{
0x30, 0x81, 0xA4, 0x02, 0x01, 0x01, 0x04, 0x30, 0x3E, 0xAD,
0xD2, 0xBB, 0xBF, 0x05, 0xA7, 0xBE, 0x3A, 0x3F, 0x7C, 0x28,
0x15, 0x12, 0x89, 0xDE, 0x5B, 0xB3, 0x64, 0x4D, 0x70, 0x11,
0x76, 0x1D, 0xB5, 0x6F, 0x2A, 0x03, 0x62, 0xFB, 0xA6, 0x4F,
0x98, 0xE6, 0x4F, 0xF9, 0x86, 0xDC, 0x4F, 0xB8, 0xEF, 0xDB,
0x2D, 0x6B, 0x8D, 0xA5, 0x71, 0x42, 0xA0, 0x07, 0x06, 0x05,
0x2B, 0x81, 0x04, 0x00, 0x22, 0xA1, 0x64, 0x03, 0x62, 0x00,
0x04, 0x38, 0xD6, 0x2B, 0xE4, 0x18, 0xFF, 0x57, 0x3F, 0xD0,
0xE0, 0x20, 0xD4, 0x88, 0x76, 0xC4, 0xE1, 0x12, 0x1D, 0xFB,
0x2D, 0x6E, 0xBE, 0xE4, 0x89, 0x5D, 0x77, 0x24, 0x31, 0x6D,
0x46, 0xA2, 0x31, 0x05, 0x87, 0x3F, 0x29, 0x86, 0xD5, 0xC7,
0x12, 0x80, 0x3A, 0x6F, 0x47, 0x1A, 0xB8, 0x68, 0x50, 0xEB,
0x06, 0x3E, 0x10, 0x89, 0x61, 0x34, 0x9C, 0xF8, 0xB4, 0xC6,
0xA4, 0xCF, 0x5E, 0x97, 0xBD, 0x7E, 0x51, 0xE9, 0x75, 0xE3,
0xE9, 0x21, 0x72, 0x61, 0x50, 0x6E, 0xB9, 0xCF, 0x3C, 0x49,
0x3D, 0x3E, 0xB8, 0x8D, 0x46, 0x7B, 0x5F, 0x27, 0xEB, 0xAB,
0x21, 0x61, 0xC0, 0x00, 0x66, 0xFE, 0xBD
};
static const int sizeof_ecc_key_der_384 = sizeof(ecc_key_der_384);
/* ./keys/server-key-ecc-521.der, ECC */
static const unsigned char ecc_key_der_521[] =
{
0x30, 0x81, 0xDC, 0x02, 0x01, 0x01, 0x04, 0x42, 0x00, 0x4C,
0xA4, 0xD8, 0x64, 0x28, 0xD9, 0x40, 0x0E, 0x7B, 0x2D, 0xF3,
0x91, 0x2E, 0xB9, 0x96, 0xC1, 0x95, 0x89, 0x50, 0x43, 0xAF,
0x92, 0xE8, 0x6D, 0xE7, 0x0A, 0xE4, 0xDF, 0x46, 0xF2, 0x2A,
0x29, 0x1A, 0x6B, 0xB2, 0x74, 0x8A, 0xAE, 0x82, 0x58, 0x0D,
0xF6, 0xC3, 0x9F, 0x49, 0xB3, 0xED, 0x82, 0xF1, 0x78, 0x9E,
0xCE, 0x1B, 0x65, 0x7D, 0x45, 0x43, 0x8C, 0xFF, 0x15, 0x65,
0x34, 0x35, 0x45, 0x75, 0xA0, 0x07, 0x06, 0x05, 0x2B, 0x81,
0x04, 0x00, 0x23, 0xA1, 0x81, 0x89, 0x03, 0x81, 0x86, 0x00,
0x04, 0x01, 0xF8, 0xD0, 0xA7, 0xC3, 0xC5, 0x8D, 0x84, 0x19,
0x57, 0x96, 0x9F, 0x21, 0x3A, 0x94, 0xF3, 0xDA, 0x55, 0x0E,
0xDF, 0x76, 0xD8, 0xDD, 0x17, 0x15, 0x31, 0xF3, 0x5B, 0xB0,
0x69, 0xC8, 0xBC, 0x30, 0x0D, 0x6F, 0x6B, 0x37, 0xD1, 0x80,
0x46, 0xA9, 0x71, 0x7F, 0x2C, 0x6F, 0x59, 0x51, 0x9C, 0x82,
0x70, 0x95, 0xB2, 0x9A, 0x63, 0x13, 0x30, 0x62, 0x18, 0xC2,
0x35, 0x76, 0x94, 0x00, 0xD0, 0xF9, 0x6D, 0x00, 0x0A, 0x19,
0x3B, 0xA3, 0x46, 0x65, 0x2B, 0xEB, 0x40, 0x9A, 0x9A, 0x45,
0xC5, 0x97, 0xA3, 0xED, 0x93, 0x2D, 0xD5, 0xAA, 0xAE, 0x96,
0xBF, 0x2F, 0x31, 0x7E, 0x5A, 0x7A, 0xC7, 0x45, 0x8B, 0x3C,
0x6C, 0xDB, 0xAA, 0x90, 0xC3, 0x55, 0x38, 0x2C, 0xDF, 0xCD,
0xCA, 0x73, 0x77, 0xD9, 0x2E, 0xB2, 0x0A, 0x5E, 0x8C, 0x74,
0x23, 0x7C, 0xA5, 0xA3, 0x45, 0xB1, 0x9E, 0x3F, 0x1A, 0x22,
0x90, 0xB1, 0x54
};
static const int sizeof_ecc_key_der_521 = sizeof(ecc_key_der_521);
#endif /* NO_FILESYSTEM */
#endif /* WOLFSSL_CERTS_TEST_H */

View File

@ -14,7 +14,8 @@ nobase_include_HEADERS+= \
wolfssh/visibility.h \
wolfssh/misc.h \
wolfssh/log.h \
wolfssh/test.h
wolfssh/test.h \
wolfssh/certs_test.h
noinst_HEADERS+= \
wolfssh/internal.h

View File

@ -45,15 +45,20 @@ extern "C" {
#define WREALLOC(p, n, h, t) wolfSSH_Realloc((p), (n))
#endif /* WMALLOC_USER */
#ifndef NO_FILESYSTEM
#define WFILE FILE
WOLFSSH_API int wfopen(WFILE**, const char*, const char*);
#define WFOPEN(f,fn,m) wfopen((f),(fn),(m))
#define WFCLOSE(f) fclose(f)
#endif
/* setup string handling */
#ifndef WSTRING_USER
#include <string.h>
#define WFILE FILE
WOLFSSH_API char* wstrnstr(const char*, const char*, unsigned int);
WOLFSSH_API int wfopen(WFILE**, const char*, const char*);
#define WMEMCPY(d,s,l) memcpy((d),(s),(l))
#define WMEMSET(b,c,l) memset((b),(c),(l))
@ -67,25 +72,39 @@ extern "C" {
#define WSTRNCAT(s1,s2,n) strncat((s1),(s2),(n))
#define WSTRSPN(s1,s2) strspn((s1),(s2))
#define WSTRCSPN(s1,s2) strcspn((s1),(s2))
#define WFOPEN(f,fn,m) wfopen((f),(fn),(m))
#define WFCLOSE(f) fclose(f)
#ifndef USE_WINDOWS_API
#ifdef USE_WINDOWS_API
#define WSTRNCPY(s1,s2,n) strncpy_s((s1),(n),(s2),(n))
#define WSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
#define WSNPRINTF(s,n,f,...) _snprintf_s((s),(n),(n),(f),##__VA_ARGS__)
#define WVSNPRINTF(s,n,f,...) vsnprintf_s((s),(n),(n),(f),##__VA_ARGS__)
#elif defined(MICROCHIP_MPLAB_HARMONY) || defined(MICROCHIP_PIC32)
#include <stdio.h>
#define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
#define WSTRNCASECMP(s1, s2, n) strncmp((s1), (s2), (n))
#define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__)
#define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__)
#else
#include <stdio.h>
#define WSTRNCPY(s1,s2,n) strncpy((s1),(s2),(n))
#define WSTRNCASECMP(s1,s2,n) strncasecmp((s1),(s2),(n))
#define WSNPRINTF(s,n,f,...) snprintf((s),(n),(f),##__VA_ARGS__)
#define WVSNPRINTF(s,n,f,...) vsnprintf((s),(n),(f),##__VA_ARGS__)
#define WLOCALTIME(c,r) (localtime_r((c),(r))!=NULL)
#else
#define WSTRNCPY(s1,s2,n) strncpy_s((s1),(n),(s2),(n))
#define WSTRNCASECMP(s1,s2,n) _strnicmp((s1),(s2),(n))
#define WSNPRINTF(s,n,f,...) _snprintf_s((s),(n),(n),(f),##__VA_ARGS__)
#define WVSNPRINTF(s,n,f,...) vsnprintf_s((s),(n),(n),(f),##__VA_ARGS__)
#define WLOCALTIME(c,r) (localtime_s((r),(c))==0)
#endif
#endif /* WSTRING_USER */
/* get local time for debug print out */
#ifdef USE_WINDOWS_API
#define WTIME time
#define WLOCALTIME(c,r) (localtime_s((r),(c))==0)
#elif defined(MICROCHIP_MPLAB_HARMONY)
#define WTIME XTIME
#define WLOCALTIME(c,r) (localtime((c)) != NULL && \
WMEMCPY((r), localtime((c)), sizeof(struct tm)))
#else
#define WTIME time
#define WLOCALTIME(c,r) (localtime_r((c),(r))!=NULL)
#endif
/* setup compiler inlining */
#ifndef INLINE

View File

@ -30,6 +30,10 @@
#include <wolfssh/visibility.h>
#ifdef WOLFSSL_USER_SETTINGS
#include "user_settings.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -26,7 +26,11 @@
#pragma once
#ifdef WOLFSSL_USER_SETTINGS
#include <wolfssl/wolfcrypt/settings.h>
#else
#include <wolfssl/options.h>
#endif
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssh/settings.h>
#include <wolfssh/version.h>

View File

@ -20,6 +20,19 @@
#include <wspiapi.h>
#endif
#define SOCKET_T SOCKET
#define NUM_SOCKETS 5
#elif defined(MICROCHIP_MPLAB_HARMONY) || defined(MICROCHIP_TCPIP)
#include "tcpip/tcpip.h"
#include <signal.h>
#ifdef MICROCHIP_MPLAB_HARMONY
#ifndef htons
#define htons TCPIP_Helper_htons
#endif
#define SOCKET_T TCP_SOCKET
#define XNTOHS TCPIP_Helper_ntohs
#endif
#define socklen_t int
#define NUM_SOCKETS 1
#else /* USE_WINDOWS_API */
#include <unistd.h>
#include <netdb.h>
@ -34,12 +47,13 @@
#include <signal.h> /* ignore SIGPIPE */
#endif
#define SOCKET_T int
#define NUM_SOCKETS 5
#endif /* USE_WINDOWS_API */
/* Socket Handling */
#ifndef WOLFSSH_SOCKET_INVALID
#ifdef USE_WINDOWS_API
#if defined(USE_WINDOWS_API) || defined(MICROCHIP_MPLAB_HARMONY)
#define WOLFSSH_SOCKET_INVALID ((SOCKET_T)INVALID_SOCKET)
#elif defined(WOLFSSH_TIRTOS)
#define WOLFSSH_SOCKET_INVALID ((SOCKET_T)-1)
@ -67,6 +81,13 @@
#ifdef USE_WINDOWS_API
#define WCLOSESOCKET(s) closesocket(s)
#define WSTARTTCP() do { WSADATA wsd; WSAStartup(0x0002, &wsd); } while(0)
#elif defined(MICROCHIP_TCPIP) || defined(MICROCHIP_MPLAB_HARMONY)
#ifdef MICROCHIP_MPLAB_HARMONY
#define WCLOSESOCKET(s) TCPIP_TCP_Close((s))
#else
#define WCLOSESOCKET(s) closesocket((s))
#endif
#define WSTARTTCP()
#else
#define WCLOSESOCKET(s) close(s)
#define WSTARTTCP()
@ -279,6 +300,8 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
#ifdef CYASSL_MDK_ARM
int err;
struct hostent* entry = gethostbyname(peer, &err);
#elif defined(MICROCHIP_MPLAB_HARMONY)
struct hostent* entry = gethostbyname((char*)peer);
#else
struct hostent* entry = gethostbyname(peer);
#endif
@ -303,8 +326,15 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
if ((size_t)peer == INADDR_ANY)
addr->sin_addr.s_addr = INADDR_ANY;
else {
if (!useLookup)
if (!useLookup) {
#ifdef MICROCHIP_MPLAB_HARMONY
IPV4_ADDR ip4;
TCPIP_Helper_StringToIPAddress(peer, &ip4);
addr->sin_addr.s_addr = ip4.Val;
#else
addr->sin_addr.s_addr = inet_addr(peer);
#endif
}
}
#else
addr->sin6_family = AF_INET_V;
@ -348,7 +378,14 @@ static INLINE void build_addr(SOCKADDR_IN_T* addr, const char* peer,
static INLINE void tcp_socket(SOCKET_T* sockFd)
{
#ifdef MICROCHIP_MPLAB_HARMONY
/* creates socket in listen or connect */
*sockFd = 0;
#elif defined(MICROCHIP_TCPIP)
*sockFd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
#else
*sockFd = socket(AF_INET_V, SOCK_STREAM, 0);
#endif
#ifdef USE_WINDOWS_API
if (*sockFd == INVALID_SOCKET)
@ -369,17 +406,25 @@ static INLINE void tcp_socket(SOCKET_T* sockFd)
}
#elif defined(CYASSL_MDK_ARM)
/* nothing to define */
#elif defined(MICROCHIP_MPLAB_HARMONY) && !defined(_FULL_SIGNAL_IMPLEMENTATION)
/* not full signal implementation */
#else /* no S_NOSIGPIPE */
signal(SIGPIPE, SIG_IGN);
#endif /* S_NOSIGPIPE */
#if defined(TCP_NODELAY)
{
#ifdef MICROCHIP_MPLAB_HARMONY
if (!TCPIP_TCP_OptionsSet(*sockFd, TCP_OPTION_NODELAY, (void*)1)) {
err_sys("setsockopt TCP_NODELAY failed\n");
}
#else
int on = 1;
socklen_t len = sizeof(on);
int res = setsockopt(*sockFd, IPPROTO_TCP, TCP_NODELAY, &on, len);
if (res < 0)
err_sys("setsockopt TCP_NODELAY failed\n");
#endif
}
#endif
#endif /* USE_WINDOWS_API */
@ -390,9 +435,13 @@ static INLINE void tcp_socket(SOCKET_T* sockFd)
#define XNTOHS(a) ntohs((a))
#endif
static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr)
{
#ifdef MICROCHIP_MPLAB_HARMONY
/* does bind and listen and returns the socket */
*sockfd = TCPIP_TCP_ServerOpen(IP_ADDRESS_TYPE_IPV4, *port, 0);
return;
#else
SOCKADDR_IN_T addr;
/* don't use INADDR_ANY by default, firewall may block, make user switch
@ -403,7 +452,12 @@ static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr)
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_MDK_ARM)\
&& !defined(WOLFSSL_KEIL_TCP_NET)
{
int res, on = 1;
int res;
#ifdef MICROCHIP_TCPIP
const byte on = 1; /* account for function signature */
#else
int on = 1;
#endif
socklen_t len = sizeof(on);
res = setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);
if (res < 0)
@ -413,7 +467,7 @@ static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr)
if (bind(*sockfd, (const struct sockaddr*)&addr, sizeof(addr)) != 0)
err_sys("tcp bind failed");
if (listen(*sockfd, 5) != 0)
if (listen(*sockfd, NUM_SOCKETS) != 0)
err_sys("tcp listen failed");
#if !defined(USE_WINDOWS_API) && !defined(WOLFSSL_TIRTOS)
if (*port == 0) {
@ -427,12 +481,13 @@ static INLINE void tcp_listen(SOCKET_T* sockfd, word16* port, int useAnyAddr)
}
}
#endif
#endif /* MICROCHIP_MPLAB_HARMONY */
}
/* Wolf Root Directory Helper */
/* KEIL-RL File System does not support relative directory */
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS)
#if !defined(WOLFSSL_MDK_ARM) && !defined(WOLFSSL_KEIL_FS) && !defined(WOLFSSL_TIRTOS) \
&& !defined(NO_WOLFSSL_DIR)
/* Maximum depth to search for WolfSSL root */
#define MAX_WOLF_ROOT_DEPTH 5