mirror of https://github.com/wolfSSL/wolfssh.git
CubePack: Better USER_IO support & cleanup warnings
parent
360abcfa09
commit
682e74fb40
|
@ -10,7 +10,7 @@ The wolfSSH Cube Pack can be found [here](https://www.wolfssl.com/files/ide/I-CU
|
|||
|
||||
4. In the `Software Packs` configuration category of the `.ioc` file, click on the wolfSSH pack and enable the library by checking the box.
|
||||
|
||||
5. Since LwIP is a dependency for the Cube Pack, enable LwIP in the `Middleware` configuration category of the project. Also enable the `LWIP_DNS` option in the LwIP configuration settings.
|
||||
5. The Pack defaults to using custom IO provided by the user. Modify `ide/STM32CUBE/userio_template.h` to supply the custom IO. If you'd like to use LwIP instead, configure the wolfSSH IO settings in the `.ioc` to enable LwIP compatibilty. You'll also have to enable LwIP in the `Middleware` configuration category of the project. Enable the `LWIP_DNS` option in the LwIP configuration settings.
|
||||
|
||||
6. Save your changes and select yes to the prompt asking about generating code.
|
||||
|
||||
|
@ -19,4 +19,4 @@ The wolfSSH Cube Pack can be found [here](https://www.wolfssl.com/files/ide/I-CU
|
|||
## Notes
|
||||
- Make sure to make [these changes](https://github.com/wolfSSL/wolfssl/tree/master/IDE/STM32Cube#stm32-printf) to redirect the printf's to the UART.
|
||||
|
||||
- If looking to enable filesystem support, the pack assumes the user has defined their own filesystem in `wolfssh/myFilesystem.h`. That file will originally contain a dummy filesystem. If going the FATFS route, make sure to replace `#define WOLFSSH_USER_FILESYSTEM` with `#define WOLFSSH_FATFS` in the `wolfSSL.I-CUBE-wolfSSH_conf.h` header file. The wolfSSL Cube Pack also defaults to disabling filesystem support so make sure to remove `#define NO_FILESYSTEM` from `wolfSSL.I-CUBE-wolfSSL_conf.h`.
|
||||
- If looking to enable filesystem support (required for SFTP), the pack assumes the user has defined their own filesystem in `wolfssh/myFilesystem.h`. That file will originally contain a dummy filesystem. If going the FATFS route, make sure to replace `#define WOLFSSH_USER_FILESYSTEM` with `#define WOLFSSH_FATFS` in the `wolfSSL.I-CUBE-wolfSSH_conf.h` header file. The wolfSSL Cube Pack also defaults to disabling filesystem support so make sure to remove `#define NO_FILESYSTEM` from `wolfSSL.I-CUBE-wolfSSL_conf.h`.
|
||||
|
|
|
@ -94,9 +94,11 @@ extern ${variable.value} ${variable.name};
|
|||
/* ------------------------------------------------------------------------- */
|
||||
/* wolfSSH IO */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
#define WOLFSSH_LWIP
|
||||
/* Remove the LWIP define and uncomment the line below to use user defined IO */
|
||||
/* #define WOLFSSL_USER_IO */
|
||||
#if defined(WOLFSSH_CONF_IO) && WOLFSSH_CONF_IO == 2
|
||||
#define WOLFSSH_LWIP
|
||||
#else
|
||||
#define WOLFSSH_USER_IO
|
||||
#endif
|
||||
|
||||
/* To be defined for the target Socket API */
|
||||
#define WSTARTTCP()
|
||||
|
@ -140,6 +142,8 @@ extern ${variable.value} ${variable.name};
|
|||
#define CURVE25519_SMALL
|
||||
#define HAVE_ED25519
|
||||
|
||||
#define WOLFSSH_IGNORE_FILE_WARN
|
||||
|
||||
typedef unsigned int size_t;
|
||||
|
||||
/* defines for unit tests */
|
||||
|
|
|
@ -40,107 +40,107 @@ 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){
|
||||
static inline int WFOPEN(FILE **f, const char *n, const char *m){
|
||||
(void) n; (void) m; (void)f;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int WFCLOSE(FILE *f) {
|
||||
static inline int WFCLOSE(FILE *f) {
|
||||
(void) f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t WFREAD(void *b, size_t s, size_t n, FILE *f) {
|
||||
static inline 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) {
|
||||
static inline 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) {
|
||||
static inline int WFSEEK(FILE *f, long int p, int m) {
|
||||
(void) f; (void) p; (void) m;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long int WFTELL(FILE *f) {
|
||||
static inline long int WFTELL(FILE *f) {
|
||||
(void) f;
|
||||
return 0;
|
||||
}
|
||||
static void WREWIND(FILE *f) {
|
||||
static inline void WREWIND(FILE *f) {
|
||||
(void) f;
|
||||
}
|
||||
|
||||
static int WOPEN (const char* n, int f, int m) {
|
||||
static inline int WOPEN (const char* n, int f, int m) {
|
||||
(void) f; (void) n; (void) m;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int WCLOSE(int f) {
|
||||
static inline int WCLOSE(int f) {
|
||||
(void) f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static size_t WPREAD(int f, void* b, size_t c, off_t *o) {
|
||||
static inline 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) {
|
||||
static inline 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){
|
||||
static inline 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){
|
||||
static inline int WRMDIR(void *fs, const char *p){
|
||||
(void) p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int WMKDIR(void *fs, const char *p, mode_t m) {
|
||||
static inline int WMKDIR(void *fs, const char *p, mode_t m) {
|
||||
(void) p; (void) m;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int WREMOVE(void *fs, const char *p){
|
||||
static inline int WREMOVE(void *fs, const char *p){
|
||||
(void) fs; (void) p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int WRENAME(void *fs, const char *p, const char *np){
|
||||
static inline 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) {
|
||||
static inline int WSTAT(const char *p, stat_t *b) {
|
||||
(void) p; (void)b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int WLSTAT(const char *p, stat_t *b) {
|
||||
static inline 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) {
|
||||
static inline 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,
|
||||
static inline 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,
|
||||
static inline int SFTP_GetAttributes_Handle(void* ssh, byte* handle, int handleSz,
|
||||
void* atr) {
|
||||
(void)ssh; (void)handle; (void)handleSz;
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
/* userio_template.h
|
||||
*
|
||||
* Copyright (C) 2014-2023 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 USERIO_TEMPLATE_H
|
||||
#define USERIO_TEMPLATE_H
|
||||
|
||||
#ifdef WOLFSSH_USER_IO
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
#define SOCK_RAW 3
|
||||
|
||||
#define SOL_SOCKET 0xfff
|
||||
#define SO_REUSEADDR 0x0004
|
||||
|
||||
#define AF_INET 2
|
||||
#define INADDR_ANY ((uint32_t)0x00000000UL)
|
||||
|
||||
#define socklen_t uint32_t
|
||||
|
||||
typedef struct { int s_addr; } in_addr;
|
||||
|
||||
struct sockaddr { int i; };
|
||||
|
||||
typedef struct sockaddr sockaddr;
|
||||
|
||||
struct sockaddr_in{
|
||||
int sin_len;
|
||||
int sin_family;
|
||||
int sin_port;
|
||||
in_addr sin_addr;
|
||||
};
|
||||
|
||||
typedef struct sockaddr_in sockaddr_in;
|
||||
|
||||
struct hostent{
|
||||
char *h_name;
|
||||
int h_length;
|
||||
char **h_addr_list;
|
||||
};
|
||||
|
||||
typedef struct hostent hostent;
|
||||
|
||||
static inline int inet_addr(const char* n){
|
||||
(void) n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int htons(unsigned int n){
|
||||
(void) n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int ntohs(unsigned int n){
|
||||
(void) n;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int socket(int d, int t, int p) {
|
||||
(void) d; (void) t; (void) p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int setsockopt(int s, int l, int n, const void *o,
|
||||
socklen_t len) {
|
||||
(void) s; (void) l; (void) n; (void) o; (void) len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int getsockname(int s, struct sockaddr *n, socklen_t* len) {
|
||||
(void) s; (void) n; (void) len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bind(int s, const struct sockaddr *n, socklen_t l) {
|
||||
(void) s; (void) n; (void) l;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int listen(int s, int b) {
|
||||
(void) s; (void) b;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct hostent* gethostbyname(const char* n) {
|
||||
(void) n;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* WOLFSSH_USER_IO */
|
||||
|
||||
#endif
|
|
@ -51,7 +51,8 @@
|
|||
|
||||
|
||||
/* Check for if compiling misc.c when not needed. */
|
||||
#if !defined(WOLFSSH_MISC_INCLUDED) && !defined(NO_INLINE)
|
||||
#if !defined(WOLFSSH_MISC_INCLUDED) && !defined(NO_INLINE) && \
|
||||
!defined(WOLFSSH_IGNORE_FILE_WARN)
|
||||
#define MISC_WARNING "misc.c does not need to be compiled when using inline (NO_INLINE not defined))"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
@ -60,7 +61,7 @@
|
|||
#pragma message("warning: " MISC_WARNING)
|
||||
#endif
|
||||
|
||||
#else /* !WOLFSSL_MISC_INCLUDED && !NO_INLINE */
|
||||
#else /* !WOLFSSL_MISC_INCLUDED && !NO_INLINE && !WOLFSSH_IGNORE_FILE_WARN */
|
||||
|
||||
|
||||
#ifndef min
|
||||
|
|
|
@ -126,6 +126,16 @@
|
|||
#endif
|
||||
#define SOCKET_T int
|
||||
#define NUM_SOCKETS 5
|
||||
#elif defined(WOLFSSH_USER_IO)
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <fcntl.h>
|
||||
#include "userio_template.h"
|
||||
#ifndef SO_NOSIGPIPE
|
||||
#include <signal.h> /* ignore SIGPIPE */
|
||||
#endif
|
||||
#define SOCKET_T int
|
||||
#define NUM_SOCKETS 5
|
||||
#else /* USE_WINDOWS_API */
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
|
|
Loading…
Reference in New Issue