blob: 8e05ae57cd883cc8ac23cd8b1dabb0a1db86d725 [file] [log] [blame]
wdenkbe9c1cb2004-02-24 02:00:03 +00001/*
2 * NFS support driver - based on etherboot and U-BOOT's tftp.c
3 *
4 * Masami Komiya <mkomiya@sonare.it> 2004
5 *
6 */
7
8/* NOTE: the NFS code is heavily inspired by the NetBSD netboot code (read:
9 * large portions are copied verbatim) as distributed in OSKit 0.97. A few
10 * changes were necessary to adapt the code to Etherboot and to fix several
11 * inconsistencies. Also the RPC message preparation is done "by hand" to
12 * avoid adding netsprintf() which I find hard to understand and use. */
13
14/* NOTE 2: Etherboot does not care about things beyond the kernel image, so
15 * it loads the kernel image off the boot server (ARP_SERVER) and does not
16 * access the client root disk (root-path in dhcpd.conf), which would use
17 * ARP_ROOTSERVER. The root disk is something the operating system we are
18 * about to load needs to use. This is different from the OSKit 0.97 logic. */
19
20/* NOTE 3: Symlink handling introduced by Anselm M Hoffmeister, 2003-July-14
21 * If a symlink is encountered, it is followed as far as possible (recursion
22 * possible, maximum 16 steps). There is no clearing of ".."'s inside the
23 * path, so please DON'T DO THAT. thx. */
24
25#include <common.h>
26#include <command.h>
27#include <net.h>
28#include <malloc.h>
Joe Hershbergered191852015-03-22 17:09:08 -050029#include <mapmem.h>
wdenkbe9c1cb2004-02-24 02:00:03 +000030#include "nfs.h"
31#include "bootp.h"
32
wdenkbe9c1cb2004-02-24 02:00:03 +000033#define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */
Hiroshi Ito3702cd72008-01-31 18:35:04 +090034#define NFS_RETRY_COUNT 30
Tetsuyuki Kobayashi147e3902012-07-03 22:25:21 +000035#ifndef CONFIG_NFS_TIMEOUT
36# define NFS_TIMEOUT 2000UL
37#else
38# define NFS_TIMEOUT CONFIG_NFS_TIMEOUT
39#endif
wdenkbe9c1cb2004-02-24 02:00:03 +000040
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +010041#define NFS_RPC_ERR 1
42#define NFS_RPC_DROP 124
43
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +000044static int fs_mounted;
45static unsigned long rpc_id;
wdenkbe9c1cb2004-02-24 02:00:03 +000046static int nfs_offset = -1;
47static int nfs_len;
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +010048static ulong nfs_timeout = NFS_TIMEOUT;
wdenkbe9c1cb2004-02-24 02:00:03 +000049
50static char dirfh[NFS_FHSIZE]; /* file handle of directory */
51static char filefh[NFS_FHSIZE]; /* file handle of kernel image */
52
Joe Hershbergerd4bb76a2012-05-23 07:59:14 +000053static enum net_loop_state nfs_download_state;
wdenkbe9c1cb2004-02-24 02:00:03 +000054static IPaddr_t NfsServerIP;
55static int NfsSrvMountPort;
56static int NfsSrvNfsPort;
57static int NfsOurPort;
58static int NfsTimeoutCount;
59static int NfsState;
60#define STATE_PRCLOOKUP_PROG_MOUNT_REQ 1
61#define STATE_PRCLOOKUP_PROG_NFS_REQ 2
62#define STATE_MOUNT_REQ 3
63#define STATE_UMOUNT_REQ 4
64#define STATE_LOOKUP_REQ 5
65#define STATE_READ_REQ 6
66#define STATE_READLINK_REQ 7
67
68static char default_filename[64];
69static char *nfs_filename;
70static char *nfs_path;
71static char nfs_path_buff[2048];
72
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +000073static inline int
74store_block(uchar *src, unsigned offset, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +000075{
wdenk77ef4c62004-02-24 22:33:21 +000076 ulong newsize = offset + len;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020077#ifdef CONFIG_SYS_DIRECT_FLASH_NFS
wdenkbe9c1cb2004-02-24 02:00:03 +000078 int i, rc = 0;
79
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +000080 for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
wdenkbe9c1cb2004-02-24 02:00:03 +000081 /* start address in flash? */
82 if (load_addr + offset >= flash_info[i].start[0]) {
83 rc = 1;
84 break;
85 }
86 }
87
88 if (rc) { /* Flash is destination for this packet */
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +000089 rc = flash_write((uchar *)src, (ulong)(load_addr+offset), len);
wdenkbe9c1cb2004-02-24 02:00:03 +000090 if (rc) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +000091 flash_perror(rc);
Wolfgang Denkb077b502005-08-06 01:11:12 +020092 return -1;
wdenkbe9c1cb2004-02-24 02:00:03 +000093 }
94 } else
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020095#endif /* CONFIG_SYS_DIRECT_FLASH_NFS */
wdenkbe9c1cb2004-02-24 02:00:03 +000096 {
Joe Hershbergered191852015-03-22 17:09:08 -050097 void *ptr = map_sysmem(load_addr + offset, len);
98
99 memcpy(ptr, src, len);
100 unmap_sysmem(ptr);
wdenkbe9c1cb2004-02-24 02:00:03 +0000101 }
wdenk77ef4c62004-02-24 22:33:21 +0000102
103 if (NetBootFileXferSize < (offset+len))
104 NetBootFileXferSize = newsize;
Wolfgang Denkb077b502005-08-06 01:11:12 +0200105 return 0;
wdenkbe9c1cb2004-02-24 02:00:03 +0000106}
107
108static char*
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000109basename(char *path)
wdenkbe9c1cb2004-02-24 02:00:03 +0000110{
111 char *fname;
112
113 fname = path + strlen(path) - 1;
114 while (fname >= path) {
115 if (*fname == '/') {
116 fname++;
117 break;
118 }
119 fname--;
120 }
121 return fname;
122}
123
124static char*
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000125dirname(char *path)
wdenkbe9c1cb2004-02-24 02:00:03 +0000126{
127 char *fname;
128
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000129 fname = basename(path);
wdenkbe9c1cb2004-02-24 02:00:03 +0000130 --fname;
131 *fname = '\0';
132 return path;
133}
134
135/**************************************************************************
wdenkbe9c1cb2004-02-24 02:00:03 +0000136RPC_ADD_CREDENTIALS - Add RPC authentication/verifier entries
137**************************************************************************/
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000138static long *rpc_add_credentials(long *p)
wdenkbe9c1cb2004-02-24 02:00:03 +0000139{
140 int hl;
141 int hostnamelen;
142 char hostname[256];
143
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000144 strcpy(hostname, "");
145 hostnamelen = strlen(hostname);
wdenkbe9c1cb2004-02-24 02:00:03 +0000146
147 /* Here's the executive summary on authentication requirements of the
148 * various NFS server implementations: Linux accepts both AUTH_NONE
149 * and AUTH_UNIX authentication (also accepts an empty hostname field
150 * in the AUTH_UNIX scheme). *BSD refuses AUTH_NONE, but accepts
151 * AUTH_UNIX (also accepts an empty hostname field in the AUTH_UNIX
152 * scheme). To be safe, use AUTH_UNIX and pass the hostname if we have
153 * it (if the BOOTP/DHCP reply didn't give one, just use an empty
154 * hostname). */
155
156 hl = (hostnamelen + 3) & ~3;
157
158 /* Provide an AUTH_UNIX credential. */
159 *p++ = htonl(1); /* AUTH_UNIX */
160 *p++ = htonl(hl+20); /* auth length */
161 *p++ = htonl(0); /* stamp */
162 *p++ = htonl(hostnamelen); /* hostname string */
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000163 if (hostnamelen & 3)
wdenkbe9c1cb2004-02-24 02:00:03 +0000164 *(p + hostnamelen / 4) = 0; /* add zero padding */
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000165 memcpy(p, hostname, hostnamelen);
wdenkbe9c1cb2004-02-24 02:00:03 +0000166 p += hl / 4;
167 *p++ = 0; /* uid */
168 *p++ = 0; /* gid */
169 *p++ = 0; /* auxiliary gid list */
170
171 /* Provide an AUTH_NONE verifier. */
172 *p++ = 0; /* AUTH_NONE */
173 *p++ = 0; /* auth length */
174
175 return p;
176}
177
178/**************************************************************************
179RPC_LOOKUP - Lookup RPC Port numbers
180**************************************************************************/
181static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000182rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
wdenkbe9c1cb2004-02-24 02:00:03 +0000183{
184 struct rpc_t pkt;
185 unsigned long id;
186 uint32_t *p;
187 int pktlen;
188 int sport;
189
wdenkacd9b102004-03-14 00:59:59 +0000190 id = ++rpc_id;
wdenkbe9c1cb2004-02-24 02:00:03 +0000191 pkt.u.call.id = htonl(id);
192 pkt.u.call.type = htonl(MSG_CALL);
193 pkt.u.call.rpcvers = htonl(2); /* use RPC version 2 */
194 pkt.u.call.prog = htonl(rpc_prog);
195 pkt.u.call.vers = htonl(2); /* portmapper is version 2 */
196 pkt.u.call.proc = htonl(rpc_proc);
197 p = (uint32_t *)&(pkt.u.call.data);
198
199 if (datalen)
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000200 memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t));
wdenkbe9c1cb2004-02-24 02:00:03 +0000201
202 pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt;
203
Joe Hershberger6fe8b452012-05-23 07:58:04 +0000204 memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_UDP_HDR_SIZE,
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000205 (char *)&pkt, pktlen);
wdenkbe9c1cb2004-02-24 02:00:03 +0000206
207 if (rpc_prog == PROG_PORTMAP)
208 sport = SUNRPC_PORT;
209 else if (rpc_prog == PROG_MOUNT)
210 sport = NfsSrvMountPort;
211 else
212 sport = NfsSrvNfsPort;
213
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000214 NetSendUDPPacket(NetServerEther, NfsServerIP, sport, NfsOurPort,
215 pktlen);
wdenkbe9c1cb2004-02-24 02:00:03 +0000216}
217
218/**************************************************************************
219RPC_LOOKUP - Lookup RPC Port numbers
220**************************************************************************/
221static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000222rpc_lookup_req(int prog, int ver)
wdenkbe9c1cb2004-02-24 02:00:03 +0000223{
224 uint32_t data[16];
225
226 data[0] = 0; data[1] = 0; /* auth credential */
227 data[2] = 0; data[3] = 0; /* auth verifier */
228 data[4] = htonl(prog);
229 data[5] = htonl(ver);
230 data[6] = htonl(17); /* IP_UDP */
231 data[7] = 0;
232
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000233 rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, data, 8);
wdenkbe9c1cb2004-02-24 02:00:03 +0000234}
235
236/**************************************************************************
237NFS_MOUNT - Mount an NFS Filesystem
238**************************************************************************/
239static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000240nfs_mount_req(char *path)
wdenkbe9c1cb2004-02-24 02:00:03 +0000241{
242 uint32_t data[1024];
243 uint32_t *p;
244 int len;
245 int pathlen;
246
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000247 pathlen = strlen(path);
wdenkbe9c1cb2004-02-24 02:00:03 +0000248
249 p = &(data[0]);
250 p = (uint32_t *)rpc_add_credentials((long *)p);
251
252 *p++ = htonl(pathlen);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000253 if (pathlen & 3)
254 *(p + pathlen / 4) = 0;
255 memcpy(p, path, pathlen);
wdenkbe9c1cb2004-02-24 02:00:03 +0000256 p += (pathlen + 3) / 4;
257
258 len = (uint32_t *)p - (uint32_t *)&(data[0]);
259
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000260 rpc_req(PROG_MOUNT, MOUNT_ADDENTRY, data, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000261}
262
263/**************************************************************************
264NFS_UMOUNTALL - Unmount all our NFS Filesystems on the Server
265**************************************************************************/
266static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000267nfs_umountall_req(void)
wdenkbe9c1cb2004-02-24 02:00:03 +0000268{
269 uint32_t data[1024];
270 uint32_t *p;
271 int len;
272
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000273 if ((NfsSrvMountPort == -1) || (!fs_mounted))
wdenkbe9c1cb2004-02-24 02:00:03 +0000274 /* Nothing mounted, nothing to umount */
275 return;
wdenkbe9c1cb2004-02-24 02:00:03 +0000276
277 p = &(data[0]);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000278 p = (uint32_t *)rpc_add_credentials((long *)p);
wdenkbe9c1cb2004-02-24 02:00:03 +0000279
280 len = (uint32_t *)p - (uint32_t *)&(data[0]);
281
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000282 rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, data, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000283}
284
285/***************************************************************************
286 * NFS_READLINK (AH 2003-07-14)
287 * This procedure is called when read of the first block fails -
288 * this probably happens when it's a directory or a symlink
289 * In case of successful readlink(), the dirname is manipulated,
290 * so that inside the nfs() function a recursion can be done.
291 **************************************************************************/
292static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000293nfs_readlink_req(void)
wdenkbe9c1cb2004-02-24 02:00:03 +0000294{
295 uint32_t data[1024];
296 uint32_t *p;
297 int len;
298
299 p = &(data[0]);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000300 p = (uint32_t *)rpc_add_credentials((long *)p);
wdenkbe9c1cb2004-02-24 02:00:03 +0000301
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000302 memcpy(p, filefh, NFS_FHSIZE);
wdenkbe9c1cb2004-02-24 02:00:03 +0000303 p += (NFS_FHSIZE / 4);
304
305 len = (uint32_t *)p - (uint32_t *)&(data[0]);
306
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000307 rpc_req(PROG_NFS, NFS_READLINK, data, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000308}
309
310/**************************************************************************
311NFS_LOOKUP - Lookup Pathname
312**************************************************************************/
313static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000314nfs_lookup_req(char *fname)
wdenkbe9c1cb2004-02-24 02:00:03 +0000315{
316 uint32_t data[1024];
317 uint32_t *p;
318 int len;
319 int fnamelen;
320
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000321 fnamelen = strlen(fname);
wdenkbe9c1cb2004-02-24 02:00:03 +0000322
323 p = &(data[0]);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000324 p = (uint32_t *)rpc_add_credentials((long *)p);
wdenkbe9c1cb2004-02-24 02:00:03 +0000325
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000326 memcpy(p, dirfh, NFS_FHSIZE);
wdenkbe9c1cb2004-02-24 02:00:03 +0000327 p += (NFS_FHSIZE / 4);
328 *p++ = htonl(fnamelen);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000329 if (fnamelen & 3)
330 *(p + fnamelen / 4) = 0;
331 memcpy(p, fname, fnamelen);
wdenkbe9c1cb2004-02-24 02:00:03 +0000332 p += (fnamelen + 3) / 4;
333
334 len = (uint32_t *)p - (uint32_t *)&(data[0]);
335
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000336 rpc_req(PROG_NFS, NFS_LOOKUP, data, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000337}
338
339/**************************************************************************
340NFS_READ - Read File on NFS Server
341**************************************************************************/
342static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000343nfs_read_req(int offset, int readlen)
wdenkbe9c1cb2004-02-24 02:00:03 +0000344{
345 uint32_t data[1024];
346 uint32_t *p;
347 int len;
348
349 p = &(data[0]);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000350 p = (uint32_t *)rpc_add_credentials((long *)p);
wdenkbe9c1cb2004-02-24 02:00:03 +0000351
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000352 memcpy(p, filefh, NFS_FHSIZE);
wdenkbe9c1cb2004-02-24 02:00:03 +0000353 p += (NFS_FHSIZE / 4);
354 *p++ = htonl(offset);
355 *p++ = htonl(readlen);
356 *p++ = 0;
357
358 len = (uint32_t *)p - (uint32_t *)&(data[0]);
359
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000360 rpc_req(PROG_NFS, NFS_READ, data, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000361}
362
363/**************************************************************************
364RPC request dispatcher
365**************************************************************************/
366
367static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000368NfsSend(void)
wdenkbe9c1cb2004-02-24 02:00:03 +0000369{
Robin Getz9e0a4d62009-07-23 03:01:03 -0400370 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000371
372 switch (NfsState) {
373 case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000374 rpc_lookup_req(PROG_MOUNT, 1);
wdenkbe9c1cb2004-02-24 02:00:03 +0000375 break;
376 case STATE_PRCLOOKUP_PROG_NFS_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000377 rpc_lookup_req(PROG_NFS, 2);
wdenkbe9c1cb2004-02-24 02:00:03 +0000378 break;
379 case STATE_MOUNT_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000380 nfs_mount_req(nfs_path);
wdenkbe9c1cb2004-02-24 02:00:03 +0000381 break;
382 case STATE_UMOUNT_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000383 nfs_umountall_req();
wdenkbe9c1cb2004-02-24 02:00:03 +0000384 break;
385 case STATE_LOOKUP_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000386 nfs_lookup_req(nfs_filename);
wdenkbe9c1cb2004-02-24 02:00:03 +0000387 break;
388 case STATE_READ_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000389 nfs_read_req(nfs_offset, nfs_len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000390 break;
391 case STATE_READLINK_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000392 nfs_readlink_req();
wdenkbe9c1cb2004-02-24 02:00:03 +0000393 break;
394 }
395}
396
397/**************************************************************************
398Handlers for the reply from server
399**************************************************************************/
400
401static int
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000402rpc_lookup_reply(int prog, uchar *pkt, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000403{
404 struct rpc_t rpc_pkt;
405
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000406 memcpy((unsigned char *)&rpc_pkt, pkt, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000407
Robin Getz9e0a4d62009-07-23 03:01:03 -0400408 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000409
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100410 if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
411 return -NFS_RPC_ERR;
412 else if (ntohl(rpc_pkt.u.reply.id) < rpc_id)
413 return -NFS_RPC_DROP;
wdenkacd9b102004-03-14 00:59:59 +0000414
wdenkbe9c1cb2004-02-24 02:00:03 +0000415 if (rpc_pkt.u.reply.rstatus ||
416 rpc_pkt.u.reply.verifier ||
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000417 rpc_pkt.u.reply.astatus)
wdenkacd9b102004-03-14 00:59:59 +0000418 return -1;
wdenkbe9c1cb2004-02-24 02:00:03 +0000419
420 switch (prog) {
421 case PROG_MOUNT:
422 NfsSrvMountPort = ntohl(rpc_pkt.u.reply.data[0]);
423 break;
424 case PROG_NFS:
425 NfsSrvNfsPort = ntohl(rpc_pkt.u.reply.data[0]);
426 break;
427 }
428
429 return 0;
430}
431
432static int
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000433nfs_mount_reply(uchar *pkt, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000434{
435 struct rpc_t rpc_pkt;
436
Robin Getz9e0a4d62009-07-23 03:01:03 -0400437 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000438
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000439 memcpy((unsigned char *)&rpc_pkt, pkt, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000440
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100441 if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
442 return -NFS_RPC_ERR;
443 else if (ntohl(rpc_pkt.u.reply.id) < rpc_id)
444 return -NFS_RPC_DROP;
wdenkacd9b102004-03-14 00:59:59 +0000445
wdenkbe9c1cb2004-02-24 02:00:03 +0000446 if (rpc_pkt.u.reply.rstatus ||
447 rpc_pkt.u.reply.verifier ||
448 rpc_pkt.u.reply.astatus ||
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000449 rpc_pkt.u.reply.data[0])
wdenkbe9c1cb2004-02-24 02:00:03 +0000450 return -1;
wdenkbe9c1cb2004-02-24 02:00:03 +0000451
452 fs_mounted = 1;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000453 memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
wdenkbe9c1cb2004-02-24 02:00:03 +0000454
455 return 0;
456}
457
458static int
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000459nfs_umountall_reply(uchar *pkt, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000460{
461 struct rpc_t rpc_pkt;
462
Robin Getz9e0a4d62009-07-23 03:01:03 -0400463 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000464
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000465 memcpy((unsigned char *)&rpc_pkt, pkt, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000466
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100467 if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
468 return -NFS_RPC_ERR;
469 else if (ntohl(rpc_pkt.u.reply.id) < rpc_id)
470 return -NFS_RPC_DROP;
wdenkacd9b102004-03-14 00:59:59 +0000471
wdenkbe9c1cb2004-02-24 02:00:03 +0000472 if (rpc_pkt.u.reply.rstatus ||
473 rpc_pkt.u.reply.verifier ||
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000474 rpc_pkt.u.reply.astatus)
wdenkbe9c1cb2004-02-24 02:00:03 +0000475 return -1;
wdenkbe9c1cb2004-02-24 02:00:03 +0000476
477 fs_mounted = 0;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000478 memset(dirfh, 0, sizeof(dirfh));
wdenkbe9c1cb2004-02-24 02:00:03 +0000479
480 return 0;
481}
482
483static int
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000484nfs_lookup_reply(uchar *pkt, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000485{
486 struct rpc_t rpc_pkt;
487
Robin Getz9e0a4d62009-07-23 03:01:03 -0400488 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000489
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000490 memcpy((unsigned char *)&rpc_pkt, pkt, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000491
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100492 if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
493 return -NFS_RPC_ERR;
494 else if (ntohl(rpc_pkt.u.reply.id) < rpc_id)
495 return -NFS_RPC_DROP;
wdenkacd9b102004-03-14 00:59:59 +0000496
wdenkbe9c1cb2004-02-24 02:00:03 +0000497 if (rpc_pkt.u.reply.rstatus ||
498 rpc_pkt.u.reply.verifier ||
499 rpc_pkt.u.reply.astatus ||
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000500 rpc_pkt.u.reply.data[0])
wdenkbe9c1cb2004-02-24 02:00:03 +0000501 return -1;
wdenkbe9c1cb2004-02-24 02:00:03 +0000502
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000503 memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
wdenkbe9c1cb2004-02-24 02:00:03 +0000504
505 return 0;
506}
507
508static int
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000509nfs_readlink_reply(uchar *pkt, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000510{
511 struct rpc_t rpc_pkt;
512 int rlen;
513
Robin Getz9e0a4d62009-07-23 03:01:03 -0400514 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000515
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000516 memcpy((unsigned char *)&rpc_pkt, pkt, len);
wdenkbe9c1cb2004-02-24 02:00:03 +0000517
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100518 if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
519 return -NFS_RPC_ERR;
520 else if (ntohl(rpc_pkt.u.reply.id) < rpc_id)
521 return -NFS_RPC_DROP;
wdenkacd9b102004-03-14 00:59:59 +0000522
wdenkbe9c1cb2004-02-24 02:00:03 +0000523 if (rpc_pkt.u.reply.rstatus ||
524 rpc_pkt.u.reply.verifier ||
525 rpc_pkt.u.reply.astatus ||
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000526 rpc_pkt.u.reply.data[0])
wdenkbe9c1cb2004-02-24 02:00:03 +0000527 return -1;
wdenkbe9c1cb2004-02-24 02:00:03 +0000528
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000529 rlen = ntohl(rpc_pkt.u.reply.data[1]); /* new path length */
wdenkbe9c1cb2004-02-24 02:00:03 +0000530
531 if (*((char *)&(rpc_pkt.u.reply.data[2])) != '/') {
532 int pathlen;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000533 strcat(nfs_path, "/");
wdenkbe9c1cb2004-02-24 02:00:03 +0000534 pathlen = strlen(nfs_path);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000535 memcpy(nfs_path + pathlen, (uchar *)&(rpc_pkt.u.reply.data[2]),
536 rlen);
Ed Swarthout867d8702009-11-19 02:47:28 -0600537 nfs_path[pathlen + rlen] = 0;
wdenkbe9c1cb2004-02-24 02:00:03 +0000538 } else {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000539 memcpy(nfs_path, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen);
wdenkbe9c1cb2004-02-24 02:00:03 +0000540 nfs_path[rlen] = 0;
541 }
542 return 0;
543}
544
545static int
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000546nfs_read_reply(uchar *pkt, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000547{
548 struct rpc_t rpc_pkt;
549 int rlen;
550
Robin Getz9e0a4d62009-07-23 03:01:03 -0400551 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000552
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000553 memcpy((uchar *)&rpc_pkt, pkt, sizeof(rpc_pkt.u.reply));
wdenkbe9c1cb2004-02-24 02:00:03 +0000554
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100555 if (ntohl(rpc_pkt.u.reply.id) > rpc_id)
556 return -NFS_RPC_ERR;
557 else if (ntohl(rpc_pkt.u.reply.id) < rpc_id)
558 return -NFS_RPC_DROP;
wdenkacd9b102004-03-14 00:59:59 +0000559
wdenkbe9c1cb2004-02-24 02:00:03 +0000560 if (rpc_pkt.u.reply.rstatus ||
561 rpc_pkt.u.reply.verifier ||
562 rpc_pkt.u.reply.astatus ||
563 rpc_pkt.u.reply.data[0]) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000564 if (rpc_pkt.u.reply.rstatus)
wdenkbe9c1cb2004-02-24 02:00:03 +0000565 return -9999;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000566 if (rpc_pkt.u.reply.astatus)
wdenkbe9c1cb2004-02-24 02:00:03 +0000567 return -9999;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000568 return -ntohl(rpc_pkt.u.reply.data[0]);
wdenkbe9c1cb2004-02-24 02:00:03 +0000569 }
570
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000571 if ((nfs_offset != 0) && !((nfs_offset) %
572 (NFS_READ_SIZE / 2 * 10 * HASHES_PER_LINE)))
573 puts("\n\t ");
574 if (!(nfs_offset % ((NFS_READ_SIZE / 2) * 10)))
575 putc('#');
wdenkbe9c1cb2004-02-24 02:00:03 +0000576
577 rlen = ntohl(rpc_pkt.u.reply.data[18]);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000578 if (store_block((uchar *)pkt + sizeof(rpc_pkt.u.reply),
579 nfs_offset, rlen))
Wolfgang Denkb077b502005-08-06 01:11:12 +0200580 return -9999;
wdenkbe9c1cb2004-02-24 02:00:03 +0000581
582 return rlen;
583}
584
585/**************************************************************************
586Interfaces of U-BOOT
587**************************************************************************/
588
589static void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000590NfsTimeout(void)
wdenkd9ee50d2004-09-28 21:51:42 +0000591{
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000592 if (++NfsTimeoutCount > NFS_RETRY_COUNT) {
593 puts("\nRetry count exceeded; starting again\n");
594 NetStartAgain();
Evan Samanasb956fba2009-11-09 20:08:36 -0600595 } else {
596 puts("T ");
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100597 NetSetTimeout(nfs_timeout + NFS_TIMEOUT * NfsTimeoutCount,
598 NfsTimeout);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000599 NfsSend();
Hiroshi Ito3702cd72008-01-31 18:35:04 +0900600 }
wdenkd9ee50d2004-09-28 21:51:42 +0000601}
602
603static void
Luca Ceresoli428ab362011-04-18 06:19:50 +0000604NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
wdenkbe9c1cb2004-02-24 02:00:03 +0000605{
606 int rlen;
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100607 int reply;
wdenkbe9c1cb2004-02-24 02:00:03 +0000608
Robin Getz9e0a4d62009-07-23 03:01:03 -0400609 debug("%s\n", __func__);
wdenkbe9c1cb2004-02-24 02:00:03 +0000610
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000611 if (dest != NfsOurPort)
612 return;
wdenkbe9c1cb2004-02-24 02:00:03 +0000613
614 switch (NfsState) {
615 case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100616 if (rpc_lookup_reply(PROG_MOUNT, pkt, len) == -NFS_RPC_DROP)
617 break;
wdenkbe9c1cb2004-02-24 02:00:03 +0000618 NfsState = STATE_PRCLOOKUP_PROG_NFS_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000619 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000620 break;
621
622 case STATE_PRCLOOKUP_PROG_NFS_REQ:
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100623 if (rpc_lookup_reply(PROG_NFS, pkt, len) == -NFS_RPC_DROP)
624 break;
wdenkbe9c1cb2004-02-24 02:00:03 +0000625 NfsState = STATE_MOUNT_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000626 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000627 break;
628
629 case STATE_MOUNT_REQ:
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100630 reply = nfs_mount_reply(pkt, len);
631 if (reply == -NFS_RPC_DROP)
632 break;
633 else if (reply == -NFS_RPC_ERR) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000634 puts("*** ERROR: Cannot mount\n");
wdenkbe9c1cb2004-02-24 02:00:03 +0000635 /* just to be sure... */
636 NfsState = STATE_UMOUNT_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000637 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000638 } else {
639 NfsState = STATE_LOOKUP_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000640 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000641 }
642 break;
643
644 case STATE_UMOUNT_REQ:
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100645 reply = nfs_umountall_reply(pkt, len);
646 if (reply == -NFS_RPC_DROP)
647 break;
648 else if (reply == -NFS_RPC_ERR) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000649 puts("*** ERROR: Cannot umount\n");
Joe Hershbergerd4bb76a2012-05-23 07:59:14 +0000650 net_set_state(NETLOOP_FAIL);
wdenkbe9c1cb2004-02-24 02:00:03 +0000651 } else {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000652 puts("\ndone\n");
Joe Hershbergerd4bb76a2012-05-23 07:59:14 +0000653 net_set_state(nfs_download_state);
wdenkbe9c1cb2004-02-24 02:00:03 +0000654 }
655 break;
656
657 case STATE_LOOKUP_REQ:
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100658 reply = nfs_lookup_reply(pkt, len);
659 if (reply == -NFS_RPC_DROP)
660 break;
661 else if (reply == -NFS_RPC_ERR) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000662 puts("*** ERROR: File lookup fail\n");
wdenkbe9c1cb2004-02-24 02:00:03 +0000663 NfsState = STATE_UMOUNT_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000664 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000665 } else {
666 NfsState = STATE_READ_REQ;
667 nfs_offset = 0;
668 nfs_len = NFS_READ_SIZE;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000669 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000670 }
671 break;
672
673 case STATE_READLINK_REQ:
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100674 reply = nfs_readlink_reply(pkt, len);
675 if (reply == -NFS_RPC_DROP)
676 break;
677 else if (reply == -NFS_RPC_ERR) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000678 puts("*** ERROR: Symlink fail\n");
wdenkbe9c1cb2004-02-24 02:00:03 +0000679 NfsState = STATE_UMOUNT_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000680 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000681 } else {
Robin Getz9e0a4d62009-07-23 03:01:03 -0400682 debug("Symlink --> %s\n", nfs_path);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000683 nfs_filename = basename(nfs_path);
684 nfs_path = dirname(nfs_path);
wdenkbe9c1cb2004-02-24 02:00:03 +0000685
686 NfsState = STATE_MOUNT_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000687 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000688 }
689 break;
690
691 case STATE_READ_REQ:
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000692 rlen = nfs_read_reply(pkt, len);
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100693 NetSetTimeout(nfs_timeout, NfsTimeout);
wdenkbe9c1cb2004-02-24 02:00:03 +0000694 if (rlen > 0) {
695 nfs_offset += rlen;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000696 NfsSend();
697 } else if ((rlen == -NFSERR_ISDIR) || (rlen == -NFSERR_INVAL)) {
wdenkbe9c1cb2004-02-24 02:00:03 +0000698 /* symbolic link */
699 NfsState = STATE_READLINK_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000700 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000701 } else {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000702 if (!rlen)
Joe Hershbergerd4bb76a2012-05-23 07:59:14 +0000703 nfs_download_state = NETLOOP_SUCCESS;
wdenkbe9c1cb2004-02-24 02:00:03 +0000704 NfsState = STATE_UMOUNT_REQ;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000705 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000706 }
707 break;
708 }
709}
710
wdenkbe9c1cb2004-02-24 02:00:03 +0000711
712void
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000713NfsStart(void)
wdenkbe9c1cb2004-02-24 02:00:03 +0000714{
Robin Getz9e0a4d62009-07-23 03:01:03 -0400715 debug("%s\n", __func__);
Joe Hershbergerd4bb76a2012-05-23 07:59:14 +0000716 nfs_download_state = NETLOOP_FAIL;
wdenkbe9c1cb2004-02-24 02:00:03 +0000717
718 NfsServerIP = NetServerIP;
719 nfs_path = (char *)nfs_path_buff;
720
721 if (nfs_path == NULL) {
Joe Hershbergerd4bb76a2012-05-23 07:59:14 +0000722 net_set_state(NETLOOP_FAIL);
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000723 puts("*** ERROR: Fail allocate memory\n");
wdenkbe9c1cb2004-02-24 02:00:03 +0000724 return;
725 }
726
727 if (BootFile[0] == '\0') {
Matthias Weisser6cc63262011-12-03 03:29:44 +0000728 sprintf(default_filename, "/nfsroot/%02X%02X%02X%02X.img",
Wolfgang Denkdec97322005-08-04 01:09:44 +0200729 NetOurIP & 0xFF,
730 (NetOurIP >> 8) & 0xFF,
731 (NetOurIP >> 16) & 0xFF,
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000732 (NetOurIP >> 24) & 0xFF);
733 strcpy(nfs_path, default_filename);
wdenkbe9c1cb2004-02-24 02:00:03 +0000734
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000735 printf("*** Warning: no boot file name; using '%s'\n",
wdenkbe9c1cb2004-02-24 02:00:03 +0000736 nfs_path);
737 } else {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000738 char *p = BootFile;
wdenkbe9c1cb2004-02-24 02:00:03 +0000739
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000740 p = strchr(p, ':');
wdenkbe9c1cb2004-02-24 02:00:03 +0000741
742 if (p != NULL) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000743 NfsServerIP = string_to_ip(BootFile);
wdenkbe9c1cb2004-02-24 02:00:03 +0000744 ++p;
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000745 strcpy(nfs_path, p);
wdenkbe9c1cb2004-02-24 02:00:03 +0000746 } else {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000747 strcpy(nfs_path, BootFile);
wdenkbe9c1cb2004-02-24 02:00:03 +0000748 }
749 }
750
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000751 nfs_filename = basename(nfs_path);
752 nfs_path = dirname(nfs_path);
wdenkbe9c1cb2004-02-24 02:00:03 +0000753
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000754 printf("Using %s device\n", eth_get_name());
wdenkbe9c1cb2004-02-24 02:00:03 +0000755
Mike Frysingerd5695f42009-02-17 00:00:53 -0500756 printf("File transfer via NFS from server %pI4"
757 "; our IP address is %pI4", &NfsServerIP, &NetOurIP);
wdenkbe9c1cb2004-02-24 02:00:03 +0000758
759 /* Check if we need to send across this subnet */
760 if (NetOurGatewayIP && NetOurSubnetMask) {
761 IPaddr_t OurNet = NetOurIP & NetOurSubnetMask;
762 IPaddr_t ServerNet = NetServerIP & NetOurSubnetMask;
763
Mike Frysingerd5695f42009-02-17 00:00:53 -0500764 if (OurNet != ServerNet)
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000765 printf("; sending through gateway %pI4",
766 &NetOurGatewayIP);
wdenkbe9c1cb2004-02-24 02:00:03 +0000767 }
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000768 printf("\nFilename '%s/%s'.", nfs_path, nfs_filename);
wdenkbe9c1cb2004-02-24 02:00:03 +0000769
770 if (NetBootFileSize) {
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000771 printf(" Size is 0x%x Bytes = ", NetBootFileSize<<9);
772 print_size(NetBootFileSize<<9, "");
wdenkbe9c1cb2004-02-24 02:00:03 +0000773 }
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000774 printf("\nLoad address: 0x%lx\n"
wdenk42c05472004-03-23 22:14:11 +0000775 "Loading: *\b", load_addr);
wdenkbe9c1cb2004-02-24 02:00:03 +0000776
Matthias Bruggerb8d5b8c2012-12-11 19:14:16 +0100777 NetSetTimeout(nfs_timeout, NfsTimeout);
Joe Hershbergerf50357b2012-05-23 07:59:15 +0000778 net_set_udp_handler(NfsHandler);
wdenkbe9c1cb2004-02-24 02:00:03 +0000779
wdenkbe9c1cb2004-02-24 02:00:03 +0000780 NfsTimeoutCount = 0;
781 NfsState = STATE_PRCLOOKUP_PROG_MOUNT_REQ;
782
783 /*NfsOurPort = 4096 + (get_ticks() % 3072);*/
784 /*FIX ME !!!*/
785 NfsOurPort = 1000;
786
787 /* zero out server ether in case the server ip has changed */
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000788 memset(NetServerEther, 0, 6);
wdenkbe9c1cb2004-02-24 02:00:03 +0000789
Joe Hershberger6ecfc6b2012-05-15 08:59:09 +0000790 NfsSend();
wdenkbe9c1cb2004-02-24 02:00:03 +0000791}