Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

protocolHandler Class Reference

#include <prohandler.h>

List of all members.

Public Methods

 protocolHandler ()
virtual ~protocolHandler ()
int add (char *pkt)
virtual void threadEntryPoint (void *arg)

Protected Methods

bool hasNext (void)
char* next (void)

Protected Attributes

int myPro

Private Attributes

pronode_ttop
pronode_tbottom
unsigned int packets


Detailed Description

Protocol Handling base class
This class must be inherited by any handler class you make
in order to work with the agent subsystem.
Test:
Test Protocol Handling subsystem

Threaded protocol handlers

Todo:
Support pluggable protocol handlers

Definition at line 60 of file prohandler.h.


Constructor & Destructor Documentation

protocolHandler::protocolHandler ( )
 

Default constructor Have any inherited classed call protocolHandler() before their constructor

Definition at line 32 of file prohandler.cpp.

00033 {
00034     //myPro = 0;
00035     packets = 0;
00036     top = bottom = NULL;
00037 }

protocolHandler::~protocolHandler ( ) [virtual]
 


Member Function Documentation

int protocolHandler::add ( char * pkt )
 

Basic packet enqueuing function Enqueues a packet pointed to by pkt into this protocolHandler's queue

Parameters:
pkt   Pointer to packet
Todo:
Include a size variable to ensure we dont smash the stack
Returns:
Number of packets now in queue

Definition at line 48 of file prohandler.cpp.

00049 {
00050     {assert(pkt != NULL);}
00051     pronode_t *newNode;
00052     agent_new(&newNode);
00053     {assert(newNode != NULL);}
00054     newNode->payload = pkt;
00055     if (top == NULL)
00056         {
00057             top = newNode;
00058             bottom = top;
00059         }
00060         else //nope
00061         {
00062             //insert at end
00063             bottom->next = newNode;
00064             newNode->prev = bottom;
00065             bottom = newNode;
00066         }
00067         packets++;
00068     return packets;
00069 }

bool protocolHandler::hasNext ( void ) [protected]
 

Check if any packets are on the queue

Returns:
true if any packets are left to dequeue

Definition at line 75 of file prohandler.cpp.

Referenced by next().

00076 {
00077     return (packets > 0);
00078 }

char * protocolHandler::next ( void ) [protected]
 

Basic packet dequeuing function Dequeues a packet from this protocolHandler's queue

Todo:
Include a size variable to ensure we dont smash the stack
Returns:
Pointer the the packet pulled off the queue or NULL if it's empty

Definition at line 88 of file prohandler.cpp.

00089 {
00090     if(!hasNext())
00091         return NULL;
00092     //top is not NULL
00093     {assert(top != NULL);}
00094     char *data;
00095     data = top->payload;
00096     top->payload = NULL;
00097     if(top == bottom)
00098     {
00099         //delete it
00100         agent_zaparr(top);
00101         top = bottom = NULL;
00102     }
00103     else
00104     {
00105         pronode_t *t = top;
00106         top->next->prev = NULL;
00107         top = top->next;
00108         t->prev = t->next = NULL;
00109         agent_zaparr(t);
00110     }
00111     packets--;
00112     return data;
00113 }

void protocolHandler::threadEntryPoint ( void * arg ) [virtual]
 


Member Data Documentation

pronode_t * protocolHandler::bottom [private]
 

Pointer to bottom of queue

Definition at line 74 of file prohandler.h.

int protocolHandler::myPro [protected]
 

my protocol number

Definition at line 71 of file prohandler.h.

unsigned int protocolHandler::packets [private]
 

Number of packets on queue

Definition at line 78 of file prohandler.h.

pronode_t * protocolHandler::top [private]
 

Pointer to top of queue

Definition at line 74 of file prohandler.h.


The documentation for this class was generated from the following files:
Generated at Thu May 30 15:12:34 2002 for Freeagent by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001