/*
* fping: fast-ping, file-ping, favorite-ping, funky-ping
*
* Ping a list of target hosts in a round robin fashion.
* A better ping overall.
*
* fping website: http://www.fping.org
*
* Current maintainer of fping: David Schweikert
* Please send suggestions and patches to: david@schweikert.ch
*
*
* Original author: Roland Schemers <schemers@stanford.edu>
* IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
* Improved main loop: David Schweikert <david@schweikert.ch>
* Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch>
* Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de)
*
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by Stanford University. The name of the University may not be used
* to endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
#include "fping.h"
#include "options.h"
/* if compiling for Windows, use this separate set
(too difficult to ifdef all the autoconf defines) */
#ifdef WIN32
/*** Windows includes ***/
#else
/*** autoconf includes ***/
#include <stdio.h>
#include <errno.h>
#include <time.h>
#include <signal.h>
#include <getopt.h>
#include <stdarg.h>
#include "config.h"
#include "seqmap.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif /* HAVE_STDLIB_H */
#include <string.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#if HAVE_SYS_FILE_H
#include <sys/file.h>
#endif /* HAVE_SYS_FILE_H */
#ifdef IPV6
#include <netinet/icmp6.h>
#endif
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <arpa/inet.h>
#include <netdb.h>
/* RS6000 has sys/select.h */
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif /* HAVE_SYS_SELECT_H */
#endif /* WIN32 */
/*** externals ***/
extern char *optarg;
extern int optind,opterr;
extern int h_errno;
#ifdef __cplusplus
}
#endif /* __cplusplus */
/*** Constants ***/
#define EMAIL "david@schweikert.ch"
/*** Ping packet defines ***/
#define MIN_PING_DATA 0
#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 */
#define DEFAULT_PING_DATA_SIZE 56
/* maxima and minima */
#define MAX_COUNT 10000
#define MIN_INTERVAL 10 /* in millisec */
#define MIN_PERHOST_INTERVAL 20 /* in millisec */
#define MIN_TIMEOUT 50 /* in millisec */
#define MAX_RETRY 20
/* response time array flags */
#define RESP_WAITING -1
#define RESP_UNUSED -2
#define RESP_ERROR -3
/* debugging flags */
#if defined( DEBUG ) || defined( _DEBUG )
#define DBG_TRACE 1
#define DBG_SENT_TIMES 2
#define DBG_RANDOM_LOSE_FEW 4
#define DBG_RANDOM_LOSE_MANY 8
#define DBG_PRINT_PER_SYSTEM 16
#define DBG_REPORT_ALL_RTTS 32
#endif /* DEBUG || _DEBUG */
/* Long names for ICMP packet types */
char *icmp_type_str[19] =
{
"ICMP Echo Reply", /* 0 */
"",
"",
"ICMP Unreachable", /* 3 */
"ICMP Source Quench", /* 4 */
"ICMP Redirect", /* 5 */
"",
"",
"ICMP Echo", /* 8 */
"",
"",
"ICMP Time Exceeded", /* 11 */
"ICMP Parameter Problem", /* 12 */
"ICMP Timestamp Request", /* 13 */
"ICMP Timestamp Reply", /* 14 */
"ICMP Information Request", /* 15 */
"ICMP Information Reply", /* 16 */
"ICMP Mask Request", /* 17 */
"ICMP Mask Reply" /* 18 */
};
char *icmp_unreach_str[16] =
{
"ICMP Network Unreachable", /* 0 */
"ICMP Host Unreachable", /* 1 */
"ICMP Protocol Unreachable", /* 2 */
"ICMP Port Unreachable", /* 3 */
"ICMP Unreachable (Fragmentation Needed)", /* 4 */
"ICMP Unreachable (Source Route Failed)", /* 5 */
"ICMP Unreachable (Destination Network Unknown)", /* 6 */
"ICMP Unreachable (Destination Host Unknown)", /* 7 */
"ICMP Unreachable (Source Host Isolated)", /* 8 */
"ICMP Unreachable (Communication with Network Prohibited)", /* 9 */
"ICMP Unreachable (Communication with Host Prohibited)", /* 10 */
"ICMP Unreachable (Network Unreachable For Type Of Service)", /* 11 */
"ICMP Unreachable (Host Unreachable For Type Of Service)", /* 12 */
"ICMP Unreachable (Communication Administratively Prohibited)", /* 13 */
"ICMP Unreachable (Host Precedence Violation)", /* 14 */
"ICMP Unreachable (Precedence cutoff in effect)" /* 15 */
};
#define ICMP_UNREACH_MAXTYPE 15
/* entry used to keep track of each host we are pinging */
#define EV_TYPE_PING 1
#define EV_TYPE_TIMEOUT 2
typedef struct host_entry
{
/* Each host can have an event attached: either the next time that a ping needs
* to be sent, or the timeout, if the last ping was sent */
struct host_entry *ev_prev; /* double linked list for the event-queue */
struct host_entry *ev_next; /* double linked list for the event-queue */
struct timeval ev_time; /* time, after which this event should happen */
int ev_type; /* event type */
int i; /* index into array */
char *name; /* name as given by user */
char *host; /* text description of host */
char *pad; /* pad to align print names */
FPING_SOCKADDR saddr; /* internet address */
int timeout; /* time to wait for response */
unsigned char running; /* unset when through sending */
unsigned char waiting; /* waiting for response */
struct timeval last_send_time; /* time of last packet sent */
int num_sent; /* number of ping packets sent */
int num_recv; /* number of pings received (duplicates ignored) */
int num_recv_total; /* number of pings received, including duplicates */
int max_reply; /* longest response time */
int min_reply; /* shortest response time */
int total_time; /* sum of response times */
/* _i -> splits (reset on every report interval) */
int num_sent_i; /* number of ping packets sent */
int num_recv_i; /* number of pings received */
int max_reply_i; /* longest response time */
int min_reply_i; /* shortest response time */
int total_time_i; /* sum of response times */
int *r
没有合适的资源?快使用搜索试试~ 我知道了~
Linux fping安装包
需积分: 16 21 下载量 148 浏览量
2015-05-28
22:34:11
上传
评论
收藏 153KB GZ 举报
温馨提示
共32个文件
c:5个
in:4个
am:3个
早期的ping扫描工具大都需要等待前一个被探测主机返回某种响应消息之后才能继续探测下一台主机是否存在,但fping却能以轮转方式并行地发出大量的ping请求。这么一来,用fping工具去扫描多个IP地址的速度要比ping快很多。fping工具有两种用法:既可以通过标准输入设备(stdin)向它提供一系列IP地址作为输入,也可以让它去读取某个文件。让fping工具去读取一个文件是件很简单的事情
资源推荐
资源详情
资源评论
收起资源包目录
fping-3.10.tar.gz (32个子文件)
fping-3.10
config.h.in 2KB
depcomp 23KB
aclocal.m4 43KB
compile 7KB
config.guess 45KB
Makefile.am 18B
config.sub 35KB
src
seqmap.c 4KB
seqmap.h 412B
socket6.c 2KB
fping.c 75KB
options.h 2KB
socket.c 2KB
Makefile.am 353B
socket4.c 2KB
Makefile.in 25KB
fping.h 603B
README 1KB
Makefile.in 24KB
INSTALL 7KB
missing 7KB
install-sh 14KB
doc
Makefile.am 264B
Makefile.in 14KB
fping.pod 6KB
README.1992 2KB
fping.8 11KB
fping6.8 11KB
configure 173KB
ChangeLog 21KB
COPYING 1KB
configure.ac 2KB
共 32 条
- 1
资源评论
zj0910
- 粉丝: 144
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功