Unison Help
- Unison Kernel
- Pthreads
- pthread_create()
- pthread_exit()
- pthread_self()
- pthread_equal()
- pthread_join()
- pthread_detach()
- pthread_setschedparam()
- pthread_getschedparam()
- pthread_attr_init()
- pthread_attr_destroy()
- pthread_attr_setstackaddr()
- pthread_attr_getstackaddr()
- pthread_attr_setstacksize()
- pthread_attr_getstacksize()
- pthread_attr_setschedparam()
- pthread_attr_getschedparam()
- pthread_attr_setdetachstate()
- pthread_attr_getdetachstate()
- pthread_stackinfo()
- pthread_setprio()
- pthread_getprio()
- sched_get_priority_max()
- sched_get_priority_min()
- sched_yield()
- Pthread Cancellation
- Mutex
- Semaphores
- Message Queues
- Conditional Variables
- Barriers
- Timers
- Clocks
- Memory Allocation
- Rendezvous
- Interrupts
- Directory Services
- Miscellaneous
- Pthreads
- Unison I/O Library
- Unison STDIO Library
- STDIO Library Calls
- clearerr()
- dprintf()
- fclose()
- fdopen()
- feof()
- ferror()
- fileno()
- fflush()
- fgetc()
- fgetpos()
- fgets()
- fopen()
- fprintf()
- fputc()
- fputs()
- fread()
- freopen()
- fscanf()
- fseek()
- fseeko()
- fsetpos()
- ftell()
- ftello()
- fwrite()
- getc()
- getc_unlocked()
- getchar()
- getchar_unlocked()
- getdelim()
- getline()
- gets()
- get_stderr_ptr()
- get_stdin_ptr()
- get_stdout_ptr()
- noperprintf()
- perprintf()
- perror()
- posix_compat()
- printf()
- putc()
- putc_unlocked()
- putchar()
- putchar_unlocked()
- puts()
- remove()
- rewind()
- scanf()
- setbuf()
- setvbuf()
- snprintf()
- sprintf()
- sscanf()
- stderr_init()
- stderr_close()
- stdin_init()
- stdin_close()
- stdout_init()
- stdout_close()
- vdprintf()
- vscanf()
- vsscanf()
- vfscanf()
- vprintf()
- vsnprintf()
- vsprintf()
- vfprintf()
- ungetc()
- Do-nothing Stubs
- STDIO Library Calls
- Unison LIBC Library
- Unison I/O Servers
- Graphics, Camera, Video, Audio
- Network Protocols
- TCP and UDP Server - tcpd
- DHCP Client Service - dhcp client
- DHCP Server - dhcpd
- Telnet Server - telnetd
- Tiny FTP Server - tftpd
- Point to Point - pppd
- Network Translation - NAT with PAT
- Firewall
- Tiny HTTP Server - thttpd
- Tiny HTTP Server with TLS
- POP3 Server
- Simple Mail Transfer Protocol Services (SMTP)
- Bootp Protocol
- File Transfer Protocol Server (FTP)
- File Transfer Client Services
- RPC / XDR
- DNS Client
- HTTP/HTTPS Client
- REST Client
- AutoIP Service - autoip client
- mDNS server - mdnsd
- SNTP Client
- SNMP Agent - Snmpd server
- SSL/TLS library
- SSH server
- IP security
- Power Control
- Serial I/O
- System Services
- Universal Serial Bus (USB)
- Wireless
- Remedy Tools for Unison
7.5.Tiny FTP Server - tftpd #
NAME
TFTP Server – tftpd
SYNOPSIS
- void tftpd_main(char *msg, uint_32 arg<strong)>); </strong)>
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 acknowledgement 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(void *arg) { tftpd_main(FSYS_MOUNT, 0); }
For dual stack:
THREAD tftp_shell(void *arg) { tftpd_main(FSYS_MOUNT, TFTPD_IP_VER); }
This partial example shows the creation and registration of the tftpd server under old tcp stack. 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*(*)(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.