Main Page | Data Structures | File List | Data Fields | Globals

interfaces.c File Reference

ISIS server interface routines. More...

#include "isisserver.h"
#include <readline/readline.h>
#include <readline/history.h>

Functions

int openSocket (int isisPort)
 Open and setup the ISIS server UDP network socket.
void closeSocket (int sockFD)
 Close the ISIS server socket.
int initSerialPorts ()
 Initialize the serial ports listed in the server's serial port table.
int getSerialInfo (int testFD)
 Map a serial port file descriptor onto a serial port table index.
void handShake ()
 Handshake with the clients on serial ports and preset UDP ports.
void serialHandler (int serialFD)
 Handle input from server serial ports.
void socketHandler (int sockFD)
 Handle input from a network client socket.
void ttyHandler (char *ttyStr)
 Handle input from the command line (readline callback function).


Detailed Description

ISIS server interface routines.

... description of the ISIS server interfaces ...

Three basic routines are provided for handling input message traffic on the various server interfaces:


Function Documentation

int openSocket int  isisPort  ) 
 

Open and setup the ISIS server UDP network socket.

Parameters:
isisPort Port number on localhost for the server socket.
Returns:
0 if successful, -1 if errors occurred.
Creates a UDP socket for the ISIS server applications and sets the file descriptor in the system table. It then binds the socket to the named port on localhost, and stores relevant information in the ISIS system table for future use without having to use thread-unsafe getxxx calls.

Errors are reported to stdout by this routine.

See also:
closeSocket()

void closeSocket int  sockFD  ) 
 

Close the ISIS server socket.

Parameters:
sockFD File descriptor of the open ISIS server socket (see openSocket())
Tears down the ISIS server socket and releases the file descriptor. Currently this is little more than a convenience wrapper for close(), but someday it might do more.

See also:
openSocket()

int initSerialPorts void   ) 
 

Initialize the serial ports listed in the server's serial port table.

Returns:
Number of serial ports opened successfully, <0 if any failed.
Initializes all of the serial ports listed in the server's serial port table (ttyTab struct, defined by entries in the runtime config file). It also attempts to close them first, allowing this function to also be used to re-initialize the ports. One failure is enough to cause an abort.

int getSerialInfo int  testFD  ) 
 

Map a serial port file descriptor onto a serial port table index.

Parameters:
testFD Serial port file descriptor to map
Returns:
The serial port table index of the test file descriptor if present, otherwise it returns ERR_UNKNOWN_FD if no match is found.
Searches for testFD in the server's active serial port table, and returns the index of the port table entry if found. The serial port table is the ttyTab struct defined in the isisserver.h header file.

void handShake void   ) 
 

Handshake with the clients on serial ports and preset UDP ports.

Sends a ">AL PING" message to all open serial ports and all preset UDP ports. This is a blind broadcast that should lead to "PONG"s back from any ISIS clients on the serial lines or connected to the UDP socket ports.

This is a placeholder that gives us minimal IMPv2 software handshaking until we can work with the system some and work out better procedures.

All strings transmitted to raw ports must be in proper IMPv2-conformal format, terminated by \r (ASCII 13).

void serialHandler int  serialFD  ) 
 

Handle input from server serial ports.

Parameters:
serialFD File descriptor of the serial port with input ready.
Reads a line of input from the specified serial port file descriptor, and spits the message into components: source host ID, destination host ID, and message body (including message type).

If the source and destination are valid, and the message is not blank or malformed, it then passes the message off to HandleMessage() to route the message to its intended recipient.

When generating IMPv2 messages for direct transmission through the server, the strings must be terminated with return (\r = ASCII 13) not a newline (\n = ASCII 10).

This function is designed to be invoked by a select() loop that watches particular file descriptors. See main.c for how it is implemented.

void socketHandler int  sockFD  ) 
 

Handle input from a network client socket.

Parameters:
sockFD File descriptor of the server's socket.
Read a line of input from the specified network socket file descriptor, and parse the message into components (source host ID, destination host ID, and message body).

If the source and destination are valid, and the message is not blank or malformed, it then passes control off to handleMessage() to do the dirty work. This may permit us to enable multithreading in the future.

When generating IMPv2-compliant messages, the strings must be terminated with return (\r = ASCII 13) not a newline (\n = ASCII 10).

This function is designed to be invoked by a select() loop that watches particular file descriptors. See main.c for how it is implemented.

void ttyHandler char *  ttyStr  ) 
 

Handle input from the command line (readline callback function).

Parameters:
ttyStr pointer to the text returned by readline()
This is the callback for readline() that lets our cli make use of the GNU readline and history mechanism (arrow keys and command-line editing). The callback is installed using the rl_callback_hander_install() function of the readline library.

Once we get an error-free string we can use, we then try to interpret it. This is the main cli handler for the server.

When generating IMPv2 messages for direct transmission onto the system, the strings must be terminated with return (\r = ASCII 13) not a newline (\n = ASCII 10).


Generated on Tue Apr 16 17:04:08 2013 for ISIS Server by  doxygen 1.3.9.1