⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arpprint.c,v

📁 关于ARP协议方面的。比较难的。。不过是源码
💻 C,V
字号:
head	1.2;access;symbols;locks	dls:1.2; strict;comment	@ * @;1.2date	97.09.21.19.22.42;	author dls;	state Dist;branches;next	1.1;1.1date	94.09.24.17.58.32;	author dls;	state Old;branches;next	;desc@@1.2log@*** empty log message ***@text@/* arpprint - arpprint */#include <conf.h>#include <kernel.h>#include <network.h>#define HDR1 \"Intf.   IP address     Physical Address   HW  Proto   State       TTL\n"#define HDR2 \"----- ---------------  -----------------  --  -----  --------  ---------\n"static int	printone();/*------------------------------------------------------------------------ * arpprint - print the ARP table on descriptor fd *------------------------------------------------------------------------ */intarpprint(fd)int	fd;{	int	i;	write(fd, HDR1, strlen(HDR1));	write(fd, HDR2, strlen(HDR2));	for (i = 0; i<ARP_TSIZE; ++i)		if (arptable[i].ae_state != AS_FREE)			printone(fd, &arptable[i]);	return OK;}char	*index();/*------------------------------------------------------------------------ * printone - print one entry in the ARP table *------------------------------------------------------------------------ */static intprintone(fd, pae)int	fd;struct	arpentry	*pae;{	char	line[128], *p;	int	i;	sprintf(line, " %2d    ", pae->ae_pni - &nif[0]);	p = index(line, '\0');	for (i=0; i<pae->ae_prlen-1; ++i) {		sprintf(p, "%u.", pae->ae_pra[i] & 0xff);		p = index(p, '\0');	}	sprintf(p, "%u", pae->ae_pra[i]);	for (i=strlen(line); i<23; ++i)		line[i] = ' ';	p = &line[23];	for (i=0; i<pae->ae_hwlen-1; ++i) {		sprintf(p, "%02x:", pae->ae_hwa[i] & 0xff);		p = index(p, '\0');	}	sprintf(p, "%02x  %2d   %04x  %8s  ", pae->ae_hwa[i] & 0xff,		pae->ae_hwtype, pae->ae_prtype,		(pae->ae_state == AS_RESOLVED) ? "RESOLVED" : "PENDING");	p = index(p, '\0');	if (pae->ae_ttl == ARP_INF)		strcpy(p, "(permanent)\n");	else		sprintf(p, "%8d s\n", pae->ae_ttl);	return write(fd, line, strlen(line));}@1.1log@Initial revision@text@d7 6a12 1static	printone();d18 1d24 2d38 1a38 1staticd44 1a44 1	int	i, inum;d46 1a46 4	if (pae->ae_state == AS_RESOLVED)		strcpy(line, "RESOLVED ");	else		strcpy(line, "PENDING  ");d53 4a56 4	sprintf(p, "%u ", pae->ae_pra[i] & 0xff);	p = index(p, '\0');	inum = pae->ae_pni - &nif[0];d62 5d68 1a68 3		sprintf(p, "%x  hw %d pr %x inum %d ttl (permanent)\n",		    pae->ae_hwa[i]&0xff, pae->ae_hwtype, pae->ae_prtype,		    inum);d70 1a70 4		sprintf(p, "%x  hw %d pr %x inum %d ttl %d s\n",		    pae->ae_hwa[i]&0xff, pae->ae_hwtype, pae->ae_prtype,		    inum, pae->ae_ttl);	p = index(p, '\0');@

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -