/* $NetBSD: etherfun.c,v 1.12 2011/09/29 09:18:17 he Exp $ */
/*
* Copyright (c) 1995 Charles D. Cranor and Seth Widoff
* All rights reserved.
*
* 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
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
*/
/* etherfun.c */
#include "sboot.h"
#include "etherfun.h"
/* Construct and send a rev arp packet */
void
do_rev_arp(void)
{
int i;
for (i = 0; i < 6; i++) {
eh->ether_dhost[i] = 0xff;
}
memcpy(eh->ether_shost, myea, 6);
eh->ether_type = ETYPE_RARP;
rarp->ar_hrd = 1; /* hardware type is 1 */
rarp->ar_pro = PTYPE_IP;
rarp->ar_hln = 6; /* length of hardware address is 6 bytes */
rarp->ar_pln = 4; /* length of ip address is 4 byte */
rarp->ar_op = OPCODE_RARP;
memcpy(rarp->arp_sha, myea, sizeof(myea));
memcpy(rarp->arp_tha, myea, sizeof(myea));
for (i = 0; i < 4; i++) {
rarp->arp_spa[i] = rarp->arp_tpa[i] = 0x00;
}