Monday, 9 September 2013

FirewallBlade , MonitoringBlade how to create a serch int sorted tree.?

FirewallBlade , MonitoringBlade how to create a serch int sorted tree.?

//chak if the address is on the tree.
MESSAGE_ACTION FirewallBlade::handleMessage(const Message& message)
{
Message::ADDRESS addrsForom = message.getFrom();
Message::ADDRESS addrsTo = message.getTo();
if(searchTree(addrsForom,m_rejectTree)||(searchTree(addrsTo,
m_rejectTree)))
return DROP_MESSAGE;
return ACCEPT_MESSAGE;
}
//serch if exsist an adres on the tree.
bool FirewallBlade::searchTree (const Message::ADDRESS&
serchMesg , Node* m_rejectTree )
{
Node* temp= m_rejectTree;
while(temp!=NULL)
{
if(temp->data == serchMesg)
return true;
else if(temp->data > serchMesg)
temp=temp->left;
else
temp=temp->right;
}
return false;
}
my only qustion is tis code is optimize?
i realy wont to know thet ?
and if ther is a way to hack optimisem.
MonitoringBlade::MonitoringBlade()
{ countMesseges=0;
myhash_map.clear();
}
MonitoringBlade::~MonitoringBlade()
{
}
MESSAGE_ACTION MonitoringBlade::handleMessage(const Message& message)
{
Message::ADDRESS ipSendAddres= message.getFrom();
countMesseges++;
it= myhash_map.find(ipSendAddres);
if (it!=myhash_map.end())
{
it->second++;
}
else
myhash_map [ipSendAddres] = 1;
return ACCEPT_MESSAGE; // always accept - don't change
}
void MonitoringBlade::getTopSourceIPs(std::set<Message::ADDRESS>&
topSourceIpAddresses)
{
topSourceIpAddresses.clear();
for ( it= myhash_map.begin() ; it != myhash_map.end(); it++ )
{ float numberOfAdd=it->second;
float ans =numberOfAdd/countMesseges;
if ((numberOfAdd/countMesseges) > 0.1)
topSourceIpAddresses.insert(it->first);
}
}
and the same qstion abut this part of the code.
éçé àãåððå îåøéðå åøáéðå îìê äîùéç ìòåìí å éçé àãåððå îåøéðå åøáéðå îìê
äîùéç ìòåìí åòã éçé àãåððå îåøéðå åøáéðå îìê äîùéç ìòåìí åòã éçé àãåððå
îåøéðå åøáéðå îìê äîùéç ìòåìí åòã éçé àãåððå îåøéðå åøáéðå îìê äîùéç ìòåìí
åòã

No comments:

Post a Comment