2 * Copyright 1994, 1995, 2000 Neil Russell.
4 * Copyright 2000, 2001 DENX Software Engineering, Wolfgang Denk, wd@denx.de
5 * Copyright 2011 Comelit Group SpA,
6 * Luca Ceresoli <luca.ceresoli@comelit.it>
10 #include <efi_loader.h>
17 #include <asm/global_data.h>
21 DECLARE_GLOBAL_DATA_PTR;
23 /* Well known TFTP port # */
24 #define WELL_KNOWN_PORT 69
25 /* Millisecs to timeout for lost pkt */
26 #define TIMEOUT 5000UL
27 /* Number of "loading" hashes per line (for checking the image size) */
28 #define HASHES_PER_LINE 65
40 static ulong timeout_ms = TIMEOUT;
41 static int timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2);
42 static ulong time_start; /* Record time we started tftp */
45 * These globals govern the timeout behavior when attempting a connection to a
46 * TFTP server. tftp_timeout_ms specifies the number of milliseconds to
47 * wait for the server to respond to initial connection. Second global,
48 * tftp_timeout_count_max, gives the number of such connection retries.
49 * tftp_timeout_count_max must be non-negative and tftp_timeout_ms must be
50 * positive. The globals are meant to be set (and restored) by code needing
51 * non-standard timeout behavior when initiating a TFTP transfer.
53 ulong tftp_timeout_ms = TIMEOUT;
54 int tftp_timeout_count_max = (CONFIG_NET_RETRY_COUNT * 2);
57 TFTP_ERR_UNDEFINED = 0,
58 TFTP_ERR_FILE_NOT_FOUND = 1,
59 TFTP_ERR_ACCESS_DENIED = 2,
60 TFTP_ERR_DISK_FULL = 3,
61 TFTP_ERR_UNEXPECTED_OPCODE = 4,
62 TFTP_ERR_UNKNOWN_TRANSFER_ID = 5,
63 TFTP_ERR_FILE_ALREADY_EXISTS = 6,
64 TFTP_ERR_OPTION_NEGOTIATION = 8,
67 static struct in_addr tftp_remote_ip;
68 /* The UDP port at their end */
69 static int tftp_remote_port;
70 /* The UDP port at our end */
71 static int tftp_our_port;
72 static int timeout_count;
73 /* packet sequence number */
74 static ulong tftp_cur_block;
75 /* last packet sequence number received */
76 static ulong tftp_prev_block;
77 /* count of sequence number wraparounds */
78 static ulong tftp_block_wrap;
79 /* memory offset due to wrapping */
80 static ulong tftp_block_wrap_offset;
81 static int tftp_state;
82 static ulong tftp_load_addr;
84 static ulong tftp_load_size;
86 #ifdef CONFIG_TFTP_TSIZE
87 /* The file size reported by the server */
88 static int tftp_tsize;
89 /* The number of hashes we printed */
90 static short tftp_tsize_num_hash;
92 /* The window size negotiated */
93 static ushort tftp_windowsize;
94 /* Next block to send ack to */
95 static ushort tftp_next_ack;
96 /* Last nack block we send */
97 static ushort tftp_last_nack;
98 #ifdef CONFIG_CMD_TFTPPUT
99 /* 1 if writing, else 0 */
100 static int tftp_put_active;
101 /* 1 if we have sent the last block */
102 static int tftp_put_final_block_sent;
104 #define tftp_put_active 0
107 #define STATE_SEND_RRQ 1
109 #define STATE_TOO_LARGE 3
110 #define STATE_BAD_MAGIC 4
112 #define STATE_RECV_WRQ 6
113 #define STATE_SEND_WRQ 7
114 #define STATE_INVALID_OPTION 8
116 /* default TFTP block size */
117 #define TFTP_BLOCK_SIZE 512
118 /* sequence number is 16 bit */
119 #define TFTP_SEQUENCE_SIZE ((ulong)(1<<16))
121 #define DEFAULT_NAME_LEN (8 + 4 + 1)
122 static char default_filename[DEFAULT_NAME_LEN];
124 #ifndef CONFIG_TFTP_FILE_NAME_MAX_LEN
127 #define MAX_LEN CONFIG_TFTP_FILE_NAME_MAX_LEN
130 static char tftp_filename[MAX_LEN];
132 /* 512 is poor choice for ethernet, MTU is typically 1500.
133 * Minus eth.hdrs thats 1468. Can get 2x better throughput with
134 * almost-MTU block sizes. At least try... fall back to 512 if need be.
135 * (but those using CONFIG_IP_DEFRAG may want to set a larger block in cfg file)
138 /* When windowsize is defined to 1,
139 * tftp behaves the same way as it was
142 #ifdef CONFIG_TFTP_WINDOWSIZE
143 #define TFTP_WINDOWSIZE CONFIG_TFTP_WINDOWSIZE
145 #define TFTP_WINDOWSIZE 1
148 static unsigned short tftp_block_size = TFTP_BLOCK_SIZE;
149 static unsigned short tftp_block_size_option = CONFIG_TFTP_BLOCKSIZE;
150 static unsigned short tftp_window_size_option = TFTP_WINDOWSIZE;
152 static inline int store_block(int block, uchar *src, unsigned int len)
154 ulong offset = block * tftp_block_size + tftp_block_wrap_offset -
156 ulong newsize = offset + len;
157 ulong store_addr = tftp_load_addr + offset;
161 ulong end_addr = tftp_load_addr + tftp_load_size;
164 end_addr = ULONG_MAX;
166 if (store_addr < tftp_load_addr ||
167 store_addr + len > end_addr) {
168 puts("\nTFTP error: ");
169 puts("trying to overwrite reserved memory...\n");
173 ptr = map_sysmem(store_addr, len);
174 memcpy(ptr, src, len);
177 if (net_boot_file_size < newsize)
178 net_boot_file_size = newsize;
183 /* Clear our state ready for a new transfer */
184 static void new_transfer(void)
188 tftp_block_wrap_offset = 0;
189 #ifdef CONFIG_CMD_TFTPPUT
190 tftp_put_final_block_sent = 0;
194 #ifdef CONFIG_CMD_TFTPPUT
196 * Load the next block from memory to be sent over tftp.
198 * @param block Block number to send
199 * @param dst Destination buffer for data
200 * @param len Number of bytes in block (this one and every other)
201 * Return: number of bytes loaded
203 static int load_block(unsigned block, uchar *dst, unsigned len)
205 /* We may want to get the final block from the previous set */
206 ulong offset = block * tftp_block_size + tftp_block_wrap_offset -
210 tosend = min(net_boot_file_size - offset, tosend);
211 (void)memcpy(dst, (void *)(image_save_addr + offset), tosend);
212 debug("%s: block=%u, offset=%lu, len=%u, tosend=%lu\n", __func__,
213 block, offset, len, tosend);
218 static void tftp_send(void);
219 static void tftp_timeout_handler(void);
221 /**********************************************************************/
223 static void show_block_marker(void)
227 #ifdef CONFIG_TFTP_TSIZE
229 pos = tftp_cur_block * tftp_block_size +
230 tftp_block_wrap_offset;
231 if (pos > tftp_tsize)
234 while (tftp_tsize_num_hash < pos * 50 / tftp_tsize) {
236 tftp_tsize_num_hash++;
241 pos = (tftp_cur_block - 1) +
242 (tftp_block_wrap * TFTP_SEQUENCE_SIZE);
245 else if (((pos + 1) % (10 * HASHES_PER_LINE)) == 0)
251 * restart the current transfer due to an error
253 * @param msg Message to print for user
255 static void restart(const char *msg)
257 printf("\n%s; starting again\n", msg);
262 * Check if the block number has wrapped, and update progress
264 * TODO: The egregious use of global variables in this file should be tidied.
266 static void update_block_number(void)
269 * RFC1350 specifies that the first data packet will
270 * have sequence number 1. If we receive a sequence
271 * number of 0 this means that there was a wrap
272 * around of the (16 bit) counter.
274 if (tftp_cur_block == 0 && tftp_prev_block != 0) {
276 tftp_block_wrap_offset += tftp_block_size * TFTP_SEQUENCE_SIZE;
277 timeout_count = 0; /* we've done well, reset the timeout */
282 /* The TFTP get or put is complete */
283 static void tftp_complete(void)
285 #ifdef CONFIG_TFTP_TSIZE
286 /* Print hash marks for the last packet received */
287 while (tftp_tsize && tftp_tsize_num_hash < 49) {
289 tftp_tsize_num_hash++;
292 print_size(tftp_tsize, "");
294 time_start = get_timer(time_start);
295 if (time_start > 0) {
296 puts("\n\t "); /* Line up with "Loading: " */
297 print_size(net_boot_file_size /
298 time_start * 1000, "/s");
301 if (IS_ENABLED(CONFIG_CMD_BOOTEFI)) {
302 if (!tftp_put_active)
303 efi_set_bootdev("Net", "", tftp_filename,
304 map_sysmem(tftp_load_addr, 0),
307 net_set_state(NETLOOP_SUCCESS);
310 static void tftp_send(void)
316 bool err_pkt = false;
319 * We will always be sending some sort of packet, so
320 * cobble together the packet headers now.
322 pkt = net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE;
324 switch (tftp_state) {
329 #ifdef CONFIG_CMD_TFTPPUT
330 *s++ = htons(tftp_state == STATE_SEND_RRQ ? TFTP_RRQ :
333 *s++ = htons(TFTP_RRQ);
336 strcpy((char *)pkt, tftp_filename);
337 pkt += strlen(tftp_filename) + 1;
338 strcpy((char *)pkt, "octet");
339 pkt += 5 /*strlen("octet")*/ + 1;
340 strcpy((char *)pkt, "timeout");
341 pkt += 7 /*strlen("timeout")*/ + 1;
342 sprintf((char *)pkt, "%lu", timeout_ms / 1000);
343 debug("send option \"timeout %s\"\n", (char *)pkt);
344 pkt += strlen((char *)pkt) + 1;
345 #ifdef CONFIG_TFTP_TSIZE
346 pkt += sprintf((char *)pkt, "tsize%c%u%c",
347 0, net_boot_file_size, 0);
349 /* try for more effic. blk size */
350 pkt += sprintf((char *)pkt, "blksize%c%d%c",
351 0, tftp_block_size_option, 0);
353 /* try for more effic. window size.
354 * Implemented only for tftp get.
355 * Don't bother sending if it's 1
357 if (tftp_state == STATE_SEND_RRQ && tftp_window_size_option > 1)
358 pkt += sprintf((char *)pkt, "windowsize%c%d%c",
359 0, tftp_window_size_option, 0);
369 s[0] = htons(TFTP_ACK);
370 s[1] = htons(tftp_cur_block);
371 pkt = (uchar *)(s + 2);
372 #ifdef CONFIG_CMD_TFTPPUT
373 if (tftp_put_active) {
374 int toload = tftp_block_size;
375 int loaded = load_block(tftp_cur_block, pkt, toload);
377 s[0] = htons(TFTP_DATA);
379 tftp_put_final_block_sent = (loaded < toload);
385 case STATE_TOO_LARGE:
388 *s++ = htons(TFTP_ERROR);
392 strcpy((char *)pkt, "File too large");
393 pkt += 14 /*strlen("File too large")*/ + 1;
398 case STATE_BAD_MAGIC:
401 *s++ = htons(TFTP_ERROR);
404 strcpy((char *)pkt, "File has bad magic");
405 pkt += 18 /*strlen("File has bad magic")*/ + 1;
410 case STATE_INVALID_OPTION:
413 *s++ = htons(TFTP_ERROR);
414 *s++ = htons(TFTP_ERR_OPTION_NEGOTIATION);
416 strcpy((char *)pkt, "Option Negotiation Failed");
417 /* strlen("Option Negotiation Failed") + NULL*/
424 net_send_udp_packet(net_server_ethaddr, tftp_remote_ip,
425 tftp_remote_port, tftp_our_port, len);
428 net_set_state(NETLOOP_FAIL);
431 #ifdef CONFIG_CMD_TFTPPUT
432 static void icmp_handler(unsigned type, unsigned code, unsigned dest,
433 struct in_addr sip, unsigned src, uchar *pkt,
436 if (type == ICMP_NOT_REACH && code == ICMP_NOT_REACH_PORT) {
437 /* Oh dear the other end has gone away */
438 restart("TFTP server died");
443 static void tftp_handler(uchar *pkt, unsigned dest, struct in_addr sip,
444 unsigned src, unsigned len)
449 u16 timeout_val_rcvd;
451 if (dest != tftp_our_port) {
454 if (tftp_state != STATE_SEND_RRQ && src != tftp_remote_port &&
455 tftp_state != STATE_RECV_WRQ && tftp_state != STATE_SEND_WRQ)
461 /* warning: don't use increment (++) in ntohs() macros!! */
465 switch (ntohs(proto)) {
470 #ifdef CONFIG_CMD_TFTPPUT
471 if (tftp_put_active) {
472 if (tftp_put_final_block_sent) {
476 * Move to the next block. We want our block
477 * count to wrap just like the other end!
479 int block = ntohs(*s);
480 int ack_ok = (tftp_cur_block == block);
482 tftp_prev_block = tftp_cur_block;
483 tftp_cur_block = (unsigned short)(block + 1);
484 update_block_number();
486 tftp_send(); /* Send next data block */
495 #ifdef CONFIG_CMD_TFTPSRV
498 tftp_remote_ip = sip;
499 tftp_remote_port = src;
500 tftp_our_port = 1024 + (get_timer(0) % 3072);
502 tftp_send(); /* Send ACK(0) */
508 for (i = 0; i < len; i++) {
515 tftp_state = STATE_OACK;
516 tftp_remote_port = src;
518 * Check for 'blksize' option.
519 * Careful: "i" is signed, "len" is unsigned, thus
520 * something like "len-8" may give a *huge* number
522 for (i = 0; i+8 < len; i++) {
523 if (strcasecmp((char *)pkt + i, "blksize") == 0) {
524 tftp_block_size = (unsigned short)
525 dectoul((char *)pkt + i + 8, NULL);
526 debug("Blocksize oack: %s, %d\n",
527 (char *)pkt + i + 8, tftp_block_size);
528 if (tftp_block_size > tftp_block_size_option) {
529 printf("Invalid blk size(=%d)\n",
531 tftp_state = STATE_INVALID_OPTION;
534 if (strcasecmp((char *)pkt + i, "timeout") == 0) {
535 timeout_val_rcvd = (unsigned short)
536 dectoul((char *)pkt + i + 8, NULL);
537 debug("Timeout oack: %s, %d\n",
538 (char *)pkt + i + 8, timeout_val_rcvd);
539 if (timeout_val_rcvd != (timeout_ms / 1000)) {
540 printf("Invalid timeout val(=%d s)\n",
542 tftp_state = STATE_INVALID_OPTION;
545 #ifdef CONFIG_TFTP_TSIZE
546 if (strcasecmp((char *)pkt + i, "tsize") == 0) {
547 tftp_tsize = dectoul((char *)pkt + i + 6,
549 debug("size = %s, %d\n",
550 (char *)pkt + i + 6, tftp_tsize);
553 if (strcasecmp((char *)pkt + i, "windowsize") == 0) {
555 dectoul((char *)pkt + i + 11, NULL);
556 debug("windowsize = %s, %d\n",
557 (char *)pkt + i + 11, tftp_windowsize);
561 tftp_next_ack = tftp_windowsize;
563 #ifdef CONFIG_CMD_TFTPPUT
564 if (tftp_put_active && tftp_state == STATE_OACK) {
565 /* Get ready to send the first block */
566 tftp_state = STATE_DATA;
570 tftp_send(); /* Send ACK or first data block */
577 if (ntohs(*(__be16 *)pkt) != (ushort)(tftp_cur_block + 1)) {
578 debug("Received unexpected block: %d, expected: %d\n",
579 ntohs(*(__be16 *)pkt),
580 (ushort)(tftp_cur_block + 1));
582 * If one packet is dropped most likely
583 * all other buffers in the window
584 * that will arrive will cause a sending NACK.
585 * This just overwellms the server, let's just send one.
587 if (tftp_last_nack != tftp_cur_block) {
589 tftp_last_nack = tftp_cur_block;
590 tftp_next_ack = (ushort)(tftp_cur_block +
597 tftp_cur_block %= TFTP_SEQUENCE_SIZE;
599 if (tftp_state == STATE_SEND_RRQ) {
600 debug("Server did not acknowledge any options!\n");
601 tftp_next_ack = tftp_windowsize;
604 if (tftp_state == STATE_SEND_RRQ || tftp_state == STATE_OACK ||
605 tftp_state == STATE_RECV_WRQ) {
606 /* first block received */
607 tftp_state = STATE_DATA;
608 tftp_remote_port = src;
611 if (tftp_cur_block != 1) { /* Assertion */
612 puts("\nTFTP error: ");
613 printf("First block is not block 1 (%ld)\n",
615 puts("Starting again\n\n");
621 if (tftp_cur_block == tftp_prev_block) {
622 /* Same block again; ignore it. */
626 update_block_number();
627 tftp_prev_block = tftp_cur_block;
628 timeout_count_max = tftp_timeout_count_max;
629 net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
631 if (store_block(tftp_cur_block, pkt + 2, len)) {
633 net_set_state(NETLOOP_FAIL);
637 if (len < tftp_block_size) {
644 * Acknowledge the block just received, which will prompt
645 * the remote for the next one.
647 if (tftp_cur_block == tftp_next_ack) {
649 tftp_next_ack += tftp_windowsize;
654 printf("\nTFTP error: '%s' (%d)\n",
655 pkt + 2, ntohs(*(__be16 *)pkt));
657 switch (ntohs(*(__be16 *)pkt)) {
658 case TFTP_ERR_FILE_NOT_FOUND:
659 case TFTP_ERR_ACCESS_DENIED:
660 puts("Not retrying...\n");
662 net_set_state(NETLOOP_FAIL);
664 case TFTP_ERR_UNDEFINED:
665 case TFTP_ERR_DISK_FULL:
666 case TFTP_ERR_UNEXPECTED_OPCODE:
667 case TFTP_ERR_UNKNOWN_TRANSFER_ID:
668 case TFTP_ERR_FILE_ALREADY_EXISTS:
670 puts("Starting again\n\n");
679 static void tftp_timeout_handler(void)
681 if (++timeout_count > timeout_count_max) {
682 restart("Retry count exceeded");
685 net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
686 if (tftp_state != STATE_RECV_WRQ)
691 /* Initialize tftp_load_addr and tftp_load_size from image_load_addr and lmb */
692 static int tftp_init_load_addr(void)
696 phys_size_t max_size;
698 lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
700 max_size = lmb_get_free_size(&lmb, image_load_addr);
704 tftp_load_size = max_size;
706 tftp_load_addr = image_load_addr;
710 void tftp_start(enum proto_t protocol)
712 #if CONFIG_NET_TFTP_VARS
713 char *ep; /* Environment pointer */
716 * Allow the user to choose TFTP blocksize and timeout.
717 * TFTP protocol has a minimal timeout of 1 second.
720 ep = env_get("tftpblocksize");
722 tftp_block_size_option = simple_strtol(ep, NULL, 10);
724 ep = env_get("tftpwindowsize");
726 tftp_window_size_option = simple_strtol(ep, NULL, 10);
728 ep = env_get("tftptimeout");
730 timeout_ms = simple_strtol(ep, NULL, 10);
732 if (timeout_ms < 1000) {
733 printf("TFTP timeout (%ld ms) too low, set min = 1000 ms\n",
738 ep = env_get("tftptimeoutcountmax");
740 tftp_timeout_count_max = simple_strtol(ep, NULL, 10);
742 if (tftp_timeout_count_max < 0) {
743 printf("TFTP timeout count max (%d ms) negative, set to 0\n",
744 tftp_timeout_count_max);
745 tftp_timeout_count_max = 0;
749 debug("TFTP blocksize = %i, TFTP windowsize = %d timeout = %ld ms\n",
750 tftp_block_size_option, tftp_window_size_option, timeout_ms);
752 tftp_remote_ip = net_server_ip;
753 if (!net_parse_bootfile(&tftp_remote_ip, tftp_filename, MAX_LEN)) {
754 sprintf(default_filename, "%02X%02X%02X%02X.img",
755 net_ip.s_addr & 0xFF,
756 (net_ip.s_addr >> 8) & 0xFF,
757 (net_ip.s_addr >> 16) & 0xFF,
758 (net_ip.s_addr >> 24) & 0xFF);
760 strncpy(tftp_filename, default_filename, DEFAULT_NAME_LEN);
761 tftp_filename[DEFAULT_NAME_LEN - 1] = 0;
763 printf("*** Warning: no boot file name; using '%s'\n",
767 printf("Using %s device\n", eth_get_name());
768 printf("TFTP %s server %pI4; our IP address is %pI4",
769 #ifdef CONFIG_CMD_TFTPPUT
770 protocol == TFTPPUT ? "to" : "from",
774 &tftp_remote_ip, &net_ip);
776 /* Check if we need to send across this subnet */
777 if (net_gateway.s_addr && net_netmask.s_addr) {
778 struct in_addr our_net;
779 struct in_addr remote_net;
781 our_net.s_addr = net_ip.s_addr & net_netmask.s_addr;
782 remote_net.s_addr = tftp_remote_ip.s_addr & net_netmask.s_addr;
783 if (our_net.s_addr != remote_net.s_addr)
784 printf("; sending through gateway %pI4", &net_gateway);
788 printf("Filename '%s'.", tftp_filename);
790 if (net_boot_file_expected_size_in_blocks) {
791 printf(" Size is 0x%x Bytes = ",
792 net_boot_file_expected_size_in_blocks << 9);
793 print_size(net_boot_file_expected_size_in_blocks << 9, "");
797 #ifdef CONFIG_CMD_TFTPPUT
798 tftp_put_active = (protocol == TFTPPUT);
799 if (tftp_put_active) {
800 printf("Save address: 0x%lx\n", image_save_addr);
801 printf("Save size: 0x%lx\n", image_save_size);
802 net_boot_file_size = image_save_size;
804 tftp_state = STATE_SEND_WRQ;
809 if (tftp_init_load_addr()) {
811 net_set_state(NETLOOP_FAIL);
812 puts("\nTFTP error: ");
813 puts("trying to overwrite reserved memory...\n");
816 printf("Load address: 0x%lx\n", tftp_load_addr);
817 puts("Loading: *\b");
818 tftp_state = STATE_SEND_RRQ;
821 time_start = get_timer(0);
822 timeout_count_max = tftp_timeout_count_max;
824 net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
825 net_set_udp_handler(tftp_handler);
826 #ifdef CONFIG_CMD_TFTPPUT
827 net_set_icmp_handler(icmp_handler);
829 tftp_remote_port = WELL_KNOWN_PORT;
831 /* Use a pseudo-random port unless a specific port is set */
832 tftp_our_port = 1024 + (get_timer(0) % 3072);
834 #ifdef CONFIG_TFTP_PORT
835 ep = env_get("tftpdstp");
837 tftp_remote_port = simple_strtol(ep, NULL, 10);
838 ep = env_get("tftpsrcp");
840 tftp_our_port = simple_strtol(ep, NULL, 10);
845 /* zero out server ether in case the server ip has changed */
846 memset(net_server_ethaddr, 0, 6);
847 /* Revert tftp_block_size to dflt */
848 tftp_block_size = TFTP_BLOCK_SIZE;
849 #ifdef CONFIG_TFTP_TSIZE
851 tftp_tsize_num_hash = 0;
857 #ifdef CONFIG_CMD_TFTPSRV
858 void tftp_start_server(void)
860 tftp_filename[0] = 0;
862 if (tftp_init_load_addr()) {
864 net_set_state(NETLOOP_FAIL);
865 puts("\nTFTP error: trying to overwrite reserved memory...\n");
868 printf("Using %s device\n", eth_get_name());
869 printf("Listening for TFTP transfer on %pI4\n", &net_ip);
870 printf("Load address: 0x%lx\n", tftp_load_addr);
872 puts("Loading: *\b");
874 timeout_count_max = tftp_timeout_count_max;
876 timeout_ms = TIMEOUT;
877 net_set_timeout_handler(timeout_ms, tftp_timeout_handler);
879 /* Revert tftp_block_size to dflt */
880 tftp_block_size = TFTP_BLOCK_SIZE;
882 tftp_our_port = WELL_KNOWN_PORT;
884 tftp_next_ack = tftp_windowsize;
886 #ifdef CONFIG_TFTP_TSIZE
888 tftp_tsize_num_hash = 0;
891 tftp_state = STATE_RECV_WRQ;
892 net_set_udp_handler(tftp_handler);
894 /* zero out server ether in case the server ip has changed */
895 memset(net_server_ethaddr, 0, 6);
897 #endif /* CONFIG_CMD_TFTPSRV */