rollback iputils

This commit is contained in:
hyird 2020-08-22 19:02:39 +08:00
parent 0d754ec4c5
commit 70ac7cbd39
9 changed files with 455 additions and 128 deletions

View File

@ -1,17 +0,0 @@
if PACKAGE_iputils-ping
config PING_LEGACY_SYMLINKS
bool
default n
prompt "Install legacy ping4 and ping6 symlinks"
help
Iputils previously generated separate "ping" and "ping6"
binaries for supporting IPv4 and IPv6 communication,
respectively. Recent versions of iputils have merged
support for both address families into a single program.
Select this option to install "ping6" and "ping4" symlinks
to the unified binary to support compatibility with
existing tools that may still expect to find the old
names.
endif

View File

@ -1,16 +0,0 @@
if PACKAGE_iputils-tracepath
config TRACEPATH_LEGACY_SYMLINKS
bool
default n
prompt "Install legacy tracepath4 and tracepath6 symlinks"
help
Iputils previously generated separate "tracepath" and
"tracepath6" binaries for supporting IPv4 and IPv6
communication, respectively. Recent versions of iputils
have merged support for both address families into a
single tracepath program. Select this option to install
"tracepath6" and "tracepath4" symlinks to the unified
binary to support compatibility with existing tools that
may still expect to find the old names.
endif

View File

@ -1,150 +1,182 @@
# #
# Copyright (C) 2006-2010 OpenWrt.org # Copyright (C) 2006-2010 OpenWrt.org
# Copyright (C) 2019 Noah Meyerhans <frodo@morgul.net>
#
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information. # See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=iputils PKG_NAME:=iputils
PKG_VERSION:=20190709 PKG_VERSION:=20101006
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-s$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://codeload.github.com/iputils/iputils/tar.gz/s$(PKG_VERSION)? PKG_SOURCE_URL:=http://www.skbuff.net/iputils
PKG_HASH:=a15720dd741d7538dd2645f9f516d193636ae4300ff7dbc8bfca757bf166490a PKG_HASH:=fd3af46c80ebb99607c2ca1f2a3608b6fe828e25bbec6e54f2afd25f6ddb6ee7
PKG_MAINTAINER:=Noah Meyerhans <frodo@morgul.net> PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=BSD-3-Clause PKG_LICENSE:=GPL-2.0+
PKG_LICENSE_FILES:=LICENSE PKG_CPE_ID:=cpe:/a:skbuff:iputils
PKG_CPE_ID:=cpe:/a:iputils_project:iputils
PKG_BUILD_DEPENDS:=sysfsutils
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-s$(PKG_VERSION)
PKG_BUILD_DIR:=$(BUILD_DIR)/iputils-s$(PKG_VERSION)
PKG_BUILD_DEPENDS:=meson/host
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include ../../devel/meson/meson.mk
MESON_ARGS:=-DBUILD_MANS=false \
-DBUILD_HTML_MANS=false \
-DUSE_CAP=false \
-DUSE_CRYPTO=kernel \
-DUSE_IDN=false \
-DUSE_GETTEXT=false \
-DNO_SETCAP_OR_SUID=true \
-DBUILD_PING=true \
-DBUILD_ARPING=true \
-DBUILD_CLOCKDIFF=true \
-DBUILD_TRACEPATH=true \
-DBUILD_TFTPD=true
define Package/iputils/Default define Package/iputils/Default
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
TITLE:=iputils URL:=http://www.skbuff.net/iputils
URL:=https://github.com/iputils/iputils
endef endef
### ping
define Package/iputils-ping
$(call Package/iputils/Default)
TITLE:=iputils-ping
DEPENDS:=+kmod-crypto-md5
endef
define Package/iputils-ping/config
source "$(SOURCE)/Config_ping.in"
endef
define Package/iputils-ping/description
Send ICMP_ECHOREQUEST packets to IP hosts and report on replies
endef
define Package/iputils-ping/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_SUID) $(MESON_BUILD_DIR)/ping $(1)/usr/bin/
ifdef CONFIG_PING_LEGACY_SYMLINKS
ln -s ping $(1)/usr/bin/ping4
ln -s ping $(1)/usr/bin/ping6
endif
endef
### arping
define Package/iputils-arping define Package/iputils-arping
$(call Package/iputils/Default) $(call Package/iputils/Default)
TITLE:=iputils-arping TITLE:=iputils - arping
DEPENDS+= +libsysfs
endef endef
define Package/iputils-arping/description define Package/iputils-arping/description
Send ARP REQUEST packets to a neighbor host Program arping from iputils.
Sends ARP REQUEST to a neighbour host.
endef endef
define Package/iputils-arping/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(MESON_BUILD_DIR)/arping $(1)/usr/bin/
endef
### clockdiff
define Package/iputils-clockdiff define Package/iputils-clockdiff
$(call Package/iputils/Default) $(call Package/iputils/Default)
TITLE:=iputils-clockdiff TITLE:=iputils - clockdiff
endef endef
define Package/iputils-clockdiff/description define Package/iputils-clockdiff/description
Measure the clock difference between two hosts Program clockdiff from iputils.
Measures clock difference between hosts.
endef
define Package/iputils-ping
$(call Package/iputils/Default)
TITLE:=iputils - ping
endef
define Package/iputils-ping/description
Program ping from iputils.
Sends ICMP ECHO_REQUEST to network hosts (IPv4).
endef
define Package/iputils-ping6
$(call Package/iputils/Default)
TITLE:=iputils - ping6
DEPENDS+= @IPV6 +USE_GLIBC:libopenssl
endef
define Package/iputils-ping6/description
Program ping6 from iputils.
Sends ICMP ECHO_REQUEST to network hosts (IPv6).
endef
define Package/iputils-tftpd
$(call Package/iputils/Default)
TITLE:=iputils - tftpd
endef
define Package/iputils-tftpd/description
Program tftpd from iputils
Trivial File Transfer Protocol server.
endef
define Package/iputils-tracepath
$(call Package/iputils/Default)
TITLE:=iputils - tracepath
endef
define Package/iputils-tracepath/description
Program tracepath from iputils.
Traces path to a network host discovering MTU along this path (IPv4).
endef
define Package/iputils-tracepath6
$(call Package/iputils/Default)
TITLE:=iputils - tracepath6
DEPENDS+= @IPV6
endef
define Package/iputils-tracepath6/description
Program tracepath6 from iputils.
Traces path to a network host discovering MTU along this path (IPv6).
endef
define Package/iputils-traceroute6
$(call Package/iputils/Default)
TITLE:=iputils - traceroute6
DEPENDS+= @IPV6
endef
define Package/iputils-traceroute6/description
Program traceroute6 from iputils.
Traces path to a network host (IPv6).
endef
ifdef CONFIG_USE_MUSL
TARGET_CFLAGS += -D__UCLIBC__
endif
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS) $(TARGET_LDFLAGS)" \
CONFIG_IPV6="$(CONFIG_IPV6)" \
CONFIG_USE_UCLIBC="$(CONFIG_USE_UCLIBC)$(CONFIG_USE_MUSL)" \
define Package/iputils-arping/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/arping $(1)/usr/bin/
endef endef
define Package/iputils-clockdiff/install define Package/iputils-clockdiff/install
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(MESON_BUILD_DIR)/clockdiff $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/clockdiff $(1)/usr/bin/
endef endef
### tracepath define Package/iputils-ping/install
$(INSTALL_DIR) $(1)/usr/bin
define Package/iputils-tracepath $(INSTALL_SUID) $(PKG_BUILD_DIR)/ping $(1)/usr/bin/
$(call Package/iputils/Default)
TITLE:=iputils-tracepath
endef endef
define Package/iputils-tracepath/description define Package/iputils-ping6/install
trace network path to a host, discovering PMTU $(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_SUID) $(PKG_BUILD_DIR)/ping6 $(1)/usr/bin/
endef endef
define Package/iputils-tracepath/config define Package/iputils-tftpd/install
source "$(SOURCE)/Config_tracepath.in" $(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tftpd $(1)/usr/sbin/
endef endef
define Package/iputils-tracepath/install define Package/iputils-tracepath/install
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(MESON_BUILD_DIR)/tracepath $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tracepath $(1)/usr/bin/
ifdef CONFIG_TRACEPATH_LEGACY_SYMLINKS
ln -s tracepath $(1)/usr/bin/tracepath4
ln -s tracepath $(1)/usr/bin/tracepath6
endif
endef endef
### tftp define Package/iputils-tracepath6/install
define Package/iputils-tftpd
$(call Package/iputils/Default)
TITLE:=iputils-tftpd
endef
define Package/iputils-tftpd/description
Trivial File Transfer Protocol server
endef
define Package/iputils-tftpd/install
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(MESON_BUILD_DIR)/tftpd $(1)/usr/bin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/tracepath6 $(1)/usr/bin/
endef
define Package/iputils-traceroute6/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_SUID) $(PKG_BUILD_DIR)/traceroute6 $(1)/usr/bin/
endef endef
$(eval $(call BuildPackage,iputils-ping))
$(eval $(call BuildPackage,iputils-arping)) $(eval $(call BuildPackage,iputils-arping))
$(eval $(call BuildPackage,iputils-clockdiff)) $(eval $(call BuildPackage,iputils-clockdiff))
$(eval $(call BuildPackage,iputils-tracepath)) $(eval $(call BuildPackage,iputils-ping))
$(eval $(call BuildPackage,iputils-tftpd)) $(eval $(call BuildPackage,iputils-tftpd))
$(eval $(call BuildPackage,iputils-tracepath))
$(eval $(call BuildPackage,iputils-ping6))
$(eval $(call BuildPackage,iputils-tracepath6))
$(eval $(call BuildPackage,iputils-traceroute6))

View File

@ -0,0 +1,14 @@
diff -ur a/Makefile b/Makefile
--- a/Makefile 2002-09-20 18:23:55.000000000 +0000
+++ b/Makefile 2007-05-17 13:59:55.000000000 +0000
@@ -16,8 +16,8 @@
CCOPT=-D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall -g
CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
-IPV4_TARGETS=tracepath ping clockdiff rdisc arping tftpd rarpd
-IPV6_TARGETS=tracepath6 traceroute6 ping6
+IPV4_TARGETS=tracepath ping clockdiff arping tftpd
+IPV6_TARGETS=tracepath6 traceroute6 ping6
TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
LASTTAG:=`git describe HEAD | sed -e 's/-.*//'`

View File

@ -0,0 +1,14 @@
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,10 @@ CFLAGS=$(CCOPT) $(GLIBCFIX) $(DEFINES)
IPV4_TARGETS=tracepath ping clockdiff arping tftpd
IPV6_TARGETS=tracepath6 traceroute6 ping6
-TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
+TARGETS=$(IPV4_TARGETS)
+ifeq ($(CONFIG_IPV6),y)
+ TARGETS=$(IPV4_TARGETS) $(IPV6_TARGETS)
+endif
LASTTAG:=`git describe HEAD | sed -e 's/-.*//'`
TAG:=`date +s%Y%m%d`

View File

@ -0,0 +1,18 @@
--- a/Makefile
+++ b/Makefile
@@ -30,9 +30,13 @@ all: $(TARGETS)
tftpd: tftpd.o tftpsubs.o
-arping: arping.o -lsysfs
+arping: arping.o
+ $(CC) $(CFLAGS) -o $@ arping.o -lsysfs
ping: ping.o ping_common.o
-ping6: ping6.o ping_common.o -lresolv -lcrypto
+ping6: ping6.o ping_common.o
+ifneq ($(CONFIG_USE_UCLIBC),y)
+ $(CC) $(CFLAGS) -o $@ ping6.o ping_common.o -lresolv -lcrypto
+endif
ping.o ping6.o ping_common.o: ping_common.h
tftpd.o tftpsubs.o: tftp.h

View File

@ -0,0 +1,200 @@
diff --git a/ping6.c b/ping6.c
index c5ff881..ef2243f 100644
--- a/ping6.c
+++ b/ping6.c
@@ -71,9 +71,11 @@ char copyright[] =
#include <linux/filter.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
+#ifndef __UCLIBC__
#include <resolv.h>
#include "ping6_niquery.h"
+#endif /* __UCLIBC__ */
#ifndef SOL_IPV6
#define SOL_IPV6 IPPROTO_IPV6
@@ -154,6 +156,7 @@ int pmtudisc=-1;
static int icmp_sock;
+#ifndef __UCLIBC__
#include <openssl/md5.h>
/* Node Information query */
@@ -165,6 +168,7 @@ int ni_subject_type = 0;
char *ni_group;
__u8 ni_nonce[8];
+#endif /* __UCLIBC__ */
static struct in6_addr in6_anyaddr;
static __inline__ int ipv6_addr_any(struct in6_addr *addr)
@@ -223,6 +227,7 @@ unsigned int if_name2index(const char *ifname)
return i;
}
+#ifndef __UCLIBC__
struct niquery_option {
char *name;
int namelen;
@@ -512,6 +517,7 @@ char *ni_groupaddr(const char *name)
strcat(nigroup_buf, q);
return nigroup_buf;
}
+#endif /* __UCLIBC__ */
int main(int argc, char *argv[])
{
@@ -595,12 +601,14 @@ int main(int argc, char *argv[])
case 'V':
printf("ping6 utility, iputils-ss%s\n", SNAPSHOT);
exit(0);
+#ifndef __UCLIBC__
case 'N':
if (niquery_option_handler(optarg) < 0) {
usage();
break;
}
break;
+#endif /* __UCLIBC__ */
COMMON_OPTIONS
common_options(ch);
break;
@@ -663,6 +671,7 @@ int main(int argc, char *argv[])
argc--;
}
+#ifndef __UCLIBC__
if (ni_query >= 0) {
int i;
for (i = 0; i < 8; i++)
@@ -674,15 +683,20 @@ int main(int argc, char *argv[])
ni_subject_type = NI_SUBJ_IPV6;
}
}
+#endif /* __UCLIBC__ */
if (argc > 1)
usage();
else if (argc == 1) {
target = *argv;
} else {
+#ifndef __UCLIBC__
if (ni_query < 0 && ni_subject_type != NI_SUBJ_NAME)
+#endif /* __UCLIBC__ */
usage();
+#ifndef __UCLIBC__
target = ni_group;
+#endif /* __UCLIBC__ */
}
memset(&hints, 0, sizeof(hints));
@@ -817,7 +831,11 @@ int main(int argc, char *argv[])
exit(2);
}
+#ifndef __UCLIBC__
if (datalen >= sizeof(struct timeval) && (ni_query < 0)) {
+#else
+ if (datalen >= sizeof(struct timeval)) {
+#endif /* __UCLIBC__ */
/* can we time transfer */
timing = 1;
}
@@ -866,9 +884,11 @@ int main(int argc, char *argv[])
ICMP6_FILTER_SETPASS(ICMP6_PARAM_PROB, &filter);
}
+#ifndef __UCLIBC__
if (ni_query >= 0)
ICMP6_FILTER_SETPASS(ICMPV6_NI_REPLY, &filter);
else
+#endif /* __UCLIBC__ */
ICMP6_FILTER_SETPASS(ICMP6_ECHO_REPLY, &filter);
err = setsockopt(icmp_sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filter,
@@ -1100,6 +1120,7 @@ int build_echo(__u8 *_icmph)
return cc;
}
+#ifndef __UCLIBC__
int build_niquery(__u8 *_nih)
{
struct ni_hdr *nih;
@@ -1125,6 +1146,7 @@ int build_niquery(__u8 *_nih)
return cc;
}
+#endif /* __UCLIBC__ */
int send_probe(void)
{
@@ -1132,9 +1154,11 @@ int send_probe(void)
CLR((ntransmitted+1) % mx_dup_ck);
+#ifndef __UCLIBC__
if (ni_query >= 0)
len = build_niquery(outpack);
else
+#endif /* __UCLIBC__ */
len = build_echo(outpack);
if (cmsglen == 0) {
@@ -1176,6 +1200,7 @@ static void putchar_safe(char c)
printf("\\%03o", c);
}
+#ifndef __UCLIBC__
void pr_niquery_reply_name(struct ni_hdr *nih, int len)
{
__u8 *h = (__u8 *)(nih + 1);
@@ -1304,6 +1329,7 @@ void pr_niquery_reply(__u8 *_nih, int len)
}
putchar(';');
}
+#endif /* __UCLIBC__ */
/*
* parse_reply --
@@ -1353,6 +1379,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
hops, 0, tv, pr_addr(&from->sin6_addr),
pr_echo_reply))
return 0;
+#ifndef __UCLIBC__
} else if (icmph->icmp6_type == ICMPV6_NI_REPLY) {
struct ni_hdr *nih = (struct ni_hdr *)icmph;
__u16 seq = ntohs(*(__u16 *)nih->ni_nonce);
@@ -1363,6 +1390,7 @@ parse_reply(struct msghdr *msg, int cc, void *addr, struct timeval *tv)
hops, 0, tv, pr_addr(&from->sin6_addr),
pr_niquery_reply))
return 0;
+#endif /* __UCLIBC__ */
} else {
int nexthdr;
struct ip6_hdr *iph1 = (struct ip6_hdr*)(icmph+1);
@@ -1557,7 +1585,9 @@ void usage(void)
"Usage: ping6 [-LUdfnqrvVaAD] [-c count] [-i interval] [-w deadline]\n"
" [-p pattern] [-s packetsize] [-t ttl] [-I interface]\n"
" [-M pmtudisc-hint] [-S sndbuf] [-F flowlabel] [-Q tclass]\n"
+#ifndef __UCLIBC__
" [[-N nodeinfo-option] ...]\n"
+#endif /* __UCLIBC__ */
" [hop1 ...] destination\n");
exit(2);
}
diff --git a/ping6_niquery.h b/ping6_niquery.h
index 61a5cfa..34c31f8 100644
--- a/ping6_niquery.h
+++ b/ping6_niquery.h
@@ -1,3 +1,4 @@
+#ifndef __UCLIBC__
#include <asm/byteorder.h>
/* Node Information Query */
@@ -45,3 +46,4 @@ struct ni_hdr {
#define NI_IPV4ADDR_F_TRUNCATE NI_IPV6ADDR_F_TRUNCATE
#define NI_IPV4ADDR_F_ALL NI_IPV6ADDR_F_ALL
+#endif /* __UCLIBC__ */

View File

@ -0,0 +1,11 @@
--- a/ping6.c
+++ b/ping6.c
@@ -66,6 +66,8 @@ char copyright[] =
* More statistics could always be gathered.
* This program has to run SUID to ROOT to access the ICMP socket.
*/
+
+#define _GNU_SOURCE
#include "ping_common.h"
#include <linux/filter.h>

View File

@ -0,0 +1,71 @@
--- a/ping_common.h
+++ b/ping_common.h
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
+#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <linux/sockios.h>
@@ -11,7 +12,7 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <sys/uio.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
@@ -24,6 +25,10 @@
#include "SNAPSHOT.h"
+#ifndef HZ
+#define HZ 100
+#endif
+
#define DEFDATALEN (64 - 8) /* default data length */
#define MAXWAIT 10 /* max seconds to wait for response */
--- a/clockdiff.c
+++ b/clockdiff.c
@@ -13,8 +13,6 @@
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
-#define TSPTYPES
-#include <protocols/timed.h>
#include <fcntl.h>
#include <netdb.h>
#include <arpa/inet.h>
--- a/tracepath.c
+++ b/tracepath.c
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
+#include <sys/time.h>
#include <linux/types.h>
#include <linux/errqueue.h>
#include <errno.h>
--- a/ping.c
+++ b/ping.c
@@ -661,8 +661,15 @@ int send_probe()
do {
static struct iovec iov = {outpack, 0};
- static struct msghdr m = { &whereto, sizeof(whereto),
- &iov, 1, &cmsg, 0, 0 };
+ static struct msghdr m = {
+ .msg_name = &whereto,
+ .msg_namelen = sizeof(whereto),
+ .msg_iov = &iov,
+ .msg_iovlen = 1,
+ .msg_control = &cmsg,
+ .msg_controllen = 0,
+ .msg_flags = 0
+ };
m.msg_controllen = cmsg_len;
iov.iov_len = cc;