Noux: remove {get,free}addrinfo

This dead-code will not be needed in the future because we now use
libc_resolv.
This commit is contained in:
Josef Söntgen 2012-08-21 12:07:27 +02:00 committed by Norman Feske
parent 6aa05e8d46
commit 57b0490fc6
5 changed files with 0 additions and 169 deletions

View File

@ -71,7 +71,6 @@ namespace Noux {
SYSCALL_GETPEERNAME,
SYSCALL_SHUTDOWN,
SYSCALL_CONNECT,
SYSCALL_GETADDRINFO,
SYSCALL_USERINFO,
SYSCALL_INVALID = -1
};
@ -116,7 +115,6 @@ namespace Noux {
NOUX_DECL_SYSCALL_NAME(GETPEERNAME)
NOUX_DECL_SYSCALL_NAME(SHUTDOWN)
NOUX_DECL_SYSCALL_NAME(CONNECT)
NOUX_DECL_SYSCALL_NAME(GETADDRINFO)
NOUX_DECL_SYSCALL_NAME(USERINFO)
case SYSCALL_INVALID: return 0;
}

View File

@ -408,11 +408,6 @@ namespace Noux {
SYSIO_DECL(connect, { int fd; struct sockaddr addr; socklen_t addrlen; },
{ int result; });
SYSIO_DECL(getaddrinfo, { Hostname hostname; Servname servname;
Addrinfo hints;
Addrinfo res[MAX_ADDRINFO_RESULTS]; },
{ int addr_num; });
SYSIO_DECL(userinfo, { int request; Uid uid; },
{ User name; Uid uid; Uid gid; Shell shell;
Home home; });

View File

@ -641,9 +641,6 @@ namespace {
bool supports_rename(const char *, const char *) { return true; }
bool supports_mkdir(const char *, mode_t) { return true; }
bool supports_socket(int, int, int) { return true; }
bool supports_freeaddrinfo(struct addrinfo *) { return true; }
bool supports_getaddrinfo(const char *, const char *,
struct addrinfo **) { return true; }
bool supports_mmap() { return true; }
Libc::File_descriptor *open(char const *, int);
@ -677,9 +674,6 @@ namespace {
socklen_t);
int connect(Libc::File_descriptor *, const struct sockaddr *addr,
socklen_t addrlen);
void freeaddrinfo(struct addrinfo *);
int getaddrinfo(const char *, const char *, const struct addrinfo *,
struct addrinfo **);
int getpeername(Libc::File_descriptor *, struct sockaddr *,
socklen_t *);
int listen(Libc::File_descriptor *, int);
@ -1353,112 +1347,6 @@ namespace {
}
void Plugin::freeaddrinfo(struct addrinfo *res)
{
#if 0
struct addrinfo *next;
while (res) {
if (res->ai_addr) {
free(res->ai_addr);
}
if (res->ai_canonname) {
free(res->ai_canonname);
}
next = res->ai_next;
free(res);
res = next;
}
#endif
}
int Plugin::getaddrinfo(const char *hostname, const char *servname,
const struct addrinfo *hints, struct addrinfo **res)
{
#if 0
const char *service = NULL;
/**
* We have to fetch the portnumber manually because lwip only
* supports getting the service by portnumber. So we first check
* if servname is already a ascii portnumber and if it is not we
* call getservent(servername, NULL).
*/
char buf[6] = { 0 };
int port = atoi(servname);
if (port <= 0 || port > 0xffff) {
struct servent *se = getservbyname(servname, NULL);
if (se != NULL) {
port = htons(se->s_port);
snprintf(buf, 6, "%d", port);
service = buf;
}
else {
return -1;
}
}
else
service = servname;
size_t len = strlen(hostname);
len = min(len, 255);
memcpy(sysio()->getaddrinfo_in.hostname, hostname, len);
sysio()->getaddrinfo_in.hostname[len] = '\0';
len = strlen(service);
len = min(len, 255);
memcpy(sysio()->getaddrinfo_in.servname, service, len);
sysio()->getaddrinfo_in.servname[len] = '\0';
if (!noux()->syscall(Noux::Session::SYSCALL_GETADDRINFO))
return -1;
struct addrinfo *rp = 0, *result;
for (int i = 0; i < sysio()->getaddrinfo_out.addr_num; i++) {
if (!rp) {
rp = (struct addrinfo *)malloc(sizeof (struct addrinfo));
*res = rp;
}
else {
rp->ai_next = (struct addrinfo *)malloc(sizeof (struct addrinfo));
rp = rp->ai_next;
}
rp->ai_flags = sysio()->getaddrinfo_in.res[i].addrinfo.ai_flags;
rp->ai_family = sysio()->getaddrinfo_in.res[i].addrinfo.ai_family;
rp->ai_socktype = sysio()->getaddrinfo_in.res[i].addrinfo.ai_socktype;
rp->ai_protocol = sysio()->getaddrinfo_in.res[i].addrinfo.ai_protocol;
rp->ai_addrlen = sysio()->getaddrinfo_in.res[i].addrinfo.ai_addrlen;
if (sysio()->getaddrinfo_in.res[i].ai_addr.sa_len != 0) {
rp->ai_addr = (struct sockaddr *)malloc(sizeof (struct sockaddr));
memcpy(rp->ai_addr, &sysio()->getaddrinfo_in.res[i].ai_addr, sizeo
f (struct sockaddr));
}
else
rp->ai_addr = 0;
if (sysio()->getaddrinfo_in.res[i].ai_canonname != 0) {
size_t len = strlen(sysio()->getaddrinfo_in.res[i].ai_canonname) +
1;
rp->ai_canonname = (char *)malloc(len);
strncpy(rp->ai_canonname, sysio()->getaddrinfo_in.res[i].ai_canonn
ame, len);
}
else
rp->ai_canonname = 0;
rp->ai_next = 0;
}
#endif
return -1;
}
int Plugin::getpeername(Libc::File_descriptor *fd, struct sockaddr *addr,
socklen_t *addrlen)
{

View File

@ -603,7 +603,6 @@ bool Noux::Child::syscall(Noux::Session::Syscall sc)
case SYSCALL_GETPEERNAME:
case SYSCALL_SHUTDOWN:
case SYSCALL_CONNECT:
case SYSCALL_GETADDRINFO:
return _syscall_net(sc);

View File

@ -328,55 +328,6 @@ bool Noux::Child::_syscall_net(Noux::Session::Syscall sc)
return true;
}
case SYSCALL_GETADDRINFO:
{
#if 0
struct addrinfo *result, *rp = NULL;
int res = lwip_getaddrinfo(_sysio->getaddrinfo_in.hostname,
_sysio->getaddrinfo_in.servname,
(const struct addrinfo *)&_sysio->getaddrinfo_in.hints,
&result);
if (res != 0) {
PERR("::getaddrinfo() returns %d", res);
return false;
}
PINF("SYSCALL_GETADDRINFO: deep-copy");
/* wipe-out old state */
memset(_sysio->getaddrinfo_in.res, 0, sizeof (_sysio->getaddrinfo_in.res));
int i = 0; rp = result;
while (i < Noux::Sysio::MAX_ADDRINFO_RESULTS && rp != NULL) {
memcpy(&_sysio->getaddrinfo_in.res[i].addrinfo, rp, sizeof (struct addrinfo));
if (rp->ai_addr) {
memcpy(&_sysio->getaddrinfo_in.res[i].ai_addr, rp->ai_addr, sizeof (struct sockaddr));
}
else
memset(&_sysio->getaddrinfo_in.res[i].ai_addr, 0, sizeof (struct sockaddr));
if (rp->ai_canonname) {
memcpy(&_sysio->getaddrinfo_in.res[i].ai_canonname,
rp->ai_canonname, strlen(rp->ai_canonname));
PINF("kopiere canonname: '%s'", rp->ai_canonname);
}
else
memset(&_sysio->getaddrinfo_in.res[i].ai_canonname, 0,
sizeof (_sysio->getaddrinfo_in.res[i].ai_canonname));
i++; rp = rp->ai_next;
}
_sysio->getaddrinfo_out.addr_num = i;
PINF("SYSCALL_GETADDRINFO: deep-copy successfull");
lwip_freeaddrinfo(result);
return true;
#endif
return false;
}
}
return false;