diff --git a/repos/libports/lib/mk/libc.mk b/repos/libports/lib/mk/libc.mk index e75ed4052..1f7aa89ea 100644 --- a/repos/libports/lib/mk/libc.mk +++ b/repos/libports/lib/mk/libc.mk @@ -15,7 +15,7 @@ SRC_CC = atexit.cc dummies.cc rlimit.cc sysctl.cc \ plugin.cc plugin_registry.cc select.cc exit.cc environ.cc nanosleep.cc \ pread_pwrite.cc readv_writev.cc poll.cc \ libc_pdbg.cc vfs_plugin.cc rtc.cc dynamic_linker.cc signal.cc \ - socket_operations.cc task.cc + socket_operations.cc task.cc addrinfo.cc CC_OPT_sysctl += -Wno-write-strings diff --git a/repos/libports/src/lib/libc/addrinfo.cc b/repos/libports/src/lib/libc/addrinfo.cc new file mode 100644 index 000000000..8de2904f0 --- /dev/null +++ b/repos/libports/src/lib/libc/addrinfo.cc @@ -0,0 +1,57 @@ +/* + * \brief libc addrinfo plugin wrappers + * \author Christian Helmuth + * \date 2017-02-08 + * + * Note, these functions are implemented by the libc_resolv library currently + * and can be removed when the library is merged into libc.lib.so. + */ + +/* + * Copyright (C) 2017 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +/* Genode includes */ +#include + +/* libc includes */ +#include + + +using namespace Libc; + + +extern "C" void freeaddrinfo(struct addrinfo *res) +{ + Plugin *plugin; + + plugin = plugin_registry()->get_plugin_for_freeaddrinfo(res); + + if (!plugin) { + Genode::error("no plugin found for freeaddrinfo()"); + return; + } + + plugin->freeaddrinfo(res); +} + + +extern "C" int getaddrinfo(const char *node, const char *service, + const struct addrinfo *hints, + struct addrinfo **res) +{ + Plugin *plugin; + + plugin = plugin_registry()->get_plugin_for_getaddrinfo(node, service, hints, res); + + if (!plugin) { + Genode::error("no plugin found for getaddrinfo()"); + return -1; + } + + return plugin->getaddrinfo(node, service, hints, res); +} + diff --git a/repos/libports/src/lib/libc/socket_operations.cc b/repos/libports/src/lib/libc/socket_operations.cc index 586e7c922..b215a4400 100644 --- a/repos/libports/src/lib/libc/socket_operations.cc +++ b/repos/libports/src/lib/libc/socket_operations.cc @@ -67,38 +67,6 @@ extern "C" int _connect(int libc_fd, const struct sockaddr *addr, } -extern "C" void freeaddrinfo(struct addrinfo *res) -{ - Plugin *plugin; - - plugin = plugin_registry()->get_plugin_for_freeaddrinfo(res); - - if (!plugin) { - Genode::error("no plugin found for freeaddrinfo()"); - return; - } - - plugin->freeaddrinfo(res); -} - - -extern "C" int getaddrinfo(const char *node, const char *service, - const struct addrinfo *hints, - struct addrinfo **res) -{ - Plugin *plugin; - - plugin = plugin_registry()->get_plugin_for_getaddrinfo(node, service, hints, res); - - if (!plugin) { - Genode::error("no plugin found for getaddrinfo()"); - return -1; - } - - return plugin->getaddrinfo(node, service, hints, res); -} - - extern "C" int _getpeername(int libc_fd, struct sockaddr *addr, socklen_t *addrlen) { FD_FUNC_WRAPPER(getpeername, libc_fd, addr, addrlen); }