Classes | Macros | Typedefs | Functions | Variables
tftpd.c File Reference
#include "server_setup.h"
#include "tftp.h"
#include <setjmp.h>
#include "curlx.h"
#include "getpart.h"
#include "util.h"
#include "server_sockaddr.h"
#include "memdebug.h"
Include dependency graph for tftpd.c:

Go to the source code of this file.

Classes

struct  bf
 
struct  errmsg
 
struct  formats
 
struct  testcase
 
union  tftphdr_storage_t
 

Macros

#define BF_ALLOC   -3 /* alloc'd but not yet filled */
 
#define BF_FREE   -2 /* free */
 
#define DEFAULT_LOGFILE   "log/tftpd.log"
 
#define DEFAULT_PORT   8999 /* UDP */
 
#define ENABLE_CURLX_PRINTF
 
#define MIN(x, y)   ((x)<(y)?(x):(y))
 
#define opcode_ACK   4
 
#define opcode_DATA   3
 
#define opcode_ERROR   5
 
#define opcode_RRQ   1
 
#define opcode_WRQ   2
 
#define PKTSIZE   (SEGSIZE + 4) /* SEGSIZE defined in arpa/tftp.h */
 
#define REQUEST_DUMP   "log/server.input"
 
#define siginterrupt(x, y)   do {} while(0)
 
#define TIMEOUT   5
 

Typedefs

typedef RETSIGTYPE(* SIGHANDLER_T) (int)
 

Functions

static int do_tftp (struct testcase *test, struct tftphdr *tp, ssize_t size)
 
static RETSIGTYPE exit_signal_handler (int signum)
 
static void install_signal_handlers (void)
 
int main (int argc, char **argv)
 
static void nak (int error)
 
static int parse_servercmd (struct testcase *req)
 
static struct tftphdrr_init (void)
 
static void read_ahead (struct testcase *test, int convert)
 
static int readit (struct testcase *test, struct tftphdr **dpp, int convert)
 
static void recvtftp (struct testcase *test, struct formats *pf)
 
static void restore_signal_handlers (void)
 
static struct tftphdrrw_init (int)
 
static void sendtftp (struct testcase *test, struct formats *pf)
 
static int synchnet (curl_socket_t)
 
static int validate_access (struct testcase *test, const char *fname, int mode)
 
static struct tftphdrw_init (void)
 
static ssize_t write_behind (struct testcase *test, int convert)
 
static int writeit (struct testcase *test, struct tftphdr *volatile *dpp, int ct, int convert)
 

Variables

static tftphdr_storage_t ackbuf
 
static struct bf bfs [2]
 
static tftphdr_storage_t buf
 
static int current
 
static struct errmsg errmsgs []
 
static volatile int exit_signal = 0
 
static struct formats formata []
 
static srvr_sockaddr_union_t from
 
static curl_socklen_t fromlen
 
SIG_ATOMIC_T got_exit_signal = 0
 
static const char * ipv_inuse = "IPv4"
 
static unsigned int maxtimeout = 5 * TIMEOUT
 
static int newline = 0
 
static int nextone
 
static curl_socket_t peer = CURL_SOCKET_BAD
 
static const char * pidname = ".tftpd.pid"
 
static int prevchar = -1
 
const char * serverlogfile = DEFAULT_LOGFILE
 
static int serverlogslocked = 0
 
static unsigned int timeout
 
static int wrotepidfile = 0
 

Macro Definition Documentation

#define BF_ALLOC   -3 /* alloc'd but not yet filled */

Definition at line 141 of file tftpd.c.

#define BF_FREE   -2 /* free */

Definition at line 142 of file tftpd.c.

#define DEFAULT_LOGFILE   "log/tftpd.log"

Definition at line 156 of file tftpd.c.

#define DEFAULT_PORT   8999 /* UDP */

Definition at line 161 of file tftpd.c.

#define ENABLE_CURLX_PRINTF

Definition at line 86 of file tftpd.c.

#define MIN (   x,
  y 
)    ((x)<(y)?(x):(y))

Definition at line 153 of file tftpd.c.

#define opcode_ACK   4

Definition at line 147 of file tftpd.c.

#define opcode_DATA   3

Definition at line 146 of file tftpd.c.

#define opcode_ERROR   5

Definition at line 148 of file tftpd.c.

#define opcode_RRQ   1

Definition at line 144 of file tftpd.c.

#define opcode_WRQ   2

Definition at line 145 of file tftpd.c.

#define PKTSIZE   (SEGSIZE + 4) /* SEGSIZE defined in arpa/tftp.h */

Definition at line 102 of file tftpd.c.

#define REQUEST_DUMP   "log/server.input"

Definition at line 159 of file tftpd.c.

#define siginterrupt (   x,
  y 
)    do {} while(0)

Definition at line 226 of file tftpd.c.

#define TIMEOUT   5

Definition at line 150 of file tftpd.c.

Typedef Documentation

typedef RETSIGTYPE(* SIGHANDLER_T) (int)

Definition at line 231 of file tftpd.c.

Function Documentation

static int do_tftp ( struct testcase test,
struct tftphdr tp,
ssize_t  size 
)
static

Definition at line 952 of file tftpd.c.

static RETSIGTYPE exit_signal_handler ( int  signum)
static

Definition at line 355 of file tftpd.c.

static void install_signal_handlers ( void  )
static

Definition at line 366 of file tftpd.c.

int main ( int  argc,
char **  argv 
)

Definition at line 667 of file tftpd.c.

static void nak ( int  error)
static

Definition at line 1410 of file tftpd.c.

static int parse_servercmd ( struct testcase req)
static

Definition at line 1069 of file tftpd.c.

static struct tftphdr * r_init ( void  )
static

Definition at line 450 of file tftpd.c.

static void read_ahead ( struct testcase test,
int  convert 
)
static

Definition at line 478 of file tftpd.c.

static int readit ( struct testcase test,
struct tftphdr **  dpp,
int  convert 
)
static

Definition at line 458 of file tftpd.c.

static void recvtftp ( struct testcase test,
struct formats pf 
)
static

Definition at line 1314 of file tftpd.c.

static void restore_signal_handlers ( void  )
static

Definition at line 406 of file tftpd.c.

static struct tftphdr * rw_init ( int  x)
static

Definition at line 434 of file tftpd.c.

static void sendtftp ( struct testcase test,
struct formats pf 
)
static

Definition at line 1236 of file tftpd.c.

static int synchnet ( curl_socket_t  f)
static

Definition at line 629 of file tftpd.c.

static int validate_access ( struct testcase test,
const char *  fname,
int  mode 
)
static

Definition at line 1137 of file tftpd.c.

static struct tftphdr * w_init ( void  )
static

Definition at line 445 of file tftpd.c.

static ssize_t write_behind ( struct testcase test,
int  convert 
)
static

Definition at line 556 of file tftpd.c.

static int writeit ( struct testcase test,
struct tftphdr *volatile *  dpp,
int  ct,
int  convert 
)
static

Definition at line 538 of file tftpd.c.

Variable Documentation

tftphdr_storage_t ackbuf
static

Definition at line 195 of file tftpd.c.

struct bf bfs[2]
static

Definition at line 185 of file tftpd.c.

tftphdr_storage_t buf
static

Definition at line 194 of file tftpd.c.

int current
static

Definition at line 188 of file tftpd.c.

struct errmsg errmsgs[]
static
Initial value:
= {
{ EUNDEF, "Undefined error code" },
{ ENOTFOUND, "File not found" },
{ EACCESS, "Access violation" },
{ ENOSPACE, "Disk full or allocation exceeded" },
{ EBADOP, "Illegal TFTP operation" },
{ EBADID, "Unknown transfer ID" },
{ EEXISTS, "File already exists" },
{ ENOUSER, "No such user" },
{ -1, 0 }
}
#define ENOSPACE
#define ENOTFOUND
#define EUNDEF
#define EEXISTS
#define EBADOP
#define ENOUSER
#define EBADID
#define EACCESS

Definition at line 167 of file tftpd.c.

volatile int exit_signal = 0
static

Definition at line 259 of file tftpd.c.

struct formats formata[]
static
Initial value:
= {
{ "netascii", 1 },
{ "octet", 0 },
{ NULL, 0 }
}

Definition at line 179 of file tftpd.c.

srvr_sockaddr_union_t from
static

Definition at line 197 of file tftpd.c.

curl_socklen_t fromlen
static

Definition at line 198 of file tftpd.c.

SIG_ATOMIC_T got_exit_signal = 0

Definition at line 255 of file tftpd.c.

const char* ipv_inuse = "IPv4"
static

Definition at line 208 of file tftpd.c.

unsigned int maxtimeout = 5 * TIMEOUT
static

Definition at line 203 of file tftpd.c.

int newline = 0
static

Definition at line 191 of file tftpd.c.

int nextone
static

Definition at line 187 of file tftpd.c.

Definition at line 200 of file tftpd.c.

const char* pidname = ".tftpd.pid"
static

Definition at line 211 of file tftpd.c.

int prevchar = -1
static

Definition at line 192 of file tftpd.c.

const char* serverlogfile = DEFAULT_LOGFILE

Definition at line 210 of file tftpd.c.

int serverlogslocked = 0
static

Definition at line 212 of file tftpd.c.

unsigned int timeout
static

Definition at line 202 of file tftpd.c.

int wrotepidfile = 0
static

Definition at line 213 of file tftpd.c.



rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sat Feb 13 2021 03:42:17