#include <prohandler.h>
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_t* | top |
pronode_t * | bottom |
unsigned int | packets |
Threaded protocol handlers
Definition at line 60 of file prohandler.h.
|
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 } |
|
|
|
Basic packet enqueuing function Enqueues a packet pointed to by pkt into this protocolHandler's 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 } |
|
Check if any packets are on the queue
Definition at line 75 of file prohandler.cpp. Referenced by next().
00076 { 00077 return (packets > 0); 00078 } |
|
Basic packet dequeuing function Dequeues a packet from this protocolHandler's queue
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 } |
|
|
|
Pointer to bottom of queue Definition at line 74 of file prohandler.h. |
|
my protocol number Definition at line 71 of file prohandler.h. |
|
Number of packets on queue Definition at line 78 of file prohandler.h. |
|
Pointer to top of queue Definition at line 74 of file prohandler.h. |