git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Another changes on API.
[stg.git]
/
projects
/
stargazer
/
plugins
/
capture
/
cap_debug
/
debug_cap.cpp
diff --git
a/projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp
b/projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp
index f4b4f8ae373af102877d7c03b1ec3fa4fde8b6e1..0ba91bbba3495046a05342c544f18c0d238e08ff 100644
(file)
--- a/
projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp
+++ b/
projects/stargazer/plugins/capture/cap_debug/debug_cap.cpp
@@
-28,19
+28,24
@@
$Date: 2009/03/19 20:03:35 $
$Author: faust $
*/
$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 <unistd.h>
-#include <signal.h>
#include <sys/types.h>
#include <sys/types.h>
-#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include "stg/plugin_creator.h"
-#include "debug_cap.h"
-#include "../../../traffcounter.h"
-#include "libpal.h"
+extern volatile time_t stgTime;
//-----------------------------------------------------------------------------
void WriteStat(uint32_t u, uint32_t d)
//-----------------------------------------------------------------------------
void WriteStat(uint32_t u, uint32_t d)
@@
-56,11
+61,16
@@
fclose(f);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
+namespace
+{
PLUGIN_CREATOR<DEBUG_CAP> cdc;
PLUGIN_CREATOR<DEBUG_CAP> cdc;
+}
+
+extern "C" PLUGIN * GetPlugin();
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-
BASE_
PLUGIN * GetPlugin()
+PLUGIN * GetPlugin()
{
return cdc.GetPlugin();
}
{
return cdc.GetPlugin();
}
@@
-74,15
+84,16
@@
RAW_PACKET MakeTCPPacket(const char * src,
uint16_t sport,
uint16_t dport,
uint16_t len);
uint16_t sport,
uint16_t dport,
uint16_t len);
-
const
string DEBUG_CAP::GetVersion() const
+
std::
string DEBUG_CAP::GetVersion() const
{
{
-return "
Debug_cap
v.0.01a";
+return "
cap_debug
v.0.01a";
}
//-----------------------------------------------------------------------------
DEBUG_CAP::DEBUG_CAP()
}
//-----------------------------------------------------------------------------
DEBUG_CAP::DEBUG_CAP()
+ : nonstop(false),
+ isRunning(false),
+ traffCnt(NULL)
{
{
-isRunning = false;
-nonstop = false;
}
//-----------------------------------------------------------------------------
void DEBUG_CAP::SetTraffcounter(TRAFFCOUNTER * tc)
}
//-----------------------------------------------------------------------------
void DEBUG_CAP::SetTraffcounter(TRAFFCOUNTER * tc)
@@
-90,7
+101,7
@@
void DEBUG_CAP::SetTraffcounter(TRAFFCOUNTER * tc)
traffCnt = tc;
}
//-----------------------------------------------------------------------------
traffCnt = tc;
}
//-----------------------------------------------------------------------------
-const string & DEBUG_CAP::GetStrError() const
+const st
d::st
ring & DEBUG_CAP::GetStrError() const
{
return errorStr;
}
{
return errorStr;
}
@@
-127,7
+138,7
@@
for (i = 0; i < 25; i++)
if (!isRunning)
break;
if (!isRunning)
break;
-
stgU
sleep(200000);
+
u
sleep(200000);
//printf(".");
}
//printf(".");
}
@@
-157,7
+168,7
@@
void * DEBUG_CAP::Run1(void * data)
{
printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid());
{
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;
dc->isRunning = true;
RAW_PACKET rp;
@@
-178,24
+189,20
@@
int dsize;
t = stgTime;
tm = localtime(&t);
int min = tm->tm_min;
t = stgTime;
tm = localtime(&t);
int min = tm->tm_min;
-int sec = tm->tm_sec;
char cliIP[20];
char srvIP[20];
char cliIP[20];
char srvIP[20];
-char trashIP1[20];
-char trashIP2[20];
while (dc->nonstop)
{
for (int i = 8; i <= 252; i++)
{
while (dc->nonstop)
{
for (int i = 8; i <= 252; i++)
{
-
usize = random()%100 + 100;
usize = random()%100 + 100;
-
dsize = random()%500 + 900;
-
+ dsize = random()%500 + 900;
+
for (int j = 2; j < 11; j++)
{
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);
sprintf(srvIP, "10.1.%d.%d", random()%8, 1);
rp = MakeTCPPacket(srvIP, cliIP, 80, random()%2 + 2000, dsize);
@@
-230,7
+237,7
@@
void * DEBUG_CAP::Run2(void * data)
{
printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid());
{
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;
dc->isRunning = true;
RAW_PACKET rp;
@@
-310,7
+317,7
@@
void * DEBUG_CAP::Run3(void * data)
{
printfd(__FILE__, "=====================| pid: %d |===================== \n", getpid());
{
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;
dc->isRunning = true;
RAW_PACKET rp;
@@
-318,7
+325,6
@@
rp = MakeTCPPacket("192.168.1.1", "192.168.1.21", 255, 255, 200);
int a = 0;
sleep(3);
int a = 0;
sleep(3);
-struct tm * tm;
time_t t;
uint32_t u = 0;
uint32_t d = 0;
time_t t;
uint32_t u = 0;
uint32_t d = 0;
@@
-329,7
+335,6
@@
int usize = 200;
int dsize = 1500;
t = stgTime;
int dsize = 1500;
t = stgTime;
-tm = localtime(&t);
char cliIP[20];
char srvIP1[20];
char cliIP[20];
char srvIP1[20];
@@
-434,12
+439,12
@@
return NULL;
//-----------------------------------------------------------------------------
uint16_t DEBUG_CAP::GetStartPosition() const
{
//-----------------------------------------------------------------------------
uint16_t DEBUG_CAP::GetStartPosition() const
{
-return 0;
+return
4
0;
}
//-----------------------------------------------------------------------------
uint16_t DEBUG_CAP::GetStopPosition() const
{
}
//-----------------------------------------------------------------------------
uint16_t DEBUG_CAP::GetStopPosition() const
{
-return 0;
+return
4
0;
}
//-----------------------------------------------------------------------------
RAW_PACKET MakeTCPPacket(const char * src,
}
//-----------------------------------------------------------------------------
RAW_PACKET MakeTCPPacket(const char * src,
@@
-492,7
+497,6
@@
if (pkt_free(&pkt))
printfd(__FILE__, "pkt_free error!\n");
}
rp.dataLen = -1;
printfd(__FILE__, "pkt_free error!\n");
}
rp.dataLen = -1;
-strcpy(rp.iface, "eth0");
return rp;
}
//-----------------------------------------------------------------------------
return rp;
}
//-----------------------------------------------------------------------------