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

📄 dump_arptab.c

📁 一款类linux的操作系统源码
💻 C
字号:
/* *  Roadrunner/pk *    Copyright (C) 1989-2001  Cornfed Systems, Inc. * *  The Roadrunner/pk operating system is free software; you can *  redistribute and/or modify it under the terms of the GNU General *  Public License, version 2, as published by the Free Software *  Foundation. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public *  License along with this program; if not, write to the Free *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, *  MA 02111-1307 USA * *  More information about the Roadrunner/pk operating system of *  which this file is a part is available on the World-Wide Web *  at: http://www.cornfed.com. * */#include <net/arp.h>#include <stdio.h>#include <string.h>#include <sys/intr.h>#include <fs/dump.h>#define ARP_HDR "ipaddr           hwaddr             state     ttl"voiddump_arptab(char *s){    arpentry_t ae;    char s1[32];    int arpcnt = 0, i, j, len;    disable;    for (i = 0; i < ARP_ENTRIES; i++)	if (arptab[i].state != ARP_ENTRY_FREE) {	    if (arpcnt++ == 0) {		sprintf(s, "%s\n", ARP_HDR);		s += strlen(ARP_HDR) + 1;	    }	    ae = &(arptab[i]);	    ip2str(ae->ip, s1);	    sprintf(s, s1);	    len = strlen(s1);	    s += len;	    for (j = 0; j < 17 - len; j++)		sprintf(s++, " ");	    if (ae->state == ARP_ENTRY_PENDING)		sprintf(s, "-                ");	    else		ether2str(ae->hwaddr, s);	    s += 17;	    sprintf(s, "  ");	    s += 2;	    if (ae->state == ARP_ENTRY_PENDING)		sprintf(s, "pending   ");	    else if (ae->state == ARP_ENTRY_RESOLVED)		sprintf(s, "resolved  ");	    else		sprintf(s, "ERROR     ");	    s += 10;	    if (ae->ttl == ARP_TTL_INFINITE) {		sprintf(s, "permanent\n");		s += 10;	    } else {		sprintf(s1, "%d\n", ae->ttl);		sprintf(s, s1);		s += strlen(s1);	    }	}    enable;}

⌨️ 快捷键说明

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