All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [RFC] Act as a TFTP server
@ 2011-04-13  9:08 Luca Ceresoli
  2011-04-13 11:37 ` Wolfgang Denk
                   ` (8 more replies)
  0 siblings, 9 replies; 72+ messages in thread
From: Luca Ceresoli @ 2011-04-13  9:08 UTC (permalink / raw)
  To: u-boot

Hi,

I am going to implement in U-Boot the ability to receive a file via TFTP acting
as a server, not a client. I've sketched up a way to implement it, and I would
appreciate any comments about it.

This is useful to solve the firewall issues that a Management Station can face
when sending files to a U-Boot device. These issues are only partially solved
using CONFIG_TFTP_PORT for '"punching through" the (Windows XP) firewall' (see
the README).

My implementation would be very basic (keep it simple):
- receive only (accept WRQ from remote client, not RRQ);
- the Filename in the WRQ is ignored: the destination is always a user-provided
   memory location;
- binary transfers only: the Mode in the WRQ is ignored; this is allowed by
   RFC1350 (section 5);
- no TFTP Option Extensions (RFC2347);
- no TFTP multicast.

After a preliminary analysis, I think the current TFTP clien implementation can
be mostly reused without code duplication, hence the amount of new code would
be pretty limited.

Even better, it would not increase binary size when the feature is disabled,
as I don't see any need to extend the existing code in a way that cannot be
easily put under appropriate #ifdefs.

 From the user point of view, I would implement a new command, activated only
when CONFIG_CMD_TFTPSRV is defined:

   Usage:    tftpsrv [<loadaddr>]

This would be used almost like tftpboot, except no file name is specified on
the commandline.
<loadaddr>  would default to the environment variable.

Here's a tentative implementation roadmap. It is presented in a roughly
top-down order, from user interface down to low level.
Many steps, except for those in net/tftp.c, are pretty trivial.

- add CONFIG_CMD_TFTPSRV config option;
- include/net.h: add TFTPSRV to proto_t, *as if it were a different protocol*;
   this may look dirty but I believe it makes implementation cleaner;
   - alternative: reuse TFTP protocol, but save in some flag (where?) whether
     the user wants a client or server transfer;
- common/cmd_net.c: add a tftpsrv command and do_tftpsrv() function;
   just like do_tftpb() simply calls netboot_common(TFTP, ...),
   do_tftpsrv() would simply call netboot_common(TFTPSRV, ...);
- common/cmd_net.c: netboot_common() should not need change, except maybe
   for the argv parsing: tftpsrv does not take a "hostaddr:filename" argument;
   to make it simpler, it could accept (but ignore) it if passed;
- net/net.c: change net_check_prereq() as needed: it should not check for
   NetServerIP when protocol==TFTPSRV;
- net/net.c: extend NetLoop() to handle the new protocol: call
   TftpStartServer() (not TftpStart()) when protocol==TFTPSRV;
- net/tftp.c: add TftpStartServer() with a role similar to TftpStart();
   - alternative: extend TftpStart() to handle both client and server mode;
     probably not worth doing as the actions to do are mostly different;
- net/tftp.c: extend the TFTP state machine (TftpHandler() and TftpStart())
   a new STATE_WAITING state (it should be enough);
   - the state machine would be different in the session setup: in
     STATE_WAITING handle WRQ packets and select a new UDP port;
   - after the setup phase, the state machine would converge on the
     currently-implemented STATE_DATA for normal DATA/ACK management.

Do you think my approach is correct?
Would this feature be considered for mainline inclusion?

Thanks in advance,
Luca

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2011-05-19 19:48 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-13  9:08 [U-Boot] [RFC] Act as a TFTP server Luca Ceresoli
2011-04-13 11:37 ` Wolfgang Denk
2011-04-13 12:47   ` Luca Ceresoli
2011-04-30 19:53     ` Wolfgang Denk
2011-05-03 12:23       ` Luca Ceresoli
2011-05-03 12:36         ` Wolfgang Denk
2011-05-16 20:57           ` Luca Ceresoli
2011-04-14 10:31 ` Luca Ceresoli
2011-04-14 15:52 ` [U-Boot] [PATCH 0/6] " Luca Ceresoli
2011-04-14 16:13   ` Albert ARIBAUD
2011-04-18 16:19   ` [U-Boot] [PATCH v2 " Luca Ceresoli
2011-04-19 14:05     ` Detlev Zundel
2011-05-17 10:03     ` [U-Boot] [PATCH v3 0/5] " Luca Ceresoli
2011-05-17 10:03     ` [U-Boot] [PATCH v3 1/5] TFTP: replace "server" with "remote" in local variable names Luca Ceresoli
2011-05-19  8:11       ` Detlev Zundel
2011-05-19 19:39       ` Wolfgang Denk
2011-05-17 10:03     ` [U-Boot] [PATCH v3 2/5] TFTP: rename STATE_RRQ to STATE_SEND_RRQ Luca Ceresoli
2011-05-19  8:12       ` Detlev Zundel
2011-05-19 19:39       ` Wolfgang Denk
2011-05-17 10:03     ` [U-Boot] [PATCH v3 3/5] TFTP: net/tftp.c: add server mode receive Luca Ceresoli
2011-05-19  8:13       ` Detlev Zundel
2011-05-19 19:48       ` Wolfgang Denk
2011-05-17 10:03     ` [U-Boot] [PATCH v3 4/5] TFTP: add tftpsrv command Luca Ceresoli
2011-05-19  8:12       ` Detlev Zundel
2011-05-19 19:48       ` Wolfgang Denk
2011-05-17 10:03     ` [U-Boot] [PATCH v3 5/5] net/tftp.c: fix typo Luca Ceresoli
2011-05-19  8:13       ` Detlev Zundel
2011-05-19 19:48       ` Wolfgang Denk
2011-04-18 16:19   ` [U-Boot] [PATCH v2 1/6] README: remove spurious line Luca Ceresoli
2011-04-19 14:07     ` Detlev Zundel
2011-04-18 16:19   ` [U-Boot] [PATCH v2 2/6] NET: pass source IP address to packet handlers Luca Ceresoli
2011-04-19 14:15     ` Detlev Zundel
2011-04-19 15:26       ` Luca Ceresoli
2011-05-12 17:38     ` Wolfgang Denk
2011-04-18 16:19   ` [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote" Luca Ceresoli
2011-04-19 14:18     ` Detlev Zundel
2011-04-19 15:29       ` Luca Ceresoli
2011-04-19 16:28         ` Detlev Zundel
2011-04-19 21:56           ` Luca Ceresoli
2011-04-20  8:17             ` Detlev Zundel
2011-05-04  7:58               ` Luca Ceresoli
2011-05-04 10:37                 ` Detlev Zundel
2011-04-20  8:41         ` Detlev Zundel
2011-04-20 10:55           ` Luca Ceresoli
2011-04-20 13:27             ` [U-Boot] checkpatch - theory and practice [was: [PATCH v2 3/6] TFTP: rename "server" to "remote"] Detlev Zundel
2011-05-16 20:35         ` [U-Boot] [PATCH v2 3/6] TFTP: rename "server" to "remote" Luca Ceresoli
2011-05-17  9:38           ` Detlev Zundel
2011-04-30  4:36     ` Mike Frysinger
2011-05-16 20:16       ` Luca Ceresoli
2011-05-12 17:46     ` Wolfgang Denk
2011-05-13  7:36       ` Luca Ceresoli
2011-05-14 16:07         ` Luca Ceresoli
2011-04-18 16:19   ` [U-Boot] [PATCH v2 4/6] TFTP: rename STATE_RRQ to STATE_SEND_RRQ Luca Ceresoli
2011-04-19 14:22     ` Detlev Zundel
2011-04-18 16:19   ` [U-Boot] [PATCH v2 5/6] TFTP: net/tftp.c: add server mode receive Luca Ceresoli
2011-04-19 14:37     ` Detlev Zundel
2011-05-17  8:06       ` Luca Ceresoli
2011-05-17  9:41         ` Detlev Zundel
2011-04-18 16:19   ` [U-Boot] [PATCH v2 6/6] TFTP: add tftpsrv command Luca Ceresoli
2011-04-19 14:39     ` Detlev Zundel
2011-04-30  4:32     ` Mike Frysinger
2011-05-04  7:02     ` Mike Frysinger
2011-04-14 15:52 ` [U-Boot] [PATCH 1/6] README: remove spurious line Luca Ceresoli
2011-04-30 20:19   ` Wolfgang Denk
2011-04-14 15:52 ` [U-Boot] [PATCH 2/6] NET: pass source IP address to packet handlers Luca Ceresoli
2011-04-30 20:22   ` Wolfgang Denk
2011-04-30 20:24   ` Wolfgang Denk
2011-05-03  8:54     ` Luca Ceresoli
2011-04-14 15:52 ` [U-Boot] [PATCH 3/6] TFTP: rename "server" to "remote" Luca Ceresoli
2011-04-14 15:52 ` [U-Boot] [PATCH 4/6] TFTP: rename STATE_RRQ to STATE_SEND_RRQ Luca Ceresoli
2011-04-14 15:52 ` [U-Boot] [PATCH 5/6] TFTP: net/tftp.c: add server mode receive Luca Ceresoli
2011-04-14 15:52 ` [U-Boot] [PATCH 6/6] TFTP: add tftpsrv command Luca Ceresoli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.