blob: acf994e78b3a4868827521aa8c01e63042a74230 (
plain) (
blame)
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
49
50
51
52
53
|
#ifndef NBD_NBTPD_HANDLERS_H
#define NBD_NBTPD_HANDLERS_H
#include <netinet/in.h>
#include "packet.h"
#define NBD_NBTPD_ARGS_PATH_MAX 768
#define NBD_NBTPD_ARGS_MODE_MAX 32
typedef enum opmode {
NOT_FOUND,
NETASCII,
OCTET,
MAIL
// any additional modes
} nbd_opmode;
typedef struct {
char path[NBD_NBTPD_ARGS_PATH_MAX];
char mode[NBD_NBTPD_ARGS_MODE_MAX];
nbd_tftp_ecode err;
struct sockaddr_in client;
} nbd_nbtpd_args;
nbd_opmode get_mode(char *mode);
/*!
* WARNING: use this only if you know what you are doing
* The actual function signature is `void read_req_resp(nbd_nbtpd_args *args)`
* Invoke this function as a response to getting a new read request.
* It opens a new UDP socket and reads file to transmit.
* ```c
* nbd_nbtpd_args *args = malloc(sizeof(nbd_nbtpd_args));
* pthread_create(thread, attrs, read_req_resp, (void *)args);
* ```
*/
void *read_req_resp(void *args);
/*!
* WARNING: use this only if you know what you are doing
* The actual function signature is `void write_req_resp(nbd_nbtpd_args *args)`
* Invoke this function as a response to getting a new write request.
* It opens a new UDP socket, receives file to write to disk.
* ```c
* nbd_nbtpd_args *args = malloc(sizeof(nbd_nbtpd_args));
* pthread_create(thread, attrs, write_req_resp, (void *)args);
* ```
*/
void *write_req_resp(void *args);
/// WARNING: use this only if you know what you are doing
void *nbd_nbtpd_resp_error(void *args);
#endif
|