tftp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /*
  2. * Copyright 1994, 1995, 2000 Neil Russell.
  3. * (See License)
  4. * Copyright 2000, 2001 DENX Software Engineering, Wolfgang Denk, wd@denx.de
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <net.h>
  9. #include "tftp.h"
  10. #include "bootp.h"
  11. #if defined(CONFIG_CMD_NET)
  12. #define WELL_KNOWN_PORT 69 /* Well known TFTP port # */
  13. #define TIMEOUT 5000UL /* Millisecs to timeout for lost pkt */
  14. #ifndef CONFIG_NET_RETRY_COUNT
  15. # define TIMEOUT_COUNT 10 /* # of timeouts before giving up */
  16. #else
  17. # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT * 2)
  18. #endif
  19. /* (for checking the image size) */
  20. #define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */
  21. /*
  22. * TFTP operations.
  23. */
  24. #define TFTP_RRQ 1
  25. #define TFTP_WRQ 2
  26. #define TFTP_DATA 3
  27. #define TFTP_ACK 4
  28. #define TFTP_ERROR 5
  29. #define TFTP_OACK 6
  30. static ulong TftpTimeoutMSecs = TIMEOUT;
  31. static int TftpTimeoutCountMax = TIMEOUT_COUNT;
  32. /*
  33. * These globals govern the timeout behavior when attempting a connection to a
  34. * TFTP server. TftpRRQTimeoutMSecs specifies the number of milliseconds to
  35. * wait for the server to respond to initial connection. Second global,
  36. * TftpRRQTimeoutCountMax, gives the number of such connection retries.
  37. * TftpRRQTimeoutCountMax must be non-negative and TftpRRQTimeoutMSecs must be
  38. * positive. The globals are meant to be set (and restored) by code needing
  39. * non-standard timeout behavior when initiating a TFTP transfer.
  40. */
  41. ulong TftpRRQTimeoutMSecs = TIMEOUT;
  42. int TftpRRQTimeoutCountMax = TIMEOUT_COUNT;
  43. static IPaddr_t TftpServerIP;
  44. static int TftpServerPort; /* The UDP port at their end */
  45. static int TftpOurPort; /* The UDP port at our end */
  46. static int TftpTimeoutCount;
  47. static ulong TftpBlock; /* packet sequence number */
  48. static ulong TftpLastBlock; /* last packet sequence number received */
  49. static ulong TftpBlockWrap; /* count of sequence number wraparounds */
  50. static ulong TftpBlockWrapOffset; /* memory offset due to wrapping */
  51. static int TftpState;
  52. #define STATE_RRQ 1
  53. #define STATE_DATA 2
  54. #define STATE_TOO_LARGE 3
  55. #define STATE_BAD_MAGIC 4
  56. #define STATE_OACK 5
  57. #define TFTP_BLOCK_SIZE 512 /* default TFTP block size */
  58. #define TFTP_SEQUENCE_SIZE ((ulong)(1<<16)) /* sequence number is 16 bit */
  59. #define DEFAULT_NAME_LEN (8 + 4 + 1)
  60. static char default_filename[DEFAULT_NAME_LEN];
  61. #ifndef CONFIG_TFTP_FILE_NAME_MAX_LEN
  62. #define MAX_LEN 128
  63. #else
  64. #define MAX_LEN CONFIG_TFTP_FILE_NAME_MAX_LEN
  65. #endif
  66. static char tftp_filename[MAX_LEN];
  67. #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
  68. extern flash_info_t flash_info[];
  69. #endif
  70. /* 512 is poor choice for ethernet, MTU is typically 1500.
  71. * Minus eth.hdrs thats 1468. Can get 2x better throughput with
  72. * almost-MTU block sizes. At least try... fall back to 512 if need be.
  73. */
  74. #define TFTP_MTU_BLOCKSIZE 1468
  75. static unsigned short TftpBlkSize=TFTP_BLOCK_SIZE;
  76. static unsigned short TftpBlkSizeOption=TFTP_MTU_BLOCKSIZE;
  77. #ifdef CONFIG_MCAST_TFTP
  78. #include <malloc.h>
  79. #define MTFTP_BITMAPSIZE 0x1000
  80. static unsigned *Bitmap;
  81. static int PrevBitmapHole,Mapsize=MTFTP_BITMAPSIZE;
  82. static uchar ProhibitMcast=0, MasterClient=0;
  83. static uchar Multicast=0;
  84. extern IPaddr_t Mcast_addr;
  85. static int Mcast_port;
  86. static ulong TftpEndingBlock; /* can get 'last' block before done..*/
  87. static void parse_multicast_oack(char *pkt,int len);
  88. static void
  89. mcast_cleanup(void)
  90. {
  91. if (Mcast_addr) eth_mcast_join(Mcast_addr, 0);
  92. if (Bitmap) free(Bitmap);
  93. Bitmap=NULL;
  94. Mcast_addr = Multicast = Mcast_port = 0;
  95. TftpEndingBlock = -1;
  96. }
  97. #endif /* CONFIG_MCAST_TFTP */
  98. static __inline__ void
  99. store_block (unsigned block, uchar * src, unsigned len)
  100. {
  101. ulong offset = block * TftpBlkSize + TftpBlockWrapOffset;
  102. ulong newsize = offset + len;
  103. #ifdef CONFIG_SYS_DIRECT_FLASH_TFTP
  104. int i, rc = 0;
  105. for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; i++) {
  106. /* start address in flash? */
  107. if (flash_info[i].flash_id == FLASH_UNKNOWN)
  108. continue;
  109. if (load_addr + offset >= flash_info[i].start[0]) {
  110. rc = 1;
  111. break;
  112. }
  113. }
  114. if (rc) { /* Flash is destination for this packet */
  115. rc = flash_write ((char *)src, (ulong)(load_addr+offset), len);
  116. if (rc) {
  117. flash_perror (rc);
  118. NetState = NETLOOP_FAIL;
  119. return;
  120. }
  121. }
  122. else
  123. #endif /* CONFIG_SYS_DIRECT_FLASH_TFTP */
  124. {
  125. (void)memcpy((void *)(load_addr + offset), src, len);
  126. }
  127. #ifdef CONFIG_MCAST_TFTP
  128. if (Multicast)
  129. ext2_set_bit(block, Bitmap);
  130. #endif
  131. if (NetBootFileXferSize < newsize)
  132. NetBootFileXferSize = newsize;
  133. }
  134. static void TftpSend (void);
  135. static void TftpTimeout (void);
  136. /**********************************************************************/
  137. static void
  138. TftpSend (void)
  139. {
  140. volatile uchar * pkt;
  141. volatile uchar * xp;
  142. int len = 0;
  143. volatile ushort *s;
  144. #ifdef CONFIG_MCAST_TFTP
  145. /* Multicast TFTP.. non-MasterClients do not ACK data. */
  146. if (Multicast
  147. && (TftpState == STATE_DATA)
  148. && (MasterClient == 0))
  149. return;
  150. #endif
  151. /*
  152. * We will always be sending some sort of packet, so
  153. * cobble together the packet headers now.
  154. */
  155. pkt = NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE;
  156. switch (TftpState) {
  157. case STATE_RRQ:
  158. xp = pkt;
  159. s = (ushort *)pkt;
  160. *s++ = htons(TFTP_RRQ);
  161. pkt = (uchar *)s;
  162. strcpy ((char *)pkt, tftp_filename);
  163. pkt += strlen(tftp_filename) + 1;
  164. strcpy ((char *)pkt, "octet");
  165. pkt += 5 /*strlen("octet")*/ + 1;
  166. strcpy ((char *)pkt, "timeout");
  167. pkt += 7 /*strlen("timeout")*/ + 1;
  168. sprintf((char *)pkt, "%lu", TIMEOUT / 1000);
  169. debug("send option \"timeout %s\"\n", (char *)pkt);
  170. pkt += strlen((char *)pkt) + 1;
  171. /* try for more effic. blk size */
  172. pkt += sprintf((char *)pkt,"blksize%c%d%c",
  173. 0,TftpBlkSizeOption,0);
  174. #ifdef CONFIG_MCAST_TFTP
  175. /* Check all preconditions before even trying the option */
  176. if (!ProhibitMcast
  177. && (Bitmap=malloc(Mapsize))
  178. && eth_get_dev()->mcast) {
  179. free(Bitmap);
  180. Bitmap=NULL;
  181. pkt += sprintf((char *)pkt,"multicast%c%c",0,0);
  182. }
  183. #endif /* CONFIG_MCAST_TFTP */
  184. len = pkt - xp;
  185. break;
  186. case STATE_OACK:
  187. #ifdef CONFIG_MCAST_TFTP
  188. /* My turn! Start at where I need blocks I missed.*/
  189. if (Multicast)
  190. TftpBlock=ext2_find_next_zero_bit(Bitmap,(Mapsize*8),0);
  191. /*..falling..*/
  192. #endif
  193. case STATE_DATA:
  194. xp = pkt;
  195. s = (ushort *)pkt;
  196. *s++ = htons(TFTP_ACK);
  197. *s++ = htons(TftpBlock);
  198. pkt = (uchar *)s;
  199. len = pkt - xp;
  200. break;
  201. case STATE_TOO_LARGE:
  202. xp = pkt;
  203. s = (ushort *)pkt;
  204. *s++ = htons(TFTP_ERROR);
  205. *s++ = htons(3);
  206. pkt = (uchar *)s;
  207. strcpy ((char *)pkt, "File too large");
  208. pkt += 14 /*strlen("File too large")*/ + 1;
  209. len = pkt - xp;
  210. break;
  211. case STATE_BAD_MAGIC:
  212. xp = pkt;
  213. s = (ushort *)pkt;
  214. *s++ = htons(TFTP_ERROR);
  215. *s++ = htons(2);
  216. pkt = (uchar *)s;
  217. strcpy ((char *)pkt, "File has bad magic");
  218. pkt += 18 /*strlen("File has bad magic")*/ + 1;
  219. len = pkt - xp;
  220. break;
  221. }
  222. NetSendUDPPacket(NetServerEther, TftpServerIP, TftpServerPort, TftpOurPort, len);
  223. }
  224. static void
  225. TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)
  226. {
  227. ushort proto;
  228. ushort *s;
  229. int i;
  230. if (dest != TftpOurPort) {
  231. #ifdef CONFIG_MCAST_TFTP
  232. if (Multicast
  233. && (!Mcast_port || (dest != Mcast_port)))
  234. #endif
  235. return;
  236. }
  237. if (TftpState != STATE_RRQ && src != TftpServerPort) {
  238. return;
  239. }
  240. if (len < 2) {
  241. return;
  242. }
  243. len -= 2;
  244. /* warning: don't use increment (++) in ntohs() macros!! */
  245. s = (ushort *)pkt;
  246. proto = *s++;
  247. pkt = (uchar *)s;
  248. switch (ntohs(proto)) {
  249. case TFTP_RRQ:
  250. case TFTP_WRQ:
  251. case TFTP_ACK:
  252. break;
  253. default:
  254. break;
  255. case TFTP_OACK:
  256. debug("Got OACK: %s %s\n", pkt, pkt+strlen(pkt)+1);
  257. TftpState = STATE_OACK;
  258. TftpServerPort = src;
  259. /*
  260. * Check for 'blksize' option.
  261. * Careful: "i" is signed, "len" is unsigned, thus
  262. * something like "len-8" may give a *huge* number
  263. */
  264. for (i=0; i+8<len; i++) {
  265. if (strcmp ((char*)pkt+i,"blksize") == 0) {
  266. TftpBlkSize = (unsigned short)
  267. simple_strtoul((char*)pkt+i+8,NULL,10);
  268. debug("Blocksize ack: %s, %d\n",
  269. (char*)pkt+i+8,TftpBlkSize);
  270. break;
  271. }
  272. }
  273. #ifdef CONFIG_MCAST_TFTP
  274. parse_multicast_oack((char *)pkt,len-1);
  275. if ((Multicast) && (!MasterClient))
  276. TftpState = STATE_DATA; /* passive.. */
  277. else
  278. #endif
  279. TftpSend (); /* Send ACK */
  280. break;
  281. case TFTP_DATA:
  282. if (len < 2)
  283. return;
  284. len -= 2;
  285. TftpBlock = ntohs(*(ushort *)pkt);
  286. /*
  287. * RFC1350 specifies that the first data packet will
  288. * have sequence number 1. If we receive a sequence
  289. * number of 0 this means that there was a wrap
  290. * around of the (16 bit) counter.
  291. */
  292. if (TftpBlock == 0) {
  293. TftpBlockWrap++;
  294. TftpBlockWrapOffset += TftpBlkSize * TFTP_SEQUENCE_SIZE;
  295. printf ("\n\t %lu MB received\n\t ", TftpBlockWrapOffset>>20);
  296. } else {
  297. if (((TftpBlock - 1) % 10) == 0) {
  298. putc ('#');
  299. } else if ((TftpBlock % (10 * HASHES_PER_LINE)) == 0) {
  300. puts ("\n\t ");
  301. }
  302. }
  303. if (TftpState == STATE_RRQ)
  304. debug("Server did not acknowledge timeout option!\n");
  305. if (TftpState == STATE_RRQ || TftpState == STATE_OACK) {
  306. /* first block received */
  307. TftpState = STATE_DATA;
  308. TftpServerPort = src;
  309. TftpLastBlock = 0;
  310. TftpBlockWrap = 0;
  311. TftpBlockWrapOffset = 0;
  312. #ifdef CONFIG_MCAST_TFTP
  313. if (Multicast) { /* start!=1 common if mcast */
  314. TftpLastBlock = TftpBlock - 1;
  315. } else
  316. #endif
  317. if (TftpBlock != 1) { /* Assertion */
  318. printf ("\nTFTP error: "
  319. "First block is not block 1 (%ld)\n"
  320. "Starting again\n\n",
  321. TftpBlock);
  322. NetStartAgain ();
  323. break;
  324. }
  325. }
  326. if (TftpBlock == TftpLastBlock) {
  327. /*
  328. * Same block again; ignore it.
  329. */
  330. break;
  331. }
  332. TftpLastBlock = TftpBlock;
  333. TftpTimeoutMSecs = TIMEOUT;
  334. TftpTimeoutCountMax = TIMEOUT_COUNT;
  335. NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
  336. store_block (TftpBlock - 1, pkt + 2, len);
  337. /*
  338. * Acknoledge the block just received, which will prompt
  339. * the server for the next one.
  340. */
  341. #ifdef CONFIG_MCAST_TFTP
  342. /* if I am the MasterClient, actively calculate what my next
  343. * needed block is; else I'm passive; not ACKING
  344. */
  345. if (Multicast) {
  346. if (len < TftpBlkSize) {
  347. TftpEndingBlock = TftpBlock;
  348. } else if (MasterClient) {
  349. TftpBlock = PrevBitmapHole =
  350. ext2_find_next_zero_bit(
  351. Bitmap,
  352. (Mapsize*8),
  353. PrevBitmapHole);
  354. if (TftpBlock > ((Mapsize*8) - 1)) {
  355. printf ("tftpfile too big\n");
  356. /* try to double it and retry */
  357. Mapsize<<=1;
  358. mcast_cleanup();
  359. NetStartAgain ();
  360. return;
  361. }
  362. TftpLastBlock = TftpBlock;
  363. }
  364. }
  365. #endif
  366. TftpSend ();
  367. #ifdef CONFIG_MCAST_TFTP
  368. if (Multicast) {
  369. if (MasterClient && (TftpBlock >= TftpEndingBlock)) {
  370. puts ("\nMulticast tftp done\n");
  371. mcast_cleanup();
  372. NetState = NETLOOP_SUCCESS;
  373. }
  374. }
  375. else
  376. #endif
  377. if (len < TftpBlkSize) {
  378. /*
  379. * We received the whole thing. Try to
  380. * run it.
  381. */
  382. puts ("\ndone\n");
  383. NetState = NETLOOP_SUCCESS;
  384. }
  385. break;
  386. case TFTP_ERROR:
  387. printf ("\nTFTP error: '%s' (%d)\n",
  388. pkt + 2, ntohs(*(ushort *)pkt));
  389. puts ("Starting again\n\n");
  390. #ifdef CONFIG_MCAST_TFTP
  391. mcast_cleanup();
  392. #endif
  393. NetStartAgain ();
  394. break;
  395. }
  396. }
  397. static void
  398. TftpTimeout (void)
  399. {
  400. if (++TftpTimeoutCount > TftpTimeoutCountMax) {
  401. puts ("\nRetry count exceeded; starting again\n");
  402. #ifdef CONFIG_MCAST_TFTP
  403. mcast_cleanup();
  404. #endif
  405. NetStartAgain ();
  406. } else {
  407. puts ("T ");
  408. NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
  409. TftpSend ();
  410. }
  411. }
  412. void
  413. TftpStart (void)
  414. {
  415. #ifdef CONFIG_TFTP_PORT
  416. char *ep; /* Environment pointer */
  417. #endif
  418. TftpServerIP = NetServerIP;
  419. if (BootFile[0] == '\0') {
  420. sprintf(default_filename, "%02lX%02lX%02lX%02lX.img",
  421. NetOurIP & 0xFF,
  422. (NetOurIP >> 8) & 0xFF,
  423. (NetOurIP >> 16) & 0xFF,
  424. (NetOurIP >> 24) & 0xFF );
  425. strncpy(tftp_filename, default_filename, MAX_LEN);
  426. tftp_filename[MAX_LEN-1] = 0;
  427. printf ("*** Warning: no boot file name; using '%s'\n",
  428. tftp_filename);
  429. } else {
  430. char *p = strchr (BootFile, ':');
  431. if (p == NULL) {
  432. strncpy(tftp_filename, BootFile, MAX_LEN);
  433. tftp_filename[MAX_LEN-1] = 0;
  434. } else {
  435. TftpServerIP = string_to_ip (BootFile);
  436. strncpy(tftp_filename, p + 1, MAX_LEN);
  437. tftp_filename[MAX_LEN-1] = 0;
  438. }
  439. }
  440. #if defined(CONFIG_NET_MULTI)
  441. printf ("Using %s device\n", eth_get_name());
  442. #endif
  443. printf("TFTP from server %pI4"
  444. "; our IP address is %pI4", &TftpServerIP, &NetOurIP);
  445. /* Check if we need to send across this subnet */
  446. if (NetOurGatewayIP && NetOurSubnetMask) {
  447. IPaddr_t OurNet = NetOurIP & NetOurSubnetMask;
  448. IPaddr_t ServerNet = TftpServerIP & NetOurSubnetMask;
  449. if (OurNet != ServerNet)
  450. printf("; sending through gateway %pI4", &NetOurGatewayIP);
  451. }
  452. putc ('\n');
  453. printf ("Filename '%s'.", tftp_filename);
  454. if (NetBootFileSize) {
  455. printf (" Size is 0x%x Bytes = ", NetBootFileSize<<9);
  456. print_size (NetBootFileSize<<9, "");
  457. }
  458. putc ('\n');
  459. printf ("Load address: 0x%lx\n", load_addr);
  460. puts ("Loading: *\b");
  461. TftpTimeoutMSecs = TftpRRQTimeoutMSecs;
  462. TftpTimeoutCountMax = TftpRRQTimeoutCountMax;
  463. NetSetTimeout (TftpTimeoutMSecs, TftpTimeout);
  464. NetSetHandler (TftpHandler);
  465. TftpServerPort = WELL_KNOWN_PORT;
  466. TftpTimeoutCount = 0;
  467. TftpState = STATE_RRQ;
  468. /* Use a pseudo-random port unless a specific port is set */
  469. TftpOurPort = 1024 + (get_timer(0) % 3072);
  470. #ifdef CONFIG_TFTP_PORT
  471. if ((ep = getenv("tftpdstp")) != NULL) {
  472. TftpServerPort = simple_strtol(ep, NULL, 10);
  473. }
  474. if ((ep = getenv("tftpsrcp")) != NULL) {
  475. TftpOurPort= simple_strtol(ep, NULL, 10);
  476. }
  477. #endif
  478. TftpBlock = 0;
  479. /* zero out server ether in case the server ip has changed */
  480. memset(NetServerEther, 0, 6);
  481. /* Revert TftpBlkSize to dflt */
  482. TftpBlkSize = TFTP_BLOCK_SIZE;
  483. #ifdef CONFIG_MCAST_TFTP
  484. mcast_cleanup();
  485. #endif
  486. TftpSend ();
  487. }
  488. #ifdef CONFIG_MCAST_TFTP
  489. /* Credits: atftp project.
  490. */
  491. /* pick up BcastAddr, Port, and whether I am [now] the master-client. *
  492. * Frame:
  493. * +-------+-----------+---+-------~~-------+---+
  494. * | opc | multicast | 0 | addr, port, mc | 0 |
  495. * +-------+-----------+---+-------~~-------+---+
  496. * The multicast addr/port becomes what I listen to, and if 'mc' is '1' then
  497. * I am the new master-client so must send ACKs to DataBlocks. If I am not
  498. * master-client, I'm a passive client, gathering what DataBlocks I may and
  499. * making note of which ones I got in my bitmask.
  500. * In theory, I never go from master->passive..
  501. * .. this comes in with pkt already pointing just past opc
  502. */
  503. static void parse_multicast_oack(char *pkt, int len)
  504. {
  505. int i;
  506. IPaddr_t addr;
  507. char *mc_adr, *port, *mc;
  508. mc_adr=port=mc=NULL;
  509. /* march along looking for 'multicast\0', which has to start at least
  510. * 14 bytes back from the end.
  511. */
  512. for (i=0;i<len-14;i++)
  513. if (strcmp (pkt+i,"multicast") == 0)
  514. break;
  515. if (i >= (len-14)) /* non-Multicast OACK, ign. */
  516. return;
  517. i+=10; /* strlen multicast */
  518. mc_adr = pkt+i;
  519. for (;i<len;i++) {
  520. if (*(pkt+i) == ',') {
  521. *(pkt+i) = '\0';
  522. if (port) {
  523. mc = pkt+i+1;
  524. break;
  525. } else {
  526. port = pkt+i+1;
  527. }
  528. }
  529. }
  530. if (!port || !mc_adr || !mc ) return;
  531. if (Multicast && MasterClient) {
  532. printf ("I got a OACK as master Client, WRONG!\n");
  533. return;
  534. }
  535. /* ..I now accept packets destined for this MCAST addr, port */
  536. if (!Multicast) {
  537. if (Bitmap) {
  538. printf ("Internal failure! no mcast.\n");
  539. free(Bitmap);
  540. Bitmap=NULL;
  541. ProhibitMcast=1;
  542. return ;
  543. }
  544. /* I malloc instead of pre-declare; so that if the file ends
  545. * up being too big for this bitmap I can retry
  546. */
  547. if (!(Bitmap = malloc (Mapsize))) {
  548. printf ("No Bitmap, no multicast. Sorry.\n");
  549. ProhibitMcast=1;
  550. return;
  551. }
  552. memset (Bitmap,0,Mapsize);
  553. PrevBitmapHole = 0;
  554. Multicast = 1;
  555. }
  556. addr = string_to_ip(mc_adr);
  557. if (Mcast_addr != addr) {
  558. if (Mcast_addr)
  559. eth_mcast_join(Mcast_addr, 0);
  560. if (eth_mcast_join(Mcast_addr=addr, 1)) {
  561. printf ("Fail to set mcast, revert to TFTP\n");
  562. ProhibitMcast=1;
  563. mcast_cleanup();
  564. NetStartAgain();
  565. }
  566. }
  567. MasterClient = (unsigned char)simple_strtoul((char *)mc,NULL,10);
  568. Mcast_port = (unsigned short)simple_strtoul(port,NULL,10);
  569. printf ("Multicast: %s:%d [%d]\n", mc_adr, Mcast_port, MasterClient);
  570. return;
  571. }
  572. #endif /* Multicast TFTP */
  573. #endif