$Author: faust $
*/
-#include <stdio.h>
+#include "debug_cap.h"
+
+#include "libpal.h"
+
+#include "stg/plugin_creator.h"
+#include "stg/traffcounter.h"
+#include "stg/common.h"
+
+#include <cstdio>
+#include <csignal>
+
#include <unistd.h>
-#include <signal.h>
#include <sys/types.h>
-#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include "libpal.h"
-#include "stg/plugin_creator.h"
-#include "stg/traffcounter.h"
-#include "debug_cap.h"
+extern volatile time_t stgTime;
//-----------------------------------------------------------------------------
void WriteStat(uint32_t u, uint32_t d)
PLUGIN_CREATOR<DEBUG_CAP> cdc;
}
-extern "C" BASE_PLUGIN * GetPlugin();
+extern "C" PLUGIN * GetPlugin();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-BASE_PLUGIN * GetPlugin()
+PLUGIN * GetPlugin()
{
return cdc.GetPlugin();
}
uint16_t len);
std::string DEBUG_CAP::GetVersion() const
{
-return "Debug_cap v.0.01a";
+return "cap_debug v.0.01a";
}
//-----------------------------------------------------------------------------
DEBUG_CAP::DEBUG_CAP()
+ : nonstop(false),
+ isRunning(false),
+ traffCnt(NULL)
{
-isRunning = false;
-nonstop = false;
}
//-----------------------------------------------------------------------------
void DEBUG_CAP::SetTraffcounter(TRAFFCOUNTER * tc)
if (!isRunning)
break;
- stgUsleep(200000);
+ usleep(200000);
//printf(".");
}
{
printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid());
-DEBUG_CAP * dc = (DEBUG_CAP *)data;
+DEBUG_CAP * dc = static_cast<DEBUG_CAP *>(data);
dc->isRunning = true;
RAW_PACKET rp;
t = stgTime;
tm = localtime(&t);
int min = tm->tm_min;
-int sec = tm->tm_sec;
char cliIP[20];
char srvIP[20];
-char trashIP1[20];
-char trashIP2[20];
while (dc->nonstop)
{
for (int i = 8; i <= 252; i++)
{
-
usize = random()%100 + 100;
- dsize = random()%500 + 900;
-
+ dsize = random()%500 + 900;
+
for (int j = 2; j < 11; j++)
{
- sprintf(cliIP, "192.168.%d.%d", j, i);
+ sprintf(cliIP, "192.168.%d.%d", j, i);
sprintf(srvIP, "10.1.%d.%d", random()%8, 1);
rp = MakeTCPPacket(srvIP, cliIP, 80, random()%2 + 2000, dsize);
{
printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid());
-DEBUG_CAP * dc = (DEBUG_CAP *)data;
+DEBUG_CAP * dc = static_cast<DEBUG_CAP *>(data);
dc->isRunning = true;
RAW_PACKET rp;
{
printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid());
-DEBUG_CAP * dc = (DEBUG_CAP *)data;
+DEBUG_CAP * dc = static_cast<DEBUG_CAP *>(data);
dc->isRunning = true;
RAW_PACKET rp;
int a = 0;
sleep(3);
-struct tm * tm;
time_t t;
uint32_t u = 0;
uint32_t d = 0;
int dsize = 1500;
t = stgTime;
-tm = localtime(&t);
char cliIP[20];
char srvIP1[20];
printfd(__FILE__, "pkt_free error!\n");
}
rp.dataLen = -1;
-strcpy(rp.iface, "eth0");
return rp;
}
//-----------------------------------------------------------------------------