tftp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Nick van IJzendoorn <nijzendoorn@engineering-spirit.nl>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for
6  * more details.
7  */
8 
42 #ifndef NET_GNRC_TFTP_H
43 #define NET_GNRC_TFTP_H
44 
45 #include <inttypes.h>
46 
47 #include "byteorder.h"
48 #include "kernel_types.h"
49 #include "net/ipv6/addr.h"
50 #include "net/gnrc/nettype.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
59 #ifndef GNRC_TFTP_MAX_FILENAME_LEN
60 #define GNRC_TFTP_MAX_FILENAME_LEN (64)
61 #endif
62 
66 #ifndef GNRC_TFTP_DEFAULT_SRC_PORT
67 #define GNRC_TFTP_DEFAULT_SRC_PORT (10690)
68 #endif
69 
73 #ifndef GNRC_TFTP_DEFAULT_DST_PORT
74 #define GNRC_TFTP_DEFAULT_DST_PORT (69)
75 #endif
76 
80 #ifndef GNRC_TFTP_MAX_TRANSFER_UNIT
81 #define GNRC_TFTP_MAX_TRANSFER_UNIT (512)
82 #endif
83 
87 #ifndef GNRC_TFTP_MAX_RETRIES
88 #define GNRC_TFTP_MAX_RETRIES (5)
89 #endif
90 
94 #ifndef GNRC_TFTP_DEFAULT_TIMEOUT
95 #define GNRC_TFTP_DEFAULT_TIMEOUT (1 * US_PER_SEC)
96 #endif
97 
101 typedef enum {
102  TFTP_READ,
103  TFTP_WRITE
104 } tftp_action_t;
105 
109 typedef enum {
110  TTM_ASCII,
111  TTM_OCTET,
112  TTM_MAIL
113 } tftp_mode_t;
114 
118 typedef enum {
122 } tftp_event_t;
123 
135 typedef bool (*tftp_start_cb_t)(tftp_action_t action, tftp_mode_t mode,
136  const char *file_name, size_t *data_len);
137 
141 typedef int (*tftp_data_cb_t)(uint32_t offset, void *data, size_t data_len);
142 
146 typedef void (*tftp_stop_cb_t)(tftp_event_t event, const char *msg);
147 
159 int gnrc_tftp_server(tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb, bool use_options);
160 
167 int gnrc_tftp_server_stop(void);
168 
185 int gnrc_tftp_client_read(ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode,
186  tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb,
187  bool use_option);
188 
205 int gnrc_tftp_client_write(ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode,
206  tftp_data_cb_t data_cb, size_t total_size, tftp_stop_cb_t stop_cb,
207  bool use_option);
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* NET_GNRC_TFTP_H */
214 
Types used by the kernel.
Definitions for IPv6 addresses.
tftp_mode_t
TFTP Transfer modes.
Definition: tftp.h:109
int gnrc_tftp_client_write(ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode, tftp_data_cb_t data_cb, size_t total_size, tftp_stop_cb_t stop_cb, bool use_option)
Start an TFTP client write action to the given destination.
event structure
Definition: event.h:139
The peer send the given error.
Definition: tftp.h:120
int gnrc_tftp_client_read(ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode, tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb, bool use_option)
Start an TFTP client read action from the given destination.
void(* tftp_stop_cb_t)(tftp_event_t event, const char *msg)
callback define which is called when an transfer is stopped
Definition: tftp.h:146
The transfer was successful.
Definition: tftp.h:119
tftp_event_t
TFTP stop / finish events.
Definition: tftp.h:118
int gnrc_tftp_server_stop(void)
Stop the TFTP server.
int gnrc_tftp_server(tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb, bool use_options)
Start the TFTP server.
tftp_action_t
TFTP action to perform.
Definition: tftp.h:101
Functions to work with different byte orders.
Adds include for missing inttype definitions.
int(* tftp_data_cb_t)(uint32_t offset, void *data, size_t data_len)
callback define which is called to get or set data from/to the user application
Definition: tftp.h:141
Data type to represent an IPv6 address.
Definition: addr.h:74
bool(* tftp_start_cb_t)(tftp_action_t action, tftp_mode_t mode, const char *file_name, size_t *data_len)
callback define which is called when a new server request is placed or when an client read request is...
Definition: tftp.h:135
There was an internal error.
Definition: tftp.h:121
Protocol type definitions.