]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Remove source code files defined by libc
authorRazvan Deaconescu <razvand@unikraft.io>
Sun, 20 Nov 2022 13:14:46 +0000 (15:14 +0200)
committerUnikraft <monkey@unikraft.io>
Fri, 25 Nov 2022 09:47:28 +0000 (09:47 +0000)
Remove source code files that are to be defined by the standard C
library (Musl or nolibc).

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Approved-by: Marco Schlumpp <marco@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #23

Makefile.uk
getnameinfo.c [deleted file]
host.c [deleted file]
inet.c [deleted file]
proto.c [deleted file]
serv.c [deleted file]

index 502a1be0a1b86e65eedd88f11c4e0fbbed889e7a..4614b20dff7f4d29377c57f7de054938a22e7eaf 100644 (file)
@@ -87,13 +87,6 @@ LIBLWIP_CXXFLAGS-y += -D__IN_LIBLWIP__
 # Core
 ################################################################################
 LIBLWIP_SRCS-y += $(LIBLWIP_BASE)/alloc.c|unikraft
-ifeq ($(CONFIG_LWIP_SOCKET),y)
-LIBLWIP_SRCS-y += $(LIBLWIP_BASE)/proto.c
-LIBLWIP_SRCS-y += $(LIBLWIP_BASE)/host.c
-LIBLWIP_SRCS-y += $(LIBLWIP_BASE)/serv.c
-LIBLWIP_SRCS-y += $(LIBLWIP_BASE)/inet.c|unikraft
-LIBLWIP_SRCS-$(CONFIG_LWIP_DNS) += $(LIBLWIP_BASE)/getnameinfo.c|unikraft
-endif
 LIBLWIP_SRCS-$(CONFIG_LWIP_THREADS) += $(LIBLWIP_BASE)/mutex.c|unikraft
 LIBLWIP_SRCS-$(CONFIG_LWIP_THREADS) += $(LIBLWIP_BASE)/semaphore.c|unikraft
 LIBLWIP_SRCS-$(CONFIG_LWIP_THREADS) += $(LIBLWIP_BASE)/mailbox.c|unikraft
diff --git a/getnameinfo.c b/getnameinfo.c
deleted file mode 100644 (file)
index d4a8a8f..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause AND MIT */
-/*
- * Copyright (C) 2014, Cloudius Systems, Ltd.
- * Copyright (c) 2019, University Politehnica of Bucharest.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-/* For the parts taken from musl (marked as such below), the MIT licence
- * applies instead:
- * ----------------------------------------------------------------------
- * Copyright (c) 2005-2014 Rich Felker, et al.
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- * ----------------------------------------------------------------------
- */
-#include <stdio.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-
-int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl,
-       char *restrict node, socklen_t nodelen,
-       char *restrict serv, socklen_t servlen,
-       int flags)
-{
-       char buf[256];
-       /*unsigned char reply[512]; TODO used in DNS reply */
-       int af = sa->sa_family;
-#if CONFIG_LIBNEWLIBC /* because of fopen() */
-       char line[512];
-       FILE *f;
-#endif
-       unsigned char *a;
-
-       switch (af) {
-       case AF_INET:
-               a = (void *) &((struct sockaddr_in *) sa)->sin_addr;
-               if (sl != sizeof(struct sockaddr_in))
-                       return EAI_FAMILY;
-               break;
-#if CONFIG_LWIP_IPV6
-       case AF_INET6:
-               a = (void *) &((struct sockaddr_in6 *) sa)->sin6_addr;
-               if (sl != sizeof(struct sockaddr_in6))
-                       return EAI_FAMILY;
-               break;
-#endif
-       default:
-               return EAI_FAMILY;
-       }
-
-#if CONFIG_LIBNEWLIBC /* because of fopen() */
-       /* Try to find ip within /etc/hosts */
-       if ((node && nodelen) && (af == AF_INET)) {
-               const char *ipstr;
-               size_t l;
-
-               ipstr = inet_ntoa(((struct sockaddr_in *)sa)->sin_addr);
-               l = strlen(ipstr);
-               f = fopen("/etc/hosts", "r");
-               if (f)
-                       while (fgets(line, sizeof(line), f)) {
-                               char *domain;
-
-                               if (strncmp(line, ipstr, l) != 0)
-                                       continue;
-
-                               domain = strtok(line, " ");
-                               if (!domain)
-                                       continue;
-                               domain = strtok(NULL, " ");
-                               if (!domain)
-                                       continue;
-
-                               if (strlen(domain) >= nodelen)
-                                       return EAI_OVERFLOW;
-                               strcpy(node, domain);
-                               fclose(f);
-                               return 0;
-                       }
-               if (f)
-                       fclose(f);
-       }
-#endif
-
-       if (node && nodelen) {
-               if ((flags & NI_NUMERICHOST)
-#if 0
-                       /* TODO we currently don't support name requests */
-                       || __dns_query(reply, a, af, 1) <= 0
-                       || __dns_get_rr(buf, 0, 256, 1, reply, RR_PTR, 1) <= 0) {
-#else
-                       || 1) {
-#endif
-                       if (flags & NI_NAMEREQD)
-                               return EAI_NONAME;
-                       inet_ntop(af, a, buf, sizeof(buf));
-               }
-               if (strlen(buf) >= nodelen)
-                       return EAI_OVERFLOW;
-               strcpy(node, buf);
-       }
-
-       if (serv && servlen) {
-               if (snprintf(buf, sizeof(buf), "%d",
-                       ntohs(((struct sockaddr_in *) sa)->sin_port)) >= (int) servlen)
-                       return EAI_OVERFLOW;
-               strcpy(serv, buf);
-       }
-
-       return 0;
-}
diff --git a/host.c b/host.c
deleted file mode 100644 (file)
index 709a03d..0000000
--- a/host.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Copyright (c) 2019, University Politehnica of Bucharest.
- *                     All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <unistd.h>
-#include <sys/socket.h>
-#include <netdb.h>
-
-
-#if LWIP_DNS && LWIP_SOCKET
-
-#if !(LWIP_COMPAT_SOCKETS)
-struct hostent *gethostbyname(const char *name)
-{
-       return lwip_gethostbyname(name);
-}
-
-int gethostbyname_r(const char *name,
-               struct hostent *ret, char *buf, size_t buflen,
-               struct hostent **result, int *h_errnop)
-{
-       return lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop);
-}
-#endif
-
-struct hostent *gethostbyaddr(const void *addr __unused,
-       socklen_t len __unused, int type __unused)
-{
-       return NULL;
-}
-#endif
-
diff --git a/inet.c b/inet.c
deleted file mode 100644 (file)
index 4af1c26..0000000
--- a/inet.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Bogdan Lascu <lascu.bogdan96@gmail.com>
- *
- * Copyright (c) 2019, University Politehnica of Bucharest. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/socket.h>
-#include <netdb.h>
-
-
-const char *inet_ntop(int af, const void *src, char *dst, socklen_t size)
-{
-       return lwip_inet_ntop(af, src, dst, size);
-}
-
-int inet_pton(int af, const char *src, void *dst)
-{
-       return lwip_inet_pton(af, src, dst);
-}
-
-#if LWIP_DNS && LWIP_SOCKET && !(LWIP_COMPAT_SOCKETS)
-int getaddrinfo(const char *node, const char *service,
-               const struct addrinfo *hints,
-               struct addrinfo **res)
-{
-       return lwip_getaddrinfo(node, service, hints, res);
-}
-
-void freeaddrinfo(struct addrinfo *res)
-{
-       return lwip_freeaddrinfo(res);
-}
-#endif /* LWIP_DNS && LWIP_SOCKET && !(LWIP_COMPAT_SOCKETS) */
-
-/* Note: lwip implementation of getaddrinfo does not return all the errors
- * codes mentioned in its man page.
- */
-const char *gai_strerror(int errcode)
-{
-       switch (errcode) {
-#if LWIP_DNS_API_DEFINE_ERRORS
-       case EAI_NONAME:
-               return "The node or service is not known; or both node and service are NULL.";
-       case EAI_SERVICE:
-               return "The requested service is not available for the requested socket type.";
-       case EAI_FAIL:
-               return "The name server returned a permanent failure indication.";
-       case EAI_MEMORY:
-               return "Out of memory.";
-       case EAI_FAMILY:
-               return "The requested address family is not supported.";
-       case EAI_OVERFLOW:
-               return "The buffer pointed to by host or serv was too small.";
-#endif /* LWIP_DNS_API_DEFINE_ERRORS */
-       default:
-               return "Error on getaddrinfo.";
-       }
-}
diff --git a/proto.c b/proto.c
deleted file mode 100644 (file)
index 0127355..0000000
--- a/proto.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Copyright (c) 2005-2014 Rich Felker, et al.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#include <sys/socket.h>
-#include <netdb.h>
-#include <string.h>
-
-/* do we really need all these?? */
-
-static size_t idx;
-static const unsigned char protos[] = {
-       "\000ip\0"
-       "\001icmp\0"
-       "\002igmp\0"
-       "\003ggp\0"
-       "\004ipencap\0"
-       "\005st\0"
-       "\006tcp\0"
-       "\010egp\0"
-       "\014pup\0"
-       "\021udp\0"
-       "\024hmp\0"
-       "\026xns-idp\0"
-       "\033rdp\0"
-       "\035iso-tp4\0"
-       "\044xtp\0"
-       "\045ddp\0"
-       "\046idpr-cmtp\0"
-       "\051ipv6\0"
-       "\053ipv6-route\0"
-       "\054ipv6-frag\0"
-       "\055idrp\0"
-       "\056rsvp\0"
-       "\057gre\0"
-       "\062esp\0"
-       "\063ah\0"
-       "\071skip\0"
-       "\072ipv6-icmp\0"
-       "\073ipv6-nonxt\0"
-       "\074ipv6-opts\0"
-       "\111rspf\0"
-       "\121vmtp\0"
-       "\131ospf\0"
-       "\136ipip\0"
-       "\142encap\0"
-       "\147pim\0"
-       "\377raw"
-};
-
-void endprotoent(void)
-{
-       idx = 0;
-}
-
-void setprotoent(int stayopen)
-{
-       idx = 0;
-}
-
-struct protoent *getprotoent(void)
-{
-       static struct protoent p;
-       static const char *aliases;
-
-       if (idx >= sizeof(protos))
-               return NULL;
-       p.p_proto = protos[idx];
-       p.p_name = (char *)&protos[idx+1];
-       p.p_aliases = (char **)&aliases;
-       idx += strlen(p.p_name) + 2;
-       return &p;
-}
-
-struct protoent *getprotobyname(const char *name)
-{
-       struct protoent *p;
-
-       endprotoent();
-       do p = getprotoent();
-       while (p && strcmp(name, p->p_name));
-       return p;
-}
-
-struct protoent *getprotobynumber(int num)
-{
-       struct protoent *p;
-
-       endprotoent();
-       do p = getprotoent();
-       while (p && p->p_proto != num);
-       return p;
-}
-
diff --git a/serv.c b/serv.c
deleted file mode 100644 (file)
index ff78c74..0000000
--- a/serv.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Copyright (c) 2019, University Politehnica of Bucharest.
- *                     All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <inttypes.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <uk/essentials.h>
-
-struct servent *getservbyname(const char *name __unused,
-       const char *proto __unused)
-{
-       return NULL;
-}
-
-struct servent *getservbyport(int port __unused,
-       const char *proto __unused)
-{
-       return NULL;
-}
-
-int getservbyport_r(int port __unused, const char *prots __unused,
-                   struct servent *se __unused, char *buf __unused,
-                   size_t buflen __unused, struct servent **res __unused)
-{
-       errno = ENOSYS;
-       return EAI_SYSTEM;
-}