-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtftp.h
48 lines (33 loc) · 1.15 KB
/
tftp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2021 Bjørn Brodtkorb
#ifndef TFTP_H
#define TFTP_H
#include "utilities.h"
#include "network.h"
#include "udp.h"
#include "time.h"
#include "backoff.h"
//--------------------------------------------------------------------------------------------------
#define TFTP_MAX_FILENAME_LENGTH 64
//--------------------------------------------------------------------------------------------------
enum {
TFTP_STATE_REQUEST,
TFTP_STATE_READ,
TFTP_STATE_DONE,
TFTP_STATE_ERROR,
};
//--------------------------------------------------------------------------------------------------
typedef struct {
Ip server_ip;
Port client_port;
Port server_port;
u16 block_number;
int state;
Time time;
Backoff backoff;
char filename[TFTP_MAX_FILENAME_LENGTH];
} TftpConnection;
//--------------------------------------------------------------------------------------------------
void tftp_download_file(TftpConnection* connection, const char* filename, Ip server_ip);
void tftp_abort_download(TftpConnection* connection, const char* error_message);
int tftp_read(TftpConnection* connection, void* buffer, int size);
#endif