1 #ifndef tftplib_h
2 #define tftplib_h
3 
4 #define TFTP_OFFSET 4 /* size of tftp header */
5 
6 #ifndef OACK
7 #define OACK 6 /* option ACK */
8 #endif
9 
10 union tftpbuf { struct tftphdr *hdr; char *buf; };
11 
12 struct tftplib_ctrl {
13 	int netascii;
14 	size_t segsize;
15 	int retries;
16 	int timeout;
17 	int force_timeout;
18 	int force_stop;
19 	int send_garbage;
20 	int duplicate_ack;
21 	char *revision;
22 	union tftpbuf sendbuf; /* of segsize+TFTP_OFFSET size */
23 	union tftpbuf recvbuf; /* of segsize+TFTP_OFFSET size */
24 	size_t first_packet_length; /* see tftp_recv.c for a description */
25 	int recognize_oack;
26 	struct sockaddr_in s_in;
27 	/* */
28 	const char *filename;     /* qualified absolute filename */
29 	const char *origfilename; /* exactly what we received */
30 	int filefd;
31 	int remotefd;
32 	unsigned long bytes;
33 	pid_t pid;
34 };
35 
36 extern int opt_verbose;
37 
38 
39 #define UTFTP_EC_OK 0
40 #define UTFTP_EC_LOCAL 1
41 #define UTFTP_EC_USAGE 2
42 #define UTFTP_EC_TIMEOUT 3
43 #define UTFTP_EC_PROTO 4
44 #define UTFTP_EC_NETWORK 5
45 #define UTFTP_EC_ERROR 6
46 #define UTFTP_EC_UNDEF 7
47 
48 
49 
50 
51 /*
52  * receive a file with TFTP
53  */
54 int tftp_receive P__((const char *server, int port, const char *remotefilename,
55 	const char *localfilename,struct tftplib_ctrl *flags));
56 /*
57  * send a file to a TFTP server
58  */
59 int tftp_send P__((const char *server, int port, const char *remotefilename,
60 	const char *localfilename, struct tftplib_ctrl *flags));
61 
62 int tftp_nak P__((int remotefd, int tftp_errcode, const char *errtext, struct tftplib_ctrl *flags));
63 size_t tftp_prepare_rq P__((int type, const char *server, unsigned short port, const char *remotefilename,
64 	struct sockaddr_in *s_in, int *may_get_oack, struct tftplib_ctrl *flags));
65 
66 struct tftplib_ctrl *tftp_setup_ctrl P__((struct tftplib_ctrl *old, size_t segsize));
67 void  tftp_free_ctrl P__((struct tftplib_ctrl *old));
68 
69 #endif
70