parent
dbbda9839b
commit
40d7902ade
|
@ -50,7 +50,8 @@ set config {
|
||||||
<start name="test-lxip_udp_echo">
|
<start name="test-lxip_udp_echo">
|
||||||
<resource name="RAM" quantum="2M"/>
|
<resource name="RAM" quantum="2M"/>
|
||||||
<config ld_verbose="yes">
|
<config ld_verbose="yes">
|
||||||
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.0.2.55" gateway="10.0.2.1" netmask="255.255.255.0">
|
<libc stdout="/dev/log" stderr="/dev/log" ip_addr="10.0.2.55"
|
||||||
|
gateway="10.0.2.1" netmask="255.255.255.0" port="1337">
|
||||||
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
<vfs> <dir name="dev"> <log/> </dir> </vfs>
|
||||||
</libc>
|
</libc>
|
||||||
</config>
|
</config>
|
||||||
|
@ -118,7 +119,7 @@ append qemu_args " -m 128 -nographic "
|
||||||
append_if [have_spec x86] qemu_args " -net nic,model=e1000 "
|
append_if [have_spec x86] qemu_args " -net nic,model=e1000 "
|
||||||
append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 "
|
append_if [have_spec lan9118] qemu_args " -net nic,model=lan9118 "
|
||||||
|
|
||||||
append qemu_args " -net user -redir tcp:5555::80 "
|
append qemu_args " -net user -redir udp:5555::1337 "
|
||||||
|
|
||||||
run_genode_until forever
|
run_genode_until forever
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <os/config.h>
|
||||||
|
|
||||||
|
using namespace Genode;
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -33,10 +35,17 @@ int main(void)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned port = 0;
|
||||||
|
Xml_node libc_node = config()->xml_node().sub_node("libc");
|
||||||
|
try { libc_node.attribute("port").value(&port); }
|
||||||
|
catch (...) {
|
||||||
|
error("Missing \"port\" attribute.");
|
||||||
|
throw Xml_node::Nonexistent_attribute();
|
||||||
|
}
|
||||||
Genode::log("Now, I will bind ...");
|
Genode::log("Now, I will bind ...");
|
||||||
struct sockaddr_in in_addr;
|
struct sockaddr_in in_addr;
|
||||||
in_addr.sin_family = AF_INET;
|
in_addr.sin_family = AF_INET;
|
||||||
in_addr.sin_port = htons(1337);
|
in_addr.sin_port = htons(port);
|
||||||
in_addr.sin_addr.s_addr = INADDR_ANY;
|
in_addr.sin_addr.s_addr = INADDR_ANY;
|
||||||
if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
|
if(bind(s, (struct sockaddr*)&in_addr, sizeof(in_addr))) {
|
||||||
Genode::error("bind failed!");
|
Genode::error("bind failed!");
|
||||||
|
@ -50,7 +59,7 @@ int main(void)
|
||||||
socklen_t len = sizeof(addr);
|
socklen_t len = sizeof(addr);
|
||||||
|
|
||||||
char buf[4096];
|
char buf[4096];
|
||||||
memset(buf, 0, sizeof(buf));
|
::memset(buf, 0, sizeof(buf));
|
||||||
|
|
||||||
ssize_t n = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&addr, &len);
|
ssize_t n = recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*)&addr, &len);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
TARGET = test-lxip_udp_echo
|
TARGET = test-lxip_udp_echo
|
||||||
LIBS = libc libc_lxip
|
LIBS = libc libc_lxip config
|
||||||
SRC_CC = main.cc
|
SRC_CC = main.cc
|
||||||
|
|
Loading…
Reference in New Issue
Block a user