/*
*
* versuch project
* Control & Status
* $Id: ControlThread.h,v 1.1 2006/03/06 13:07:56 warlock_kg Exp $
* warlock copyright since 2005 Nov
*
*/
#ifndef _CONTROLTHREAD_H
#define _CONTROLTHREAD_H
#include "CallThread.h"
#include "Sockets.h"
#include <vector>
#include <map>
#include <string>
class CallThread;
class SignallingThread;
class TStatusThread;
class ControlThread;
struct T_control_thread_data
{
ControlThread * ch;
};
class TStatusTable
{
public:
TStatusTable() {};
~TStatusTable();
void Add(TStatusThread * StatThread);
void Del(TStatusThread * StatThread);
unsigned GetSize() { return mList.size(); };
string who();
void PrintForEach(string Info);
private:
vector<TStatusThread*> mList;
};
class ControlThread
{
public:
ControlThread(CallThread *Parent, unsigned int Port);
~ControlThread();
void Main();
struct T_control_thread_data * control_tdata;
TStatusTable StatusTable;
private:
CallThread * ParentCallThread;
unsigned int StausPort;
WTelnetSocket2 Listener;
};
struct T_status_thread_data
{
TStatusThread * ch;
TStatusTable * Table;
};
class TStatusThread
{
public:
TStatusThread(CallThread *Parent, WTCPSocket * vSocket, TStatusTable * Table);
~TStatusThread();
void Main();
bool ReadMsg();
struct T_status_thread_data * status_tdata;
WTelnetSocket2 * StatSocket;
private:
CallThread * ParentCallThread;
bool HandleRequest(string Mess);
bool WriteMsg(string Msg);
unsigned IsDetailRequest(string Msg);
unsigned IsKillRequest(string Msg);
unsigned IsShutdownRequest(string Msg);
string IsGWstatusRequest(string Msg);
string IsGWcountersRequest(string Msg);
int IsTraceLevelRequest(string Msg);
bool ReadCommand(string& cmd);
unsigned GetUptime();
pthread_t ThreadID;
TStatusTable * Table;
vector<string> CommandHistory;
unsigned int LastCmd;
};
typedef vector<SignallingThread *>::iterator SigItr;
class CallTable
{
public:
CallTable();
void AddCall(SignallingThread * SThread);
void DelCall(SignallingThread * SThread);
string ListCalls();
string ColumnListCalls();
unsigned CallNumber() { return mList.size(); };
string CallDetails(unsigned int CallRef);
string KillCall(unsigned int CallRef);
string ShutdownCall(unsigned int CallRef);
void KillAllCalls();
void IncSGWusage(WSocket::Address GWaddr) { SGWusage[(DWORD)GWaddr]++; CheckWMGWusage(GWaddr); } ;
void IncDGWusage(WSocket::Address GWaddr) { DGWusage[(DWORD)GWaddr]++; CheckWMGWusage(GWaddr); } ;
void DecSGWusage(WSocket::Address GWaddr) { SGWusage[(DWORD)GWaddr]--; } ;
void DecDGWusage(WSocket::Address GWaddr) { DGWusage[(DWORD)GWaddr]--; } ;
int GetGWusage(WSocket::Address GWaddr) { return DGWusage[(DWORD)GWaddr] + SGWusage[(DWORD)GWaddr]; } ;
string GWusage();
string GWstatus(string GWaddr);
int GWLinesUsage(string GWaddr);
void IncCIA(WSocket::Address GWaddr) { CntInAttempts[(DWORD)GWaddr]++; };
void IncCIC(WSocket::Address GWaddr) { CntInCalls[(DWORD)GWaddr]++; };
void IncCOA(WSocket::Address GWaddr) { CntOutAttempts[(DWORD)GWaddr]++; };
void IncCOC(WSocket::Address GWaddr) { CntOutCalls[(DWORD)GWaddr]++; };
string GWcounters(string GWaddr);
bool isUniqCallIdent(H225_CallIdentifier CallIdent);
int GetUsage(WSocket::Address Addr);
bool FindCall(const string CallId, SignallingThread *SigThread, unsigned int & CallRef);
private:
void CheckWMGWusage(WSocket::Address GWaddr);
string GetNumber(SignallingThread * S);
vector<SignallingThread *> mList;
map<unsigned, int> DGWusage, SGWusage, WMGWusage;
map<unsigned, int> CntInAttempts, CntInCalls, CntOutAttempts, CntOutCalls;
SignallingThread * ResolveRef(unsigned CallRef);
};
#endif // _CONTROLTHREAD_H
syntax highlighted by Code2HTML, v. 0.9.1