/*
* HostNode.cpp
* Copyright (c) 2004-2006 Vlad GALU <dudu@dudu.ro>
* Andrei GAVRILOAIE <gavriloaie_andrei@yahoo.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Class.h>
CHostNode::CHostNode(
in_addr& ip,
time_t& lastflow,
time_t& lastpacket)
{
m_ip = ip;
m_nrFlows = 1;
m_nrPackets = 1;
m_lastCheck = 0;
m_lastFlow = lastflow;
m_lastPacket = lastpacket;
m_pLeft = NULL;
m_pRight = NULL;
m_pParent = NULL;
};
CHostNode::~CHostNode()
{
if (m_pLeft != NULL) {
delete m_pLeft;
m_pLeft = NULL;
}
if (m_pRight != NULL) {
delete m_pRight;
m_pRight = NULL;
}
};
#ifdef _DEBUG
void CHostNode::show(FILE* file)
{
if (m_pLeft != NULL)
m_pLeft->show(file);
dprintf("Host: %s flows: %d speed: %.3f flows/sec\n",
inet_ntoa(m_ip),
m_nrFlows,
(m_lastFlow-m_lastCheck)==0?0.00:(double)m_nrFlows/(double)(m_lastFlow-m_lastCheck));
if (m_pRight != NULL)
m_pRight->show(file);
};
#endif //_DEBUG
// vi:ts=4
syntax highlighted by Code2HTML, v. 0.9.1