1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

David Lang fixed IPv6 support for TFTP!

This commit is contained in:
Daniel Stenberg 2005-11-10 22:25:07 +00:00
parent 29676f473d
commit ae9fbe573e
3 changed files with 18 additions and 10 deletions

View File

@ -9,6 +9,8 @@
Daniel (10 November 2005) Daniel (10 November 2005)
- David Lang fixed IPv6 support for TFTP!
- Introducing range stepping to the curl globbing support. Now you can specify - Introducing range stepping to the curl globbing support. Now you can specify
step counter by adding :[num] within the brackets when specifying a range: step counter by adding :[num] within the brackets when specifying a range:

View File

@ -18,6 +18,7 @@ This release includes the following changes:
This release includes the following bugfixes: This release includes the following bugfixes:
o TFTP over IPv6 works
o no reverse lookups on IP addresses when ipv6-enabled o no reverse lookups on IP addresses when ipv6-enabled
o SSPI compatibility fix: using the proper DLLs o SSPI compatibility fix: using the proper DLLs
o binary LDAP properties are now shown base64 encoded 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 Dave Dribin, Bradford Bruce, Temprimus, Ofer, Dima Barsky, Amol Pattekar, Jaz
Fresh, tommink[at]post.pl, Gisle Vanem, Nis Jorgensen, Vilmos Nebehaj, 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) Thanks! (and sorry if I forgot to mention someone)

View File

@ -156,9 +156,9 @@ typedef struct tftp_state_data {
time_t start_time; time_t start_time;
time_t max_time; time_t max_time;
unsigned short block; unsigned short block;
struct sockaddr local_addr; struct sockaddr_storage local_addr;
socklen_t local_addrlen; socklen_t local_addrlen;
struct sockaddr remote_addr; struct sockaddr_storage remote_addr;
socklen_t remote_addrlen; socklen_t remote_addrlen;
int rbytes; int rbytes;
int sbytes; 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.event = htons(TFTP_EVENT_ACK);
state->spacket.u.ack.block = htons(state->block); state->spacket.u.ack.block = htons(state->block);
sbytes = sendto(state->sockfd, &state->spacket, 4, MSG_NOSIGNAL, 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) { if(sbytes < 0) {
failf(data, "%s\n", strerror(errno)); 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 */ /* Resend the previous ACK */
sbytes = sendto(state->sockfd, &state->spacket, sbytes = sendto(state->sockfd, &state->spacket,
4, MSG_NOSIGNAL, 4, MSG_NOSIGNAL,
&state->remote_addr, state->remote_addrlen); (struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
/* Check all sbytes were sent */ /* Check all sbytes were sent */
if(sbytes<0) { if(sbytes<0) {
failf(data, "%s\n", strerror(errno)); 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); Curl_fillreadbuffer(state->conn, 512, &state->sbytes);
sbytes = sendto(state->sockfd, &state->spacket, sbytes = sendto(state->sockfd, &state->spacket,
4+state->sbytes, MSG_NOSIGNAL, 4+state->sbytes, MSG_NOSIGNAL,
&state->remote_addr, state->remote_addrlen); (struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
/* Check all sbytes were sent */ /* Check all sbytes were sent */
if(sbytes<0) { if(sbytes<0) {
failf(data, "%s\n", strerror(errno)); 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 */ /* Re-send the data packet */
sbytes = sendto(state->sockfd, &state->spacket, sbytes = sendto(state->sockfd, &state->spacket,
4+state->sbytes, MSG_NOSIGNAL, 4+state->sbytes, MSG_NOSIGNAL,
&state->remote_addr, state->remote_addrlen); (struct sockaddr *)&state->remote_addr,
state->remote_addrlen);
/* Check all sbytes were sent */ /* Check all sbytes were sent */
if(sbytes<0) { if(sbytes<0) {
failf(data, "%s\n", strerror(errno)); failf(data, "%s\n", strerror(errno));
@ -542,7 +546,8 @@ CURLcode Curl_tftp_connect(struct connectdata *conn, bool *done)
tftp_set_timeouts(state); tftp_set_timeouts(state);
/* Bind to any interface, random UDP port */ /* 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) { if(rc) {
failf(conn->data, "bind() failed; %s\n", failf(conn->data, "bind() failed; %s\n",
Curl_strerror(conn,Curl_ourerrno())); Curl_strerror(conn,Curl_ourerrno()));
@ -592,7 +597,7 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done)
tftp_event_t event; tftp_event_t event;
CURLcode code; CURLcode code;
int rc; int rc;
struct sockaddr fromaddr; struct sockaddr_storage fromaddr;
socklen_t fromlen; socklen_t fromlen;
int check_time = 0; int check_time = 0;
@ -626,7 +631,7 @@ CURLcode Curl_tftp(struct connectdata *conn, bool *done)
fromlen=sizeof(fromaddr); fromlen=sizeof(fromaddr);
state->rbytes = recvfrom(state->sockfd, state->rbytes = recvfrom(state->sockfd,
(void *)&state->rpacket, sizeof(state->rpacket), (void *)&state->rpacket, sizeof(state->rpacket),
0, &fromaddr, &fromlen); 0, (struct sockaddr *)&fromaddr, &fromlen);
if(state->remote_addrlen==0) { if(state->remote_addrlen==0) {
memcpy(&state->remote_addr, &fromaddr, fromlen); memcpy(&state->remote_addr, &fromaddr, fromlen);
state->remote_addrlen = fromlen; state->remote_addrlen = fromlen;