mirror of https://github.com/wolfSSL/wolfssh.git
commit
ff05e7c9cd
|
@ -85,7 +85,7 @@ int wfopen(WFILE** f, const char* filename, const char* mode)
|
||||||
#if (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP)) && \
|
#if (defined(WOLFSSH_SFTP) || defined(WOLFSSH_SCP)) && \
|
||||||
!defined(NO_WOLFSSH_SERVER)
|
!defined(NO_WOLFSSH_SERVER)
|
||||||
|
|
||||||
#if defined(USE_WINDOWS_API)
|
#if defined(USE_WINDOWS_API) || defined(WOLFSSL_NUCLEUS)
|
||||||
|
|
||||||
/* This is current inline in the source. */
|
/* This is current inline in the source. */
|
||||||
|
|
||||||
|
|
|
@ -3380,7 +3380,8 @@ int SFTP_GetAttributes(const char* fileName, WS_SFTP_FILEATRB* atr, byte link,
|
||||||
}
|
}
|
||||||
|
|
||||||
atr->flags |= WOLFSSH_FILEATRB_SIZE;
|
atr->flags |= WOLFSSH_FILEATRB_SIZE;
|
||||||
atr->sz = (word64)stats.fsize;
|
atr->sz[0] = (word32)(stats.fsize);
|
||||||
|
atr->sz[1] = (word32)(0);
|
||||||
|
|
||||||
/* get additional attributes */
|
/* get additional attributes */
|
||||||
{
|
{
|
||||||
|
@ -3443,7 +3444,8 @@ int SFTP_GetAttributes_Handle(WOLFSSH* ssh, byte* handle, int handleSz,
|
||||||
WMEMSET(atr, 0, sizeof(WS_SFTP_FILEATRB));
|
WMEMSET(atr, 0, sizeof(WS_SFTP_FILEATRB));
|
||||||
|
|
||||||
atr->flags |= WOLFSSH_FILEATRB_SIZE;
|
atr->flags |= WOLFSSH_FILEATRB_SIZE;
|
||||||
atr->sz = (word64)stats.fsize;
|
atr->sz[0] = (word32)(stats.fsize);
|
||||||
|
atr->sz[1] = (word32)(0);
|
||||||
|
|
||||||
{
|
{
|
||||||
byte atrib = stats.fattribute;
|
byte atrib = stats.fattribute;
|
||||||
|
|
|
@ -349,7 +349,7 @@ extern "C" {
|
||||||
static inline int wPwrite(WFD fd, unsigned char* buf, unsigned int sz,
|
static inline int wPwrite(WFD fd, unsigned char* buf, unsigned int sz,
|
||||||
const unsigned int* shortOffset)
|
const unsigned int* shortOffset)
|
||||||
{
|
{
|
||||||
long ofst = ((long)shortOffset[1] << 32) | shortOffset[0];
|
INT32 ofst = shortOffset[0];
|
||||||
if (ofst > 0) {
|
if (ofst > 0) {
|
||||||
NU_Seek(fd, ofst, 0);
|
NU_Seek(fd, ofst, 0);
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ extern "C" {
|
||||||
static inline int wPread(WFD fd, unsigned char* buf, unsigned int sz,
|
static inline int wPread(WFD fd, unsigned char* buf, unsigned int sz,
|
||||||
const unsigned int* shortOffset)
|
const unsigned int* shortOffset)
|
||||||
{
|
{
|
||||||
long ofst = ((long)shortOffset[1] << 32) | shortOffset[0];
|
INT32 ofst = shortOffset[0];
|
||||||
if (ofst > 0) {
|
if (ofst > 0) {
|
||||||
NU_Seek(fd, ofst, 0);
|
NU_Seek(fd, ofst, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,22 @@
|
||||||
/* test.h */
|
/* test.h
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014-2019 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -572,26 +590,54 @@ enum {
|
||||||
WS_SELECT_ERROR_READY
|
WS_SELECT_ERROR_READY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_NUCLEUS
|
||||||
|
#define WFD_SET_TYPE FD_SET
|
||||||
|
#define WFD_SET NU_FD_Set
|
||||||
|
#define WFD_ZERO NU_FD_Init
|
||||||
|
#define WFD_ISSET NU_FD_Check
|
||||||
|
#else
|
||||||
|
#define WFD_SET_TYPE fd_set
|
||||||
|
#define WFD_SET FD_SET
|
||||||
|
#define WFD_ZERO FD_ZERO
|
||||||
|
#define WFD_ISSET FD_ISSET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* returns 1 or greater when something is ready to be read */
|
||||||
|
static INLINE int wSelect(int nfds, WFD_SET_TYPE* recvfds,
|
||||||
|
WFD_SET_TYPE *writefds, WFD_SET_TYPE *errfds, struct timeval* timeout)
|
||||||
|
{
|
||||||
|
#ifdef WOLFSSL_NUCLEUS
|
||||||
|
int ret = NU_Select (nfds, recvfds, writefds, errfds,
|
||||||
|
(UNSIGNED)timeout->tv_sec);
|
||||||
|
if (ret == NU_SUCCESS) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
|
return select(nfds, recvfds, writefds, errfds, timeout);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
|
static INLINE int tcp_select(SOCKET_T socketfd, int to_sec)
|
||||||
{
|
{
|
||||||
fd_set recvfds, errfds;
|
WFD_SET_TYPE recvfds, errfds;
|
||||||
int nfds = (int)socketfd + 1;
|
int nfds = (int)socketfd + 1;
|
||||||
struct timeval timeout = {(to_sec > 0) ? to_sec : 0, 0};
|
struct timeval timeout = {(to_sec > 0) ? to_sec : 0, 0};
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
FD_ZERO(&recvfds);
|
WFD_ZERO(&recvfds);
|
||||||
FD_SET(socketfd, &recvfds);
|
WFD_SET(socketfd, &recvfds);
|
||||||
FD_ZERO(&errfds);
|
WFD_ZERO(&errfds);
|
||||||
FD_SET(socketfd, &errfds);
|
WFD_SET(socketfd, &errfds);
|
||||||
|
|
||||||
result = select(nfds, &recvfds, NULL, &errfds, &timeout);
|
result = wSelect(nfds, &recvfds, NULL, &errfds, &timeout);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
return WS_SELECT_TIMEOUT;
|
return WS_SELECT_TIMEOUT;
|
||||||
else if (result > 0) {
|
else if (result > 0) {
|
||||||
if (FD_ISSET(socketfd, &recvfds))
|
if (WFD_ISSET(socketfd, &recvfds))
|
||||||
return WS_SELECT_RECV_READY;
|
return WS_SELECT_RECV_READY;
|
||||||
else if(FD_ISSET(socketfd, &errfds))
|
else if(WFD_ISSET(socketfd, &errfds))
|
||||||
return WS_SELECT_ERROR_READY;
|
return WS_SELECT_ERROR_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue