\begin{flushleft}
{\small
\verb%libcomm.c(3)                                         libcomm.c(3)%\\
\verb%%\\
\verb%%\\
\verb%%\\
\verb%%{\large NAME}\verb%%\\
\verb%       libcomm.c - Main part of libcomm.%\\
\verb%%\\
\verb%%{\large SYNOPSIS}\verb%%\\
\verb%       #include <stdio.h>%\\
\verb%       #include <stdlib.h>%\\
\verb%       #include <sys/types.h>%\\
\verb%       #include <sys/socket.h>%\\
\verb%       #include <sys/time.h>%\\
\verb%       #include <unistd.h>%\\
\verb%       #include <sys/poll.h>%\\
\verb%       #include <string.h>%\\
\verb%       #include 'libcomm.h'%\\
\verb%       #include 'md5.h'%\\
\verb%       #include <pthread.h>%\\
\verb%       #include <netinet/in.h>%\\
\verb%       #include <netdb.h>%\\
\verb%       #include <arpa/inet.h>%\\
\verb%%\\
\verb%%\\
\verb%   %{\large Functions}\verb%%\\
\verb%       void %{\large socket\_accept\_thread }\verb%(struct %{\large LIBCOMMPTHREADP}\verb%%\\
\verb%           *libcommpthreadp)%\\
\verb%           %\underline{\tt This is a part of }\verb%%{\large socket\_accept}\verb%%\underline{\tt () and must not called}\verb%%\\
\verb%           %\underline{\tt from the user.}\verb%%\\
\verb%       %{\large int socket\_accept (int sockport, int id,}\verb%%\\
\verb%           %{\large void(*socket\_accept\_do)(int fd, int id, char *pip,}\verb%%\\
\verb%           %{\large struct sockaddr\_in their\_addr))}\verb%%\\
\verb%           %\underline{\tt Start a new thread, wait for connections and start}\verb%%\\
\verb%           %\underline{\tt socket}\verb%%{\large \_}\verb%%\underline{\tt accept}\verb%%{\large \_}\verb%%\underline{\tt do() when someone connects.}\verb%%\\
\verb%       %{\large int socket\_bind (int port, int cqueue)}\verb%%\\
\verb%           %\underline{\tt Bind a socket to a port (Server side).}\verb%%\\
\verb%       %{\large int socket\_connect (char *host, int port)}\verb%%\\
\verb%           %\underline{\tt Connect a TCP-stream to a server (Client side).}\verb%%\\
\verb%       %{\large char * block\_random (char *buf, int size)}\verb%%\\
\verb%           %\underline{\tt Get random numbers/bytes.}\verb%%\\
\verb%       %{\large void thread1 (struct LIBCOMMPTHREADS *libcommpthreads)}\verb%%\\
\verb%           %\underline{\tt This is a part of }\verb%%{\large block\_call}\verb%%\underline{\tt () and must not called}\verb%%\\
\verb%           %\underline{\tt from the user.}\verb%%\\
\verb%       %{\large int block\_call (int fd, int id, int term,}\verb%%\\
\verb%           %{\large void(*block\_call\_do)(int fd, int id, unsigned int}\verb%%\\
\verb%           %{\large type, char *buf, unsigned int size, int term),}\verb%%\\
\verb%           %{\large void(*block\_call\_term)(int fd, int id))}\verb%%\\
\verb%           %\underline{\tt Waits in a new thread for a datablock to be received}\verb%%\\
\verb%           %\underline{\tt and calls the function block}\verb%%{\large \_}\verb%%\underline{\tt call}\verb%%{\large \_}\verb%%\underline{\tt do() if this event}\verb%%\\
\verb%           %\underline{\tt occurs or block}\verb%%{\large \_}\verb%%\underline{\tt call}\verb%%{\large \_}\verb%%\underline{\tt term() when the connection}\verb%%\\
\verb%           %\underline{\tt terminates.}\verb%%\\
\verb%       %{\large int block\_ifdata (int fd)}\verb%%\\
\verb%           %\underline{\tt This function tests if new data is available to read}\verb%%\\
\verb%           %\underline{\tt on a stream.}\verb%%\\
\verb%       %{\large char * block\_receive\_poll (int fd, unsigned int *type,}\verb%%\\
\verb%           %{\large char *buf, unsigned int *size, unsigned int maxsize,}\verb%%\\
\verb%           %{\large int term)}\verb%%\\
\verb%           %\underline{\tt Test if is there data available on the socket's input}\verb%%\\
\verb%           %\underline{\tt buffer and starts receiving a block if there is.}\verb%%\\
\verb%       %{\large char * block\_receive (int fd, unsigned int *type, char}\verb%%\\
\verb%           %{\large *buf, unsigned int *size, unsigned int maxsize, int}\verb%%\\
\verb%           %{\large term)}\verb%%\\
\verb%           %\underline{\tt Receive a block (composition of: type, size of}\verb%%\\
\verb%           %\underline{\tt datablock and datablock) from a socket.}\verb%%\\
\verb%       %{\large int block\_receive\_integer (int fd, unsigned int *recvi)}\verb%%\\
\verb%           %\underline{\tt Receive an integer (two bytes; 16Bit) from the socket.}\verb%%\\
\verb%       %{\large int block\_receive\_nbytes (int fd, char *buf, int n)}\verb%%\\
\verb%           %\underline{\tt Receive n bytes from socket.}\verb%%\\
\verb%       %{\large int block\_send (int fd, unsigned int type, char *buf,}\verb%%\\
\verb%           %{\large unsigned int size)}\verb%%\\
\verb%           %\underline{\tt Send a block (composition of: type, size of datablock}\verb%%\\
\verb%           %\underline{\tt and datablock (buf)) to a socket.}\verb%%\\
\verb%       %{\large void free\_authinfo (struct AUTHINFO *destroy)}\verb%%\\
\verb%           %\underline{\tt Free the memory space which is used by an }\verb%%{\large AUTHINFO}\verb%%\\
\verb%           %\underline{\tt structure.}\verb%%\\
\verb%       %{\large int socket\_md5auth (int fd, char *netname, char *name,}\verb%%\\
\verb%           %{\large struct AUTHINFO **plocallogin, struct AUTHINFO}\verb%%\\
\verb%           %{\large **premotelogin)}\verb%%\\
\verb%           %\underline{\tt Do both side authentification.}\verb%%\\
\verb%       %{\large AUTHINFO * getauthinfo (char *netname, char *name)}\verb%%\\
\verb%           %\underline{\tt Load authentication informations (netname, name,}\verb%%\\
\verb%           %\underline{\tt passwd, keyencrypt, keydecrypt) from authfile.}\verb%%\\
\verb%       %{\large void linemonitor\_server\_thread (struct}\verb%%\\
\verb%           %{\large LINEMONITOR\_THREAD\_DATA *linemonitor\_thread\_data)}\verb%%\\
\verb%           %\underline{\tt Thread used by }\verb%%{\large linemonitor\_server}\verb%%\underline{\tt () NOT for direct}\verb%%\\
\verb%           %\underline{\tt usage.}\verb%%\\
\verb%       %{\large int linemonitor\_server (int port, int soft\_msec, int}\verb%%\\
\verb%           %{\large hard\_msec, int wait\_msec,}\verb%%\\
\verb%           %{\large void(*linemonitor\_exception)(char *server, int port,}\verb%%\\
\verb%           %{\large int type))}\verb%%\\
\verb%           %\underline{\tt Monitor if the 'line' is fast enough: Server}\verb%%\\
\verb%           %\underline{\tt Application.}\verb%%\\
\verb%       %{\large void linemonitor\_emergencystop (int sock)}\verb%%\\
\verb%           %\underline{\tt Sends an 'Emergency Stop' to the client's side,}\verb%%\\
\verb%           %{\large linemonitor}\verb%%\underline{\tt () will produce an 'Emergency Stop'}\verb%%\\
\verb%           %\underline{\tt exception (type 4).}\verb%%\\
\verb%       %{\large int linemonitor\_thread (struct LINEMONITOR\_THREAD\_DATA}\verb%%\\
\verb%           %{\large *linemonitor\_thread\_data)}\verb%%\\
\verb%           %\underline{\tt Thread used by }\verb%%{\large linemonitor}\verb%%\underline{\tt () NOT for direct usage.}\verb%%\\
\verb%       %{\large int linemonitor (char *server, int port, int soft\_msec,}\verb%%\\
\verb%           %{\large int hard\_msec, int wait\_msec,}\verb%%\\
\verb%           %{\large void(*linemonitor\_exception)(char *server, int port,}\verb%%\\
\verb%           %{\large int type))}\verb%%\\
\verb%           %\underline{\tt Monitor if the 'line' is fast enough: Client/Robot}\verb%%\\
\verb%           %\underline{\tt Application.}\verb%%\\
\verb%%\\
\verb%%{\large DETAILED DESCRIPTION}\verb%%\\
\verb%       Main part of libcomm.%\\
\verb%%\\
\verb%%\\
\verb%%\\
\verb%%{\large FUNCTION DOCUMENTATION}\verb%%\\
\verb%   %{\large int block\_call (int fd, int id, int term, void(*}\verb%%\\
\verb%       %{\large block\_call\_do)(int fd, int id, unsigned int type, char}\verb%%\\
\verb%       %{\large *buf, unsigned int size, int term), void(*}\verb%%\\
\verb%       %{\large block\_call\_term)(int fd, int id))}\verb%%\\
\verb%       Waits in a new thread for a datablock to be received and%\\
\verb%       calls the function block_call_do() if this event occurs or%\\
\verb%       block_call_term() when the connection terminates.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) descriptor of socket%\\
\verb%%\\
\verb%       %\underline{\tt id}\verb%     (int) arbitrary id of background process / thread%\\
\verb%%\\
\verb%       %\underline{\tt term}\verb%   (int) 0: do not terminate the buffer, 1: terminate%\\
\verb%              the buffer by appending a 0x00.%\\
\verb%%\\
\verb%       %\underline{\tt block}\verb%%{\large \_}\verb%%\underline{\tt call}\verb%%{\large \_}\verb%%\underline{\tt do}\verb%%\\
\verb%              (int fd, int id, unsigned int type, char *buf,%\\
\verb%              unsigned int size, int term) (function) this%\\
\verb%              function is called if a datablock was received. fd,%\\
\verb%              id and term are the same as in %{\large block\_call}\verb%(). type%\\
\verb%              describes the type of the received datablock, buf%\\
\verb%              is a pointer to this datablock and size is the%\\
\verb%              number of bytes of the datablock%\\
\verb%%\\
\verb%       %\underline{\tt block}\verb%%{\large \_}\verb%%\underline{\tt call}\verb%%{\large \_}\verb%%\underline{\tt term}\verb%%\\
\verb%              (int fd, int id) (function) this function is called%\\
\verb%              if the connection terminates. fd and id are the%\\
\verb%              same as in %{\large block\_call}\verb%().%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           If all right zero otherwise non zero.%\\
\verb%%\\
\verb%   %{\large int block\_ifdata (int fd)}\verb%%\\
\verb%       This function tests if new data is available to read on a%\\
\verb%       stream.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) discriptor of stream to test%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (int) 1: Data to read; 0: No data to read%\\
\verb%%\\
\verb%   %{\large char* block\_random (char * buf, int size)}\verb%%\\
\verb%       Get random numbers/bytes.%\\
\verb%%\\
\verb%       This function reads random numbers/bytes from /dev/urandom%\\
\verb%       and stores this bytes in a buffer.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt buf}\verb%    (char *) in which the bytes will be stored. If this%\\
\verb%              parameter is equal to NULL dynamic memory will be%\\
\verb%              allocated.%\\
\verb%%\\
\verb%       %\underline{\tt size}\verb%   an integer, specifies ths size of the buffer (the%\\
\verb%              number of the random bytes). WARNING: If buf is not%\\
\verb%              equal to null, n*(size) bytes will be stored in%\\
\verb%              this buffer without any check of ths size of this%\\
\verb%              buf.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (char *) a pointer to the buffer in which the random%\\
\verb%           bytes are stored.%\\
\verb%%\\
\verb%   %{\large char* block\_receive (int fd, unsigned int * type, char * buf,}\verb%%\\
\verb%       %{\large unsigned int * size, unsigned int maxsize, int term)}\verb%%\\
\verb%       Receive a block (composition of: type, size of datablock%\\
\verb%       and datablock) from a socket.%\\
\verb%%\\
\verb%       Waits for a block to be received completely. WARNING: The%\\
\verb%       integers (type and size; excluding fd) are only 16 bit%\\
\verb%       values (0 - 65535).%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) descriptor of socket%\\
\verb%%\\
\verb%       %\underline{\tt type}\verb%   (unsigned int *) pointer to integer, this value can%\\
\verb%              be used as buyer's option%\\
\verb%%\\
\verb%       %\underline{\tt buf}\verb%    (char *) buffer for datablock. Memory will be%\\
\verb%              allocated if this parameter is equal to null.%\\
\verb%%\\
\verb%       %\underline{\tt size}\verb%   (unsigned int *) pointer to integer in which the%\\
\verb%              size of the received datablock is saved.%\\
\verb%%\\
\verb%       %\underline{\tt maxsize}\verb%%\\
\verb%              (unsigned int *) describes size of buf. This%\\
\verb%              parameter will be ignored if buf is equal to null.%\\
\verb%%\\
\verb%       %\underline{\tt term}\verb%   (int) 0: do not terminate the buffer, 1: terminate%\\
\verb%              the buffer by appending a 0x00.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (char *) pointer to buffer which contains the received%\\
\verb%           datablock; NULL if fail.%\\
\verb%%\\
\verb%   %{\large int block\_receive\_integer (int fd, unsigned int * recvi)}\verb%%\\
\verb%       Receive an integer (two bytes; 16Bit) from the socket.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) descriptor of socket%\\
\verb%%\\
\verb%       %\underline{\tt recvi}\verb%  (unsigned int *) pointer to integer in which the%\\
\verb%              received integer is saved.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (int) 2: OK; -1: fail%\\
\verb%%\\
\verb%   %{\large int block\_receive\_nbytes (int fd, char * buf, int n)}\verb%%\\
\verb%       Receive n bytes from socket.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (integer) descriptor of socket%\\
\verb%%\\
\verb%       %\underline{\tt buf}\verb%    (char *) buffer for saving the received bytes%\\
\verb%%\\
\verb%       %\underline{\tt n}\verb%      (integer) number of bytes to receive%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (integer) n: OK; -1 fial%\\
\verb%%\\
\verb%   %{\large char* block\_receive\_poll (int fd, unsigned int * type, char *}\verb%%\\
\verb%       %{\large buf, unsigned int * size, unsigned int maxsize, int term)}\verb%%\\
\verb%       Test if is there data available on the socket's input%\\
\verb%       buffer and starts receiving a block if there is.%\\
\verb%%\\
\verb%       WARNING: The integers (type and size; excluding fd) are%\\
\verb%       only 16 bit values (0 - 65535).%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) descriptor of socket%\\
\verb%%\\
\verb%       %\underline{\tt type}\verb%   (unsigned int *) pointer to integer, this value can%\\
\verb%              be used as buyer's option%\\
\verb%%\\
\verb%       %\underline{\tt buf}\verb%    (char *) buffer for datablock. Memory will be%\\
\verb%              allocated if this parameter is equal to null.%\\
\verb%%\\
\verb%       %\underline{\tt size}\verb%   (unsigned int *) pointer to integer in which the%\\
\verb%              size of the received datablock is saved.%\\
\verb%%\\
\verb%       %\underline{\tt maxsize}\verb%%\\
\verb%              (unsigned int *) describes size of buf. This%\\
\verb%              parameter will be ignored if buf is equal to null.%\\
\verb%%\\
\verb%       %\underline{\tt term}\verb%   (int) 0: do not terminate the buffer, 1: terminate%\\
\verb%              the buffer by appending a 0x00.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (char *) pointer to buffer which contains the received%\\
\verb%           datablock; NULL if fail; 1 if no data available.%\\
\verb%%\\
\verb%   %{\large int block\_send (int fd, unsigned int type, char * buf,}\verb%%\\
\verb%       %{\large unsigned int size)}\verb%%\\
\verb%       Send a block (composition of: type, size of datablock and%\\
\verb%       datablock (buf)) to a socket.%\\
\verb%%\\
\verb%       The function blocks until the whole block is transfered to%\\
\verb%       the buffer. If the buffer is full, data has to be sent%\\
\verb%       first. WARNING: The integers (type and size; excluding fd)%\\
\verb%       are only 16 bit values (0 - 65535).%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) descriptor of the socket to which buf should%\\
\verb%              send%\\
\verb%%\\
\verb%       %\underline{\tt type}\verb%   (unsigned int) This value can be used as buyer's%\\
\verb%              option%\\
\verb%%\\
\verb%       %\underline{\tt buf}\verb%    (char *) which should be send%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           number of sent bytes, -1 if an error is occurt.%\\
\verb%%\\
\verb%   %{\large void free\_authinfo (struct AUTHINFO * destroy)}\verb%%\\
\verb%       Free the memory space which is used by an %{\large AUTHINFO}\verb%%\\
\verb%       structure.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt struct }\verb%%{\large AUTHINFO }\verb%*) pointer to structure to destroy.%\\
\verb%%\\
\verb%   %{\large struct AUTHINFO* getauthinfo (char * netname, char * name)}\verb%%\\
\verb%       Load authentication informations (netname, name, passwd,%\\
\verb%       keyencrypt, keydecrypt) from authfile.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt netname}\verb%%\\
\verb%              (char *) specify the network name (may IP). NULL%\\
\verb%              not specified.%\\
\verb%%\\
\verb%       %\underline{\tt name}\verb%   (char *) specity the login name. NULL not%\\
\verb%              specified.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (struct %{\large AUTHINFO }\verb%*) the first entry from authfile%\\
\verb%           which matches network name OR login name. If both%\\
\verb%           values are NULL, the first entry of the authfile is%\\
\verb%           given back.%\\
\verb%%\\
\verb%   %{\large int linemonitor (char * server, int port, int soft\_msec, int}\verb%%\\
\verb%       %{\large hard\_msec, int wait\_msec, void(*}\verb%%\\
\verb%       %{\large linemonitor\_exception)(char *server, int port, int type))}\verb%%\\
\verb%       Monitor if the 'line' is fast enough: Client/Robot%\\
\verb%       Application.%\\
\verb%%\\
\verb%       This function opens a socket stream, sents pings/bytes and%\\
\verb%       wait for them to come back. The soft-timeout will called%\\
\verb%       after soft_msec is timeouted. The hard-timeout will called%\\
\verb%       after soft-timeout was called AND hard_msec is timeouted.%\\
\verb%       wait_msec specifies the time which is waited after a ping%\\
\verb%       is received befor the next one will be launched.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt server }\verb%(char *) server to be connected%\\
\verb%%\\
\verb%       %\underline{\tt port}\verb%   (int) port to be connected%\\
\verb%%\\
\verb%       %\underline{\tt soft}\verb%%{\large \_}\verb%%\underline{\tt msec}\verb%%\\
\verb%              (int) timeout in milliseconds which causes soft-%\\
\verb%              real-time exception.%\\
\verb%%\\
\verb%       %\underline{\tt hard}\verb%%{\large \_}\verb%%\underline{\tt msec}\verb%%\\
\verb%              (int) timeout in milliseconds which causes hard-%\\
\verb%              real-time exception.%\\
\verb%%\\
\verb%       %\underline{\tt wait}\verb%%{\large \_}\verb%%\underline{\tt msec}\verb%%\\
\verb%              (int) timeout for resent -- sending of the next%\\
\verb%              ping.%\\
\verb%%\\
\verb%       %\underline{\tt linemonitor}\verb%%{\large \_}\verb%%\underline{\tt exception}\verb%%\\
\verb%              (pointer to function) This function will be called%\\
\verb%              if an exception occurs. It becomes the following%\\
\verb%              parameters: server name (char *) which is always%\\
\verb%              null, port (int): listend port and type (int) of%\\
\verb%              exception which can be: 0: Connicion Fault, 1: Soft%\\
\verb%              Real Time Exception, 2: HARD Real Time Exception,%\\
\verb%              3: Transmission Fault, 4: Emergency Stop.%\\
\verb%%\\
\verb%   %{\large void linemonitor\_emergencystop (int sock)}\verb%%\\
\verb%       Sends an 'Emergency Stop' to the client's side,%\\
\verb%       %{\large linemonitor}\verb%() will produce an 'Emergency Stop' exception%\\
\verb%       (type 4).%\\
\verb%%\\
\verb%%\\
\verb%   %{\large int linemonitor\_server (int port, int soft\_msec, int}\verb%%\\
\verb%       %{\large hard\_msec, int wait\_msec, void(*}\verb%%\\
\verb%       %{\large linemonitor\_exception)(char *server, int port, int type))}\verb%%\\
\verb%       Monitor if the 'line' is fast enough: Server Application.%\\
\verb%%\\
\verb%       This function opens a port and wait for the first%\\
\verb%       connection on this port. All data/pings which is sent by%\\
\verb%       this first connection will be sent back. The soft-timeout%\\
\verb%       will called after wait_msec AND soft_msec is timeouted.%\\
\verb%       The hard-timeout will called after soft-timeout was called%\\
\verb%       AND hard_msec is timeouted.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt port}\verb%   (int) port which should be listend%\\
\verb%%\\
\verb%       %\underline{\tt soft}\verb%%{\large \_}\verb%%\underline{\tt msec}\verb%%\\
\verb%              (int) timeout in milliseconds which causes soft-%\\
\verb%              real-time exception.%\\
\verb%%\\
\verb%       %\underline{\tt hard}\verb%%{\large \_}\verb%%\underline{\tt msec}\verb%%\\
\verb%              (int) timeout in milliseconds which causes hard-%\\
\verb%              real-time exception.%\\
\verb%%\\
\verb%       %\underline{\tt wait}\verb%%{\large \_}\verb%%\underline{\tt msec}\verb%%\\
\verb%              (int) timeout for resent -- sending of the next%\\
\verb%              ping.%\\
\verb%%\\
\verb%       %\underline{\tt linemonitor}\verb%%{\large \_}\verb%%\underline{\tt exception}\verb%%\\
\verb%              (pointer to function) This function will be called%\\
\verb%              if an exception occurs. It becomes the following%\\
\verb%              parameters: server name (char *) which is always%\\
\verb%              null, port (int): listend port and type (int) of%\\
\verb%              exception which can be: 0: Connicion Fault, 1: Soft%\\
\verb%              Real Time Exception, 2: HARD Real Time Exception.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (int) Filediscriptor to the used socket. Only for%\\
\verb%           usage with %{\large linemonitor\_emergencystop}\verb%().%\\
\verb%%\\
\verb%   %{\large void linemonitor\_server\_thread (struct LINEMONITOR\_THREAD\_DATA}\verb%%\\
\verb%       %{\large * linemonitor\_thread\_data)}\verb%%\\
\verb%       Thread used by %{\large linemonitor\_server}\verb%() NOT for direct usage.%\\
\verb%%\\
\verb%%\\
\verb%   %{\large int linemonitor\_thread (struct LINEMONITOR\_THREAD\_DATA *}\verb%%\\
\verb%       %{\large linemonitor\_thread\_data)}\verb%%\\
\verb%       Thread used by %{\large linemonitor}\verb%() NOT for direct usage.%\\
\verb%%\\
\verb%%\\
\verb%   %{\large int socket\_accept (int sockport, int id, void(*}\verb%%\\
\verb%       %{\large socket\_accept\_do)(int fd, int id, char *pip, struct}\verb%%\\
\verb%       %{\large sockaddr\_in their\_addr))}\verb%%\\
\verb%       Start a new thread, wait for connections and start%\\
\verb%       socket_accept_do() when someone connects.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt sockport}\verb%%\\
\verb%              (int) descriptor of a tcp socket/port from%\\
\verb%              %{\large socket\_bind}\verb%()%\\
\verb%%\\
\verb%       %\underline{\tt id}\verb%     (int) arbitrary id of background process / thread.%\\
\verb%              (May be it is a good idea to use the portnumber.)%\\
\verb%%\\
\verb%       %\underline{\tt aocket}\verb%%{\large \_}\verb%%\underline{\tt accept}\verb%%{\large \_}\verb%%\underline{\tt do}\verb%%\\
\verb%              (int fd, int id, char *pip, struct sockaddr_in%\\
\verb%              their_addr) (function) this function is called if%\\
\verb%              somebody connects. fd is the descriptor of the new%\\
\verb%              socket to the connected tcp-tream. id is the same%\\
\verb%              as in %{\large socket\_accept}\verb%(). pip contains the ip-address%\\
\verb%              of the connected client. The structure their_addr%\\
\verb%              contails all known information about the connected%\\
\verb%              client.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           If all right zero otherwise non zero.%\\
\verb%%\\
\verb%   %{\large void socket\_accept\_thread (struct LIBCOMMPTHREADP *}\verb%%\\
\verb%       %{\large libcommpthreadp)}\verb%%\\
\verb%       This is a part of %{\large socket\_accept}\verb%() and must not called from%\\
\verb%       the user.%\\
\verb%%\\
\verb%       This function is the thread which is started from%\\
\verb%       %{\large socket\_accept}\verb%() and runs in background.%\\
\verb%%\\
\verb%   %{\large int socket\_bind (int port, int cqueue)}\verb%%\\
\verb%       Bind a socket to a port (Server side).%\\
\verb%%\\
\verb%       This function creates a socket and binds it to a local%\\
\verb%       port.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt port}\verb%   an integer which specifies the port%\\
\verb%%\\
\verb%       %\underline{\tt cqueue }\verb%an integer how many pending connections queue will%\\
\verb%              hold in the waiting queue.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           The File Descriptor (FD) which allows access to the%\\
\verb%           bound port.%\\
\verb%%\\
\verb%   %{\large int socket\_connect (char * host, int port)}\verb%%\\
\verb%       Connect a TCP-stream to a server (Client side).%\\
\verb%%\\
\verb%       Creates a socket and connect it over a TCP-stream to the%\\
\verb%       specified port on the specified server.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt host}\verb%   a string (char *) which specifies the name or the%\\
\verb%              IP-address of the server.%\\
\verb%%\\
\verb%       %\underline{\tt port}\verb%   an integer which specifies the port on the server.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           The File Descriptor (FD) which allows access to the%\\
\verb%           TCP-stream-socket or -1 if the connection fails.%\\
\verb%%\\
\verb%   %{\large int socket\_md5auth (int fd, char * netname, char * name,}\verb%%\\
\verb%       %{\large struct AUTHINFO ** plocallogin, struct AUTHINFO **}\verb%%\\
\verb%       %{\large premotelogin)}\verb%%\\
\verb%       Do both side authentification.%\\
\verb%%\\
\verb%       This function is usually called just after a socket stream%\\
\verb%       is established. The function must be called on both sides.%\\
\verb%%\\
\verb%       WARNING: This authentication can be bypassed simply by%\\
\verb%       using the multiple session attack if multiple session are%\\
\verb%       allowd and the same password is used for both sides.%\\
\verb%%\\
\verb%       Both sides following these steps:%\\
\verb%%\\
\verb%       1. get auth info ([login] name, passwd) by using%\\
\verb%       %{\large getauthinfo}\verb%() from name or netname for remote login%\\
\verb%%\\
\verb%       2. generate random numbers%\\
\verb%%\\
\verb%       3. exchange (first send, then receive) login names%\\
\verb%%\\
\verb%       4. exchange random numbers%\\
\verb%%\\
\verb%       5. calculate md5 checksum over the random numbers%\\
\verb%       (received from other side) and the remote passwd.%\\
\verb%%\\
\verb%       6. exchange md5 checksums%\\
\verb%%\\
\verb%       7. get auth info from name (received from other side) for%\\
\verb%       local login%\\
\verb%%\\
\verb%       8. calculate md5 checksum over the local random numbers%\\
\verb%       and the local passwd.%\\
\verb%%\\
\verb%       9. check login -- compare the received md5sum (6.) with%\\
\verb%       the generated one (8.); send acknowledgement%\\
\verb%%\\
\verb%       10. receive remote acknowledgement%\\
\verb%%\\
\verb%       11. return suitable values%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt fd}\verb%     (int) describes the socket on which the%\\
\verb%              authentication has to be done%\\
\verb%%\\
\verb%       %\underline{\tt netname}\verb%%\\
\verb%              (char *) use netname to resolve [login] name and%\\
\verb%              passwd of the remote machine (NULL: not specified)%\\
\verb%%\\
\verb%       %\underline{\tt netname}\verb%%\\
\verb%              (char *) use [login] name to resolve passwd of the%\\
\verb%              remote machine (NULL: not specified; both NULL use%\\
\verb%              first entry in file, see %{\large getauthinfo}\verb%())%\\
\verb%%\\
\verb%       %\underline{\tt plocallogin}\verb%%\\
\verb%              (struct %{\large AUTHINFO }\verb%**) (pointer to pointer to an%\\
\verb%              %{\large AUTHINFO }\verb%struct) in this (double pointed) struct%\\
\verb%              the local authinfo will be loaded, if the parameter%\\
\verb%              is not null.%\\
\verb%%\\
\verb%       %\underline{\tt premotelogin}\verb%%\\
\verb%              (struct %{\large AUTHINFO }\verb%**) in this (double pointed)%\\
\verb%              struct the remote authinfo will be loaded, if the%\\
\verb%              parameter is not null.%\\
\verb%%\\
\verb%       %{\large Returns:}\verb%%\\
\verb%           (int) 0: Authentication/Login OK; -1: remote login%\\
\verb%           error; -2: login error on both sides; -3: local login%\\
\verb%           error; -4: other (network) error; -5: cannot load%\\
\verb%           remote auth info; -6: cannot load local auth info;%\\
\verb%%\\
\verb%   %{\large void thread1 (struct LIBCOMMPTHREADS * libcommpthreads)}\verb%%\\
\verb%       This is a part of %{\large block\_call}\verb%() and must not called from%\\
\verb%       the user.%\\
\verb%%\\
\verb%       This function is the thread which is started from%\\
\verb%       %{\large block\_call}\verb%() and runs in background.%\\
\verb%%\\
\verb%       Parameters:%\\
\verb%%\\
\verb%       %\underline{\tt libcommpthreads}\verb%%\\
\verb%              (struct %{\large LIBCOMMPTHREADS }\verb%*) holds pointers to the%\\
\verb%              functions to be call, fd (socket discriptor) and%\\
\verb%              id.%\\
\verb%%\\
\verb%%{\large AUTHOR}\verb%%\\
\verb%       Generated automatically by Doxygen for%\\
\verb%       Hofmeier_FYP:libcomm from the source code.%\\
\verb%%\\
\verb%%\\
\verb%%\\
\verb%Hofmeier_FYP:libcomm       25 Apr 2005               libcomm.c(3)%\\
\verb%%
}
\end{flushleft}
