File:  [XINU] / xinu / sys / arpfind.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:39:02 2018 UTC (8 years, 2 months ago) by root
Branches: xinu, MAIN
CVS tags: xinu-19870308, HEAD
Xinu for VAX

/* arpfind.c - arpfind */

#include <conf.h>
#include <kernel.h>
#include <proc.h>
#include <network.h>

/*------------------------------------------------------------------------
 *  arpfind  -  find or insert entry in ARP cache and return its index
 *------------------------------------------------------------------------
 */
arpfind(faddr)
IPaddr	faddr;
{
	int	i;
	int	arindex;
	struct	arpent	*atabptr;

	for (arindex=0; arindex<Arp.atabsiz; arindex++) {
		atabptr = &Arp.arptab[arindex];
		if (blkequ(atabptr->arp_Iad, faddr, IPLEN)
			&& atabptr->arp_state != AR_FREE)
			return(arindex);
	}
	if (Arp.atabsiz < AR_TAB) {
		Arp.atabsiz++;
	}
	arindex = Arp.atabnxt++;
	if (Arp.atabnxt >= AR_TAB)
		Arp.atabnxt = 0;
	atabptr = &Arp.arptab[arindex];
	atabptr->arp_state = AR_ALLOC;
	blkcopy(atabptr->arp_Iad, faddr, IPLEN);
	for(i=0 ; i<EPADLEN ; i++)
		atabptr->arp_Ead[i] = '\0';
	atabptr->arp_dev = -1;
	return(arindex);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.