NAME

TFTP Server - tftpd

SYNOPSIS

pthread_create(&pid, &attr, &tftp_shell, 0);
THREAD tftp_shell(void)
void tftpd_main(char *msg, uint_32 arg)

DESCRIPTION

The tftp server provides a network tftp protocol and utilizes the file server technology to save or provide files. Typically, when initialized, it allows users to both read and write files over the network. It is a minimal implementation for memory reasons. It does not support advanced commands of any kind.

The tftp server waits on a socket connection for commands. When a command to either read or write a file is received, the server reads or writes the file. It has a standard error output which may be redefined to a serial stream. There is no login support.

The tftpd is launched with a shell which passes two parameters into tftp_main. The first parameter is a pointer to a string which defines the mount point of the file system which is used to save and retrieve files. The second parameter is ignored.

The tftpd only supports tftp server requests. Client requests are not supported. If a client request is required, the use of a separate tftp client is required or the use of telnet is required to transfer the files after the upload or download is completed.

Either text or data can be transferred using tftpd. There is no file length limitations and packet acknownledgement is used to guarentee correct data transfer.

RETURN CODES

The tftpd is a server and responds to server requests. These requests can generate errors and these error responses are provided through the network interface to the requesting tftp or ftp client program. A list of errors is given below.

ERRORS

ERR_UNDEF	0		/* not defined */ 
ERR_NOTFOUND	1		/* file not found */ 
ERR_ACCESS	2		/* access violation */ 
ERR_NOSPACE	3		/* disk full or allocation exceeded */
ERR_BADOP	4		/* illegal TFTP operation */ 
ERR_BADID	5		/* unknown transfer ID */ 
ERR_EXISTS	6		/* file already exists */ 
ERR_NOUSER	7		/* no such user */

EXAMPLE

tftpd initialization


#define FSYS_MOUNT /dev/rd/tftpdir

/*************************************************************************
 *  Subroutine  : tftp_shell
 *  Purpose     : Task shell for starting device specific TFTP server
 ************************************************************************/
THREAD tftp_shell()
{
	tftpd_main(FSYS_MOUNT, 0);
}

This partial example shows the creation and registration of the tftpd server. After creation, tftpd waits on the correct port for requests.


	/*
	 *
	 *   Start TFTP server
	 *
	 */
	xprintf("\n--- Start TFTP server ---\n");

	// set up stack size and priority for main TFTP thread
      pthread_attr_setstacksize(&attr, TFTPSTACKSIZE);
      myNewPriority.sched_priority = TFTPPRIO;
	pthread_attr_setschedparam(&attr, &myNewPriority);

	if(pthread_create(&tid, &attr, (void *)&tftp_shell, 0))
	{
		xprintf("..Unable to create TFTP Server..\n");
		pthread_exit((void*)1);
	}

  ...

NOTES

There is a demo available for the Unison and DSPnano tftpd server which is found in installdir/demos.

SEE ALSO

telnetd, tcpd




< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2009 >