Initial import.
This commit is contained in:
72
process.h
Normal file
72
process.h
Normal 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
|
||||
Reference in New Issue
Block a user