Added default initialization of billid so it can track calls.

git-svn-id: http://yate.null.ro/svn/yate/trunk@589 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2005-11-26 18:26:46 +00:00
parent 7f490b5366
commit 8c8af3dad4
5 changed files with 57 additions and 5 deletions

View File

@ -27,6 +27,9 @@
using namespace TelEngine; using namespace TelEngine;
static unsigned int s_callid = 0;
static Mutex s_callidMutex;
// this is to protect against two threads trying to (dis)connect a pair // this is to protect against two threads trying to (dis)connect a pair
// of call endpoints at the same time // of call endpoints at the same time
static Mutex s_mutex(true); static Mutex s_mutex(true);
@ -250,6 +253,9 @@ void Channel::init()
m_driver->changed(); m_driver->changed();
m_driver->unlock(); m_driver->unlock();
} }
// assign a new billid only to incoming calls
if (m_billid.null() && !m_outgoing)
m_billid << Engine::runId() << "-" << allocId();
DDebug(this,DebugInfo,"Channel::init() '%s' [%p]",m_id.c_str(),this); DDebug(this,DebugInfo,"Channel::init() '%s' [%p]",m_id.c_str(),this);
} }
@ -281,6 +287,13 @@ void Channel::zeroRefs()
CallEndpoint::zeroRefs(); CallEndpoint::zeroRefs();
} }
void Channel::connected(const char* reason)
{
Channel* peer = YOBJECT(Channel,getPeer());
if (peer && peer->billid() && m_billid.null())
m_billid = peer->billid();
}
void Channel::disconnected(bool final, const char* reason) void Channel::disconnected(bool final, const char* reason)
{ {
if (final || Engine::exiting()) if (final || Engine::exiting())
@ -477,6 +490,13 @@ bool Channel::setDebug(Message& msg)
return true; return true;
} }
unsigned int Channel::allocId()
{
s_callidMutex.lock();
unsigned int id = ++s_callid;
s_callidMutex.unlock();
return id;
}
TokenDict Module::s_messages[] = { TokenDict Module::s_messages[] = {
{ "engine.status", Module::Status }, { "engine.status", Module::Status },

View File

@ -131,11 +131,12 @@ bool s_dynplugin = false;
int s_maxworkers = 10; int s_maxworkers = 10;
static bool s_sigabrt = false; static bool s_sigabrt = false;
const char* s_cfgfile = 0; static const char* s_cfgfile = 0;
const char* s_logfile = 0; static const char* s_logfile = 0;
Configuration s_cfg; static Configuration s_cfg;
ObjList plugins; static ObjList plugins;
ObjList* s_cmds = 0; static ObjList* s_cmds = 0;
static unsigned int s_runid = 0;
class SLib : public GenObject class SLib : public GenObject
{ {
@ -478,6 +479,7 @@ int Engine::run()
#else #else
::signal(SIGPIPE,SIG_IGN); ::signal(SIGPIPE,SIG_IGN);
#endif #endif
s_runid = Time::secNow();
s_cfg = configFile(s_cfgfile); s_cfg = configFile(s_cfgfile);
s_cfg.load(); s_cfg.load();
Debug(DebugAll,"Engine::run()"); Debug(DebugAll,"Engine::run()");
@ -807,6 +809,11 @@ bool Engine::dispatch(const char* name)
return s_self->m_dispatcher.dispatch(msg); return s_self->m_dispatcher.dispatch(msg);
} }
unsigned int Engine::runId()
{
return s_runid;
}
static void usage(bool client, FILE* f) static void usage(bool client, FILE* f)
{ {
::fprintf(f, ::fprintf(f,

View File

@ -1409,6 +1409,13 @@ YateSIPConnection::YateSIPConnection(Message& msg, const String& uri, const char
if (hl) if (hl)
*hl = desc + *hl; *hl = desc + *hl;
} }
if (msg.getParam("calledname")) {
String desc;
desc << "\"" << msg.getValue("calledname") << "\" ";
SIPHeaderLine* hl = const_cast<SIPHeaderLine*>(m->getHeader("To"));
if (hl)
*hl = desc + *hl;
}
if (plugin.ep()->engine()->prack()) if (plugin.ep()->engine()->prack())
m->addHeader("Supported","100rel"); m->addHeader("Supported","100rel");
m_host = m->getParty()->getPartyAddr(); m_host = m->getParty()->getPartyAddr();

View File

@ -723,6 +723,12 @@ public:
*/ */
static const Configuration& config(); static const Configuration& config();
/**
* Get a - supposedly unique - instance ID
* @return Unique ID of the current running instance
*/
static unsigned int runId();
/** /**
* Reinitialize the plugins * Reinitialize the plugins
*/ */

View File

@ -1349,6 +1349,12 @@ public:
*/ */
bool startRouter(Message* msg); bool startRouter(Message* msg);
/**
* Allocate an unique (per engine run) call ID
* @return Unique call ID number
*/
static unsigned int allocId();
protected: protected:
/** /**
* Constructor * Constructor
@ -1377,6 +1383,12 @@ protected:
*/ */
virtual void zeroRefs(); virtual void zeroRefs();
/**
* Connect notification method.
* @param reason Text that describes connect reason.
*/
virtual void connected(const char* reason);
/** /**
* Disconnect notification method. * Disconnect notification method.
* @param final True if this disconnect was called from the destructor. * @param final True if this disconnect was called from the destructor.