Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions netutils/dropbear/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ if(CONFIG_NETUTILS_DROPBEAR)
list(FILTER LIBTOMCRYPT_SRCS EXCLUDE REGEX ".*/prngs/sober128tab\\.c$")
list(APPEND DROPBEAR_SRCS ${LIBTOMCRYPT_SRCS})

if(CONFIG_NETUTILS_DROPBEAR_SCP)
list(APPEND DROPBEAR_SRCS dropbear/src/scpmisc.c port/nuttx_scp.c)
endif()

nuttx_add_application(
NAME
${PROGNAME}
Expand All @@ -150,6 +154,20 @@ if(CONFIG_NETUTILS_DROPBEAR)
DEPENDS
${DROPBEAR_UNPACKNAME})

if(CONFIG_NETUTILS_DROPBEAR_SCP)
nuttx_add_application(
NAME
scp
SRCS
dropbear/src/scp.c
STACKSIZE
${CONFIG_NETUTILS_DROPBEAR_SCP_STACKSIZE}
PRIORITY
${CONFIG_NETUTILS_DROPBEAR_SCP_PRIORITY}
DEPENDS
${DROPBEAR_UNPACKNAME})
endif()

target_include_directories(
${PROGNAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
Expand All @@ -160,6 +178,14 @@ if(CONFIG_NETUTILS_DROPBEAR)
${CMAKE_CURRENT_SOURCE_DIR}/dropbear/libtommath
${CMAKE_CURRENT_SOURCE_DIR}/../../nshlib)

if(CONFIG_NETUTILS_DROPBEAR_SCP)
target_include_directories(
scp
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/port
${CMAKE_CURRENT_SOURCE_DIR}/dropbear
${CMAKE_CURRENT_SOURCE_DIR}/dropbear/src)
endif()

if(CONFIG_NETUTILS_DROPBEAR_COMPRESSION)
target_include_directories(
${PROGNAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../system/zlib/zlib)
Expand All @@ -169,17 +195,46 @@ if(CONFIG_NETUTILS_DROPBEAR)
${PROGNAME} PRIVATE LOCALOPTIONS_H_EXISTS=1 DROPBEAR_NUTTX=1
DROPBEAR_NUTTX_PASSWD=1)

if(CONFIG_NETUTILS_DROPBEAR_SCP)
target_compile_definitions(
scp PRIVATE LOCALOPTIONS_H_EXISTS=1 DROPBEAR_NUTTX=1
DROPBEAR_NUTTX_PASSWD=1)
endif()

set_source_files_properties(
dropbear_nshsession.c
PROPERTIES COMPILE_DEFINITIONS
"Channel=dropbear_channel;ChanType=dropbear_chantype")

if(CONFIG_NETUTILS_DROPBEAR_SCP)
set_source_files_properties(
dropbear/src/scp.c
PROPERTIES
COMPILE_DEFINITIONS
"xmalloc=dropbear_scp_xmalloc;xrealloc=dropbear_scp_xrealloc;xfree=dropbear_scp_xfree;execvp=dropbear_scp_execvp"
)
set_source_files_properties(
dropbear/src/scpmisc.c
PROPERTIES
COMPILE_DEFINITIONS
"xmalloc=dropbear_scp_xmalloc;xrealloc=dropbear_scp_xrealloc;xfree=dropbear_scp_xfree"
)
endif()

# LTC_SOURCE must be set only for libtomcrypt sources.
set_source_files_properties(${LIBTOMCRYPT_SRCS} PROPERTIES COMPILE_DEFINITIONS
LTC_SOURCE=1)

target_compile_options(${PROGNAME} PRIVATE -Wno-pointer-sign -Wno-format)

if(CONFIG_NETUTILS_DROPBEAR_SCP)
target_compile_options(
scp
PRIVATE -Wno-pointer-sign -Wno-format -include
${CMAKE_CURRENT_SOURCE_DIR}/port/nuttx_scp.h
-Wno-strict-prototypes)
endif()

target_sources(apps PRIVATE ${DROPBEAR_SRCS})

endif()
20 changes: 20 additions & 0 deletions netutils/dropbear/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ config NETUTILS_DROPBEAR_SHELL_STACKSIZE
int "Dropbear NSH session task stack size"
default 8192

config NETUTILS_DROPBEAR_SCP
bool "Enable scp remote copy helper"
default y
depends on PIPES
---help---
Build Dropbear's scp program and allow SSH exec requests so a host
scp client can copy files to and from NuttX using the legacy scp
protocol. This does not build a full SSH client for initiating scp
transfers from the target.

config NETUTILS_DROPBEAR_SCP_STACKSIZE
int "Dropbear scp stack size"
default 32768
depends on NETUTILS_DROPBEAR_SCP

config NETUTILS_DROPBEAR_SCP_PRIORITY
int "Dropbear scp priority"
default 100
depends on NETUTILS_DROPBEAR_SCP

config NETUTILS_DROPBEAR_PORT
int "Dropbear listen port"
default 2222
Expand Down
26 changes: 26 additions & 0 deletions netutils/dropbear/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ PROGNAME = $(CONFIG_NETUTILS_DROPBEAR_PROGNAME)
PRIORITY = $(CONFIG_NETUTILS_DROPBEAR_PRIORITY)
STACKSIZE = $(CONFIG_NETUTILS_DROPBEAR_STACKSIZE)

ifneq ($(CONFIG_NETUTILS_DROPBEAR_SCP),)
PROGNAME += scp
PRIORITY += $(CONFIG_NETUTILS_DROPBEAR_SCP_PRIORITY)
STACKSIZE += $(CONFIG_NETUTILS_DROPBEAR_SCP_STACKSIZE)
endif

CFLAGS += ${INCDIR_PREFIX}"$(APPDIR)$(DELIM)netutils$(DELIM)dropbear"
CFLAGS += ${INCDIR_PREFIX}"$(APPDIR)$(DELIM)netutils$(DELIM)dropbear$(DELIM)port"
CFLAGS += ${INCDIR_PREFIX}"$(APPDIR)$(DELIM)netutils$(DELIM)dropbear$(DELIM)dropbear"
Expand Down Expand Up @@ -116,11 +122,31 @@ TOMCRYPT_SRCS = $(shell if [ -d "$(DROPBEAR_UNPACKNAME)/libtomcrypt/src" ]; then
CSRCS += $(TOMMATH_SRCS)
CSRCS += $(TOMCRYPT_SRCS)

ifneq ($(CONFIG_NETUTILS_DROPBEAR_SCP),)
CSRCS += dropbear/src/scpmisc.c
CSRCS += port/nuttx_scp.c
endif

# Match the ESP-IDF port behavior: LTC_SOURCE is only for libtomcrypt sources.
$(foreach src,$(TOMCRYPT_SRCS),$(eval $(src)_CFLAGS += ${DEFINE_PREFIX}LTC_SOURCE=1))

MAINSRC = dropbear_main.c

ifneq ($(CONFIG_NETUTILS_DROPBEAR_SCP),)
MAINSRC += dropbear/src/scp.c

dropbear/src/scp.c_CFLAGS += ${DEFINE_PREFIX}xmalloc=dropbear_scp_xmalloc
dropbear/src/scp.c_CFLAGS += ${DEFINE_PREFIX}xrealloc=dropbear_scp_xrealloc
dropbear/src/scp.c_CFLAGS += ${DEFINE_PREFIX}xfree=dropbear_scp_xfree
dropbear/src/scp.c_CFLAGS += ${DEFINE_PREFIX}execvp=dropbear_scp_execvp
dropbear/src/scp.c_CFLAGS += -include port/nuttx_scp.h
dropbear/src/scp.c_CFLAGS += -Wno-strict-prototypes

dropbear/src/scpmisc.c_CFLAGS += ${DEFINE_PREFIX}xmalloc=dropbear_scp_xmalloc
dropbear/src/scpmisc.c_CFLAGS += ${DEFINE_PREFIX}xrealloc=dropbear_scp_xrealloc
dropbear/src/scpmisc.c_CFLAGS += ${DEFINE_PREFIX}xfree=dropbear_scp_xfree
endif

$(DROPBEAR_ZIP):
@echo "Downloading: $(DROPBEAR_ZIP)"
$(Q) curl -L -o $(DROPBEAR_ZIP) $(DROPBEAR_URL)/$(DROPBEAR_ZIP)
Expand Down
Loading
Loading