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

clients.c File Reference

Server client host table functions. More...

#include "isisserver.h"

Functions

void initHostTable ()
 Initialize the server client host table.
int updateHosts (char *hostID, int method, int fd, long addr, int port)
 Update the client host table with client info.
int removeHost (char *hostID)
 Remove an entry from the client host table.
int isKnownHost (char *hostID)
 Verify that client is a known host (i.e., in the client table).
void printHosts (char *hostID)
 Prints the server's client host table on stdout.
void hostInfo (char *hostID, char *reply)
 Report host information to a remote client.


Detailed Description

Server client host table functions.

These routines are used by the server to create and manipulate the contents of its dynamic client host table.

Functions:


Function Documentation

void initHostTable  ) 
 

Initialize the server client host table.

Initializes the contents of the ISIS client table, clearing all host entries. Must be called before filling the client table either at server startup or restart.

int updateHosts char *  hostID,
int  method,
int  fd,
long  addr,
int  port
 

Update the client host table with client info.

Parameters:
hostID new host's ID (IMPv2 format)
method new host's transport method (SERIAL, SOCKET, etc.)
fd new host's port file descriptor
addr new host's 32-bit IP address if method=SOCKET
port new host's port number if method=SOCKET
Returns:
The host table index assigned to this client if successful, or ERR_HOSTS_FULL if the host table is full.
Searches the Client Table (clientTab struct), and either adds or updates the table with the incoming host info. Because it changes the contents of global variables, this particular routine is not very thread-safe without lots of work to wrap mutex_ bits around things.

See isKnownHost() for how to test to see if a recipient is known to the system.

int removeHost char *  hostID  ) 
 

Remove an entry from the client host table.

Parameters:
hostID Name of the client host to remove
Returns:
0 if successful, or ERR_UNKNOWN_HOST if hostID was not in the table.
Removes a single host by name from the ISIS client table. See InitHostTable() for how to clear the entire table all at once.

Since the number of allowed clients is expected to remain a small number, repacking the table to remove gaps does not offer any economies at present, but someday if it is decided it is necessary, the repacking should go in this routine.

int isKnownHost char *  hostID  ) 
 

Verify that client is a known host (i.e., in the client table).

Parameters:
hostID Client host name to test
Returns:
Host table index of the recipient if valid, or HostUnknown if not.
Searches the server client table in clientTab struct, and returns the index in the host table of the named client. Called by the various message handlers attached to the select() event handler.

void printHosts char *  hostID  ) 
 

Prints the server's client host table on stdout.

Parameters:
hostID Name of the host to print. If "all", print all hosts.
Prints a table of the clients currently connected to the server onto stdout (i.e., onto the server's console window).

For output tailored for sending back to remote clients (i.e., output as an IMPv2-conformal message string), see hostInfo().

void hostInfo char *  hostID,
char *  reply
 

Report host information to a remote client.

Parameters:
hostID Name of the host of interest. If ALL, send a list of all hosts.
reply String to contain the information.
Generates an IMPv2 message string containing the info the server hass on hostID. If hostID="ALL" it will instead create a string giving a concise listing of all known hosts.

For detailed output tailored for the server's command console window (i.e., printing on stdout), see printHosts().


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