Changeset 243

Show
Ignore:
Timestamp:
06/17/10 08:49:05 (2 years ago)
Author:
marek
Message:

ap51-flash: on repeat block seek the file to the right location

Signed-off-by: Marek Lindner <lindner_marek@…>
Acked-by: Linus Luessing <linus.luessing@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ap51-flash/trunk/packet.c

    r238 r243  
    3535 
    3636unsigned long tftp_bytes_sent = 0; 
    37 unsigned short tftp_ack_block = 0, tftp_sent_block = 0, xfer_in_progress = 0, write_req_timeout = 4; 
     37unsigned short last_packet_size = 0, tftp_ack_block = 0, tftp_sent_block = 0, xfer_in_progress = 0, write_req_timeout = 4; 
    3838char tcp_status = TCP_CONTINUE; 
    3939 
     
    130130 
    131131        if (read_len > 0) { 
     132                lseek(fff->fd, seek_pos, SEEK_SET); 
     133 
    132134                if (read_len != read(fff->fd, target_buff, read_len)) { 
    133135                        perror(fff->fname); 
     
    191193                block = 0; 
    192194                tftp_bytes_sent = 0; 
     195                last_packet_size = 0; 
    193196                /* fall through - start sending data */ 
    194197        /* TFTP ack */ 
     
    204207                } else if (block != tftp_sent_block) { 
    205208                        if (block < tftp_sent_block) 
    206                                 fprintf(stderr, "tftp repeat block %d %d\n", block + 1, tftp_ack_block); 
     209                                fprintf(stderr, "tftp repeat block %d, last received ack: %d\n", block + 1, tftp_ack_block); 
    207210                        else 
    208211                                fprintf(stderr, "tftp acks unsent block %d (last sent block: %d)\n", 
     
    210213 
    211214                        block = tftp_ack_block; 
     215                        tftp_bytes_sent -= last_packet_size; 
    212216                } else { 
    213217                        if (block * 512 > tftp_xfer_size) { 
     
    239243                } 
    240244 
     245                last_packet_size = tftp_data_len; 
    241246                tftp_bytes_sent += tftp_data_len; 
    242247                tftp_data_len += 4; /* opcode size */