资源简介
本源码包含了在阅读和分析源码过程中添加的大量的注释。与本源码同时发布的是《iputils网络工具源码分析》系列文章,可在http://blog.csdn.net/fsdev中找到。

代码片段和文件信息
/*
* arping.c
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License or (at your option) any later version.
*
* Authors: Alexey Kuznetsov
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include “SNAPSHOT.h“
static void usage(void) __attribute__((noreturn));
int quit_on_reply=0;
char *device=“eth0“;
int ifindex;
char *source;
struct in_addr src dst;
char *target;
int dad unsolicited advert;
int quiet;
int count=-1;
int timeout;
int unicasting;
int s;
int broadcast_only;
struct sockaddr_ll me;
struct sockaddr_ll he;
/*
struct sockaddr_ll
{
unsigned short sll_family;
__be16 sll_protocol;
int sll_ifindex;
unsigned short sll_hatype;
unsigned char sll_pkttype;
unsigned char sll_halen;
unsigned char sll_addr[8];
};
linux-2.6.27/include/linux/if_packet.h
*/
struct timeval start last;
int sent brd_sent;
int received brd_recv req_recv;
#define MS_TDIFF(tv1tv2) ( ((tv1).tv_sec-(tv2).tv_sec)*1000 + \
((tv1).tv_usec-(tv2).tv_usec)/1000 )
#define lixiprintf printf
void usage(void)
{
fprintf(stderr
“Usage: arping [-fqbDUAV] [-c count] [-w timeout] [-I device] [-s source] destination\n“
“ -f : quit on first reply\n“
“ -q : be quiet\n“
“ -b : keep broadcasting don‘t go unicast\n“
“ -D : duplicate address detection mode\n“
“ -U : Unsolicited ARP mode update your neighbours\n“
“ -A : ARP answer mode update your neighbours\n“
“ -V : print version and exit\n“
“ -c count : how many packets to send\n“
“ -w timeout : how long to wait for a reply\n“
“ -I device : which ethernet device to use (eth0)\n“
“ -s source : source ip address\n“
“ destination : ask for what ip address\n“
);
exit(2);
}
void set_signal(int signo void (*handler)(void))
{
struct sigaction sa;
memset(&sa 0 sizeof(sa));
sa.sa_handler = (void (*)(int))handler;
sa.sa_flags = SA_RESTART;
sigaction(signo &sa NULL);
}
int send_pack(int s struct in_addr src struct in_addr dst
struct sockaddr_ll *ME struct sockaddr_ll *HE)
{
int err;
struct timeval now;
unsigned char buf[256];
struct arphdr *ah = (struct arphdr*)buf;
unsigned char *p = (unsigned char *)(ah+1);
/*
struct arphdr
{
__be16 ar_hrd; //format of hardware address
__be16 ar_pro; //format of protocol address
unsigned char ar_hln; //length of hardware address
unsigned char ar_pln; //length of protocol address
__be16 a
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2009-04-13 18:13 iputils-s20071127-lixi\
文件 19271 2008-12-03 18:47 iputils-s20071127-lixi\arping.c
文件 22962 2008-12-03 18:47 iputils-s20071127-lixi\clockdiff.c
目录 0 2009-04-13 18:13 iputils-s20071127-lixi\doc\
文件 6044 2008-12-03 18:47 iputils-s20071127-lixi\doc\arping.sgml
文件 4606 2008-12-03 18:47 iputils-s20071127-lixi\doc\clockdiff.sgml
文件 4606 2008-12-03 18:47 iputils-s20071127-lixi\doc\clockdiff.sgml~
文件 26655 2008-12-03 18:47 iputils-s20071127-lixi\doc\docbook2man-spec.pl
文件 622 2008-12-03 18:47 iputils-s20071127-lixi\doc\index.db
文件 3533 2008-12-03 18:47 iputils-s20071127-lixi\doc\index.out
文件 6678 2008-12-03 18:47 iputils-s20071127-lixi\doc\iputils.db
文件 1165 2008-12-03 18:47 iputils-s20071127-lixi\doc\Makefile
文件 4839 2008-12-03 18:47 iputils-s20071127-lixi\doc\pg3.sgml
文件 19792 2008-12-03 18:47 iputils-s20071127-lixi\doc\ping.sgml
文件 4794 2008-12-03 18:47 iputils-s20071127-lixi\doc\rarpd.sgml
文件 6731 2008-12-03 18:47 iputils-s20071127-lixi\doc\rdisc.sgml
文件 7 2008-12-03 18:47 iputils-s20071127-lixi\doc\snapshot.db
文件 5090 2008-12-03 18:47 iputils-s20071127-lixi\doc\tftpd.sgml
目录 0 2008-12-22 13:39 iputils-s20071127-lixi\doc\tmp.db2html\
文件 5334 2008-12-03 18:47 iputils-s20071127-lixi\doc\tracepath.sgml
文件 2936 2008-12-03 18:47 iputils-s20071127-lixi\doc\traceroute6.sgml
文件 429 2008-12-03 18:47 iputils-s20071127-lixi\INSTALL
文件 571 2008-12-03 18:47 iputils-s20071127-lixi\ipg
文件 2084 2008-12-03 18:47 iputils-s20071127-lixi\iputils.spec
文件 2021 2008-12-03 18:47 iputils-s20071127-lixi\Makefile
目录 0 2009-04-13 18:13 iputils-s20071127-lixi\Modules\
文件 215 2008-12-03 18:47 iputils-s20071127-lixi\Modules\Makefile
文件 15506 2008-12-03 18:47 iputils-s20071127-lixi\Modules\pg3.c
文件 48674 2008-12-03 18:47 iputils-s20071127-lixi\ping.c
文件 25526 2008-12-03 18:47 iputils-s20071127-lixi\ping6.c
文件 29934 2008-12-03 18:47 iputils-s20071127-lixi\ping_common.c
............此处省略11个文件信息
- 上一篇:员工绩效管理系统的设计及实现
- 下一篇:电梯梯控数据分析助手
相关资源
- E4A无障碍跨程序操作类库(带源码、
- 设备管理系统源码
- 安卓wifi直连app源码
- 我的世界源码(易语言版)
- labview编程软件滤波器以及编写程序设
- 我的界面(visual foxpro)源码
- 易语言:一键cf基址源码
- The Secret Path 3D 3D魔方迷宫[源码][scra
- scratch垃圾分类源码(最终版本).sb
- 安卓QQ6.71协议源码易语言,qq协议源码
- 编译原理实验工具及参考源码(lex&
- E盾偷后台工具源码
- UNIX/LINUX编程实践教程的源码
- 十以内加减法练习 powerbuilder源码
- 农场开发项目
- OCR源码
- PLC上位机编程软件
- 用foobar2000听google音乐[更新一下]
- 学生信息管理系统源码
- 用VC 编写的仿QQ聊天室程序源代码
- 毕业论文之温度传感器DS18B20(源码
- 可自定义导航网站源码
- 栅栏填充算法源码(VC)
- msp430F149操作红外接收模块源码
- [免费]图像识别c 源码
- 周易排盘源码
- RSA算法源码
- 一个人脸识别程序源码
- 编译原理课程设计:词法语法编译器
- 透明加密源码及说明
评论
共有 条评论