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

cctalk-server.c File Reference


Detailed Description

Provide a Unix socket interface to the cctalk.

Author:
Rod Boyce
I'm still not sure about this but it will provide a multi-program interface to the cctalk sub system and that seems easy to do. So this module will look after opening a Unix named socket for access to the cctalk sub system. This module will open a socket for listening and allow up to 5 different connections. The connection will consist of a data packet that starts with a length word and then a data packet. All packets will be transfered in this way. The first X bytes received will tell the interface how many bytes to come and the packet type
Date:
20/10/04

#include <stdio.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include "cctalk-channel-defs.h"
#include "cctalk-operations.h"
#include "cctalk-channel.h"
#include "cctalk-pkts.h"
#include "cctalk-pkt-utls.h"
#include "cctalk-svr-mem.h"
#include "cctalk-socket.h"
#include "cctalk-server.h"
#include "cctalk-debug.h"

Include dependency graph for cctalk-server.c:

Include dependency graph

Defines

#define CCTALK_TIME_UNIT   (10000) /* 10mS */
#define CCTS_CAN_BECOME_SERVER   1
 Used to allow the cctalk server to fork or not.


Functions

void ccts_GetPackets (void)
 Receive packets to be processed.

void ccts_ReceivePkt2Process (int fdHandle)
 We have received the start packet magic number process the packet.

teCCTALK_ERRORS ccts_ProcessCommandPkt (tsCCT_PKT_CHANNEL_CMD *psCctCmdPkt, int fd)
 So the packet received was a command packet action it.

void ccts_SendErrorReturnPacket (int fdSock, teCCTALK_ERRORS eErr)
 Send an error return packet to the client.

void ccts_ReceiveCctalkOperation (int fdSock, teCCTALK_CHANNEL eCctCh)
 After receiving a cctalk operation processed request send a reply.

void ccts_ProcessCommandLine (int argc, char *argv[])
 Read and process the command line arguments.

void ccts_ProcessMain (void)
 This is the guts of main.

int ccts_DaemonInit (void)
 Fork off a new process and cause the parent to exit but the child lives on.

int main (int argc, char *argv[], char *env[])
 Server entry point.


Variables

char ** pacEnvoriment
char * pacCmdLineNames []
int zlMaxFds
int zlqKeepRunning = 0
int qBecomeServer = 0
char acSocketToOpen [100] = "/dev/cctalk"

Define Documentation

#define CCTS_CAN_BECOME_SERVER   1
 

Used to allow the cctalk server to fork or not.

If DEBUG is set in the makefile that the server process will not fork ever. But some debugging information is printed out by the server to check memory usage.


Function Documentation

int ccts_DaemonInit void   )  [static]
 

Fork off a new process and cause the parent to exit but the child lives on.

Called when running detached from the console. This function will fork off a new process returning the child process and exit from the parent process.

Date:
04/11/04
Author:
Rod Boyce.

History

void ccts_GetPackets void   )  [static]
 

Receive packets to be processed.

Date:
21/10/04
Author:
Rod Boyce

History

Here is the call graph for this function:

void ccts_ProcessCommandLine int  argc,
char *  argv[]
[static]
 

Read and process the command line arguments.

Process the command line arguments passed from the command line to the cctalk server.

Date:
04/11/04
Author:
Rod Boyce
Parameters:
argc - A count of command line arguments
argv - pointer to an array of pointers to the command line arguments

History

teCCTALK_ERRORS ccts_ProcessCommandPkt tsCCT_PKT_CHANNEL_CMD psCctCmdPkt,
int  fd
[static]
 

So the packet received was a command packet action it.

OK so we received a command packet so figure what the command was perform the command and return the result to the client.

Date:
22/10/04
Author:
Rod Boyce
Parameters:
psCctCmdPkt - pointer to the command packet.
Returns:
The error result from the command

History

Here is the call graph for this function:

void ccts_ProcessMain void   )  [static]
 

This is the guts of main.

This is the main process for the cctalk server. This server will control cctalk operations over many ttyS's and allow many clients to connect to it. This function exists because this server can run in two modes. The first mode is as a standard process that takes a whole console and outputs debugging information to the console. The other operational mode is as a detached server that splits itself from the console an runs in the background.

Date:
04/11/04
Author:
Rod Boyce

History

Here is the call graph for this function:

void ccts_ReceiveCctalkOperation int  fdSock,
teCCTALK_CHANNEL  eCctCh
[static]
 

After receiving a cctalk operation processed request send a reply.

Date:
27/10/04
Author:
Rod Boyce We have received a request from a client to send a finished cctalk operation back to it if there is one available. See if there is one available and send it back or send error reply saying that there are no packets from that socket and channel combination
Parameters:
fdSock - The Socket this request was received from.
eCctCh - The cctalk channel we are interest in.
Returns:

History

Here is the call graph for this function:

void ccts_ReceivePkt2Process int  fdHandle  )  [static]
 

We have received the start packet magic number process the packet.

The server has just received a packet to process to start processing the packet. Receive the rest of the header and then figure out what sort of packet it is then read the rest of the packet.

Date:
22/10/04
Author:
Rod Boyce
Parameters:
fdHandle - the socket handle the packet is being received on.

History

Here is the call graph for this function:

void ccts_SendErrorReturnPacket int  fdSock,
teCCTALK_ERRORS  eErr
[static]
 

Send an error return packet to the client.

No matter what the operation the client has to know how it went so an error reply packet is sent to inform the client what happened.

Date:
27/10/04
Author:
Rod Boyce
Parameters:
fdSock - the socket to replay to.
eErr - the error value to reply back to.
Returns:

History

Here is the call graph for this function:

main int  argc,
char *  argv[],
char *  env[]
 

Server entry point.

This is the main cctalk server program entry point

Date:
21/10/04
Author:
Rod Boyce
Parameters:
argc - count on the number of arguments passed to the cctalk server at startup
argv - An array of pointers to program arguments
env - An array of environment variables in the shell of the cctalk server
Returns:
0 on program completion

History

Here is the call graph for this function:


Variable Documentation

char acSocketToOpen[ 100 ] = "/dev/cctalk" [static]
 

Name of the socket to use for client server communication

char* pacCmdLineNames[] [static]
 

Initial value:

{
    "--become-server",
    "--use-socket",

    NULL
}

char** pacEnvoriment
 

global pointer to the environment

int qBecomeServer = 0 [static]
 

To fork or not to fork this is the answer

int zlMaxFds [static]
 

The maximum file handles a process can open

int zlqKeepRunning = 0 [static]
 

Used to keep the main loop running


Generated on Thu Jan 20 16:12:32 2005 for Axis cctalk sub-system by doxygen 1.3.6