tftp.c (256244) | tftp.c (276079) |
---|---|
1/* $NetBSD: tftp.c,v 1.4 1997/09/17 16:57:07 drochner Exp $ */ 2 3/* 4 * Copyright (c) 1996 5 * Matthias Drochner. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> | 1/* $NetBSD: tftp.c,v 1.4 1997/09/17 16:57:07 drochner Exp $ */ 2 3/* 4 * Copyright (c) 1996 5 * Matthias Drochner. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 18 unchanged lines hidden (view full) --- 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/lib/libstand/tftp.c 256244 2013-10-09 21:33:19Z kan $"); | 35__FBSDID("$FreeBSD: head/lib/libstand/tftp.c 276079 2014-12-22 20:42:36Z ian $"); |
36 37/* 38 * Simple TFTP implementation for libsa. 39 * Assumes: 40 * - socket descriptor (int) at open_file->f_devdata 41 * - server host IP in global servip 42 * Restrictions: 43 * - read only --- 398 unchanged lines hidden (view full) --- 442 return (0); 443} 444 445static int 446tftp_read(struct open_file *f, void *addr, size_t size, 447 size_t *resid /* out */) 448{ 449 struct tftp_handle *tftpfile; | 36 37/* 38 * Simple TFTP implementation for libsa. 39 * Assumes: 40 * - socket descriptor (int) at open_file->f_devdata 41 * - server host IP in global servip 42 * Restrictions: 43 * - read only --- 398 unchanged lines hidden (view full) --- 442 return (0); 443} 444 445static int 446tftp_read(struct open_file *f, void *addr, size_t size, 447 size_t *resid /* out */) 448{ 449 struct tftp_handle *tftpfile; |
450 static int tc = 0; | |
451 tftpfile = (struct tftp_handle *) f->f_fsdata; 452 453 while (size > 0) { 454 int needblock, count; 455 | 450 tftpfile = (struct tftp_handle *) f->f_fsdata; 451 452 while (size > 0) { 453 int needblock, count; 454 |
456 if (!(tc++ % 16)) 457 twiddle(); | 455 twiddle(32); |
458 459 needblock = tftpfile->off / tftpfile->tftp_blksize + 1; 460 461 if (tftpfile->currblock > needblock) { /* seek backwards */ 462 tftp_senderr(tftpfile, 0, "No error: read aborted"); 463 tftp_makereq(tftpfile); /* no error check, it worked 464 * for open */ 465 } --- 284 unchanged lines hidden --- | 456 457 needblock = tftpfile->off / tftpfile->tftp_blksize + 1; 458 459 if (tftpfile->currblock > needblock) { /* seek backwards */ 460 tftp_senderr(tftpfile, 0, "No error: read aborted"); 461 tftp_makereq(tftpfile); /* no error check, it worked 462 * for open */ 463 } --- 284 unchanged lines hidden --- |