libc: separate unit for freeaddrinfo/getaddrinfo
Preperation for merge of libc_resolv into libc.
This commit is contained in:
parent
2d700d0b2d
commit
957653d4b9
|
@ -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 \
|
plugin.cc plugin_registry.cc select.cc exit.cc environ.cc nanosleep.cc \
|
||||||
pread_pwrite.cc readv_writev.cc poll.cc \
|
pread_pwrite.cc readv_writev.cc poll.cc \
|
||||||
libc_pdbg.cc vfs_plugin.cc rtc.cc dynamic_linker.cc signal.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
|
CC_OPT_sysctl += -Wno-write-strings
|
||||||
|
|
||||||
|
|
57
repos/libports/src/lib/libc/addrinfo.cc
Normal file
57
repos/libports/src/lib/libc/addrinfo.cc
Normal file
|
@ -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 <base/log.h>
|
||||||
|
|
||||||
|
/* libc includes */
|
||||||
|
#include <libc-plugin/plugin_registry.h>
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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) {
|
extern "C" int _getpeername(int libc_fd, struct sockaddr *addr, socklen_t *addrlen) {
|
||||||
FD_FUNC_WRAPPER(getpeername, libc_fd, addr, addrlen); }
|
FD_FUNC_WRAPPER(getpeername, libc_fd, addr, addrlen); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user