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

📄 arp.c

📁 一款类linux的操作系统源码
💻 C
字号:
/* *  Roadrunner/pk *    Copyright (C) 1989-2002  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 <stdlib.h>#include <string.h>#include <sys/intr.h>#include <sys/time.h>#include <sys/timer.h>#define ARP_TIMER_PERIOD	5struct arpentry arptab[ARP_ENTRIES];static voidarp_timer(void *arg){    arpentry_t ae;    int i;    for (i = 0; i < ARP_ENTRIES; i++) {	ae = &(arptab[i]);	if (ae->state == ARP_ENTRY_PENDING) {	    ae->ttl -= ARP_TIMER_PERIOD;	    if (ae->ttl <= 0) {		ae->ttl = ARP_TTL_PENDING;		enable;		arp_send(ae->ip);		disable;	    }	} else if (ae->state == ARP_ENTRY_RESOLVED &&		   ae->ttl != ARP_TTL_INFINITE) {	    ae->ttl -= ARP_TIMER_PERIOD;	    if (ae->ttl == 0) {		buf_t b;		for (;;) {		    b = bdeq(&(ae->pktq));		    if (b == NULL)			break;		    brel(b);		}		bzero(ae, sizeof(struct arpentry));	    }	}    }}voidarp_init(){    struct timeval tv;    bzero(arptab, ARP_ENTRIES * sizeof(struct arpentry));    tv.tv_sec = ARP_TIMER_PERIOD;    tv.tv_usec = 0;    timer_loop("arp", &tv, arp_timer, NULL);}

⌨️ 快捷键说明

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