master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
25#include "urldata.h"
26#include "tftp.h"
28#ifndef CURL_DISABLE_TFTP
30#ifdef HAVE_NETINET_IN_H
31#include <netinet/in.h>
32#endif
33#ifdef HAVE_NETDB_H
34#include <netdb.h>
35#endif
36#ifdef HAVE_ARPA_INET_H
37#include <arpa/inet.h>
38#endif
39#ifdef HAVE_NET_IF_H
40#include <net/if.h>
41#endif
42#ifdef HAVE_SYS_IOCTL_H
43#include <sys/ioctl.h>
44#endif
46#ifdef HAVE_SYS_PARAM_H
47#include <sys/param.h>
48#endif
50#include "cfilters.h"
51#include "cf-socket.h"
52#include "transfer.h"
53#include "sendf.h"
54#include "curl_trc.h"
55#include "progress.h"
56#include "connect.h"
57#include "sockaddr.h" /* required for Curl_sockaddr_storage */
58#include "url.h"
59#include "strcase.h"
60#include "select.h"
61#include "escape.h"
62#include "curlx/strerr.h"
63#include "curlx/strparse.h"
64#include "curlx/strcopy.h"
66/* RFC2348 allows the block size to be negotiated */
67#define TFTP_BLKSIZE_DEFAULT 512
68#define TFTP_OPTION_BLKSIZE "blksize"
70/* from RFC2349: */
71#define TFTP_OPTION_TSIZE "tsize"
72#define TFTP_OPTION_INTERVAL "timeout"
74typedef enum {
75 TFTP_MODE_NETASCII = 0,
76 TFTP_MODE_OCTET
77} tftp_mode_t;
79typedef enum {
80 TFTP_STATE_START = 0,
81 TFTP_STATE_RX,
82 TFTP_STATE_TX,
83 TFTP_STATE_FIN
84} tftp_state_t;
86typedef enum {
87 TFTP_EVENT_NONE = -1,
88 TFTP_EVENT_INIT = 0,
89 TFTP_EVENT_RRQ = 1,
90 TFTP_EVENT_WRQ = 2,
91 TFTP_EVENT_DATA = 3,
92 TFTP_EVENT_ACK = 4,
93 TFTP_EVENT_ERROR = 5,
94 TFTP_EVENT_OACK = 6,
95 TFTP_EVENT_TIMEOUT
96} tftp_event_t;
98typedef enum {
99 TFTP_ERR_UNDEF = 0,
100 TFTP_ERR_NOTFOUND,
101 TFTP_ERR_PERM,
102 TFTP_ERR_DISKFULL,
103 TFTP_ERR_ILLEGAL,
104 TFTP_ERR_UNKNOWNID,
105 TFTP_ERR_EXISTS,
106 TFTP_ERR_NOSUCHUSER, /* This will never be triggered by this code */
108 /* The remaining error codes are internal to curl */
109 TFTP_ERR_NONE = -100,
110 TFTP_ERR_TIMEOUT,
111 TFTP_ERR_NORESPONSE
112} tftp_error_t;
114struct tftp_packet {
115 unsigned char *data;
116};
118/* meta key for storing protocol meta at connection */
119#define CURL_META_TFTP_CONN "meta:proto:tftp:conn"
121struct tftp_conn {
122 struct Curl_sockaddr_storage local_addr;
123 struct Curl_sockaddr_storage remote_addr;
124 struct tftp_packet rpacket;
125 struct tftp_packet spacket;
126 tftp_state_t state;
127 tftp_mode_t mode;
128 tftp_error_t error;
129 tftp_event_t event;
130 struct Curl_easy *data;
131 curl_socket_t sockfd;
132 int retries;
133 int retry_time;
134 int retry_max;
135 time_t rx_time;
136 curl_socklen_t remote_addrlen;
137 int rbytes;
138 size_t sbytes;
139 unsigned int blksize;
140 unsigned int requested_blksize;
141 unsigned short block;
142 BIT(remote_pinned);
143};
145/**********************************************************
146 *
147 * tftp_set_timeouts -
148 *
149 * Set timeouts based on state machine state.
150 * Use user provided connect timeouts until DATA or ACK
151 * packet is received, then use user-provided transfer timeouts
152 *
153 *
154 **********************************************************/
155static CURLcode tftp_set_timeouts(struct tftp_conn *state)
156{
157 time_t timeout;
158 timediff_t timeout_ms;
160 /* Compute drop-dead time */
161 timeout_ms = Curl_timeleft_ms(state->data);
163 if(timeout_ms < 0) {
164 /* time-out, bail out, go home */
165 failf(state->data, "Connection time-out");
166 return CURLE_OPERATION_TIMEDOUT;
167 }
169 /* Set per-block timeout to total */
170 if((timeout_ms > 0) && (timeout_ms < 3600000))
171 /* do the calculation only if the timeout is "reasonable" */
172 timeout = (time_t)(timeout_ms + 500) / 1000;
173 else
174 timeout = 15;
176 /* Average reposting an ACK after 5 seconds */
177 state->retry_max = (int)timeout / 5;
179 /* Bound the total number */
180 if(state->retry_max < 3)
181 state->retry_max = 3;
183 if(state->retry_max > 50)
184 state->retry_max = 50;
186 /* Compute the re-ACK interval to suit the timeout */
187 state->retry_time = (int)(timeout / state->retry_max);
188 if(state->retry_time < 1)
189 state->retry_time = 1;
191 infof(state->data,
192 "set timeouts for state %d; Total %" FMT_OFF_T ", retry %d maxtry %d",
193 (int)state->state, timeout_ms, state->retry_time, state->retry_max);
195 /* init RX time */
196 state->rx_time = time(NULL);
198 return CURLE_OK;
199}
201/**********************************************************
202 *
203 * tftp_set_send_first
204 *
205 * Event handler for the START state
206 *
207 **********************************************************/
209static void setpacketevent(struct tftp_packet *packet, unsigned short num)
210{
211 packet->data[0] = (unsigned char)(num >> 8);
212 packet->data[1] = (unsigned char)(num & 0xff);
213}
215static void setpacketblock(struct tftp_packet *packet, unsigned short num)
216{
217 packet->data[2] = (unsigned char)(num >> 8);
218 packet->data[3] = (unsigned char)(num & 0xff);
219}
221static unsigned short getrpacketevent(const struct tftp_packet *packet)
222{
223 return (unsigned short)((packet->data[0] << 8) | packet->data[1]);
224}
226static unsigned short getrpacketblock(const struct tftp_packet *packet)
227{
228 return (unsigned short)((packet->data[2] << 8) | packet->data[3]);
229}
231static size_t tftp_strnlen(const char *string, size_t maxlen)
232{
233 const char *end = memchr(string, '\0', maxlen);
234 return end ? (size_t)(end - string) : maxlen;
235}
237static const char *tftp_option_get(const char *buf, size_t len,
238 const char **option, const char **value)
239{
240 size_t loc;
242 loc = tftp_strnlen(buf, len);
243 loc++; /* NULL term */
245 if(loc >= len)
246 return NULL;
247 *option = buf;
249 loc += tftp_strnlen(buf + loc, len - loc);
250 loc++; /* NULL term */
252 if(loc > len)
253 return NULL;
254 *value = &buf[strlen(*option) + 1];
256 return &buf[loc];
257}
259static CURLcode tftp_parse_option_ack(struct tftp_conn *state,
260 const char *ptr, int len)
261{
262 const char *tmp = ptr;
263 struct Curl_easy *data = state->data;
265 /* if OACK does not contain blksize option, the default (512) must be used */
266 state->blksize = TFTP_BLKSIZE_DEFAULT;
268 while(tmp < ptr + len) {
269 const char *option, *value;
270 size_t olen;
272 tmp = tftp_option_get(tmp, ptr + len - tmp, &option, &value);
273 if(!tmp) {
274 failf(data, "Malformed ACK packet, rejecting");
275 return CURLE_TFTP_ILLEGAL;
276 }
277 olen = strlen(option);
279 infof(data, "got option=(%s) value=(%s)", option, value);
281 if((CURL_CSTRLEN(TFTP_OPTION_BLKSIZE) == olen) &&
282 checkprefix(TFTP_OPTION_BLKSIZE, option)) {
283 curl_off_t blksize;
284 if(curlx_str_number(&value, &blksize, TFTP_BLKSIZE_MAX)) {
285 failf(data, "%s (%d)", "blksize is larger than max supported",
286 TFTP_BLKSIZE_MAX);
287 return CURLE_TFTP_ILLEGAL;
288 }
289 if(!blksize) {
290 failf(data, "invalid blocksize value in OACK packet");
291 return CURLE_TFTP_ILLEGAL;
292 }
293 else if(blksize < TFTP_BLKSIZE_MIN) {
294 failf(data, "%s (%d)", "blksize is smaller than min supported",
295 TFTP_BLKSIZE_MIN);
296 return CURLE_TFTP_ILLEGAL;
297 }
298 else if(blksize > state->requested_blksize) {
299 /* could realloc pkt buffers here, but the spec does not call out
300 * support for the server requesting a bigger blksize than the client
301 * requests */
302 failf(data, "server requested blksize larger than allocated (%"
303 CURL_FORMAT_CURL_OFF_T ")", blksize);
304 return CURLE_TFTP_ILLEGAL;
305 }
307 state->blksize = (unsigned int)blksize;
308 infof(data, "blksize parsed from OACK (%u) requested (%u)",
309 state->blksize, state->requested_blksize);
310 }
311 else if((CURL_CSTRLEN(TFTP_OPTION_TSIZE) == olen) &&
312 checkprefix(TFTP_OPTION_TSIZE, option)) {
313 curl_off_t tsize = 0;
314 /* tsize should be ignored on upload: Who cares about the size of the
315 remote file? */
316 if(!data->state.upload &&
317 !curlx_str_number(&value, &tsize, CURL_OFF_T_MAX)) {
318 if(!tsize) {
319 failf(data, "invalid tsize -:%s:- value in OACK packet", value);
320 return CURLE_TFTP_ILLEGAL;
321 }
322 infof(data, "tsize parsed from OACK (%" CURL_FORMAT_CURL_OFF_T ")",
323 tsize);
324 Curl_pgrsSetDownloadSize(data, tsize);
325 }
326 }
327 }
329 return CURLE_OK;
330}
332static CURLcode tftp_option_add(struct tftp_conn *state, size_t *csize,
333 size_t index, const char *option)
334{
335 char *buf = (char *)&state->spacket.data[index];
336 size_t oplen = strlen(option);
337 size_t blen;
338 if((state->blksize <= index) ||
339 (oplen + 1) > (size_t)(state->blksize - index))
340 return CURLE_TFTP_ILLEGAL;
341 blen = state->blksize - index;
342 curlx_strcopy(buf, blen, option, oplen);
343 *csize += oplen + 1;
344 return CURLE_OK;
345}
347/* the next blocknum is x + 1 but it needs to wrap at an unsigned 16-bit
348 boundary */
349#define NEXT_BLOCKNUM(x) (((x) + 1) & 0xffff)
351/**********************************************************
352 *
353 * tftp_tx
354 *
355 * Event handler for the TX state
356 *
357 **********************************************************/
358static CURLcode tftp_tx(struct tftp_conn *state, tftp_event_t event)
359{
360 struct Curl_easy *data = state->data;
361 ssize_t sbytes;
362 CURLcode result = CURLE_OK;
363 struct SingleRequest *k = &data->req;
364 size_t cb; /* Bytes currently read */
365 char buffer[STRERROR_LEN];
366 char *bufptr;
367 bool eos;
369 if(!data->state.upload)
370 return CURLE_TFTP_ILLEGAL;
372 switch(event) {
374 case TFTP_EVENT_ACK:
375 case TFTP_EVENT_OACK:
376 if(event == TFTP_EVENT_ACK) {
377 /* Ack the packet */
378 int rblock = getrpacketblock(&state->rpacket);
380 if(rblock != state->block &&
381 /* There is a bug in tftpd-hpa that causes it to send us an ACK for
382 * 65535 when the block number wraps to 0. To handle it, when we are
383 * expecting 0, also accept 65535. See
384 * https://www.syslinux.org/archives/2010-September/015612.html
385 * */
386 !(state->block == 0 && rblock == 65535)) {
387 /* This is not the expected block. Log it and up the retry counter */
388 infof(data, "Received ACK for block %d, expecting %d",
389 rblock, state->block);
390 state->retries++;
391 /* Bail out if over the maximum */
392 if(state->retries > state->retry_max) {
393 failf(data, "tftp_tx: giving up waiting for block %d ack",
394 state->block);
395 result = CURLE_SEND_ERROR;
396 }
397 else {
398 /* Re-send the data packet */
399 sbytes = sendto(state->sockfd, (void *)state->spacket.data,
400 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
401 (struct sockaddr *)&state->remote_addr,
402 state->remote_addrlen);
403 /* Check all sbytes were sent */
404 if(sbytes < 0) {
405 failf(data, "%s",
406 curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
407 result = CURLE_SEND_ERROR;
408 }
409 }
411 return result;
412 }
413 /* This is the expected packet. Reset the counters and send the next
414 block */
415 state->rx_time = time(NULL);
416 state->block++;
417 }
418 else
419 state->block = 1; /* first data block is 1 when using OACK */
421 state->retries = 0;
422 setpacketevent(&state->spacket, TFTP_EVENT_DATA);
423 setpacketblock(&state->spacket, state->block);
424 if(state->block > 1 && state->sbytes < state->blksize) {
425 state->state = TFTP_STATE_FIN;
426 return CURLE_OK;
427 }
429 /* TFTP considers data block size < 512 bytes as an end of session, so
430 * in some cases we must wait for additional data to build full (512 bytes)
431 * data block.
432 * */
433 state->sbytes = 0;
434 bufptr = (char *)state->spacket.data + 4;
435 do {
436 result = Curl_client_read(data, bufptr, state->blksize - state->sbytes,
437 &cb, &eos);
438 if(result)
439 return result;
440 state->sbytes += cb;
441 bufptr += cb;
442 } while(state->sbytes < state->blksize && cb);
444 sbytes = sendto(state->sockfd, (void *)state->spacket.data,
445 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
446 (struct sockaddr *)&state->remote_addr,
447 state->remote_addrlen);
448 /* Check all sbytes were sent */
449 if(sbytes < 0) {
450 failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
451 return CURLE_SEND_ERROR;
452 }
453 /* Update the progress meter */
454 k->writebytecount += state->sbytes;
455 Curl_pgrs_upload_inc(data, state->sbytes);
456 break;
458 case TFTP_EVENT_TIMEOUT:
459 /* Increment the retry counter and log the timeout */
460 state->retries++;
461 infof(data, "Timeout waiting for block %d ACK. "
462 "Retries = %d", NEXT_BLOCKNUM(state->block), state->retries);
463 /* Decide if we have had enough */
464 if(state->retries > state->retry_max) {
465 state->error = TFTP_ERR_TIMEOUT;
466 state->state = TFTP_STATE_FIN;
467 }
468 else {
469 /* Re-send the data packet */
470 sbytes = sendto(state->sockfd, (void *)state->spacket.data,
471 4 + (SEND_TYPE_ARG3)state->sbytes, SEND_4TH_ARG,
472 (struct sockaddr *)&state->remote_addr,
473 state->remote_addrlen);
474 /* Check all sbytes were sent */
475 if(sbytes < 0) {
476 failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
477 return CURLE_SEND_ERROR;
478 }
479 /* since this was a re-send, we remain at the still byte position */
480 Curl_pgrsSetUploadCounter(data, k->writebytecount);
481 }
482 break;
484 case TFTP_EVENT_ERROR:
485 state->state = TFTP_STATE_FIN;
486 setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
487 setpacketblock(&state->spacket, state->block);
488 (void)sendto(state->sockfd, (void *)state->spacket.data, 4, SEND_4TH_ARG,
489 (struct sockaddr *)&state->remote_addr,
490 state->remote_addrlen);
491 /* do not bother with the return code, but if the socket is still up we
492 * should be a good TFTP client and let the server know we are done */
493 state->state = TFTP_STATE_FIN;
494 break;
496 default:
497 failf(data, "tftp_tx: internal error, event: %d", (int)event);
498 break;
499 }
501 return result;
502}
504static CURLcode tftp_connect_for_tx(struct tftp_conn *state,
505 tftp_event_t event)
506{
507 CURLcode result;
509 infof(state->data, "%s", "Connected for transmit");
511 state->state = TFTP_STATE_TX;
512 result = tftp_set_timeouts(state);
513 if(result)
514 return result;
515 return tftp_tx(state, event);
516}
518/**********************************************************
519 *
520 * tftp_rx
521 *
522 * Event handler for the RX state
523 *
524 **********************************************************/
525static CURLcode tftp_rx(struct tftp_conn *state, tftp_event_t event)
526{
527 ssize_t sbytes;
528 int rblock;
529 struct Curl_easy *data = state->data;
530 char buffer[STRERROR_LEN];
532 switch(event) {
534 case TFTP_EVENT_DATA:
535 /* Is this the block we expect? */
536 rblock = getrpacketblock(&state->rpacket);
537 if(NEXT_BLOCKNUM(state->block) == rblock) {
538 /* This is the expected block. Reset counters and ACK it. */
539 state->retries = 0;
540 }
541 else if(state->block == rblock) {
542 /* This is the last recently received block again. Log it and ACK it
543 again. */
544 infof(data, "Received last DATA packet block %d again.", rblock);
545 }
546 else {
547 /* totally unexpected, log it */
548 infof(data,
549 "Received unexpected DATA packet block %d, expecting block %d",
550 rblock, NEXT_BLOCKNUM(state->block));
551 break;
552 }
554 /* ACK this block. */
555 state->block = (unsigned short)rblock;
556 setpacketevent(&state->spacket, TFTP_EVENT_ACK);
557 setpacketblock(&state->spacket, state->block);
558 sbytes = sendto(state->sockfd, (void *)state->spacket.data,
559 4, SEND_4TH_ARG,
560 (struct sockaddr *)&state->remote_addr,
561 state->remote_addrlen);
562 if(sbytes < 0) {
563 failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
564 return CURLE_SEND_ERROR;
565 }
567 /* Check if completed (That is, a less than full packet is received) */
568 if(state->rbytes < (ssize_t)state->blksize + 4) {
569 state->state = TFTP_STATE_FIN;
570 }
571 else {
572 state->state = TFTP_STATE_RX;
573 }
574 state->rx_time = time(NULL);
575 break;
577 case TFTP_EVENT_OACK:
578 /* ACK option acknowledgement so we can move on to data */
579 state->block = 0;
580 state->retries = 0;
581 setpacketevent(&state->spacket, TFTP_EVENT_ACK);
582 setpacketblock(&state->spacket, state->block);
583 sbytes = sendto(state->sockfd, (void *)state->spacket.data,
584 4, SEND_4TH_ARG,
585 (struct sockaddr *)&state->remote_addr,
586 state->remote_addrlen);
587 if(sbytes < 0) {
588 failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
589 return CURLE_SEND_ERROR;
590 }
592 /* we are ready to RX data */
593 state->state = TFTP_STATE_RX;
594 state->rx_time = time(NULL);
595 break;
597 case TFTP_EVENT_TIMEOUT:
598 /* Increment the retry count and fail if over the limit */
599 state->retries++;
600 infof(data,
601 "Timeout waiting for block %d ACK. Retries = %d",
602 NEXT_BLOCKNUM(state->block), state->retries);
603 if(state->retries > state->retry_max) {
604 state->error = TFTP_ERR_TIMEOUT;
605 state->state = TFTP_STATE_FIN;
606 }
607 else {
608 /* Resend the previous ACK */
609 sbytes = sendto(state->sockfd, (void *)state->spacket.data,
610 4, SEND_4TH_ARG,
611 (struct sockaddr *)&state->remote_addr,
612 state->remote_addrlen);
613 if(sbytes < 0) {
614 failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
615 return CURLE_SEND_ERROR;
616 }
617 }
618 break;
620 case TFTP_EVENT_ERROR:
621 setpacketevent(&state->spacket, TFTP_EVENT_ERROR);
622 setpacketblock(&state->spacket, state->block);
623 (void)sendto(state->sockfd, (void *)state->spacket.data,
624 4, SEND_4TH_ARG,
625 (struct sockaddr *)&state->remote_addr,
626 state->remote_addrlen);
627 /* do not bother with the return code, but if the socket is still up we
628 * should be a good TFTP client and let the server know we are done */
629 state->state = TFTP_STATE_FIN;
630 break;
632 default:
633 failf(data, "%s", "tftp_rx: internal error");
634 return CURLE_TFTP_ILLEGAL; /* not really the perfect return code for
635 this */
636 }
637 return CURLE_OK;
638}
640static CURLcode tftp_connect_for_rx(struct tftp_conn *state,
641 tftp_event_t event)
642{
643 CURLcode result;
645 infof(state->data, "%s", "Connected for receive");
647 state->state = TFTP_STATE_RX;
648 result = tftp_set_timeouts(state);
649 if(result)
650 return result;
651 return tftp_rx(state, event);
652}
654static CURLcode tftp_send_first(struct tftp_conn *state,
655 tftp_event_t event)
656{
657 size_t sbytes;
658 ssize_t senddata;
659 const char *mode = "octet";
660 char *filename;
661 struct Curl_easy *data = state->data;
662 const struct Curl_sockaddr_ex *remote_addr = NULL;
663 CURLcode result = CURLE_OK;
665 /* Set ASCII mode if -B flag was used */
666 if(data->state.prefer_ascii)
667 mode = "netascii";
669 switch(event) {
671 case TFTP_EVENT_INIT: /* Send the first packet out */
672 case TFTP_EVENT_TIMEOUT: /* Resend the first packet out */
673 /* Increment the retry counter, quit if over the limit */
674 state->retries++;
675 if(state->retries > state->retry_max) {
676 state->error = TFTP_ERR_NORESPONSE;
677 state->state = TFTP_STATE_FIN;
678 return result;
679 }
681 if(data->state.upload) {
682 /* If we are uploading, send a WRQ */
683 setpacketevent(&state->spacket, TFTP_EVENT_WRQ);
684 if(data->state.infilesize != -1)
685 Curl_pgrsSetUploadSize(data, data->state.infilesize);
686 }
687 else {
688 /* If we are downloading, send an RRQ */
689 setpacketevent(&state->spacket, TFTP_EVENT_RRQ);
690 }
691 /* As RFC3617 describes the separator slash is not actually part of the
692 filename so we skip the always-present first letter of the path
693 string. */
694 if(!state->data->state.up.path[1]) {
695 failf(data, "Missing filename");
696 return CURLE_TFTP_ILLEGAL;
697 }
698 result = Curl_urldecode(&state->data->state.up.path[1], 0,
699 &filename, NULL, REJECT_ZERO);
700 if(result)
701 return result;
703 if(strlen(filename) + strlen(mode) + 4 > state->blksize) {
704 failf(data, "TFTP filename too long");
705 curlx_free(filename);
706 return CURLE_TFTP_ILLEGAL; /* too long filename field */
707 }
709 sbytes = 2 +
710 curl_msnprintf((char *)state->spacket.data + 2,
711 state->blksize,
712 "%s%c%s%c", filename, '\0', mode, '\0');
713 curlx_free(filename);
715 /* optional addition of TFTP options */
716 if(!data->set.tftp_no_options) {
717 char buf[64];
718 /* add tsize option */
719 curl_msnprintf(buf, sizeof(buf), "%" FMT_OFF_T,
720 data->state.upload && (data->state.infilesize != -1) ?
721 data->state.infilesize : 0);
723 result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_TSIZE);
724 if(result == CURLE_OK)
725 result = tftp_option_add(state, &sbytes, sbytes, buf);
727 /* add blksize option */
728 curl_msnprintf(buf, sizeof(buf), "%u", state->requested_blksize);
729 if(result == CURLE_OK)
730 result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_BLKSIZE);
731 if(result == CURLE_OK)
732 result = tftp_option_add(state, &sbytes, sbytes, buf);
734 /* add timeout option */
735 curl_msnprintf(buf, sizeof(buf), "%d", state->retry_time);
736 if(result == CURLE_OK)
737 result = tftp_option_add(state, &sbytes, sbytes, TFTP_OPTION_INTERVAL);
738 if(result == CURLE_OK)
739 result = tftp_option_add(state, &sbytes, sbytes, buf);
741 if(result != CURLE_OK) {
742 failf(data, "TFTP buffer too small for options");
743 return CURLE_TFTP_ILLEGAL;
744 }
745 }
747 /* the typecast for the 3rd argument is mostly for systems that do
748 not have a size_t argument, like older unixes that want an 'int' */
749#ifdef __AMIGA__
750#define CURL_SENDTO_ARG5(x) CURL_UNCONST(x)
751#else
752#define CURL_SENDTO_ARG5(x) (x)
753#endif
754 remote_addr = Curl_conn_get_remote_addr(data, FIRSTSOCKET);
755 if(!remote_addr)
756 return CURLE_FAILED_INIT;
758 senddata = sendto(state->sockfd, (void *)state->spacket.data,
759 (SEND_TYPE_ARG3)sbytes, 0,
760 CURL_SENDTO_ARG5(&remote_addr->curl_sa_addr),
761 (curl_socklen_t)remote_addr->addrlen);
762 if(senddata != (ssize_t)sbytes) {
763 char buffer[STRERROR_LEN];
764 failf(data, "%s", curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
765 return CURLE_SEND_ERROR;
766 }
767 break;
769 case TFTP_EVENT_OACK:
770 if(data->state.upload) {
771 result = tftp_connect_for_tx(state, event);
772 }
773 else {
774 result = tftp_connect_for_rx(state, event);
775 }
776 break;
778 case TFTP_EVENT_ACK: /* Connected for transmit */
779 if(!data->state.upload)
780 return CURLE_TFTP_ILLEGAL;
781 result = tftp_connect_for_tx(state, event);
782 break;
784 case TFTP_EVENT_DATA: /* Connected for receive */
785 if(data->state.upload)
786 return CURLE_TFTP_ILLEGAL;
787 result = tftp_connect_for_rx(state, event);
788 break;
790 case TFTP_EVENT_ERROR:
791 state->state = TFTP_STATE_FIN;
792 break;
794 default:
795 failf(state->data, "tftp_send_first: internal error");
796 return CURLE_TFTP_ILLEGAL;
797 }
799 return result;
800}
802/**********************************************************
803 *
804 * tftp_translate_code
805 *
806 * Translate internal error codes to CURL error codes
807 *
808 **********************************************************/
809static CURLcode tftp_translate_code(tftp_error_t error)
810{
811 CURLcode result = CURLE_OK;
813 if(error != TFTP_ERR_NONE) {
814 switch(error) {
815 case TFTP_ERR_NOTFOUND:
816 result = CURLE_TFTP_NOTFOUND;
817 break;
818 case TFTP_ERR_PERM:
819 result = CURLE_TFTP_PERM;
820 break;
821 case TFTP_ERR_DISKFULL:
822 result = CURLE_REMOTE_DISK_FULL;
823 break;
824 case TFTP_ERR_UNDEF:
825 case TFTP_ERR_ILLEGAL:
826 result = CURLE_TFTP_ILLEGAL;
827 break;
828 case TFTP_ERR_UNKNOWNID:
829 result = CURLE_TFTP_UNKNOWNID;
830 break;
831 case TFTP_ERR_EXISTS:
832 result = CURLE_REMOTE_FILE_EXISTS;
833 break;
834 case TFTP_ERR_NOSUCHUSER:
835 result = CURLE_TFTP_NOSUCHUSER;
836 break;
837 case TFTP_ERR_TIMEOUT:
838 result = CURLE_OPERATION_TIMEDOUT;
839 break;
840 case TFTP_ERR_NORESPONSE:
841 result = CURLE_COULDNT_CONNECT;
842 break;
843 default:
844 result = CURLE_ABORTED_BY_CALLBACK;
845 break;
846 }
847 }
848 else
849 result = CURLE_OK;
851 return result;
852}
854/**********************************************************
855 *
856 * tftp_state_machine
857 *
858 * The tftp state machine event dispatcher
859 *
860 **********************************************************/
861static CURLcode tftp_state_machine(struct tftp_conn *state,
862 tftp_event_t event)
863{
864 CURLcode result = CURLE_OK;
865 struct Curl_easy *data = state->data;
867 switch(state->state) {
868 case TFTP_STATE_START:
869 DEBUGF(infof(data, "TFTP_STATE_START"));
870 result = tftp_send_first(state, event);
871 break;
872 case TFTP_STATE_RX:
873 DEBUGF(infof(data, "TFTP_STATE_RX"));
874 result = tftp_rx(state, event);
875 break;
876 case TFTP_STATE_TX:
877 DEBUGF(infof(data, "TFTP_STATE_TX"));
878 result = tftp_tx(state, event);
879 break;
880 case TFTP_STATE_FIN:
881 infof(data, "%s", "TFTP finished");
882 break;
883 default:
884 DEBUGF(infof(data, "STATE: %d", (int)state->state));
885 failf(data, "%s", "Internal state machine error");
886 result = CURLE_TFTP_ILLEGAL;
887 break;
888 }
890 return result;
891}
893static void tftp_conn_dtor(const void *key, size_t klen, void *entry)
894{
895 struct tftp_conn *state = entry;
896 (void)key;
897 (void)klen;
898 curlx_safefree(state->rpacket.data);
899 curlx_safefree(state->spacket.data);
900 curlx_free(state);
901}
903/**********************************************************
904 *
905 * tftp_connect
906 *
907 * The connect callback
908 *
909 **********************************************************/
910static CURLcode tftp_connect(struct Curl_easy *data, bool *done)
911{
912 struct tftp_conn *state;
913 int blksize;
914 int need_blksize;
915 struct connectdata *conn = data->conn;
916 const struct Curl_sockaddr_ex *remote_addr = NULL;
917 CURLcode result;
919 blksize = TFTP_BLKSIZE_DEFAULT;
921 state = curlx_calloc(1, sizeof(*state));
922 if(!state ||
923 Curl_conn_meta_set(conn, CURL_META_TFTP_CONN, state, tftp_conn_dtor))
924 return CURLE_OUT_OF_MEMORY;
926 /* alloc pkt buffers based on specified blksize */
927 if(data->set.tftp_blksize)
928 /* range checked when set */
929 blksize = (int)data->set.tftp_blksize;
931 need_blksize = blksize;
932 /* default size is the fallback when no OACK is received */
933 if(need_blksize < TFTP_BLKSIZE_DEFAULT)
934 need_blksize = TFTP_BLKSIZE_DEFAULT;
936 if(!state->rpacket.data) {
937 state->rpacket.data = curlx_calloc(1, need_blksize + 2 + 2);
939 if(!state->rpacket.data)
940 return CURLE_OUT_OF_MEMORY;
941 }
943 if(!state->spacket.data) {
944 state->spacket.data = curlx_calloc(1, need_blksize + 2 + 2);
946 if(!state->spacket.data)
947 return CURLE_OUT_OF_MEMORY;
948 }
950 /* we do not keep TFTP connections up because there is none or little gain
951 * for UDP */
952 connclose(conn);
954 state->data = data;
955 state->sockfd = conn->sock[FIRSTSOCKET];
956 state->state = TFTP_STATE_START;
957 state->error = TFTP_ERR_NONE;
958 state->blksize = TFTP_BLKSIZE_DEFAULT; /* Unless updated by OACK response */
959 state->requested_blksize = blksize;
961 remote_addr = Curl_conn_get_remote_addr(data, FIRSTSOCKET);
962 DEBUGASSERT(remote_addr);
963 if(!remote_addr)
964 return CURLE_FAILED_INIT;
966 ((struct sockaddr *)&state->local_addr)->sa_family =
967 (CURL_SA_FAMILY_T)remote_addr->family;
969 result = tftp_set_timeouts(state);
970 if(result)
971 return result;
973 if(!conn->bits.bound) {
974 /* If not already bound, bind to any interface, random UDP port. If it is
975 * reused or a custom local port was desired, this has already been done!
976 *
977 * We once used the size of the local_addr struct as the third argument
978 * for bind() to better work with IPv6 or whatever size the struct could
979 * have, but we learned that at least Tru64, AIX and IRIX *requires* the
980 * size of that argument to match the exact size of a 'sockaddr_in' struct
981 * when running IPv4-only.
982 *
983 * Therefore we use the size from the address we connected to, which we
984 * assume uses the same IP version and thus hopefully this works for both
985 * IPv4 and IPv6...
986 */
987 int rc = bind(state->sockfd, (struct sockaddr *)&state->local_addr,
988 (curl_socklen_t)remote_addr->addrlen);
989 if(rc) {
990 char buffer[STRERROR_LEN];
991 failf(data, "bind() failed; %s",
992 curlx_strerror(SOCKERRNO, buffer, sizeof(buffer)));
993 return CURLE_COULDNT_CONNECT;
994 }
995 conn->bits.bound = TRUE;
996 }
998 *done = TRUE;
1000 return CURLE_OK;
1001}
1003/**********************************************************
1004 *
1005 * tftp_done
1006 *
1007 * The done callback
1008 *
1009 **********************************************************/
1010static CURLcode tftp_done(struct Curl_easy *data, CURLcode status,
1011 bool premature)
1012{
1013 CURLcode result = CURLE_OK;
1014 struct connectdata *conn = data->conn;
1015 struct tftp_conn *state = Curl_conn_meta_get(conn, CURL_META_TFTP_CONN);
1017 (void)status;
1018 (void)premature;
1020 if(Curl_pgrsDone(data, Curl_pgrs_now(data)))
1021 return CURLE_ABORTED_BY_CALLBACK;
1023 /* If we have encountered an error */
1024 if(state)
1025 result = tftp_translate_code(state->error);
1027 return result;
1028}
1030static CURLcode tftp_pollset(struct Curl_easy *data,
1031 struct easy_pollset *ps)
1032{
1033 return Curl_pollset_add_in(data, ps, data->conn->sock[FIRSTSOCKET]);
1034}
1036/**********************************************************
1037 *
1038 * tftp_receive_packet
1039 *
1040 * Called once select fires and data is ready on the socket
1041 *
1042 **********************************************************/
1043static CURLcode tftp_receive_packet(struct Curl_easy *data,
1044 struct tftp_conn *state)
1045{
1046 CURLcode result = CURLE_OK;
1047 struct Curl_sockaddr_storage remote_addr;
1048 curl_socklen_t fromlen = sizeof(remote_addr);
1050 /* Receive the packet */
1051 state->rbytes = (int)recvfrom(state->sockfd,
1052 (void *)state->rpacket.data,
1053 (RECV_TYPE_ARG3)state->blksize + 4,
1054 0,
1055 (struct sockaddr *)&remote_addr,
1056 &fromlen);
1057 if((state->rbytes >= 0) && fromlen) {
1058 if(state->remote_pinned) {
1059 /* pinned, verify that it comes from the same address */
1060 if((state->remote_addrlen != fromlen) ||
1061 memcmp(&remote_addr, &state->remote_addr, fromlen)) {
1062 failf(data, "Data received from another address");
1063 return CURLE_RECV_ERROR;
1064 }
1065 }
1066 else {
1067 /* pin address on first use */
1068 state->remote_pinned = TRUE;
1069 state->remote_addrlen = fromlen;
1070 memcpy(&state->remote_addr, &remote_addr, fromlen);
1071 }
1072 }
1074 /* Sanity check packet length */
1075 if(state->rbytes < 4) {
1076 failf(data, "Received too short packet");
1077 /* Not a timeout, but how best to handle it? */
1078 state->event = TFTP_EVENT_TIMEOUT;
1079 }
1080 else {
1081 /* The event is given by the TFTP packet time */
1082 unsigned short event = getrpacketevent(&state->rpacket);
1083 state->event = (tftp_event_t)event;
1085 switch(state->event) {
1086 case TFTP_EVENT_DATA:
1087 if(data->state.upload)
1088 return CURLE_TFTP_ILLEGAL;
1089 /* Do not pass to the client empty or retransmitted packets */
1090 if(state->rbytes > 4 &&
1091 (NEXT_BLOCKNUM(state->block) == getrpacketblock(&state->rpacket))) {
1092 result = Curl_client_write(data, CLIENTWRITE_BODY,
1093 (const char *)state->rpacket.data + 4,
1094 state->rbytes - 4);
1095 if(result) {
1096 tftp_state_machine(state, TFTP_EVENT_ERROR);
1097 return result;
1098 }
1099 }
1100 break;
1101 case TFTP_EVENT_ERROR: {
1102 unsigned short error = getrpacketblock(&state->rpacket);
1103 const char *str = (const char *)state->rpacket.data + 4;
1104 size_t strn = state->rbytes - 4;
1105 state->error = (tftp_error_t)error;
1106 if(tftp_strnlen(str, strn) < strn)
1107 infof(data, "TFTP error: %s", str);
1108 break;
1109 }
1110 case TFTP_EVENT_ACK:
1111 break;
1112 case TFTP_EVENT_OACK:
1113 result = tftp_parse_option_ack(state,
1114 (const char *)state->rpacket.data + 2,
1115 state->rbytes-2);
1116 if(result)
1117 return result;
1118 break;
1119 case TFTP_EVENT_RRQ:
1120 case TFTP_EVENT_WRQ:
1121 default:
1122 failf(data, "%s", "Internal error: Unexpected packet");
1123 break;
1124 }
1126 /* Update the progress meter */
1127 result = Curl_pgrsUpdate(data);
1128 if(result) {
1129 tftp_state_machine(state, TFTP_EVENT_ERROR);
1130 return result;
1131 }
1132 }
1133 return result;
1134}
1136/**********************************************************
1137 *
1138 * tftp_state_timeout
1139 *
1140 * Check if timeouts have been reached
1141 *
1142 **********************************************************/
1143static timediff_t tftp_state_timeout(struct tftp_conn *state,
1144 tftp_event_t *event)
1145{
1146 time_t current;
1147 timediff_t timeout_ms;
1149 if(event)
1150 *event = TFTP_EVENT_NONE;
1152 timeout_ms = Curl_timeleft_ms(state->data);
1153 if(timeout_ms < 0) {
1154 state->error = TFTP_ERR_TIMEOUT;
1155 state->state = TFTP_STATE_FIN;
1156 return timeout_ms;
1157 }
1158 current = time(NULL);
1159 if(current > state->rx_time + state->retry_time) {
1160 if(event)
1161 *event = TFTP_EVENT_TIMEOUT;
1162 state->rx_time = time(NULL); /* update even though we received nothing */
1163 }
1165 return timeout_ms;
1166}
1168/**********************************************************
1169 *
1170 * tftp_multi_statemach
1171 *
1172 * Handle single RX socket event and return
1173 *
1174 **********************************************************/
1175static CURLcode tftp_multi_statemach(struct Curl_easy *data, bool *done)
1176{
1177 tftp_event_t event;
1178 CURLcode result = CURLE_OK;
1179 struct connectdata *conn = data->conn;
1180 struct tftp_conn *state = Curl_conn_meta_get(conn, CURL_META_TFTP_CONN);
1181 timediff_t timeout_ms;
1183 *done = FALSE;
1184 if(!state)
1185 return CURLE_FAILED_INIT;
1187 timeout_ms = tftp_state_timeout(state, &event);
1188 if(timeout_ms < 0) {
1189 failf(data, "TFTP response timeout");
1190 return CURLE_OPERATION_TIMEDOUT;
1191 }
1192 if(event != TFTP_EVENT_NONE) {
1193 result = tftp_state_machine(state, event);
1194 if(result)
1195 return result;
1196 *done = (state->state == TFTP_STATE_FIN);
1197 if(*done)
1198 /* Tell curl we are done */
1199 Curl_xfer_setup_nop(data);
1200 }
1201 else {
1202 /* no timeouts to handle, check our socket */
1203 int rc = SOCKET_READABLE(state->sockfd, 0);
1205 if(rc == -1) {
1206 /* bail out */
1207 int sockerr = SOCKERRNO;
1208 char buffer[STRERROR_LEN];
1209 failf(data, "%s", curlx_strerror(sockerr, buffer, sizeof(buffer)));
1210 state->event = TFTP_EVENT_ERROR;
1211 }
1212 else if(rc) {
1213 result = tftp_receive_packet(data, state);
1214 if(result)
1215 return result;
1216 result = tftp_state_machine(state, state->event);
1217 if(result)
1218 return result;
1219 *done = (state->state == TFTP_STATE_FIN);
1220 if(*done)
1221 /* Tell curl we are done */
1222 Curl_xfer_setup_nop(data);
1223 }
1224 /* if rc == 0, then select() timed out */
1225 }
1227 return result;
1228}
1230/**********************************************************
1231 *
1232 * tftp_doing
1233 *
1234 * Called from multi.c while DOing
1235 *
1236 **********************************************************/
1237static CURLcode tftp_doing(struct Curl_easy *data, bool *dophase_done)
1238{
1239 CURLcode result;
1240 result = tftp_multi_statemach(data, dophase_done);
1242 if(*dophase_done) {
1243 DEBUGF(infof(data, "DO phase is complete"));
1244 }
1245 else if(!result) {
1246 /* The multi code does not have this logic for the DOING state so we
1247 provide it for TFTP since it may do the entire transfer in this
1248 state. */
1249 result = Curl_pgrsCheck(data);
1250 }
1251 return result;
1252}
1254/**********************************************************
1255 *
1256 * tftp_perform
1257 *
1258 * Entry point for transfer from tftp_do, starts state mach
1259 *
1260 **********************************************************/
1261static CURLcode tftp_perform(struct Curl_easy *data, bool *dophase_done)
1262{
1263 CURLcode result = CURLE_OK;
1264 struct connectdata *conn = data->conn;
1265 struct tftp_conn *state = Curl_conn_meta_get(conn, CURL_META_TFTP_CONN);
1267 *dophase_done = FALSE;
1268 if(!state)
1269 return CURLE_FAILED_INIT;
1271 result = tftp_state_machine(state, TFTP_EVENT_INIT);
1273 if((state->state == TFTP_STATE_FIN) || result)
1274 return result;
1276 result = tftp_multi_statemach(data, dophase_done);
1278 if(*dophase_done)
1279 DEBUGF(infof(data, "DO phase is complete"));
1281 return result;
1282}
1284/**********************************************************
1285 *
1286 * tftp_do
1287 *
1288 * The do callback
1289 *
1290 * This callback initiates the TFTP transfer
1291 *
1292 **********************************************************/
1294static CURLcode tftp_do(struct Curl_easy *data, bool *done)
1295{
1296 struct connectdata *conn = data->conn;
1297 struct tftp_conn *state = Curl_conn_meta_get(conn, CURL_META_TFTP_CONN);
1298 CURLcode result;
1300 *done = FALSE;
1302 if(!state) {
1303 result = tftp_connect(data, done);
1304 if(result)
1305 return result;
1307 state = Curl_conn_meta_get(conn, CURL_META_TFTP_CONN);
1308 if(!state)
1309 return CURLE_TFTP_ILLEGAL;
1310 }
1312 result = tftp_perform(data, done);
1314 /* If tftp_perform() returned an error, use that for return code. If it
1315 was OK, see if tftp_translate_code() has an error. */
1316 if(!result)
1317 /* If we have encountered an internal tftp error, translate it. */
1318 result = tftp_translate_code(state->error);
1320 return result;
1321}
1323static CURLcode tftp_setup_connection(struct Curl_easy *data,
1324 struct connectdata *conn)
1325{
1326 char *path = data->state.up.path;
1327 size_t len = strlen(path);
1329 conn->transport_wanted = TRNSPRT_UDP;
1331 /* TFTP URLs support a trailing ";mode=netascii" or ";mode=octet" */
1332 if((len >= 14) && !memcmp(&path[len - 14], ";mode=netascii", 14)) {
1333 data->state.prefer_ascii = TRUE;
1334 path[len - 14] = 0; /* cut it there */
1335 }
1336 else if((len >= 11) && !memcmp(&path[len - 11], ";mode=octet", 11)) {
1337 data->state.prefer_ascii = FALSE;
1338 path[len - 11] = 0; /* cut it there */
1339 }
1341 return CURLE_OK;
1342}
1344/*
1345 * TFTP protocol handler.
1346 */
1347const struct Curl_protocol Curl_protocol_tftp = {
1348 tftp_setup_connection, /* setup_connection */
1349 ZERO_NULL, /* setup_filters */
1350 tftp_do, /* do_it */
1351 tftp_done, /* done */
1352 ZERO_NULL, /* do_more */
1353 tftp_connect, /* connect_it */
1354 tftp_multi_statemach, /* connecting */
1355 tftp_doing, /* doing */
1356 tftp_pollset, /* proto_pollset */
1357 tftp_pollset, /* doing_pollset */
1358 ZERO_NULL, /* domore_pollset */
1359 ZERO_NULL, /* perform_pollset */
1360 ZERO_NULL, /* disconnect */
1361 ZERO_NULL, /* write_resp */
1362 ZERO_NULL, /* write_resp_hd */
1363 ZERO_NULL, /* connection_is_dead */
1364 ZERO_NULL, /* attach connection */
1365 ZERO_NULL, /* follow */
1366};
1368#endif
Diagnostics4 git calls · 30 ms
CallStatusSizeTime030 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=2 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit2 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=23 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=2 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch20011 KiB · hit25 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=10984 git.response.cache=HIT git.response.duration_ms=25 git.fetch.wants=41cf2816973326cb0d95c0f80dd03d46e74e455a git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=10984 git.pkt.payload.max=10963 git.sideband.band1.bytes=10962 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e2c211ba3a89da
- Request
- a244c6f3…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format