1/** 2 * \file 3 * \brief TFTP library 4 */ 5 6/* 7 * Copyright (c) 2015 ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#include <barrelfish/barrelfish.h> 16#include <net_sockets/net_sockets.h> 17 18#include <tftp/tftp.h> 19#include "tftp_internal.h" 20 21 22/* 23 * ------------------------------------------------------------------------------ 24 * Ack 25 * ------------------------------------------------------------------------------ 26 */ 27 28errval_t tftp_send_ack(struct net_socket *socket, uint32_t blockno, 29 struct in_addr addr, uint16_t port) 30{ 31 TFTP_DEBUG_PACKETS("sending ack(%u)\n", blockno); 32 void *payload = net_alloc(TFTP_MAX_MSGSIZE); 33 if (payload == NULL) { 34 return LIB_ERR_MALLOC_FAIL; 35 } 36 37 memset(payload, 0, sizeof(uint32_t) + sizeof(uint16_t)); 38 39 size_t length = set_opcode(payload, TFTP_OP_ACK); 40 length += set_block_no(payload + length, blockno); 41 42 errval_t err; 43 err = net_send_to(socket, payload, length + 1, addr, port); 44 assert(err_is_ok(err)); 45 46 return SYS_ERR_OK; 47} 48