Merge branch 'master' of git://git.denx.de/u-boot-net
[platform/kernel/u-boot.git] / net / nfs.c
1 /*
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>
29 #include "nfs.h"
30 #include "bootp.h"
31
32 #define HASHES_PER_LINE 65      /* Number of "loading" hashes per line  */
33 #define NFS_RETRY_COUNT 30
34 #define NFS_TIMEOUT 2000UL
35
36 static int fs_mounted;
37 static unsigned long rpc_id;
38 static int nfs_offset = -1;
39 static int nfs_len;
40
41 static char dirfh[NFS_FHSIZE];  /* file handle of directory */
42 static char filefh[NFS_FHSIZE]; /* file handle of kernel image */
43
44 static int      NfsDownloadState;
45 static IPaddr_t NfsServerIP;
46 static int      NfsSrvMountPort;
47 static int      NfsSrvNfsPort;
48 static int      NfsOurPort;
49 static int      NfsTimeoutCount;
50 static int      NfsState;
51 #define STATE_PRCLOOKUP_PROG_MOUNT_REQ  1
52 #define STATE_PRCLOOKUP_PROG_NFS_REQ    2
53 #define STATE_MOUNT_REQ                 3
54 #define STATE_UMOUNT_REQ                4
55 #define STATE_LOOKUP_REQ                5
56 #define STATE_READ_REQ                  6
57 #define STATE_READLINK_REQ              7
58
59 static char default_filename[64];
60 static char *nfs_filename;
61 static char *nfs_path;
62 static char nfs_path_buff[2048];
63
64 static inline int
65 store_block(uchar *src, unsigned offset, unsigned len)
66 {
67         ulong newsize = offset + len;
68 #ifdef CONFIG_SYS_DIRECT_FLASH_NFS
69         int i, rc = 0;
70
71         for (i = 0; i < CONFIG_SYS_MAX_FLASH_BANKS; i++) {
72                 /* start address in flash? */
73                 if (load_addr + offset >= flash_info[i].start[0]) {
74                         rc = 1;
75                         break;
76                 }
77         }
78
79         if (rc) { /* Flash is destination for this packet */
80                 rc = flash_write((uchar *)src, (ulong)(load_addr+offset), len);
81                 if (rc) {
82                         flash_perror(rc);
83                         return -1;
84                 }
85         } else
86 #endif /* CONFIG_SYS_DIRECT_FLASH_NFS */
87         {
88                 (void)memcpy((void *)(load_addr + offset), src, len);
89         }
90
91         if (NetBootFileXferSize < (offset+len))
92                 NetBootFileXferSize = newsize;
93         return 0;
94 }
95
96 static char*
97 basename(char *path)
98 {
99         char *fname;
100
101         fname = path + strlen(path) - 1;
102         while (fname >= path) {
103                 if (*fname == '/') {
104                         fname++;
105                         break;
106                 }
107                 fname--;
108         }
109         return fname;
110 }
111
112 static char*
113 dirname(char *path)
114 {
115         char *fname;
116
117         fname = basename(path);
118         --fname;
119         *fname = '\0';
120         return path;
121 }
122
123 /**************************************************************************
124 RPC_ADD_CREDENTIALS - Add RPC authentication/verifier entries
125 **************************************************************************/
126 static long *rpc_add_credentials(long *p)
127 {
128         int hl;
129         int hostnamelen;
130         char hostname[256];
131
132         strcpy(hostname, "");
133         hostnamelen = strlen(hostname);
134
135         /* Here's the executive summary on authentication requirements of the
136          * various NFS server implementations:  Linux accepts both AUTH_NONE
137          * and AUTH_UNIX authentication (also accepts an empty hostname field
138          * in the AUTH_UNIX scheme).  *BSD refuses AUTH_NONE, but accepts
139          * AUTH_UNIX (also accepts an empty hostname field in the AUTH_UNIX
140          * scheme).  To be safe, use AUTH_UNIX and pass the hostname if we have
141          * it (if the BOOTP/DHCP reply didn't give one, just use an empty
142          * hostname).  */
143
144         hl = (hostnamelen + 3) & ~3;
145
146         /* Provide an AUTH_UNIX credential.  */
147         *p++ = htonl(1);                /* AUTH_UNIX */
148         *p++ = htonl(hl+20);            /* auth length */
149         *p++ = htonl(0);                /* stamp */
150         *p++ = htonl(hostnamelen);      /* hostname string */
151         if (hostnamelen & 3)
152                 *(p + hostnamelen / 4) = 0; /* add zero padding */
153         memcpy(p, hostname, hostnamelen);
154         p += hl / 4;
155         *p++ = 0;                       /* uid */
156         *p++ = 0;                       /* gid */
157         *p++ = 0;                       /* auxiliary gid list */
158
159         /* Provide an AUTH_NONE verifier.  */
160         *p++ = 0;                       /* AUTH_NONE */
161         *p++ = 0;                       /* auth length */
162
163         return p;
164 }
165
166 /**************************************************************************
167 RPC_LOOKUP - Lookup RPC Port numbers
168 **************************************************************************/
169 static void
170 rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen)
171 {
172         struct rpc_t pkt;
173         unsigned long id;
174         uint32_t *p;
175         int pktlen;
176         int sport;
177
178         id = ++rpc_id;
179         pkt.u.call.id = htonl(id);
180         pkt.u.call.type = htonl(MSG_CALL);
181         pkt.u.call.rpcvers = htonl(2);  /* use RPC version 2 */
182         pkt.u.call.prog = htonl(rpc_prog);
183         pkt.u.call.vers = htonl(2);     /* portmapper is version 2 */
184         pkt.u.call.proc = htonl(rpc_proc);
185         p = (uint32_t *)&(pkt.u.call.data);
186
187         if (datalen)
188                 memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t));
189
190         pktlen = (char *)p + datalen*sizeof(uint32_t) - (char *)&pkt;
191
192         memcpy((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE,
193                 (char *)&pkt, pktlen);
194
195         if (rpc_prog == PROG_PORTMAP)
196                 sport = SUNRPC_PORT;
197         else if (rpc_prog == PROG_MOUNT)
198                 sport = NfsSrvMountPort;
199         else
200                 sport = NfsSrvNfsPort;
201
202         NetSendUDPPacket(NetServerEther, NfsServerIP, sport, NfsOurPort,
203                 pktlen);
204 }
205
206 /**************************************************************************
207 RPC_LOOKUP - Lookup RPC Port numbers
208 **************************************************************************/
209 static void
210 rpc_lookup_req(int prog, int ver)
211 {
212         uint32_t data[16];
213
214         data[0] = 0; data[1] = 0;       /* auth credential */
215         data[2] = 0; data[3] = 0;       /* auth verifier */
216         data[4] = htonl(prog);
217         data[5] = htonl(ver);
218         data[6] = htonl(17);    /* IP_UDP */
219         data[7] = 0;
220
221         rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, data, 8);
222 }
223
224 /**************************************************************************
225 NFS_MOUNT - Mount an NFS Filesystem
226 **************************************************************************/
227 static void
228 nfs_mount_req(char *path)
229 {
230         uint32_t data[1024];
231         uint32_t *p;
232         int len;
233         int pathlen;
234
235         pathlen = strlen(path);
236
237         p = &(data[0]);
238         p = (uint32_t *)rpc_add_credentials((long *)p);
239
240         *p++ = htonl(pathlen);
241         if (pathlen & 3)
242                 *(p + pathlen / 4) = 0;
243         memcpy(p, path, pathlen);
244         p += (pathlen + 3) / 4;
245
246         len = (uint32_t *)p - (uint32_t *)&(data[0]);
247
248         rpc_req(PROG_MOUNT, MOUNT_ADDENTRY, data, len);
249 }
250
251 /**************************************************************************
252 NFS_UMOUNTALL - Unmount all our NFS Filesystems on the Server
253 **************************************************************************/
254 static void
255 nfs_umountall_req(void)
256 {
257         uint32_t data[1024];
258         uint32_t *p;
259         int len;
260
261         if ((NfsSrvMountPort == -1) || (!fs_mounted))
262                 /* Nothing mounted, nothing to umount */
263                 return;
264
265         p = &(data[0]);
266         p = (uint32_t *)rpc_add_credentials((long *)p);
267
268         len = (uint32_t *)p - (uint32_t *)&(data[0]);
269
270         rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, data, len);
271 }
272
273 /***************************************************************************
274  * NFS_READLINK (AH 2003-07-14)
275  * This procedure is called when read of the first block fails -
276  * this probably happens when it's a directory or a symlink
277  * In case of successful readlink(), the dirname is manipulated,
278  * so that inside the nfs() function a recursion can be done.
279  **************************************************************************/
280 static void
281 nfs_readlink_req(void)
282 {
283         uint32_t data[1024];
284         uint32_t *p;
285         int len;
286
287         p = &(data[0]);
288         p = (uint32_t *)rpc_add_credentials((long *)p);
289
290         memcpy(p, filefh, NFS_FHSIZE);
291         p += (NFS_FHSIZE / 4);
292
293         len = (uint32_t *)p - (uint32_t *)&(data[0]);
294
295         rpc_req(PROG_NFS, NFS_READLINK, data, len);
296 }
297
298 /**************************************************************************
299 NFS_LOOKUP - Lookup Pathname
300 **************************************************************************/
301 static void
302 nfs_lookup_req(char *fname)
303 {
304         uint32_t data[1024];
305         uint32_t *p;
306         int len;
307         int fnamelen;
308
309         fnamelen = strlen(fname);
310
311         p = &(data[0]);
312         p = (uint32_t *)rpc_add_credentials((long *)p);
313
314         memcpy(p, dirfh, NFS_FHSIZE);
315         p += (NFS_FHSIZE / 4);
316         *p++ = htonl(fnamelen);
317         if (fnamelen & 3)
318                 *(p + fnamelen / 4) = 0;
319         memcpy(p, fname, fnamelen);
320         p += (fnamelen + 3) / 4;
321
322         len = (uint32_t *)p - (uint32_t *)&(data[0]);
323
324         rpc_req(PROG_NFS, NFS_LOOKUP, data, len);
325 }
326
327 /**************************************************************************
328 NFS_READ - Read File on NFS Server
329 **************************************************************************/
330 static void
331 nfs_read_req(int offset, int readlen)
332 {
333         uint32_t data[1024];
334         uint32_t *p;
335         int len;
336
337         p = &(data[0]);
338         p = (uint32_t *)rpc_add_credentials((long *)p);
339
340         memcpy(p, filefh, NFS_FHSIZE);
341         p += (NFS_FHSIZE / 4);
342         *p++ = htonl(offset);
343         *p++ = htonl(readlen);
344         *p++ = 0;
345
346         len = (uint32_t *)p - (uint32_t *)&(data[0]);
347
348         rpc_req(PROG_NFS, NFS_READ, data, len);
349 }
350
351 /**************************************************************************
352 RPC request dispatcher
353 **************************************************************************/
354
355 static void
356 NfsSend(void)
357 {
358         debug("%s\n", __func__);
359
360         switch (NfsState) {
361         case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
362                 rpc_lookup_req(PROG_MOUNT, 1);
363                 break;
364         case STATE_PRCLOOKUP_PROG_NFS_REQ:
365                 rpc_lookup_req(PROG_NFS, 2);
366                 break;
367         case STATE_MOUNT_REQ:
368                 nfs_mount_req(nfs_path);
369                 break;
370         case STATE_UMOUNT_REQ:
371                 nfs_umountall_req();
372                 break;
373         case STATE_LOOKUP_REQ:
374                 nfs_lookup_req(nfs_filename);
375                 break;
376         case STATE_READ_REQ:
377                 nfs_read_req(nfs_offset, nfs_len);
378                 break;
379         case STATE_READLINK_REQ:
380                 nfs_readlink_req();
381                 break;
382         }
383 }
384
385 /**************************************************************************
386 Handlers for the reply from server
387 **************************************************************************/
388
389 static int
390 rpc_lookup_reply(int prog, uchar *pkt, unsigned len)
391 {
392         struct rpc_t rpc_pkt;
393
394         memcpy((unsigned char *)&rpc_pkt, pkt, len);
395
396         debug("%s\n", __func__);
397
398         if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
399                 return -1;
400
401         if (rpc_pkt.u.reply.rstatus  ||
402             rpc_pkt.u.reply.verifier ||
403             rpc_pkt.u.reply.astatus)
404                 return -1;
405
406         switch (prog) {
407         case PROG_MOUNT:
408                 NfsSrvMountPort = ntohl(rpc_pkt.u.reply.data[0]);
409                 break;
410         case PROG_NFS:
411                 NfsSrvNfsPort = ntohl(rpc_pkt.u.reply.data[0]);
412                 break;
413         }
414
415         return 0;
416 }
417
418 static int
419 nfs_mount_reply(uchar *pkt, unsigned len)
420 {
421         struct rpc_t rpc_pkt;
422
423         debug("%s\n", __func__);
424
425         memcpy((unsigned char *)&rpc_pkt, pkt, len);
426
427         if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
428                 return -1;
429
430         if (rpc_pkt.u.reply.rstatus  ||
431             rpc_pkt.u.reply.verifier ||
432             rpc_pkt.u.reply.astatus  ||
433             rpc_pkt.u.reply.data[0])
434                 return -1;
435
436         fs_mounted = 1;
437         memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
438
439         return 0;
440 }
441
442 static int
443 nfs_umountall_reply(uchar *pkt, unsigned len)
444 {
445         struct rpc_t rpc_pkt;
446
447         debug("%s\n", __func__);
448
449         memcpy((unsigned char *)&rpc_pkt, pkt, len);
450
451         if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
452                 return -1;
453
454         if (rpc_pkt.u.reply.rstatus  ||
455             rpc_pkt.u.reply.verifier ||
456             rpc_pkt.u.reply.astatus)
457                 return -1;
458
459         fs_mounted = 0;
460         memset(dirfh, 0, sizeof(dirfh));
461
462         return 0;
463 }
464
465 static int
466 nfs_lookup_reply(uchar *pkt, unsigned len)
467 {
468         struct rpc_t rpc_pkt;
469
470         debug("%s\n", __func__);
471
472         memcpy((unsigned char *)&rpc_pkt, pkt, len);
473
474         if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
475                 return -1;
476
477         if (rpc_pkt.u.reply.rstatus  ||
478             rpc_pkt.u.reply.verifier ||
479             rpc_pkt.u.reply.astatus  ||
480             rpc_pkt.u.reply.data[0])
481                 return -1;
482
483         memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
484
485         return 0;
486 }
487
488 static int
489 nfs_readlink_reply(uchar *pkt, unsigned len)
490 {
491         struct rpc_t rpc_pkt;
492         int rlen;
493
494         debug("%s\n", __func__);
495
496         memcpy((unsigned char *)&rpc_pkt, pkt, len);
497
498         if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
499                 return -1;
500
501         if (rpc_pkt.u.reply.rstatus  ||
502             rpc_pkt.u.reply.verifier ||
503             rpc_pkt.u.reply.astatus  ||
504             rpc_pkt.u.reply.data[0])
505                 return -1;
506
507         rlen = ntohl(rpc_pkt.u.reply.data[1]); /* new path length */
508
509         if (*((char *)&(rpc_pkt.u.reply.data[2])) != '/') {
510                 int pathlen;
511                 strcat(nfs_path, "/");
512                 pathlen = strlen(nfs_path);
513                 memcpy(nfs_path + pathlen, (uchar *)&(rpc_pkt.u.reply.data[2]),
514                         rlen);
515                 nfs_path[pathlen + rlen] = 0;
516         } else {
517                 memcpy(nfs_path, (uchar *)&(rpc_pkt.u.reply.data[2]), rlen);
518                 nfs_path[rlen] = 0;
519         }
520         return 0;
521 }
522
523 static int
524 nfs_read_reply(uchar *pkt, unsigned len)
525 {
526         struct rpc_t rpc_pkt;
527         int rlen;
528
529         debug("%s\n", __func__);
530
531         memcpy((uchar *)&rpc_pkt, pkt, sizeof(rpc_pkt.u.reply));
532
533         if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
534                 return -1;
535
536         if (rpc_pkt.u.reply.rstatus  ||
537             rpc_pkt.u.reply.verifier ||
538             rpc_pkt.u.reply.astatus  ||
539             rpc_pkt.u.reply.data[0]) {
540                 if (rpc_pkt.u.reply.rstatus)
541                         return -9999;
542                 if (rpc_pkt.u.reply.astatus)
543                         return -9999;
544                 return -ntohl(rpc_pkt.u.reply.data[0]);
545         }
546
547         if ((nfs_offset != 0) && !((nfs_offset) %
548                         (NFS_READ_SIZE / 2 * 10 * HASHES_PER_LINE)))
549                 puts("\n\t ");
550         if (!(nfs_offset % ((NFS_READ_SIZE / 2) * 10)))
551                 putc('#');
552
553         rlen = ntohl(rpc_pkt.u.reply.data[18]);
554         if (store_block((uchar *)pkt + sizeof(rpc_pkt.u.reply),
555                         nfs_offset, rlen))
556                 return -9999;
557
558         return rlen;
559 }
560
561 /**************************************************************************
562 Interfaces of U-BOOT
563 **************************************************************************/
564
565 static void
566 NfsTimeout(void)
567 {
568         if (++NfsTimeoutCount > NFS_RETRY_COUNT) {
569                 puts("\nRetry count exceeded; starting again\n");
570                 NetStartAgain();
571         } else {
572                 puts("T ");
573                 NetSetTimeout(NFS_TIMEOUT, NfsTimeout);
574                 NfsSend();
575         }
576 }
577
578 static void
579 NfsHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src, unsigned len)
580 {
581         int rlen;
582
583         debug("%s\n", __func__);
584
585         if (dest != NfsOurPort)
586                 return;
587
588         switch (NfsState) {
589         case STATE_PRCLOOKUP_PROG_MOUNT_REQ:
590                 rpc_lookup_reply(PROG_MOUNT, pkt, len);
591                 NfsState = STATE_PRCLOOKUP_PROG_NFS_REQ;
592                 NfsSend();
593                 break;
594
595         case STATE_PRCLOOKUP_PROG_NFS_REQ:
596                 rpc_lookup_reply(PROG_NFS, pkt, len);
597                 NfsState = STATE_MOUNT_REQ;
598                 NfsSend();
599                 break;
600
601         case STATE_MOUNT_REQ:
602                 if (nfs_mount_reply(pkt, len)) {
603                         puts("*** ERROR: Cannot mount\n");
604                         /* just to be sure... */
605                         NfsState = STATE_UMOUNT_REQ;
606                         NfsSend();
607                 } else {
608                         NfsState = STATE_LOOKUP_REQ;
609                         NfsSend();
610                 }
611                 break;
612
613         case STATE_UMOUNT_REQ:
614                 if (nfs_umountall_reply(pkt, len)) {
615                         puts("*** ERROR: Cannot umount\n");
616                         NetState = NETLOOP_FAIL;
617                 } else {
618                         puts("\ndone\n");
619                         NetState = NfsDownloadState;
620                 }
621                 break;
622
623         case STATE_LOOKUP_REQ:
624                 if (nfs_lookup_reply(pkt, len)) {
625                         puts("*** ERROR: File lookup fail\n");
626                         NfsState = STATE_UMOUNT_REQ;
627                         NfsSend();
628                 } else {
629                         NfsState = STATE_READ_REQ;
630                         nfs_offset = 0;
631                         nfs_len = NFS_READ_SIZE;
632                         NfsSend();
633                 }
634                 break;
635
636         case STATE_READLINK_REQ:
637                 if (nfs_readlink_reply(pkt, len)) {
638                         puts("*** ERROR: Symlink fail\n");
639                         NfsState = STATE_UMOUNT_REQ;
640                         NfsSend();
641                 } else {
642                         debug("Symlink --> %s\n", nfs_path);
643                         nfs_filename = basename(nfs_path);
644                         nfs_path     = dirname(nfs_path);
645
646                         NfsState = STATE_MOUNT_REQ;
647                         NfsSend();
648                 }
649                 break;
650
651         case STATE_READ_REQ:
652                 rlen = nfs_read_reply(pkt, len);
653                 NetSetTimeout(NFS_TIMEOUT, NfsTimeout);
654                 if (rlen > 0) {
655                         nfs_offset += rlen;
656                         NfsSend();
657                 } else if ((rlen == -NFSERR_ISDIR) || (rlen == -NFSERR_INVAL)) {
658                         /* symbolic link */
659                         NfsState = STATE_READLINK_REQ;
660                         NfsSend();
661                 } else {
662                         if (!rlen)
663                                 NfsDownloadState = NETLOOP_SUCCESS;
664                         NfsState = STATE_UMOUNT_REQ;
665                         NfsSend();
666                 }
667                 break;
668         }
669 }
670
671
672 void
673 NfsStart(void)
674 {
675         debug("%s\n", __func__);
676         NfsDownloadState = NETLOOP_FAIL;
677
678         NfsServerIP = NetServerIP;
679         nfs_path = (char *)nfs_path_buff;
680
681         if (nfs_path == NULL) {
682                 NetState = NETLOOP_FAIL;
683                 puts("*** ERROR: Fail allocate memory\n");
684                 return;
685         }
686
687         if (BootFile[0] == '\0') {
688                 sprintf(default_filename, "/nfsroot/%02X%02X%02X%02X.img",
689                         NetOurIP & 0xFF,
690                         (NetOurIP >>  8) & 0xFF,
691                         (NetOurIP >> 16) & 0xFF,
692                         (NetOurIP >> 24) & 0xFF);
693                 strcpy(nfs_path, default_filename);
694
695                 printf("*** Warning: no boot file name; using '%s'\n",
696                         nfs_path);
697         } else {
698                 char *p = BootFile;
699
700                 p = strchr(p, ':');
701
702                 if (p != NULL) {
703                         NfsServerIP = string_to_ip(BootFile);
704                         ++p;
705                         strcpy(nfs_path, p);
706                 } else {
707                         strcpy(nfs_path, BootFile);
708                 }
709         }
710
711         nfs_filename = basename(nfs_path);
712         nfs_path     = dirname(nfs_path);
713
714         printf("Using %s device\n", eth_get_name());
715
716         printf("File transfer via NFS from server %pI4"
717                 "; our IP address is %pI4", &NfsServerIP, &NetOurIP);
718
719         /* Check if we need to send across this subnet */
720         if (NetOurGatewayIP && NetOurSubnetMask) {
721                 IPaddr_t OurNet     = NetOurIP    & NetOurSubnetMask;
722                 IPaddr_t ServerNet  = NetServerIP & NetOurSubnetMask;
723
724                 if (OurNet != ServerNet)
725                         printf("; sending through gateway %pI4",
726                                 &NetOurGatewayIP);
727         }
728         printf("\nFilename '%s/%s'.", nfs_path, nfs_filename);
729
730         if (NetBootFileSize) {
731                 printf(" Size is 0x%x Bytes = ", NetBootFileSize<<9);
732                 print_size(NetBootFileSize<<9, "");
733         }
734         printf("\nLoad address: 0x%lx\n"
735                 "Loading: *\b", load_addr);
736
737         NetSetTimeout(NFS_TIMEOUT, NfsTimeout);
738         NetSetHandler(NfsHandler);
739
740         NfsTimeoutCount = 0;
741         NfsState = STATE_PRCLOOKUP_PROG_MOUNT_REQ;
742
743         /*NfsOurPort = 4096 + (get_ticks() % 3072);*/
744         /*FIX ME !!!*/
745         NfsOurPort = 1000;
746
747         /* zero out server ether in case the server ip has changed */
748         memset(NetServerEther, 0, 6);
749
750         NfsSend();
751 }