From 57b0490fc620bd14b7f1d327ba4e6806a2cd22bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Tue, 21 Aug 2012 12:07:27 +0200 Subject: [PATCH] Noux: remove {get,free}addrinfo This dead-code will not be needed in the future because we now use libc_resolv. --- ports/include/noux_session/noux_session.h | 2 - ports/include/noux_session/sysio.h | 5 - ports/src/lib/libc_noux/plugin.cc | 112 ---------------------- ports/src/noux/main.cc | 1 - ports/src/noux/net/net.cc | 49 ---------- 5 files changed, 169 deletions(-) diff --git a/ports/include/noux_session/noux_session.h b/ports/include/noux_session/noux_session.h index 33d5397800..31c96cfd57 100644 --- a/ports/include/noux_session/noux_session.h +++ b/ports/include/noux_session/noux_session.h @@ -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; } diff --git a/ports/include/noux_session/sysio.h b/ports/include/noux_session/sysio.h index dbeedd0484..5729ebd73f 100644 --- a/ports/include/noux_session/sysio.h +++ b/ports/include/noux_session/sysio.h @@ -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; }); diff --git a/ports/src/lib/libc_noux/plugin.cc b/ports/src/lib/libc_noux/plugin.cc index eb480e1e4d..01b9edfb5d 100644 --- a/ports/src/lib/libc_noux/plugin.cc +++ b/ports/src/lib/libc_noux/plugin.cc @@ -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) { diff --git a/ports/src/noux/main.cc b/ports/src/noux/main.cc index 43c8fd314c..a4aa76e333 100644 --- a/ports/src/noux/main.cc +++ b/ports/src/noux/main.cc @@ -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); diff --git a/ports/src/noux/net/net.cc b/ports/src/noux/net/net.cc index a0fc7179d5..482ab55069 100644 --- a/ports/src/noux/net/net.cc +++ b/ports/src/noux/net/net.cc @@ -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;