Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / SLOF / clients / net-snk / app / netlib / tftp.h
1 /******************************************************************************
2  * Copyright (c) 2004, 2008 IBM Corporation
3  * All rights reserved.
4  * This program and the accompanying materials
5  * are made available under the terms of the BSD License
6  * which accompanies this distribution, and is available at
7  * http://www.opensource.org/licenses/bsd-license.php
8  *
9  * Contributors:
10  *     IBM Corporation - initial implementation
11  *****************************************************************************/
12
13
14 #ifndef _TFTP_H_
15 #define _TFTP_H_
16
17 #include <stdint.h>
18 #include <netlib/ipv6.h>
19
20 struct tftphdr {
21         int16_t th_opcode;
22         uint16_t th_data;
23 };
24
25 typedef struct {
26         uint32_t own_ip;
27         ip6_addr_t own_ip6;
28         uint32_t server_ip;
29         ip6_addr_t server_ip6;
30         ip6_addr_t dns_ip6;
31         int8_t filename[256];
32         int    fd;
33 } __attribute__ ((packed)) filename_ip_t ;
34
35 typedef struct {
36         uint32_t bad_tftp_packets;
37         uint32_t no_packets;
38         uint32_t blocks_missed;
39         uint32_t blocks_received;
40 } tftp_err_t;
41
42 int tftp(filename_ip_t *, unsigned char  *, int, unsigned int,
43          tftp_err_t *, int32_t mode, int32_t blocksize, int ip_version);
44 int tftp_netsave(filename_ip_t *, uint8_t * buffer, int len,
45                  int use_ci, unsigned int retries, tftp_err_t * tftp_err);
46
47 int32_t handle_tftp(int fd, uint8_t *, int32_t);
48 void handle_tftp_dun(uint8_t err_code);
49 int parse_tftp_args(char buffer[], char *server_ip, char filename[], int fd, int len);
50
51 #endif