add echoserver project for EWARM

pull/332/head
Takashi Kojo 2021-04-23 08:28:38 +09:00
parent 8dae886735
commit 14f9c4e63f
9 changed files with 5261 additions and 257 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,155 @@
/* dummy_filesystem.h
*
* Copyright (C) 2014-2020 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 DUMMY_FILESYSTEM_H
#define DUMMY_FILESYSTEM_H
#ifdef WOLFSSH_USER_FILESYSTEM
typedef unsigned int off_t;
typedef int mode_t;
#define WFILE int
typedef int FILE;
#define WSEEK_END SEEK_END
#define WBADFILE NULL
#define WS_DELIM '/'
enum {
WOLFSSH_O_RDWR, WOLFSSH_O_RDONLY, WOLFSSH_O_WRONLY,
WOLFSSH_O_APPEND, WOLFSSH_O_CREAT, WOLFSSH_O_TRUNC, WOLFSSH_O_EXCL
} ;
#define WSTAT_T stat_t
typedef struct { int i; } stat_t;
#define WFD int
enum { O_RDWR, O_RDONLY, O_WRONLY, O_APPEND, O_CREAT, O_TRUNC, O_EXCL } ;
static int WFOPEN(FILE **f, const char *n, const char *m){
(void) n; (void) m; (void)f;
return NULL;
}
static int WFCLOSE(FILE *f) {
(void) f;
return 0;
}
static size_t WFREAD(void *b, size_t s, size_t n, FILE *f) {
(void) b; (void) s; (void) n; (void) f;
return 0;
}
static size_t WFWRITE(const void *b, size_t s, size_t n, FILE *f) {
(void) b; (void) s; (void) n; (void) f;
return 0;
}
static int WFSEEK(FILE *f, long int p, int m) {
(void) f; (void) p; (void) m;
return 0;
}
static long int WFTELL(FILE *f) {
(void) f;
return 0;
}
static void WREWIND(FILE *f) {
(void) f;
}
static int WOPEN (const char* n, int f, int m) {
(void) f; (void) n; (void) m;
return 0;
}
static int WCLOSE(int f) {
(void) f;
return 0;
}
static size_t WPREAD(int f, void* b, size_t c, off_t *o) {
(void) f; (void) b; (void) c; (void)o;
return 0;
}
static size_t WPWRITE(int f, void* b, size_t c, off_t *o) {
(void) f; (void) b; (void) c; (void)o;
return 0;
}
static char *WGETCWD(void *fs, char *f, size_t l){
(void) fs; (void) f; (void) l;
return 0;
}
static int WRMDIR(void *fs, const char *p){
(void) p;
return 0;
}
static int WMKDIR(void *fs, const char *p, mode_t m) {
(void) p; (void) m;
return 0;
}
static int WREMOVE(void *fs, const char *p){
(void) fs; (void) p;
return 0;
}
static int WRENAME(void *fs, const char *p, const char *np){
(void) fs; (void) p; (void)np;
return 0;
}
static int WSTAT(const char *p, stat_t *b) {
(void) p; (void)b;
return 0;
}
static int WLSTAT(const char *p, stat_t *b) {
(void) p; (void)b;
return 0;
}
static int WCHMOD(void *fs, const char *p, mode_t m) {
(void) fs; (void) p; (void)m;
return 0;
}
static int SFTP_GetAttributes(void* fs, const char* fileName,
void* atr, byte link, void* heap) {
(void)fs; (void)fileName; (void)atr; (void)link; (void)heap;
return 0;
}
static int SFTP_GetAttributes_Handle(void* ssh, byte* handle, int handleSz,
void* atr) {
(void)ssh; (void)handle; (void)handleSz;
return 0;
}
#endif /* WOLFSSH_USER_FILESYSTEM */
#endif

View File

@ -337,7 +337,7 @@
</option> </option>
<option> <option>
<name>PreInclude</name> <name>PreInclude</name>
<state>stddef.h</state> <state></state>
</option> </option>
<option> <option>
<name>CompilerMisraOverride</name> <name>CompilerMisraOverride</name>
@ -348,6 +348,7 @@
<state>$PROJ_DIR$\..</state> <state>$PROJ_DIR$\..</state>
<state>$PROJ_DIR$\..\..\..\..</state> <state>$PROJ_DIR$\..\..\..\..</state>
<state>$PROJ_DIR$\..\..\..\..\..\wolfssl</state> <state>$PROJ_DIR$\..\..\..\..\..\wolfssl</state>
<state>$PROJ_DIR$</state>
</option> </option>
<option> <option>
<name>CCStdIncCheck</name> <name>CCStdIncCheck</name>
@ -1048,7 +1049,7 @@
</option> </option>
<option> <option>
<name>IarchiveOutput</name> <name>IarchiveOutput</name>
<state>C:\wolfSupport\PALSYSTEM\wolfssh\ide\IAR-EWARM\Projects\lib\Debug\Exe\wolfSSH-Lib.a</state> <state>C:\wolfSupport\PALTEK\wolfssh\ide\IAR-EWARM\Projects\lib\Debug\Exe\wolfSSH-Lib.a</state>
</option> </option>
</data> </data>
</settings> </settings>

View File

@ -1,137 +0,0 @@
/* dummy_filesystem.c
*
* Copyright (C) 2014-2020 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/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssh/internal.h>
#include <wolfssh/ssh.h>
#ifdef WOLFSSH_USER_FILESYSTEM
#include "myFilesystem.h"
int dummy_wfopen(FILE **f, const char *n, const char *m){
(void) n; (void) m; (void)f;
return NULL;
}
int dummy_fclose(FILE *f) {
(void) f;
return 0;
}
size_t dummy_fread(void *b, size_t s, size_t n, FILE *f) {
(void) b; (void) s; (void) n; (void) f;
return 0;
}
size_t dummy_fwrite(const void *b, size_t s, size_t n, FILE *f) {
(void) b; (void) s; (void) n; (void) f;
return 0;
}
int dummy_fseek(FILE *f, long int p, int m) {
(void) f; (void) p; (void) m;
return 0;
}
long int dummy_ftell(FILE *f) {
(void) f;
return 0;
}
void dummy_rewind(FILE *f) {
(void) f;
}
#define WFD int
int dummy_open (const char* n, int f, int m) {
(void) f; (void) n; (void) m;
return 0;
}
int dummy_close(int f) {
(void) f;
return 0;
}
size_t dummy_pread (int f, void* b, size_t c, off_t *o) {
(void) f; (void) b; (void) c; (void)o;
return 0;
}
size_t dummy_pwrite (int f, void* b, size_t c, off_t *o) {
(void) f; (void) b; (void) c; (void)o;
return 0;
}
char *dummy_getcwd(char *f, size_t l){
(void) f; (void) l;
return 0;
}
int dummy_rmdir(const char *p){
(void) p;
return 0;
}
int dummy_mkdir(const char *p, mode_t m) {
(void) p; (void) m;
return 0;
}
int dummy_remove(const char *p){
(void) p;
return 0;
}
int dummy_rename(const char *p, const char *np){
(void) p; (void)np;
return 0;
}
int dummy_stat(const char *p, stat_t *b) {
(void) p; (void)b;
return 0;
}
int dummy_lstat(const char *p, stat_t *b) {
(void) p; (void)b;
return 0;
}
int dummy_chmod(const char *p, mode_t m) {
(void) p; (void)m;
return 0;
}
int SFTP_GetAttributes(void* fs, const char* fileName,
void* atr, byte link, void* heap) {
(void)fs; (void)fileName; (void)atr; (void)link; (void)heap;
return 0;
}
int SFTP_GetAttributes_Handle(void* ssh, byte* handle, int handleSz,
void* atr) {
(void)ssh; (void)handle; (void)handleSz;
return 0;
}
#endif

View File

@ -1,98 +0,0 @@
/* dummy_filesystem.h
*
* Copyright (C) 2014-2020 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 DUMMY_FILESYSTEM_H
#define DUMMY_FILESYSTEM_H
#ifdef WOLFSSH_USER_FILESYSTEM
typedef unsigned int off_t;
typedef int mode_t;
#define WFILE int
#define WFOPEN(f,n,m) dummy_wfopen((f),(n),(m))
#define WFCLOSE(f) dummy_fclose(f)
#define WFREAD(b,s,a,f) dummy_fread((b),(s),(a),(f))
#define WFWRITE(b,s,a,f) dummy_fwrite((b),(s),(a),(f))
#define WFSEEK(s,o,w) dummy_fseek((s),(o),(w))
#define WFTELL(s) dummy_ftell((s))
#define WREWIND(s) dummy_rewind((s))
#define WSEEK_END SEEK_END
#define WBADFILE NULL
#define WS_DELIM '/'
#define WFD int
typedef int FILE;
enum {
WOLFSSH_O_RDWR, WOLFSSH_O_RDONLY, WOLFSSH_O_WRONLY,
WOLFSSH_O_APPEND, WOLFSSH_O_CREAT, WOLFSSH_O_TRUNC, WOLFSSH_O_EXCL
} ;
#define WOPEN(p, m, f) dummy_open(p, m, f)
#define WCLOSE(f) dummy_close(f)
#define WPREAD(f, b, c, o) dummy_pread(f, b, c, o)
#define WPWRITE(f, b, c, o) dummy_pwrite(f, b, c, o)
#define WGETCWD(f, b, l) dummy_getcwd(b, l)
#define WRMDIR(f, p) dummy_rmdir(p)
#define WMKDIR(f, p, m) dummy_mkdir(p, m)
#define WREMOVE(fs,d) dummy_remove((d))
#define WRENAME(fs,o,n) dummy_rename((o),(n))
#define WSTAT_T stat_t
typedef struct { int i; } stat_t;
#define WSTAT(p,b) dummy_stat((b),(p))
#define WLSTAT(p,b) dummy_lstat((b),(p))
#define WCHMOD(fs,f,m) dummy_chmod((f),(m))
int dummy_wfopen(FILE **f, const char *n, const char *m);
int dummy_fclose(FILE *f);
size_t dummy_fread(void *b, size_t s, size_t n, FILE *f);
size_t dummy_fwrite(const void *b, size_t s, size_t n, FILE *f);
int dummy_fseek(FILE *f, long int p, int m);
long dummy_ftell(FILE *f);
void dummy_rewind(FILE *f);
int dummy_open (const char* n, int f, int m);
int dummy_close(int f);
size_t dummy_pread (int f, void* b, size_t c, off_t *o);
size_t dummy_pwrite (int f, void* b, size_t c, off_t *o);
char *dummy_getcwd(char *f, size_t l);
int dummy_rmdir(const char *p);
int dummy_mkdir(const char *p, mode_t m);
int dummy_remove(const char *p);
int dummy_rename(const char *p, const char *np);
int dummy_stat(const char *p, stat_t *b);
int dummy_lstat(const char *p, stat_t *b);
int dummy_chmod(const char *p, mode_t m);
#define WFD int
enum { O_RDWR, O_RDONLY, O_WRONLY, O_APPEND, O_CREAT, O_TRUNC, O_EXCL } ;
int SFTP_GetAttributes(void* fs, const char* fileName,
void* atr, byte link, void* heap);
int SFTP_GetAttributes_Handle(void* ssh, byte* handle, int handleSz,
void* atr);
#endif /* WOLFSSH_USER_FILESYSTEM */
#endif

View File

@ -23,9 +23,6 @@
#define WC_RSA_BLINDING #define WC_RSA_BLINDING
#define SINGLE_THREADED /* or define RTOS option */ #define SINGLE_THREADED /* or define RTOS option */
#define WOLFSSH_THREAD
typedef unsigned int THREAD_RETURN;
/* #define WOLFSSL_CMSIS_RTOS */ /* #define WOLFSSL_CMSIS_RTOS */
/* #define NO_FILESYSTEM */ /* #define NO_FILESYSTEM */
@ -48,21 +45,11 @@ typedef unsigned int THREAD_RETURN;
/* To be defined for the target Socket API */ /* To be defined for the target Socket API */
#define WSTARTTCP() #define WSTARTTCP()
#define WCLOSESOCKET(s)
#define ChangeToWolfSshRoot(a)
typedef int SOCKADDR_IN_T;
#define WOLFSSH_LOG_PRINTF #define WOLFSSH_LOG_PRINTF
#define WOLFSSL_LOG_PRINTF #define WOLFSSL_LOG_PRINTF
#define XFPRINTF(err, ... ) printf(__VA_ARGS__) #define fprintf(err, ... ) printf(__VA_ARGS__)
#define err_sys(...) printf(__VA_ARGS__)
enum { typedef unsigned int size_t;
WS_SELECT_FAIL,
WS_SELECT_TIMEOUT,
WS_SELECT_RECV_READY,
WS_SELECT_ERROR_READY
};
#endif #endif

View File

@ -8,6 +8,5 @@ EXTRA_DIST+= ide/IAR-EWARM/Projects/lib/wolfSSH-Lib.ewp
EXTRA_DIST+= ide/IAR-EWARM/Projects/lib/wolfSSH-Lib.ewd EXTRA_DIST+= ide/IAR-EWARM/Projects/lib/wolfSSH-Lib.ewd
EXTRA_DIST+= ide/IAR-EWARM/Projects/echoserver/echoserver.ewp EXTRA_DIST+= ide/IAR-EWARM/Projects/echoserver/echoserver.ewp
EXTRA_DIST+= ide/IAR-EWARM/Projects/echoserver/echoserver.ewd EXTRA_DIST+= ide/IAR-EWARM/Projects/echoserver/echoserver.ewd
EXTRA_DIST+= ide/IAR-EWARM/Projects/myFilesystem.c EXTRA_DIST+= ide/IAR-EWARM/Projects/lib/myFilesystem.h
EXTRA_DIST+= ide/IAR-EWARM/Projects/myFilesystem.h
EXTRA_DIST+= ide/IAR-EWARM/Projects/README.md EXTRA_DIST+= ide/IAR-EWARM/Projects/README.md

View File

@ -3329,9 +3329,9 @@ static int DoKexDhReply(WOLFSSH* ssh, byte* buf, word32 len, word32* idx)
if (sigKeyBlock_ptr) if (sigKeyBlock_ptr)
WFREE(sigKeyBlock_ptr, ssh->ctx->heap, DYNTYPE_PRIVKEY); WFREE(sigKeyBlock_ptr, ssh->ctx->heap, DYNTYPE_PRIVKEY);
#ifndef WOLFSSH_NO_ECDSA #ifndef WOLFSSH_NO_ECDSA
if (key_ptr) if (key_ptr)
WFREE(key_ptr, ssh->ctx->heap, DYNTYPE_PRIVKEY); WFREE(key_ptr, ssh->ctx->heap, DYNTYPE_PRIVKEY);
#endif #endif
#endif #endif
WLOG(WS_LOG_DEBUG, "Leaving DoKexDhReply(), ret = %d", ret); WLOG(WS_LOG_DEBUG, "Leaving DoKexDhReply(), ret = %d", ret);
return ret; return ret;