/* $NetBSD: arp.c,v 1.18 1997/07/07 15:52:49 drochner Exp $ */
/*
* Copyright (c) 1992 Regents of the University of California.
* All rights reserved.
*
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#) Header: arp.c,v 1.5 93/07/15 05:52:26 leres Exp (LBL)
*/
__FBSDID("$FreeBSD$");
#include <netinet/if_ether.h>
#include <netinet/in_systm.h>
#include <string.h>
#include "stand.h"
#include "net.h"
/* Cache stuff */
struct arp_list {
/* XXX - net order `INADDR_BROADCAST' must be a constant */
{ {0xffffffff}, BA }
};
/* Local forwards */
/* Broadcast an ARP packet, asking who has addr on interface d */
u_char *
struct iodesc *d;
{
int i;
struct {
struct {
} data;
} wbuf;
struct {
struct {
} data;
} rbuf;
/* Try for cached answer first */
/* Don't overflow cache */
printf("arpwhohas: overflowed arp_list!\n");
}
#ifdef ARP_DEBUG
if (debug)
#endif
/* Leave zeros in arp_tha */
/* Store ip address in cache (incomplete entry). */
i = sendrecv(d,
if (i == -1) {
panic("arp: no response for %s\n",
}
/* Store ethernet address in cache */
#ifdef ARP_DEBUG
if (debug) {
printf("arp: response from %s\n",
printf("arp: cacheing %s --> %s\n",
}
#endif
++arp_num;
}
static ssize_t
struct iodesc *d;
void *pkt;
{
#ifdef ARP_DEBUG
if (debug)
printf("arpsend: called\n");
#endif
}
/*
* Returns 0 if this is the packet we're waiting for
* else -1 (and errno == 0)
*/
static ssize_t
struct iodesc *d;
void *pkt;
{
ssize_t n;
#ifdef ARP_DEBUG
if (debug)
printf("arprecv: ");
#endif
errno = 0; /* XXX */
if (n == -1 || n < sizeof(struct ether_arp)) {
#ifdef ARP_DEBUG
if (debug)
printf("bad len=%d\n", n);
#endif
return (-1);
}
if (etype != ETHERTYPE_ARP) {
#ifdef ARP_DEBUG
if (debug)
#endif
return (-1);
}
/* Ethernet address now checked in readether() */
{
#ifdef ARP_DEBUG
if (debug)
#endif
return (-1);
}
#ifdef ARP_DEBUG
if (debug)
printf("is request\n");
#endif
return (-1);
}
#ifdef ARP_DEBUG
if (debug)
printf("not ARP reply\n");
#endif
return (-1);
}
/* Is the reply from the source we want? */
{
#ifdef ARP_DEBUG
if (debug)
printf("unwanted address\n");
#endif
return (-1);
}
/* We don't care who the reply was sent to. */
/* We have our answer. */
#ifdef ARP_DEBUG
if (debug)
printf("got it\n");
#endif
return (n);
}
/*
* Convert an ARP request into a reply and send it.
* Notes: Re-uses buffer. Pad to length = 46.
*/
void
struct iodesc *d;
void *pkt; /* the request */
{
{
#ifdef ARP_DEBUG
if (debug)
#endif
return;
}
#ifdef ARP_DEBUG
if (debug)
printf("arp_reply: not request!\n");
#endif
return;
}
/* If we are not the target, ignore the request. */
return;
#ifdef ARP_DEBUG
if (debug) {
}
#endif
/* source becomes target */
/* here becomes source */
/*
* No need to get fancy here. If the send fails, the
* requestor will just ask again.
*/
}