Initial import.

This commit is contained in:
Arnout Engelen
2004-06-29 13:31:04 +00:00
commit be624683f0
21 changed files with 1804 additions and 0 deletions

72
process.h Normal file
View File

@@ -0,0 +1,72 @@
#ifndef __PROCESS_H
#define __PROCESS_H
#include <assert.h>
#include "nethogs.h"
#include "connection.h"
class ConnList
{
public:
ConnList (Connection * m_val, ConnList * m_next)
{
if (DEBUG)
assert (m_val != NULL);
val = m_val; next = m_next;
}
Connection * getVal ()
{
return val;
}
ConnList * getNext ()
{
return next;
}
private:
Connection * val;
ConnList * next;
};
class Process
{
public:
Process (unsigned long m_inode, char* m_name = NULL)
{
inode = m_inode;
name = m_name;
incoming = NULL;
outgoing = NULL;
}
int getLastPacket ()
{
int lastpacket=0;
ConnList * curconn=incoming;
while (curconn != NULL)
{
if (DEBUG)
{
assert (curconn != NULL);
assert (curconn->getVal() != NULL);
}
if (curconn->getVal()->getLastPacket() > lastpacket)
lastpacket = curconn->getVal()->getLastPacket();
curconn = curconn->getNext();
}
return lastpacket;
}
const char * name;
int pid;
int uid;
unsigned long inode;
ConnList * incoming;
ConnList * outgoing;
};
Process * getProcess (Connection * connection);
void do_refresh ();
void procclean ();
#endif