Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

wccpd.c File Reference


Functions

int createSocket (int port)
 Create a socket for the WCCP port. More...

int getPacket (int fd, int timeout, void *buf, int len, struct sockaddr_in *from, socklen_t *fromlen)
 Get a single packet from the socket. More...

void processPacket (int fd, void *buf, int len, struct sockaddr_in *client, socklen_t *client_len)
 Process a single packet, and send a reply if applicable. More...

void main_loop (int fd)
 The main loop of the daemon. More...

int main (int argc, char **argv)
 The main function. More...


Variables

int fShutdown = 0
 The shutdown flag, incremented when the daemon receives a SIGTERM/SIGINT.


Function Documentation

int createSocket ( int port ) [static]
 

Create a socket for the WCCP port.

Parameters:
port   the port number to use.
Returns:
a socket file descriptor, or -1 if there was an error.

int getPacket ( int fd,
int timeout,
void * buf,
int len,
struct sockaddr_in * from,
socklen_t * fromlen ) [static]
 

Get a single packet from the socket.

Parameters:
fd   the socket file descriptor used to receive the packet.
timeout   wait at most this much for the next packet.
buf   the packet's data.
len   the length of the packet's data.
from   where to store the client's address.
fromlen   a pointer to store the length of the client's address.

int main ( int argc,
char ** argv )
 

The main function.

It parses options and optionally daemonizes the program. Then it creates the socket and calls main_loop.

Parameters:
argc   the number of arguments in the command line.
argv   the arguments in the command line.

void main_loop ( int fd ) [static]
 

The main loop of the daemon.

It loops until fShutdown is greater than 0. Each interaction it times-out clients, gets a packet and processes it.

Parameters:
fd   the socket file descriptor used to send/receive packets.

void processPacket ( int fd,
void * buf,
int len,
struct sockaddr_in * client,
socklen_t * client_len ) [static]
 

Process a single packet, and send a reply if applicable.

If the len is less than or equals to 0, then there was an error receiving the packet, so we should ignore the request.

Parameters:
fd   the socket file descriptor used to send the reply.
buf   the packet's data.
len   the length of the packet's data.
client   the client's address.
client_len   a pointer to the length of the client's address.


Variable Documentation

int fShutdown = 0 [static]
 

The shutdown flag, incremented when the daemon receives a SIGTERM/SIGINT.


Generated at Fri Jan 25 19:22:24 2002 for wccpd by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001