Mistake on this page?
Report an issue in GitHub or email us
tftp_server.h
Go to the documentation of this file.
1 /**
2  *
3  * @file tftp_server.h
4  *
5  * @author Logan Gunthorpe <logang@deltatee.com>
6  *
7  * @brief Trivial File Transfer Protocol (RFC 1350)
8  *
9  * Copyright (c) Deltatee Enterprises Ltd. 2013
10  * All rights reserved.
11  *
12  */
13 
14 /*
15  * Redistribution and use in source and binary forms, with or without
16  * modification,are permitted provided that the following conditions are met:
17  *
18  * 1. Redistributions of source code must retain the above copyright notice,
19  * this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright notice,
21  * this list of conditions and the following disclaimer in the documentation
22  * and/or other materials provided with the distribution.
23  * 3. The name of the author may not be used to endorse or promote products
24  * derived from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
27  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
29  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
31  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Author: Logan Gunthorpe <logang@deltatee.com>
38  *
39  */
40 
41 #ifndef LWIP_HDR_APPS_TFTP_SERVER_H
42 #define LWIP_HDR_APPS_TFTP_SERVER_H
43 
44 #include "lwip/apps/tftp_opts.h"
45 #include "lwip/err.h"
46 #include "lwip/pbuf.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 /** @ingroup tftp
53  * TFTP context containing callback functions for TFTP transfers
54  */
55 struct tftp_context {
56  /**
57  * Open file for read/write.
58  * @param fname Filename
59  * @param mode Mode string from TFTP RFC 1350 (netascii, octet, mail)
60  * @param write Flag indicating read (0) or write (!= 0) access
61  * @returns File handle supplied to other functions
62  */
63  void* (*open)(const char* fname, const char* mode, u8_t write);
64  /**
65  * Close file handle
66  * @param handle File handle returned by open()
67  */
68  void (*close)(void* handle);
69  /**
70  * Read from file
71  * @param handle File handle returned by open()
72  * @param buf Target buffer to copy read data to
73  * @param bytes Number of bytes to copy to buf
74  * @returns &gt;= 0: Success; &lt; 0: Error
75  */
76  int (*read)(void* handle, void* buf, int bytes);
77  /**
78  * Write to file
79  * @param handle File handle returned by open()
80  * @param pbuf PBUF adjusted such that payload pointer points
81  * to the beginning of write data. In other words,
82  * TFTP headers are stripped off.
83  * @returns &gt;= 0: Success; &lt; 0: Error
84  */
85  int (*write)(void* handle, struct pbuf* p);
86 };
87 
88 err_t tftp_init(const struct tftp_context* ctx);
89 void tftp_cleanup(void);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 #endif /* LWIP_HDR_APPS_TFTP_SERVER_H */
int(* read)(void *handle, void *buf, int bytes)
Read from file.
Definition: tftp_server.h:76
Trivial File Transfer Protocol (RFC 1350) implementation options.
Main packet buffer struct.
lwIP Error codes
TFTP context containing callback functions for TFTP transfers.
Definition: tftp_server.h:55
int(* write)(void *handle, struct pbuf *p)
Write to file.
Definition: tftp_server.h:85
pbuf API
void(* close)(void *handle)
Close file handle.
Definition: tftp_server.h:68
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.