mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2024-11-25 02:30:38 +02:00
add fping
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@508 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
cbf6a4ec01
commit
657abff31c
@ -36,6 +36,7 @@ source "package/nfs-server/Config.in"
|
||||
source "package/ser/Config.in"
|
||||
source "package/wol/Config.in"
|
||||
source "package/chillispot/Config.in"
|
||||
source "package/fping/Config.in"
|
||||
|
||||
comment "Libraries"
|
||||
source "package/zlib/Config.in"
|
||||
|
@ -12,6 +12,7 @@ package-$(BR2_PACKAGE_DROPBEAR) += dropbear
|
||||
package-$(BR2_PACKAGE_DNSMASQ) += dnsmasq
|
||||
package-$(BR2_PACKAGE_EBTABLES) += ebtables
|
||||
package-$(BR2_PACKAGE_EZIPUPDATE) += ez-ipupdate
|
||||
package-$(BR2_PACKAGE_FPING) += fping
|
||||
package-$(BR2_PACKAGE_GMP) += gmp
|
||||
package-$(BR2_PACKAGE_HASERL) += haserl
|
||||
package-$(BR2_PACKAGE_IPTABLES) += iptables
|
||||
|
12
openwrt/package/fping/Config.in
Normal file
12
openwrt/package/fping/Config.in
Normal file
@ -0,0 +1,12 @@
|
||||
config BR2_PACKAGE_FPING
|
||||
tristate "fping"
|
||||
default m
|
||||
help
|
||||
fping is a ping(1) like program which uses the Internet Control Message Protocol
|
||||
(ICMP) echo request to determine if a host is up. fping is different from ping in
|
||||
that you can specify any number of hosts on the command line, or specify a file
|
||||
containing the lists of hosts to ping. Instead of trying one host until it timeouts
|
||||
or replies, fping will send out a ping packet and move on to the next host in a
|
||||
round-robin fashion. If a host replies, it is noted and removed from the list of
|
||||
hosts to check. If a host does not respond within a certain time limit and/or retry
|
||||
limit it will be considered unreachable.
|
75
openwrt/package/fping/Makefile
Normal file
75
openwrt/package/fping/Makefile
Normal file
@ -0,0 +1,75 @@
|
||||
# $Id$
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fping
|
||||
PKG_VERSION:=2.4b2_to-ipv6
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=3ad516765514249a40d3c5b6caab812a
|
||||
|
||||
PKG_SOURCE_URL:=http://www.fping.com/download/
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_CAT:=zcat
|
||||
PKG_IPK:=$(PACKAGE_DIR)/$(PKG_NAME)_$(PKG_VERSION)-$(PKG_RELEASE)_$(ARCH).ipk
|
||||
PKG_IPK_DIR:=$(PKG_BUILD_DIR)/ipkg
|
||||
|
||||
$(DL_DIR)/$(PKG_SOURCE):
|
||||
$(SCRIPT_DIR)/download.pl $(DL_DIR) $(PKG_SOURCE) $(PKG_MD5SUM) $(PKG_SOURCE_URL)
|
||||
|
||||
$(PKG_BUILD_DIR)/.patched: $(DL_DIR)/$(PKG_SOURCE)
|
||||
$(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
|
||||
$(PATCH) $(PKG_BUILD_DIR) ./patches
|
||||
touch $(PKG_BUILD_DIR)/.patched
|
||||
|
||||
$(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.patched
|
||||
(cd $(PKG_BUILD_DIR); rm -rf config.cache; \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
./configure \
|
||||
--target=$(GNU_TARGET_NAME) \
|
||||
--host=$(GNU_TARGET_NAME) \
|
||||
--build=$(GNU_HOST_NAME) \
|
||||
--prefix=/usr \
|
||||
--exec-prefix=/usr \
|
||||
--bindir=/usr/bin \
|
||||
--sbindir=/usr/sbin \
|
||||
--libexecdir=/usr/lib \
|
||||
--sysconfdir=/etc \
|
||||
--datadir=/usr/share \
|
||||
--localstatedir=/var \
|
||||
--mandir=/usr/man \
|
||||
--infodir=/usr/info \
|
||||
$(DISABLE_NLS) \
|
||||
$(DISABLE_LARGEFILE) \
|
||||
);
|
||||
touch $(PKG_BUILD_DIR)/.configured
|
||||
|
||||
$(PKG_BUILD_DIR)/$(PKG_NAME)4: $(PKG_BUILD_DIR)/.configured
|
||||
$(MAKE) CC=$(TARGET_CC) CFLAGS="$(TARGET_CFLAGS)" -C $(PKG_BUILD_DIR) clean $(PKG_NAME)
|
||||
mv $(PKG_BUILD_DIR)/$(PKG_NAME) $(PKG_BUILD_DIR)/$(PKG_NAME)4
|
||||
|
||||
$(PKG_BUILD_DIR)/$(PKG_NAME)6: $(PKG_BUILD_DIR)/.configured
|
||||
$(MAKE) CC=$(TARGET_CC) CFLAGS="$(TARGET_CFLAGS) -DIPV6=1" -C $(PKG_BUILD_DIR) clean $(PKG_NAME)
|
||||
mv $(PKG_BUILD_DIR)/$(PKG_NAME) $(PKG_BUILD_DIR)/$(PKG_NAME)6
|
||||
|
||||
$(PKG_IPK): $(PKG_BUILD_DIR)/$(PKG_NAME)4 $(PKG_BUILD_DIR)/$(PKG_NAME)6
|
||||
$(SCRIPT_DIR)/make-ipkg-dir.sh $(PKG_IPK_DIR) $(PKG_NAME).control $(PKG_VERSION)-$(PKG_RELEASE) $(ARCH)
|
||||
mkdir -p $(PKG_IPK_DIR)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/$(PKG_NAME)4 $(PKG_IPK_DIR)/usr/bin/$(PKG_NAME)
|
||||
cp $(PKG_BUILD_DIR)/$(PKG_NAME)6 $(PKG_IPK_DIR)/usr/bin/
|
||||
$(STRIP) $(PKG_IPK_DIR)/usr/bin/*
|
||||
mkdir -p $(PACKAGE_DIR)
|
||||
$(IPKG_BUILD) $(PKG_IPK_DIR) $(PACKAGE_DIR)
|
||||
|
||||
$(IPKG_STATE_DIR)/info/$(PKG_NAME).list: $(PKG_IPK)
|
||||
$(IPKG) install $(PKG_IPK)
|
||||
|
||||
source: $(DL_DIR)/$(PKG_SOURCE)
|
||||
prepare: $(PKG_BUILD_DIR)/.patched
|
||||
compile: $(PKG_IPK)
|
||||
install: $(IPKG_STATE_DIR)/info/$(PKG_NAME).list
|
||||
|
||||
clean:
|
||||
rm -rf $(PKG_BUILD_DIR)
|
||||
rm -f $(PKG_IPK)
|
6
openwrt/package/fping/fping.control
Normal file
6
openwrt/package/fping/fping.control
Normal file
@ -0,0 +1,6 @@
|
||||
Package: fping
|
||||
Priority: optional
|
||||
Section: net
|
||||
Maintainer: Felix Fietkau <nbd@vd-s.ath.cx>
|
||||
Source: buildroot internal
|
||||
Description: A program to ping hosts in parallel
|
165
openwrt/package/fping/patches/debian-10.patch
Normal file
165
openwrt/package/fping/patches/debian-10.patch
Normal file
@ -0,0 +1,165 @@
|
||||
--- fping-2.4b2-to-ipv6.orig/fping.8
|
||||
+++ fping-2.4b2-to-ipv6/fping.8
|
||||
@@ -1,4 +1,4 @@
|
||||
-.TH fping l
|
||||
+.TH fping 8
|
||||
.SH NAME
|
||||
fping \- send ICMP ECHO_REQUEST packets to network hosts
|
||||
.SH SYNOPSIS
|
||||
@@ -152,7 +152,7 @@
|
||||
example none the less.
|
||||
.nf
|
||||
|
||||
-#!/usr/local/bin/perl
|
||||
+#!/usr/bin/perl
|
||||
require 'open2.pl';
|
||||
|
||||
$MAILTO = "root";
|
||||
@@ -178,7 +178,7 @@
|
||||
that are currently reachable.
|
||||
.nf
|
||||
|
||||
-#!/usr/local/bin/perl
|
||||
+#!/usr/bin/perl
|
||||
|
||||
$hosts_to_backup = `cat /etc/hosts.backup | fping -a`;
|
||||
|
||||
--- fping-2.4b2-to-ipv6.orig/fping.c
|
||||
+++ fping-2.4b2-to-ipv6/fping.c
|
||||
@@ -42,7 +42,6 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
-#define IPV6 1 /* This should be a compiler option, or even better be done from the Makefile... ;) */
|
||||
|
||||
#ifndef _NO_PROTO
|
||||
#if !__STDC__ && !defined( __cplusplus ) && !defined( FUNCPROTO ) \
|
||||
@@ -101,13 +100,8 @@
|
||||
#endif
|
||||
#include <netinet/in_systm.h>
|
||||
|
||||
-/* Linux has bizarre ip.h and ip_icmp.h */
|
||||
-#if defined( __linux__ )
|
||||
-#include "linux.h"
|
||||
-#else
|
||||
#include <netinet/ip.h>
|
||||
#include <netinet/ip_icmp.h>
|
||||
-#endif /* defined(__linux__) */
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
@@ -150,7 +144,11 @@
|
||||
#define MIN_PING_DATA sizeof( PING_DATA )
|
||||
#define MAX_IP_PACKET 65536 /* (theoretical) max IP packet size */
|
||||
#define SIZE_IP_HDR 20
|
||||
+#ifndef IPV6
|
||||
#define SIZE_ICMP_HDR ICMP_MINLEN /* from ip_icmp.h */
|
||||
+#else
|
||||
+#define SIZE_ICMP_HDR sizeof(FPING_ICMPHDR)
|
||||
+#endif
|
||||
#define MAX_PING_DATA ( MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR )
|
||||
|
||||
/* sized so as to be like traditional ping */
|
||||
@@ -474,6 +472,35 @@
|
||||
sizeof(opton)))
|
||||
err(1, "setsockopt(IPV6_RTHDR)");
|
||||
#endif
|
||||
+#ifndef USE_SIN6_SCOPE_ID
|
||||
+#ifdef IPV6_RECVPKTINFO
|
||||
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &opton,
|
||||
+ sizeof(opton)))
|
||||
+ err(1, "setsockopt(IPV6_RECVPKTINFO)");
|
||||
+#else /* old adv. API */
|
||||
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_PKTINFO, &opton,
|
||||
+ sizeof(opton)))
|
||||
+ err(1, "setsockopt(IPV6_PKTINFO)");
|
||||
+#endif
|
||||
+#endif /* USE_SIN6_SCOPE_ID */
|
||||
+#ifdef IPV6_RECVHOPLIMIT
|
||||
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &opton,
|
||||
+ sizeof(opton)))
|
||||
+ err(1, "setsockopt(IPV6_RECVHOPLIMIT)");
|
||||
+#else /* old adv. API */
|
||||
+ if (setsockopt(s, IPPROTO_IPV6, IPV6_HOPLIMIT, &opton,
|
||||
+ sizeof(opton)))
|
||||
+ err(1, "setsockopt(IPV6_HOPLIMIT)");
|
||||
+#endif
|
||||
+#ifdef IPV6_CHECKSUM
|
||||
+#ifndef SOL_RAW
|
||||
+#define SOL_RAW IPPROTO_IPV6
|
||||
+#endif
|
||||
+ opton = 2;
|
||||
+ if (setsockopt(s, SOL_RAW, IPV6_CHECKSUM, &opton,
|
||||
+ sizeof(opton)))
|
||||
+ err(1, "setsockopt(SOL_RAW,IPV6_CHECKSUM)");
|
||||
+#endif
|
||||
#endif
|
||||
|
||||
if( ( uid = getuid() ) )
|
||||
@@ -1112,7 +1139,7 @@
|
||||
/* but allow time for the last one to come in */
|
||||
if( count_flag )
|
||||
{
|
||||
- if( ( cursor->num_sent >= count ) && ( ht > cursor->timeout ) )
|
||||
+ if( ( cursor->num_sent >= count ) && ( cursor->num_recv >= count || ht > cursor->timeout ) )
|
||||
{
|
||||
remove_job( cursor );
|
||||
continue;
|
||||
@@ -1382,15 +1409,15 @@
|
||||
if( h->num_recv_i <= h->num_sent_i )
|
||||
{
|
||||
fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%",
|
||||
- h->num_sent_i, h->num_recv_i,
|
||||
- ( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i );
|
||||
+ h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
|
||||
+ ( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i : 0 );
|
||||
|
||||
}/* IF */
|
||||
else
|
||||
{
|
||||
fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%",
|
||||
- h->num_sent_i, h->num_recv_i,
|
||||
- ( ( h->num_recv_i * 100 ) / h->num_sent_i ) );
|
||||
+ h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
|
||||
+ ( ( h->num_recv_i * 100 ) / h->num_sent_i ) : 0 );
|
||||
|
||||
}/* ELSE */
|
||||
|
||||
@@ -2165,20 +2192,33 @@
|
||||
struct addrinfo *res, hints;
|
||||
int ret_ga;
|
||||
char *hostname;
|
||||
+ size_t len;
|
||||
|
||||
/* getaddrinfo */
|
||||
bzero(&hints, sizeof(struct addrinfo));
|
||||
- hints.ai_flags = AI_CANONNAME;
|
||||
+ hints.ai_flags = name_flag ? AI_CANONNAME : 0;
|
||||
hints.ai_family = AF_INET6;
|
||||
hints.ai_socktype = SOCK_RAW;
|
||||
hints.ai_protocol = IPPROTO_ICMPV6;
|
||||
|
||||
ret_ga = getaddrinfo(name, NULL, &hints, &res);
|
||||
- if (ret_ga) errx(1, "%s", gai_strerror(ret_ga));
|
||||
+ if (ret_ga) {
|
||||
+ if(!quiet_flag)
|
||||
+ warnx("%s", gai_strerror(ret_ga));
|
||||
+ num_noaddress++;
|
||||
+ return;
|
||||
+ }
|
||||
if (res->ai_canonname) hostname = res->ai_canonname;
|
||||
else hostname = name;
|
||||
- if (!res->ai_addr) errx(1, "getaddrinfo failed");
|
||||
- (void)memcpy(&dst, res->ai_addr, sizeof(FPING_SOCKADDR)); /*res->ai_addrlen);*/
|
||||
+ if (!res->ai_addr) {
|
||||
+ if(!quiet_flag)
|
||||
+ warnx("getaddrinfo failed");
|
||||
+ num_noaddress++;
|
||||
+ return;
|
||||
+ }
|
||||
+ len = res->ai_addrlen;
|
||||
+ if (len > sizeof(FPING_SOCKADDR)) len = sizeof(FPING_SOCKADDR);
|
||||
+ (void)memcpy(&dst, res->ai_addr, len);
|
||||
add_addr(name, name, &dst);
|
||||
#endif
|
||||
} /* add_name() */
|
Loading…
Reference in New Issue
Block a user