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.4.Telnet Server - telnetd #
NAME
Telnet Server – telnetd
SYNOPSIS
#include <posh_init.h>
#include < sys.h >
- pthread_create(&pid, &attr, &telnet_shell, 0);
- THREAD telnetd(int(*shell)(void));
// For dual TCP stack:
- THREAD telnetd(int(*shell)(void), int ip_ver);
DESCRIPTION
The telnet server provides a network telnet protocol and utilizes the vtty server technology and the posh shell server for user interaction via telnet. Typically, when initialized, it allows users to query files, examine the file structure, create new files and look at the content of files, all over the network. It is a minimal implementation for memory reasons. It does not support terminal formating of any kind and only supports the absolute minimal set of commands.
The telnet server inputs characters and outputs results of command requests via the network. The first character data negotiates the telnet protocol. The first command request is a login request. Unlike many implementations, the login support is contained within posh – it does not have a separate thread for this purpose. The .login file is specified at posh creation time in the initialization structure.
The posh_init initialization structure also specifies the mount points for two file systems. These mount points are important to avoid attempts to list non-existent files. Setup these mount points at creation time for proper operation. The final elements of the initalization structure are the input and output streams. These two are specified as files. The structure is shown below.
SPECIFIC OPTIONS
Dual stack options:
Option | Default | Description | Placement |
---|---|---|---|
TELNET_PORT | 23 | Port number for telnet connection | library |
TELNETD_IP_VER | 4 | IP network version: 4 – IPv4, 6 – IPv6 | demo |
EXAMPLE
Posh initialization structure.
struct set_posh { char *stdinstring; // set the input stream char *stdoutstring; // set output stream char *mountpoint; // set first file mount point char *mountpoint2; // set second file mount point char *loginfile; };
This partial example shows the creation and registration of the telnetd server and its associated vtty file I/O. After creation, posh is created which interacts via the vtty file I/O ports for input and output.
int start_posh(void); THREAD telnet_shell(void *arg) { telnetd(start_posh); }
Telnet start for dual TCP stack:
THREAD telnet_shell(void *arg) { telnetd(start_posh, TELNETD_IP_VER); return 0; //just to avoid warning } ... int start_posh(void) { struct set_posh *set_posh_tty; pthread_t poshTid; pthread_attr_t poshattr; struct sched_param poshPriority; if( (set_posh_tty = malloc(sizeof(struct set_posh)))==NULL) { xprintf("posh create - no memory\n"); return 0; } set_posh_tty->stdinstring = "/dev/vtty"; set_posh_tty->stdoutstring = "/dev/vtty"; set_posh_tty->mountpoint = "/dev/rd/d1"; set_posh_tty->mountpoint2 = NULL; set_posh_tty->loginfile = "/dev/rd/d1/.login"; pthread_attr_init(&poshattr); pthread_attr_setstacksize(&poshattr, 1400); poshPriority.sched_priority = 5; pthread_attr_setdetachstate(&poshattr, PTHREAD_CREATE_DETACHED); pthread_attr_setschedparam(&poshattr, &poshPriority); pthread_create(&poshTid, &poshattr, (void *(*)(void*))posh, set_posh_tty); pthread_attr_destroy(&poshattr); return 1; } /* * Start telnetd example */ ... pthread_attr_init(&attr); myNewPriority.sched_priority = 6; pthread_attr_setschedparam(&attr, &myNewPriority); pthread_attr_setstacksize(&attr, 1024); if(pthread_create(&pid, &attr, &telnet_shell, 0)!=0) { xprintf("pthread_create = %d\n", errno); pthread_exit(0); } pthread_attr_destroy(&attr); if(dir_register("/dev/vtty", pid, TYPE_SERVER)==0) { xprintf("dir_register = %d\n", errno); pthread_exit(0); } xprintf("\ntelnetd started!\n"); ...
TELNET – POSH COMMANDS AND OPTIONS
- help – help listing
- alias [alias_name=”value”] – setup an alias for an expression
- cat – concatenate output
- cd <dir> – change directory to <dir>
- chmod <mode> <dir | file> – change a file’s access control mode
mode – file access mode, for example “rwx”
dir | file – path to the target file to which mode is setting
- cp <src> <dst> – copy a file from <src> path to <dst> path
- exit – exit the posh shell
- ln <src> <dst> – create link to file
src – target path for link
dst – link name (with path)
- logout – logout of posh
- ls [option] – list directory contents
-l – for long list
-d – lists directories, not content
- mkdir <dir> – make a directory specified by <dir>
- mv <src> <dst> – move a file from <src> path to <dst> path
- printenv [env_name] – print all or part of environment
printenv [VARIABLE] or printenv OPTION
If VARIABLE or OPTION not specified, then all present will be printed
- pwd – present working directory
- rm <file> – remove a file
- rmdir – remove a directory
- setenv [env_name=”value”] – set an environment variable
Example: setenv PATH “/d0:/sd/d1:/sd/d1/d2”
- unalias <alias_name> – delete an alias
- useradd <username> <password> – add a user with a password
- userdel <username> – delete a user
- userpasswd <username> <oldpassword> <newpassword> – set (or reset) a user password
NOTES
There is a demo available for the Unison and DSPnano telnetd server which is found in installdir/demos.