cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker Archives

[ curl-Bugs-3154436 ] TFTP GET works with IP addr but not with resolvable hostname

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Mon, 10 Jan 2011 23:22:43 +0000

Bugs item #3154436, was opened at 2011-01-10 18:01
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3154436&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: TFTP
Group: wrong behaviour
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: dperham (dperham)
Assigned to: Daniel Stenberg (bagder)
Summary: TFTP GET works with IP addr but not with resolvable hostname

Initial Comment:
TFTP GET works when using an IP address but not when using a resolvable (confirmed) hostname

Version: curl 7.21.3 (armv5-unknown-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.7e zlib/1.2.1.1
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: Largefile NTLM SSL libz

The problem is this, ALTHOUGH tftp.c sets the "conn->socktype" explicitly to SOCK_DGRAM anticipating a UDP connection, hostip4.c[Curl_ipv4_resolve_r()] explicitly sets the hints.ai_socktype to SOCK_STREAM and passes that to Curl_getaddrinfo_ex() which results in the Curl_addrinfo->ai_protocol = IPPROTO_TCP. When connect.c[singleipconnect()) trys to create a socket it fails because ai_socktype is SOCK_DGRAM, but ai_protoco is IPPROTO_TCP.

I guess it worked when using an IP address because it doesn't go through all of the resolver stuff and so ai_protocol didn't get set to IPPROTO_TCP and remained IPPROTO_IP (which is '0')

This problem may be specific to the arm or the ancient montavista toolchain that I'm using to compile -- however, I've seen references that others have had this problem.

this patch fixed my problem:

*** connect.c 4 Jan 2011 21:38:42 -0000 1.1
--- connect.c 10 Jan 2011 16:23:57 -0000 1.2
***************
*** 1055,1060 ****
--- 1055,1063 ----
    for (curr_addr = ai, aliasindex=0; curr_addr;
         curr_addr = curr_addr->ai_next, aliasindex++) {
  
+ if( conn->socktype == SOCK_DGRAM
+ && curr_addr->ai_protocol == IPPROTO_TCP )
+ curr_addr->ai_protocol = IPPROTO_UDP;
      /* start connecting to the IP curr_addr points to */
      CURLcode res =
        singleipconnect(conn, curr_addr, timeout_per_addr, &sockfd, connected);

----------------------------------------------------------------------

>Comment By: Daniel Stenberg (bagder)
Date: 2011-01-11 00:22

Message:
Thanks, I could repeat this problem and I fixed it slightly differently in
the git repo just now.

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3154436&group_id=976
Received on 2011-01-11

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET