ports: add socat

Fixes #5007
This commit is contained in:
Christian Prochaska 2023-08-28 11:23:24 +02:00 committed by Christian Helmuth
parent abc3c5f0df
commit 4bef85d7bc
9 changed files with 650 additions and 0 deletions

View File

@ -0,0 +1 @@
b901b68ba7c1ae5afabb8b7b913201805edafd9f

View File

@ -0,0 +1,10 @@
LICENSE := GPLv2
VERSION := 1.7.4.4
DOWNLOADS := socat.archive
URL(socat) := http://www.dest-unreach.org/socat/download/socat-$(VERSION).tar.gz
SHA(socat) := 0f8f4b9d5c60b8c53d17b60d79ababc4a0f51b3bb6d2bd3ae8a6a4b9d68f195e
DIR(socat) := src/noux-pkg/socat
PATCHES := src/noux-pkg/socat/socat.patch
PATCH_OPT := -p1 -d src/noux-pkg/socat

View File

@ -0,0 +1,12 @@
content: src/noux-pkg/socat LICENSE
PORT_DIR := $(call port_dir,$(REP_DIR)/ports/socat)
src/noux-pkg/socat:
mkdir -p $@
cp -a $(PORT_DIR)/src/noux-pkg/socat/* $@
cp -a $(REP_DIR)/src/noux-pkg/socat/* $@
LICENSE:
cp $(PORT_DIR)/src/noux-pkg/socat/COPYING $@

View File

@ -0,0 +1 @@
2023-09-27 0e49d77995131e485bd175a29bcfa866604be3ce

View File

@ -0,0 +1,3 @@
libc
noux
posix

291
repos/ports/run/socat.run Normal file
View File

@ -0,0 +1,291 @@
proc platform_supported { } {
if {[have_board pc]} {
return 1
} elseif {[have_board rpi3] && [have_include power_on/qemu]} {
return 1
}
return 0
}
if {![platform_supported]} {
puts "Run script is not supported on this platform"
exit 0
}
create_boot_directory
import_from_depot [depot_user]/src/[base_src] \
[depot_user]/src/init \
[depot_user]/src/terminal_crosslink \
[depot_user]/src/vfs \
[depot_user]/src/fs_rom \
[depot_user]/src/libc \
[depot_user]/src/posix \
[depot_user]/src/socat \
[depot_user]/src/test-terminal_echo
if {[have_include power_on/qemu]} {
build { drivers/uart }
} else {
import_from_depot [depot_user]/pkg/[drivers_nic_pkg] \
[depot_user]/src/nic_router \
[depot_user]/src/vfs_lwip
}
append config {
<config>
<parent-provides>
<service name="LOG"/>
<service name="PD"/>
<service name="CPU"/>
<service name="ROM"/>
<service name="IRQ"/>
<service name="IO_MEM"/>
<service name="IO_PORT"/>
<service name="RM"/>
</parent-provides>
<default-route>
<any-service> <parent/> <any-child/> </any-service>
</default-route>
<default caps="100"/>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides> <service name="Timer"/> </provides>
</start>
}
if { [have_include power_on/qemu] } {
append_if [have_board pc] config {
<start name="uart_drv">
<binary name="pc_uart_drv"/>
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Terminal"/>
<service name="Uart"/>
</provides>
<config>
<policy label_prefix="socat" uart="1"/>
</config>
</start>
}
append_if [have_board rpi3] config {
<start name="uart_drv">
<binary name="rpi3_uart_drv"/>
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Terminal"/>
<service name="Uart"/>
</provides>
<config>
<policy label_prefix="socat" uart="0"/>
</config>
</start>
}
} else {
append config {
<start name="drivers" caps="1000" managing_system="yes">
<resource name="RAM" quantum="32M"/>
<binary name="init"/>
<route>
<service name="ROM" label="config"> <parent label="drivers.config"/> </service>
<service name="Timer"> <child name="timer"/> </service>
<service name="Uplink"> <child name="nic_router"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="nic_router" caps="200">
<resource name="RAM" quantum="10M"/>
<provides>
<service name="Nic"/>
<service name="Uplink"/>
</provides>
<config verbose_domain_state="yes">
<policy label_prefix="socat" domain="downlink"/>
<policy label_prefix="drivers" domain="uplink"/>
<domain name="uplink">
<nat domain="downlink"
tcp-ports="1"
udp-ports="1"
icmp-ids="1"/>
<tcp-forward port="5555" domain="downlink" to="10.0.3.2"/>
</domain>
<domain name="downlink" interface="10.0.3.1/24">
<dhcp-server ip_first="10.0.3.2" ip_last="10.0.3.2"/>
<tcp dst="0.0.0.0/0"><permit-any domain="uplink" /></tcp>
</domain>
</config>
</start>
}
}
append config {
<start name="terminal_crosslink">
<resource name="RAM" quantum="2M"/>
<provides>
<service name="Terminal"/>
</provides>
</start>
<start name="vfs" caps="120">
<resource name="RAM" quantum="30M"/>
<provides><service name="File_system"/></provides>
<config>
<vfs>
<tar name="socat.tar" />
</vfs>
<policy label_prefix="vfs_rom" root="/"/>
<default-policy root="/" writeable="no"/>
</config>
</start>
<start name="vfs_rom">
<resource name="RAM" quantum="30M"/>
<binary name="fs_rom"/>
<provides> <service name="ROM"/> </provides>
<config/>
<route>
<service name="File_system"> <child name="vfs"/> </service>
<any-service> <parent/> </any-service>
</route>
</start>
<start name="socat" caps="200">
<binary name="/bin/socat"/>
<resource name="RAM" quantum="30M" />
<config>
<vfs>
<dir name="dev">
<log/>
<inline name="rtc">2018-01-01 00:01</inline>
<terminal name="crosslink" label="crosslink"/>}
append_if [have_include power_on/qemu] config {
<terminal name="uart" label="uart"/>
}
append config {
</dir>}
if {![have_include power_on/qemu]} {
append config {
<dir name="socket"> <lwip dhcp="yes"/> </dir>
}
}
append config {
<fs/>
</vfs>
<libc stdout="/dev/log"
stderr="/dev/log"
rtc="/dev/rtc"
socket="/socket"/>
<arg value="socat"/>
<arg value="/dev/crosslink"/>}
if {[have_include power_on/qemu]} {
append config {
<arg value="/dev/uart"/>
}
} else {
append config {
<arg value="TCP4-LISTEN:5555"/>
}
}
append config {
</config>
<route>
<service name="File_system"> <child name="vfs"/> </service>
<service name="ROM" label_suffix=".lib.so"> <parent/> </service>
<service name="ROM" label_last="/bin/socat"> <child name="vfs_rom"/> </service>
<service name="Terminal" label="uart">
<child name="uart_drv"/>
</service>
<service name="Terminal" label="crosslink">
<child name="terminal_crosslink"/>
</service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
<start name="test-terminal_echo">
<resource name="RAM" quantum="1M"/>
<route>
<service name="Terminal"> <child name="terminal_crosslink"/> </service>
<any-service> <parent/> <any-child/> </any-service>
</route>
</start>
</config>
}
install_config $config
build_boot_image [build_artifacts]
set port 5555
if {[have_include power_on/qemu]} {
set host "localhost"
# qemu config
append qemu_args " -display none "
if {[have_board rpi3]} {
# connect comport 0 with TCP port $port
append qemu_args " -serial chardev:uart "
# connect comport 1 to stdio
append qemu_args " -serial stdio "
} else {
# connect comport 0 to stdio
append qemu_args " -serial stdio "
# connect comport 1 with TCP port $port
append qemu_args " -serial chardev:uart "
}
append qemu_args " -chardev socket,id=uart,port=$port,host=$host,server,nowait,ipv4 "
run_genode_until {\[init -> uart_drv\].*\n} 30
} else {
set match_string "nic_router. .uplink. dynamic IP config: interface .*\n"
run_genode_until $match_string 30
regexp $match_string $output host
regexp {[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+} $host host
}
# wait a moment for all components to become ready
after 2000
set genode_id [output_spawn_id]
eval spawn socat - TCP:$host:$port
set host_socat_id [list $spawn_id $genode_id]
send "test message\n"
# echo of input by host socat
run_genode_until {test message} 10 $host_socat_id
# log message from test-terminal_echo
run_genode_until {got 13 byte} 10 $genode_id
# intro message from test-terminal_echo
run_genode_until {--- Terminal echo test started - now you can type characters to be echoed. ---} 10 $host_socat_id
# echo from test-terminal_echo
run_genode_until {test message} 10 $host_socat_id

View File

@ -0,0 +1,326 @@
socat.patch
diff --git a/configure b/configure
index a52ae13..3ce708a 100755
--- a/configure
+++ b/configure
@@ -6285,7 +6285,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6321,7 +6321,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6357,7 +6357,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6393,7 +6393,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6429,7 +6429,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6465,7 +6465,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6501,7 +6501,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6537,7 +6537,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6573,7 +6573,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -6632,7 +6632,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sc_cv_type_longlong" >&5
$as_echo "$sc_cv_type_longlong" >&6; }
-ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "#include \"sysincludes.h\"
+ac_fn_c_check_type "$LINENO" "sig_atomic_t" "ac_cv_type_sig_atomic_t" "#include \"${srcdir}/sysincludes.h\"
"
if test "x$ac_cv_type_sig_atomic_t" = xyes; then :
$as_echo "#define HAVE_TYPE_SIG_ATOMIC_T 1" >>confdefs.h
@@ -8109,7 +8109,7 @@ if ${sc_cv_struct_in6_pktinfo+:} false; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -8352,7 +8352,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
@@ -20735,7 +20735,7 @@ else
CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN $(echo "$CFLAGS1" | sed -e 's@-Wall@@g')"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20749,7 +20749,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20763,7 +20763,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20777,7 +20777,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20791,7 +20791,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20805,7 +20805,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20819,7 +20819,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20833,7 +20833,7 @@ if ac_fn_c_try_compile "$LINENO"; then :
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int
main ()
{
@@ -20888,7 +20888,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; return!(sizeof(x.cmsg_len)==sizeof(short));}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -20902,7 +20902,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; x.cmsg_len=-1; return !(x.cmsg_len<0);}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -20925,7 +20925,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; return!(sizeof(x.cmsg_len)==sizeof(int));}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -20939,7 +20939,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; x.cmsg_len=-1; return !(x.cmsg_len<0);}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -20962,7 +20962,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; return !(sizeof(x.cmsg_len)==sizeof(long));}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -20976,7 +20976,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; x.cmsg_len=-1; return !(x.cmsg_len<0);}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -20999,7 +20999,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { struct cmsghdr x; return !(sizeof(x.cmsg_len)==sizeof(long long));}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
@@ -21013,7 +21013,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-#include "sysincludes.h"
+#include "${srcdir}/sysincludes.h"
int main() { x struct cmsghdr; x.cmsg_len=-1; return !(x.cmsg_len<0);}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
diff --git a/configure.ac b/configure.ac
index 9d60473..86c3bd6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -109,7 +109,7 @@ define(AC_CHECK_PROTOTYPE_LIB,[
AC_MSG_CHECKING(for $1 prototype)
AC_CACHE_VAL(sc_cv_have_prototype_lib_$1,
[CFLAGS1="$CFLAGS"; CFLAGS="$ERRONWARN -Wall $CFLAGS1";
- AC_TRY_LINK([#include "sysincludes.h"
+ AC_TRY_LINK([#include "${srcdir}/sysincludes.h"
$2],[return(&$1==(void *)&$1);],
[sc_cv_have_prototype_lib_$1=yes],
[sc_cv_have_prototype_lib_$1=no]);
@@ -868,7 +868,7 @@ if test $sc_cv_type_longlong = yes; then
fi
AC_MSG_RESULT($sc_cv_type_longlong)
-AC_CHECK_TYPE(sig_atomic_t,AC_DEFINE(HAVE_TYPE_SIG_ATOMIC_T),,[#include "sysincludes.h"])
+AC_CHECK_TYPE(sig_atomic_t,AC_DEFINE(HAVE_TYPE_SIG_ATOMIC_T),,[#include "${srcdir}/sysincludes.h"])
AC_MSG_CHECKING(for bool)
AC_CACHE_VAL(sc_cv_type_bool,
@@ -1443,7 +1443,7 @@ fi
dnl check for struct in6_pktinfo
AC_MSG_CHECKING(for struct in6_pktinfo)
AC_CACHE_VAL(sc_cv_struct_in6_pktinfo,
-[AC_TRY_COMPILE([#include "sysincludes.h"],
+[AC_TRY_COMPILE([#include "${srcdir}/sysincludes.h"],
[struct in6_pktinfo s;],
[sc_cv_struct_in6_pktinfo=yes],
[sc_cv_struct_in6_pktinfo=no])])
@@ -1950,7 +1950,7 @@ AC_TYPEOF_COMPONENT([#include <sys/types.h>
struct rlimit, rlim_max, HAVE_TYPEOF_RLIM_MAX, sc_cv_type_rlimit_rlimmax_basic)
# Fedora-19 doc says it is socklen_t which is equivalent to unsigned int, but it is equivalent to size_t (x86_64)
-AC_TYPEOF_COMPONENT([#include "sysincludes.h"], struct cmsghdr, cmsg_len, HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN, sc_cv_typeof_struct_cmsghdr_cmsg_len)
+AC_TYPEOF_COMPONENT([#include "${srcdir}/sysincludes.h"], struct cmsghdr, cmsg_len, HAVE_TYPEOF_STRUCT_CMSGHDR_CMSG_LEN, sc_cv_typeof_struct_cmsghdr_cmsg_len)
### snprintf, vsnprintf
AC_MSG_CHECKING(for /dev/ptmx)
diff --git a/error.c b/error.c
index 2fad6c2..e34f426 100644
--- a/error.c
+++ b/error.c
@@ -420,6 +420,9 @@ void diag_flush(void) {
return;
}
+ if (diag_sock_recv == -1)
+ return;
+
while (recv(diag_sock_recv, &recv_dgram, sizeof(recv_dgram)-1,
0 /* for canonical reasons */
#ifdef MSG_DONTWAIT
@@ -520,10 +523,11 @@ int diag_select(int nfds, fd_set *readfds, fd_set *writefds,
if (exceptfds) { memcpy(&save_exceptfds, exceptfds, sizeof(*exceptfds)); }
while (1) {
- FD_SET(diag_sock_recv, readfds);
+ if (diag_sock_recv >= 0)
+ FD_SET(diag_sock_recv, readfds);
result = Select(nfds, readfds, writefds,
exceptfds, timeout);
- if (!FD_ISSET(diag_sock_recv, readfds)) {
+ if ((diag_sock_recv == -1) || !FD_ISSET(diag_sock_recv, readfds)) {
/* select terminated not due to diag_sock_recv, normalt continuation */
break;
}

View File

@ -0,0 +1,5 @@
include $(call select_from_repositories,mk/noux.mk)
INSTALL_TARGET = install
PATCHES := src/noux-pkg/socat/socat.patch

View File

@ -68,6 +68,7 @@ smartcard
smbios_decoder smbios_decoder
smp smp
sntp_client sntp_client
socat
ssh_exec_channel ssh_exec_channel
sub_rm sub_rm
tar_rom tar_rom