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 
35 #ifndef NET_GNRC_TFTP_H
36 #define NET_GNRC_TFTP_H
37 
38 #include <inttypes.h>
39 
40 #include "byteorder.h"
41 #include "kernel_types.h"
42 #include "net/ipv6/addr.h"
43 #include "net/gnrc/nettype.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
52 #ifndef GNRC_TFTP_MAX_FILENAME_LEN
53 #define GNRC_TFTP_MAX_FILENAME_LEN (64)
54 #endif
55 
59 #ifndef GNRC_TFTP_DEFAULT_SRC_PORT
60 #define GNRC_TFTP_DEFAULT_SRC_PORT (10690)
61 #endif
62 
66 #ifndef GNRC_TFTP_DEFAULT_DST_PORT
67 #define GNRC_TFTP_DEFAULT_DST_PORT (69)
68 #endif
69 
73 #ifndef GNRC_TFTP_MAX_TRANSFER_UNIT
74 #define GNRC_TFTP_MAX_TRANSFER_UNIT (512)
75 #endif
76 
80 #ifndef GNRC_TFTP_MAX_RETRIES
81 #define GNRC_TFTP_MAX_RETRIES (5)
82 #endif
83 
87 #ifndef GNRC_TFTP_DEFAULT_TIMEOUT
88 #define GNRC_TFTP_DEFAULT_TIMEOUT (1 * US_PER_SEC)
89 #endif
90 
94 typedef enum {
95  TFTP_READ,
96  TFTP_WRITE
98 
102 typedef enum {
103  TTM_ASCII,
104  TTM_OCTET,
105  TTM_MAIL
106 } tftp_mode_t;
107 
111 typedef enum {
115 } tftp_event_t;
116 
128 typedef bool (*tftp_start_cb_t)(tftp_action_t action, tftp_mode_t mode,
129  const char *file_name, size_t *data_len);
130 
134 typedef int (*tftp_data_cb_t)(uint32_t offset, void *data, size_t data_len);
135 
139 typedef void (*tftp_stop_cb_t)(tftp_event_t event, const char *msg);
140 
152 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);
153 
160 int gnrc_tftp_server_stop(void);
161 
176 int gnrc_tftp_client_read(ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode,
177  tftp_data_cb_t data_cb, tftp_start_cb_t start_cb, tftp_stop_cb_t stop_cb,
178  bool use_option);
179 
194 int gnrc_tftp_client_write(ipv6_addr_t *addr, const char *file_name, tftp_mode_t mode,
195  tftp_data_cb_t data_cb, size_t total_size, tftp_stop_cb_t stop_cb,
196  bool use_option);
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #endif /* NET_GNRC_TFTP_H */
203 
Types used by the kernel.
Definitions for IPv6 addresses.
tftp_mode_t
TFTP Transfer modes.
Definition: tftp.h:102
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.
The peer send the given error.
Definition: tftp.h:113
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:139
The transfer was successful.
Definition: tftp.h:112
tftp_event_t
TFTP stop / finish events.
Definition: tftp.h:111
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:94
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:134
Data type to represent an IPv6 address.
Definition: ipv6/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:128
There was an internal error.
Definition: tftp.h:114
Protocol type definitions.