2 * (C) Copyright 2000-2002
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #if defined(CONFIG_CMD_NET)
34 #define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */
35 #ifndef CONFIG_NET_RETRY_COUNT
36 # define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
38 # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
45 * Handle a RARP received packet.
48 RarpHandler(uchar * dummi0, unsigned dummi1, unsigned dummi2, unsigned dummi3)
51 debug("Got good RARP\n");
52 if ((s = getenv("autoload")) != NULL) {
55 * Just use RARP to configure system;
56 * Do not use TFTP/NFS to to load the bootfile.
58 NetState = NETLOOP_SUCCESS;
60 #if defined(CONFIG_CMD_NFS)
61 } else if ((s != NULL) && !strcmp(s, "NFS")) {
72 * Timeout on BOOTP request.
77 if (RarpTry >= TIMEOUT_COUNT) {
78 puts ("\nRetry count exceeded; starting again\n");
81 NetSetTimeout (TIMEOUT, RarpTimeout);
94 printf("RARP broadcast %d\n", ++RarpTry);
97 pkt += NetSetEther(pkt, NetBcastAddr, PROT_RARP);
101 rarp->ar_hrd = htons (ARP_ETHER);
102 rarp->ar_pro = htons (PROT_IP);
105 rarp->ar_op = htons (RARPOP_REQUEST);
106 memcpy (&rarp->ar_data[0], NetOurEther, 6); /* source ET addr */
107 memcpy (&rarp->ar_data[6], &NetOurIP, 4); /* source IP addr */
108 memcpy (&rarp->ar_data[10], NetOurEther, 6); /* dest ET addr = source ET addr ??*/
109 /* dest. IP addr set to broadcast */
110 for (i = 0; i <= 3; i++) {
111 rarp->ar_data[16 + i] = 0xff;
114 NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE);
116 NetSetTimeout(TIMEOUT, RarpTimeout);
117 NetSetHandler(RarpHandler);