cURL / Mailing Lists / curl-library / Single Mail

curl-library

Implementing TFTP support

From: John Kelly <kellyjf_at_yahoo.com>
Date: Mon, 29 Aug 2005 10:00:43 -0700 (PDT)

Hi Folks,

I am about ready to start testing a patch that
implements TFTP support in curl. I want to run some
of the implementation design issues past you before
posting the patch.

Changes that seem obvious, and should cause no issues:

1. --enable-tftp, --disable-tftp options added to
configure.ac
2. RFC 1350 specified error messages added to
curl_easy_strerror with associated CURLcodes in curl.h
3. PORT_TFTP defined in lib/url.c
4. PROT_TFTP defined in lib/urldata.h
5. test for TFTP urls in CreateConnection (lib/url.c)
6. add "tftp" to protocols in lib/version.c

The tricky part comes in lib/connect.c in
singleipconnect, where the connect call is made on the
network socket. Here, I put a
ai_socktype==SOCK_STREAM conditional around the
connect call, and just passed through an rc=0 success
assignment otherwise.

I set the ai_socktype to SOCK_DGRAM based on PROT_TFTP
in conn->protocol in Curl_getaddrinfo (lib/hostip6.c)
and based on port in Curl_he2ai (lib/hostip4.c). It
seems like conn->protocol is the more robust test, but
conn is not passed into Curl_he2ai. It might be
cleaner to put some tcp/upd flag in connectdata that
would be set when the URL is parsed--since I can't see
any other UDP protocols on the horizon, I took the
easier route.

Initially, I had hoped to hook the tftp transfer into
the Curl_readwrite, but that seemed pretty intrusive,
and swrite and sread would have to be modified to use
sendto/recvfrom based on socktype. Instead, I used
the telnet approach, and implemented the transfer
entirely within a new Curl_tftp. The implementations
are in lib/tftp.c with prototypes lib/tftp.h;
Makefile.inc is modified to include them.

There was also a "feedback" note about RFC 3617. I
didn't see anywhere that this ";mode=" parsing is done
already, and it seems like the "-B" flag is already in
use for FTP, so I just used that to select "netascii"
mode instead of a default "octet".

It also seems like there are two abitrary parameters
in my Curl_tftp--the select() timeout interval and the
maximum number of retries to attempt. Should I add
CURLOPTs for these to give users control over them?

Thanks for any comments.

-jk

                
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
 
Received on 2005-08-29