-
Notifications
You must be signed in to change notification settings - Fork 5
/
tftpd.h
115 lines (100 loc) · 3.6 KB
/
tftpd.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* hey emacs! -*- Mode: C; c-file-style: "k&r"; indent-tabs-mode: nil -*- */
/*
* tftpd.h
*
* $Id: tftpd.h,v 1.22 2004/02/27 02:05:26 jp Exp $
*
* Copyright (c) 2000 Jean-Pierre Lefebvre <[email protected]>
* and Remi Lefebvre <[email protected]>
*
* atftp is free software; you can redistribute them and/or modify them
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#ifndef tftpd_h
#define tftpd_h
#include <pthread.h>
#include <arpa/tftp.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include "tftp_io.h"
/*
* Per thread data. There is a thread for each client or group
* (multicast) of client.
*/
struct thread_data {
pthread_t tid;
/* private to thread */
char *data_buffer;
int data_buffer_size;
int timeout;
int checkport; /* Disable TID check. Violate RFC */
int mcast_switch_client; /* When set, server will switch to next client
on first timeout from the current client. */
int trace;
int sockfd;
/* multicast stuff */
short mc_port; /* multicast port */
char *mc_addr; /* multicast address */
struct sockaddr_storage sa_mcast;
union ip_mreq_storage mcastaddr;
u_char mcast_ttl;
/*
* Self can read/write until client_ready is set. Then only allowed to read.
* Other thread can read it only when client_ready is set. Remember that access
* to client_ready below is protected by a mutex.
*/
struct tftp_opt *tftp_options;
/*
* Must lock to insert in the list or search, but not to read or write
* in the client_info structure, since only the propriotary thread do it.
*/
pthread_mutex_t client_mutex;
struct client_info *client_info;
int client_ready; /* one if other thread may add client */
/* must be lock (list lock) to update */
struct thread_data *prev;
struct thread_data *next;
};
struct client_info {
struct sockaddr_storage client;
int done; /* that client as receive it's file */
struct client_info *next;
};
/*
* Functions defined in tftpd_file.c
*/
int tftpd_rules_check(char *filename);
int tftpd_receive_file(struct thread_data *data);
int tftpd_send_file(struct thread_data *data);
/*
* Defined in tftpd_list.c, operation on thread_data list.
*/
int tftpd_list_add(struct thread_data *new);
int tftpd_list_remove(struct thread_data *old);
int tftpd_list_num_of_thread(void);
int tftpd_list_find_multicast_server_and_add(struct thread_data **thread,
struct thread_data *data,
struct client_info *client);
/*
* Defined in tftpd_list.c, operation on client structure list.
*/
void tftpd_clientlist_ready(struct thread_data *thread);
void tftpd_clientlist_remove(struct thread_data *thread,
struct client_info *client);
void tftpd_clientlist_free(struct thread_data *thread);
int tftpd_clientlist_done(struct thread_data *thread,
struct client_info *client,
struct sockaddr_storage *sock);
int tftpd_clientlist_next(struct thread_data *thread,
struct client_info **client);
void tftpd_list_kill_threads(void);
/*
* Defines in tftpd_mcast.c
*/
int tftpd_mcast_get_tid(char **addr, short *port);
int tftpd_mcast_free_tid(char *addr, short port);
int tftpd_mcast_parse_opt(char *addr, char *ports);
#endif