Skip to content

Commit

Permalink
[nes]: STP changes ...
Browse files Browse the repository at this point in the history
  • Loading branch information
nes-repo committed May 8, 2015
1 parent e009f20 commit ec198cd
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions stp/stp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
#include "stp_defines.h"
#include "switch_ext.h"

#include "lib/bitmap.h"
#include "lib/sync.h"
#include "lib/message.h"
#include "lib/thread.h"


Expand All @@ -41,6 +44,8 @@ static xThreadInfo_t oStpThread =
.poStart = &stp_start,
};

static xMessageQueue_t *poStpMessageQueue = NULL;


void *
stp_main (
Expand All @@ -49,6 +54,11 @@ stp_main (
ieee8021SpanningTreeMib_init ();
ieee8021MstpMib_init ();

if ((poStpMessageQueue = xMessageQueue_create (oStpThread.u32Index)) == NULL)
{
return NULL;
}

if (xThread_create (&oStpThread) == NULL)
{
Stp_log (xLog_err_c, "xThread_create() failed\n");
Expand All @@ -62,10 +72,44 @@ void *
stp_start (
void *pvArgv)
{
while (1)
xThread_waitPrepare (&oStpThread);

while (xThread_wait (&oStpThread, NULL))
{
xThread_sleep (1);
if (xBitmap_getBit (oStpThread.au8Flags, xThreadInfo_flagsMessage_c))
{
register xMessage_t *poMsg = NULL;

while ((poMsg = xMessageAck_getMessage (poStpMessageQueue)) != NULL)
{
/* TODO */

if (!xMessageAck_remove (poMsg, poStpMessageQueue))
{
break;
}
}

while ((poMsg = xMessageDst_getMessage (poStpMessageQueue)) != NULL)
{
/* TODO */

switch (poMsg->poMsgInfo->u32Type)
{
default:
break;
}

if (!xMessageDst_remove (poMsg, poStpMessageQueue))
{
break;
}
}

xMessage_cleanupThread (poStpMessageQueue, &oStpThread);
}
}

return NULL;
}

Expand Down

0 comments on commit ec198cd

Please sign in to comment.