TFTP Client Example

Eric Norum eric.norum at usask.ca
Thu Apr 19 14:31:05 UTC 2001


Gerke Kok wrote:
> 
> I think you could have a look at the tftp client in the 'etherboot' project.
> I use it myself in a bootloader program. It only requires you to have
> ether_read and ether_write functions. You can easily port it to RTEMS I
> think.
> wkr,
> Gerke
> 

Yes, but RTEMS already has a TFTP `network file system' driver which
makes access to files on a TFTP server almost the same as access to any
other file.  Usage is very simple:
    1) After initializing the network, register the TFTP driver:
        rtems_bsdnet_initialize_network ();
        rtems_bsdnet_initialize_tftp_filesystem ();

    2) Remote files are opened by prepending /TFTP/server_address/ to
the paths:
         open ("/TFTP/128.233.xx.yy/path/name', 0);
       or
         fopen ("/TFTP/128.233.xx.yy/path/name', "r");

    3) Then just read/fread/getc as for any other file.
        No seek operations, though.
        A file can be open for reading or writing, but not both.
        Opening a file for writing must meet the TFTP restrictions
(already exist on server, world writeable).

    The above calls will open /tftpboot/path/name on my TFTP server,
since the TFTP daemon has been started with:
        /usr/sbin/in.tftpd -s /tftpboot
-- 
Eric Norum                                 eric.norum at usask.ca
Department of Electrical Engineering       Phone: (306) 966-5394
University of Saskatchewan                 FAX:   (306) 966-5407
Saskatoon, Canada.



More information about the users mailing list