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

◆ BF_ALLOC

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

Definition at line 141 of file tftpd.c.

◆ BF_FREE

#define BF_FREE   -2 /* free */

Definition at line 142 of file tftpd.c.

◆ DEFAULT_LOGFILE

#define DEFAULT_LOGFILE   "log/tftpd.log"

Definition at line 156 of file tftpd.c.

◆ DEFAULT_PORT

#define DEFAULT_PORT   8999 /* UDP */

Definition at line 161 of file tftpd.c.

◆ ENABLE_CURLX_PRINTF

#define ENABLE_CURLX_PRINTF

Definition at line 86 of file tftpd.c.

◆ MIN

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

Definition at line 153 of file tftpd.c.

◆ opcode_ACK

#define opcode_ACK   4

Definition at line 147 of file tftpd.c.

◆ opcode_DATA

#define opcode_DATA   3

Definition at line 146 of file tftpd.c.

◆ opcode_ERROR

#define opcode_ERROR   5

Definition at line 148 of file tftpd.c.

◆ opcode_RRQ

#define opcode_RRQ   1

Definition at line 144 of file tftpd.c.

◆ opcode_WRQ

#define opcode_WRQ   2

Definition at line 145 of file tftpd.c.

◆ PKTSIZE

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

Definition at line 102 of file tftpd.c.

◆ REQUEST_DUMP

#define REQUEST_DUMP   "log/server.input"

Definition at line 159 of file tftpd.c.

◆ siginterrupt

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

Definition at line 226 of file tftpd.c.

◆ TIMEOUT

#define TIMEOUT   5

Definition at line 150 of file tftpd.c.

Typedef Documentation

◆ SIGHANDLER_T

typedef RETSIGTYPE(* SIGHANDLER_T) (int)

Definition at line 231 of file tftpd.c.

Function Documentation

◆ do_tftp()

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

Definition at line 952 of file tftpd.c.

◆ exit_signal_handler()

static RETSIGTYPE exit_signal_handler ( int  signum)
static

Definition at line 355 of file tftpd.c.

◆ install_signal_handlers()

static void install_signal_handlers ( void  )
static

Definition at line 366 of file tftpd.c.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 667 of file tftpd.c.

◆ nak()

static void nak ( int  error)
static

Definition at line 1410 of file tftpd.c.

◆ parse_servercmd()

static int parse_servercmd ( struct testcase req)
static

Definition at line 1069 of file tftpd.c.

◆ r_init()

static struct tftphdr * r_init ( void  )
static

Definition at line 450 of file tftpd.c.

◆ read_ahead()

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

Definition at line 478 of file tftpd.c.

◆ readit()

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

Definition at line 458 of file tftpd.c.

◆ recvtftp()

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

Definition at line 1314 of file tftpd.c.

◆ restore_signal_handlers()

static void restore_signal_handlers ( void  )
static

Definition at line 406 of file tftpd.c.

◆ rw_init()

static struct tftphdr * rw_init ( int  x)
static

Definition at line 434 of file tftpd.c.

◆ sendtftp()

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

Definition at line 1236 of file tftpd.c.

◆ synchnet()

static int synchnet ( curl_socket_t  f)
static

Definition at line 629 of file tftpd.c.

◆ validate_access()

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

Definition at line 1137 of file tftpd.c.

◆ w_init()

static struct tftphdr * w_init ( void  )
static

Definition at line 445 of file tftpd.c.

◆ write_behind()

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

Definition at line 556 of file tftpd.c.

◆ writeit()

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

◆ ackbuf

tftphdr_storage_t ackbuf
static

Definition at line 195 of file tftpd.c.

◆ bfs

struct bf bfs[2]
static

Definition at line 185 of file tftpd.c.

◆ buf

tftphdr_storage_t buf
static

Definition at line 194 of file tftpd.c.

◆ current

int current
static

Definition at line 188 of file tftpd.c.

◆ errmsgs

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 }
}

Definition at line 167 of file tftpd.c.

◆ exit_signal

volatile int exit_signal = 0
static

Definition at line 259 of file tftpd.c.

◆ formata

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

Definition at line 179 of file tftpd.c.

◆ from

srvr_sockaddr_union_t from
static

Definition at line 197 of file tftpd.c.

◆ fromlen

curl_socklen_t fromlen
static

Definition at line 198 of file tftpd.c.

◆ got_exit_signal

SIG_ATOMIC_T got_exit_signal = 0

Definition at line 255 of file tftpd.c.

◆ ipv_inuse

const char* ipv_inuse = "IPv4"
static

Definition at line 208 of file tftpd.c.

◆ maxtimeout

unsigned int maxtimeout = 5 * TIMEOUT
static

Definition at line 203 of file tftpd.c.

◆ newline

int newline = 0
static

Definition at line 191 of file tftpd.c.

◆ nextone

int nextone
static

Definition at line 187 of file tftpd.c.

◆ peer

Definition at line 200 of file tftpd.c.

◆ pidname

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

Definition at line 211 of file tftpd.c.

◆ prevchar

int prevchar = -1
static

Definition at line 192 of file tftpd.c.

◆ serverlogfile

const char* serverlogfile = DEFAULT_LOGFILE

Definition at line 210 of file tftpd.c.

◆ serverlogslocked

int serverlogslocked = 0
static

Definition at line 212 of file tftpd.c.

◆ timeout

unsigned int timeout
static

Definition at line 202 of file tftpd.c.

◆ wrotepidfile

int wrotepidfile = 0
static

Definition at line 213 of file tftpd.c.

EBADID
#define EBADID
Definition: tests/server/tftp.h:57
EACCESS
#define EACCESS
Definition: tests/server/tftp.h:54
ENOTFOUND
#define ENOTFOUND
Definition: tests/server/tftp.h:53
EEXISTS
#define EEXISTS
Definition: tests/server/tftp.h:58
EBADOP
#define EBADOP
Definition: tests/server/tftp.h:56
ENOUSER
#define ENOUSER
Definition: tests/server/tftp.h:59
ENOSPACE
#define ENOSPACE
Definition: tests/server/tftp.h:55
EUNDEF
#define EUNDEF
Definition: tests/server/tftp.h:52


rc_tagdetect_client
Author(s): Monika Florek-Jasinska , Raphael Schaller
autogenerated on Sun May 15 2022 02:25:02