diff --git a/run/eth_udp.run b/run/eth_udp.run new file mode 100644 index 0000000..2e9d6d6 --- /dev/null +++ b/run/eth_udp.run @@ -0,0 +1,84 @@ +# +# Build +# + +if {[expr [have_spec linux]] || + [expr [have_spec imx53] && [have_spec trustzone]] || + [have_spec rpi3] || + [expr [have_spec riscv]]} { + puts "\n Run script is not supported on this platform. \n"; exit 0 } + +create_boot_directory + +import_from_depot [depot_user]/src/[base_src] \ + [depot_user]/pkg/[drivers_nic_pkg] \ + [depot_user]/src/init \ + [depot_user]/src/libc \ + [depot_user]/src/vfs_lwip \ + [depot_user]/src/vfs + +build { app/eth_udp } + +install_config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} + +build_boot_image { eth_udp } + +# +# Qemu config +# +proc qemu_nic_model {} { + if [have_spec x86] { return e1000 } + if [have_spec lan9118] { return lan9118 } + if [have_spec zynq] { return cadence_gem } + return nic_model_missing +} +append qemu_args " -nographic " +append qemu_args " -net nic,model=[qemu_nic_model],netdev=net0 " + +run_genode_until forever + +# vi: set ft=tcl : diff --git a/src/app/eth_udp/main.cc b/src/app/eth_udp/main.cc new file mode 100644 index 0000000..ff6880a --- /dev/null +++ b/src/app/eth_udp/main.cc @@ -0,0 +1,53 @@ +/* + * \brief Test client for the Hello RPC interface + * \author Björn Döbel + * \author Norman Feske + * \date 2008-03-20 + */ + +/* + * Copyright (C) 2008-2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +void Libc::Component::construct(Libc::Env &env) +{ + Libc::with_libc([&] () { + struct sockaddr_in srv_addr; + srv_addr.sin_port = htons(8080); + srv_addr.sin_family = AF_INET; + srv_addr.sin_addr.s_addr = inet_addr("192.168.100.0"); + + unsigned int len = sizeof(srv_addr); + + int sd = ::socket(AF_INET, SOCK_DGRAM, 0); + sendto(sd, "Hello World\n", 12, 0, (struct sockaddr*)&srv_addr, len); + + char buf[64] = {'\0'}; + int ret = -1; + while(true) { + ret = recvfrom(sd, buf, sizeof(buf), 0, NULL, NULL); + buf[ret] = '\0'; + Genode::log((const char *)buf); + } + + Genode::log("Connection closed…"); + + // ---------------------------------- + + }); +} diff --git a/src/app/eth_udp/target.mk b/src/app/eth_udp/target.mk new file mode 100644 index 0000000..4c4e16e --- /dev/null +++ b/src/app/eth_udp/target.mk @@ -0,0 +1,5 @@ +TARGET = eth_udp +SRC_CC = main.cc +LIBS = base libc + +CC_CXX_WARN_STRICT =