From ae9fbe573e4717adb1bfaa2d980a4b9896856617 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Nov 2005 22:25:07 +0000 Subject: [PATCH] David Lang fixed IPv6 support for TFTP! --- CHANGES | 2 ++ RELEASE-NOTES | 3 ++- lib/tftp.c | 23 ++++++++++++++--------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGES b/CHANGES index 5ee6285..9ff2316 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ Daniel (10 November 2005) +- David Lang fixed IPv6 support for TFTP! + - Introducing range stepping to the curl globbing support. Now you can specify step counter by adding :[num] within the brackets when specifying a range: diff --git a/RELEASE-NOTES b/RELEASE-NOTES index ac18e8f..400771d 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -18,6 +18,7 @@ This release includes the following changes: This release includes the following bugfixes: + o TFTP over IPv6 works o no reverse lookups on IP addresses when ipv6-enabled o SSPI compatibility fix: using the proper DLLs o binary LDAP properties are now shown base64 encoded @@ -45,6 +46,6 @@ advice from friends like these: Dave Dribin, Bradford Bruce, Temprimus, Ofer, Dima Barsky, Amol Pattekar, Jaz Fresh, tommink[at]post.pl, Gisle Vanem, Nis Jorgensen, Vilmos Nebehaj, - Dmitry Bartsevich + Dmitry Bartsevich, David Lang Thanks! (and sorry if I forgot to mention someone) diff --git a/lib/tftp.c b/lib/tftp.c index 9d42842..201f7d2 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -156,9 +156,9 @@ typedef struct tftp_state_data { time_t start_time; time_t max_time; unsigned short block; - struct sockaddr local_addr; + struct sockaddr_storage local_addr; socklen_t local_addrlen; - struct sockaddr remote_addr; + struct sockaddr_storage remote_addr; socklen_t remote_addrlen; int rbytes; int sbytes; @@ -345,7 +345,8 @@ static void tftp_rx(tftp_state_data_t *state, tftp_event_t event) state->spacket.event = htons(TFTP_EVENT_ACK); state->spacket.u.ack.block = htons(state->block); sbytes = sendto(state->sockfd, &state->spacket, 4, MSG_NOSIGNAL, - &state->remote_addr, state->remote_addrlen); + (struct sockaddr *)&state->remote_addr, + state->remote_addrlen); if(sbytes < 0) { failf(data, "%s\n", strerror(errno)); } @@ -371,7 +372,8 @@ static void tftp_rx(tftp_state_data_t *state, tftp_event_t event) /* Resend the previous ACK */ sbytes = sendto(state->sockfd, &state->spacket, 4, MSG_NOSIGNAL, - &state->remote_addr, state->remote_addrlen); + (struct sockaddr *)&state->remote_addr, + state->remote_addrlen); /* Check all sbytes were sent */ if(sbytes<0) { failf(data, "%s\n", strerror(errno)); @@ -436,7 +438,8 @@ static void tftp_tx(tftp_state_data_t *state, tftp_event_t event) Curl_fillreadbuffer(state->conn, 512, &state->sbytes); sbytes = sendto(state->sockfd, &state->spacket, 4+state->sbytes, MSG_NOSIGNAL, - &state->remote_addr, state->remote_addrlen); + (struct sockaddr *)&state->remote_addr, + state->remote_addrlen); /* Check all sbytes were sent */ if(sbytes<0) { failf(data, "%s\n", strerror(errno)); @@ -456,7 +459,8 @@ static void tftp_tx(tftp_state_data_t *state, tftp_event_t event) /* Re-send the data packet */ sbytes = sendto(state->sockfd, &state->spacket, 4+state->sbytes, MSG_NOSIGNAL, - &state->remote_addr, state->remote_addrlen); + (struct sockaddr *)&state->remote_addr, + state->remote_addrlen); /* Check all sbytes were sent */ if(sbytes<0) { failf(data, "%s\n", strerror(errno)); @@ -542,7 +546,8 @@ CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done) tftp_set_timeouts(state); /* Bind to any interface, random UDP port */ - rc = bind(state->sockfd, &state->local_addr, sizeof(state->local_addr)); + rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr, + sizeof(state->local_addr)); if(rc) { failf(conn->data, "bind() failed; %s\n", Curl_strerror(conn,Curl_ourerrno())); @@ -592,7 +597,7 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done) tftp_event_t event; CURLcode code; int rc; - struct sockaddr fromaddr; + struct sockaddr_storage fromaddr; socklen_t fromlen; int check_time = 0; @@ -626,7 +631,7 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done) fromlen=sizeof(fromaddr); state->rbytes = recvfrom(state->sockfd, (void *)&state->rpacket, sizeof(state->rpacket), - 0, &fromaddr, &fromlen); + 0, (struct sockaddr *)&fromaddr, &fromlen); if(state->remote_addrlen==0) { memcpy(&state->remote_addr, &fromaddr, fromlen); state->remote_addrlen = fromlen; -- 2.7.4