[U-Boot] [RFC] Act as a TFTP server

Luca Ceresoli luca.ceresoli at comelit.it
Thu Apr 14 12:31:55 CEST 2011


Luca Ceresoli wrote:

> - 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.
Right now the TFTP server is working here, but before submitting patches I
have a question about the TftpHandler() callback function.

TftpHandler() is of type:

include/net.h:80: typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);

The 4 parameters are: packet pointer, UDP source port, UDP destination
port and packet length.

Upon reception of a Write Request packet, the TFTP server needs to know the
remote (client) IP address, or it won't be able to send any packet back.

This is different from currently implemented network file transfer modes,
which are always initiated by U-Boot in client mode, and thus the remote
(server) IP address is known a priori.

I plan to add a new parameter to the rxhand_t, and change accordingly all
handlers to have the new (unused) parameter:

- typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);
+ typedef void rxhand_f(uchar *pkt, unsigned dest_port,
                         IPaddr_t src_ip, unsigned src_port,
                         unsigned len);

Is this ok, or do you foresee any issues with the function footprint or
anything else?

Thanks,
Luca




More information about the U-Boot mailing list