Lines Matching +full:out +full:- +full:of +full:- +full:window
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * notice, this list of conditions and the following disclaimer in the
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
43 #include "tftp-file.h"
44 #include "tftp-io.h"
45 #include "tftp-utils.h"
46 #include "tftp-options.h"
47 #include "tftp-transfer.h"
67 struct block_data window[WINDOWSIZE_MAX]; in tftp_send() local
71 ts->amount = 0; in tftp_send()
77 tftp_log(LOG_DEBUG, "Sending block %d (window block %d)", in tftp_send()
80 window[windowblock].offset = tell_file(); in tftp_send()
81 window[windowblock].block = *block; in tftp_send()
86 return -1; in tftp_send()
88 window[windowblock].size = size; in tftp_send()
100 return -1; in tftp_send()
107 /* Only check for ACK for last block in window. */ in tftp_send()
117 return -1; in tftp_send()
124 ts->retries++; in tftp_send()
125 if (seek_file(window[0].offset) != 0) { in tftp_send()
130 return -1; in tftp_send()
132 *block = window[0].block; in tftp_send()
141 return -1; in tftp_send()
143 if (rp->th_opcode == ACK) { in tftp_send()
146 * window. in tftp_send()
149 if (rp->th_block == window[i].block) in tftp_send()
157 "ACK %d out of window", in tftp_send()
158 rp->th_block); in tftp_send()
160 /* Re-synchronize with the other side */ in tftp_send()
163 /* Resend the current window. */ in tftp_send()
164 ts->retries++; in tftp_send()
165 if (seek_file(window[0].offset) != 0) { in tftp_send()
170 return -1; in tftp_send()
172 *block = window[0].block; in tftp_send()
183 window[j].block); in tftp_send()
184 ts->blocks++; in tftp_send()
185 ts->amount += window[j].size; in tftp_send()
190 * un-ACKed block. in tftp_send()
196 if (seek_file(window[i + 1].offset) != in tftp_send()
202 return -1; in tftp_send()
204 *block = window[i + 1].block; in tftp_send()
206 ts->retries++; in tftp_send()
228 ts->rollovers++; in tftp_send()
230 gettimeofday(&(ts->tstop), NULL); in tftp_send()
238 * - It could be that the first block has already arrived while
239 * trying to figure out if we were receiving options or not. In
251 ts->amount = 0; in tftp_receive()
255 writesize = write_file(firstblock->th_data, fb_size); in tftp_receive()
256 ts->amount += writesize; in tftp_receive()
257 ts->blocks++; in tftp_receive()
267 return -1; in tftp_receive()
281 gettimeofday(&(ts->tstop), NULL); in tftp_receive()
302 ts->rollovers++; in tftp_receive()
308 "Receiving DATA block %d (window block %d)", in tftp_receive()
318 return -1; in tftp_receive()
333 return -1; in tftp_receive()
335 if (rp->th_opcode == DATA) { in tftp_receive()
336 ts->blocks++; in tftp_receive()
338 if (rp->th_block == *block) in tftp_receive()
343 * window. in tftp_receive()
351 windowstart = *block - windowsize; in tftp_receive()
354 if (rp->th_block > windowstart && in tftp_receive()
355 rp->th_block < *block) { in tftp_receive()
359 rp->th_block); in tftp_receive()
367 *block, rp->th_block); in tftp_receive()
369 /* Re-synchronize with the other side */ in tftp_receive()
374 ts->retries++; in tftp_receive()
380 packettype(rp->th_opcode)); in tftp_receive()
385 writesize = write_file(rp->th_data, n_data); in tftp_receive()
386 ts->amount += writesize; in tftp_receive()
394 return -1; in tftp_receive()
401 /* Only send ACKs for the last block in the window. */ in tftp_receive()
413 return -1; in tftp_receive()
427 gettimeofday(&(ts->tstop), NULL); in tftp_receive()
436 NULL, -timeoutpacket); in tftp_receive()
440 rp->th_opcode == DATA && /* and got a data block */ in tftp_receive()
441 *block == rp->th_block) /* then my last ack was lost */ in tftp_receive()