Renamed CallSignalling class to SignallingCall to match others.
git-svn-id: http://voip.null.ro/svn/yate@762 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
fce4f372aa
commit
cb4e0baec9
|
@ -24,6 +24,24 @@
|
|||
#include "yatess7.h"
|
||||
#include <yateversn.h>
|
||||
|
||||
namespace TelEngine {
|
||||
|
||||
class SignallingThreadPrivate : public Thread
|
||||
{
|
||||
public:
|
||||
inline SignallingThreadPrivate(SignallingEngine*engine, const char* name, Priority prio, unsigned long usec)
|
||||
: Thread(name,prio), m_engine(engine), m_sleep(usec)
|
||||
{ }
|
||||
virtual ~SignallingThreadPrivate()
|
||||
{ }
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
SignallingEngine* m_engine;
|
||||
unsigned long m_sleep;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
using namespace TelEngine;
|
||||
|
||||
|
@ -32,6 +50,25 @@ SignallingComponent::~SignallingComponent()
|
|||
detach();
|
||||
}
|
||||
|
||||
const String& SignallingComponent::toString()
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
void SignallingComponent::insert(SignallingComponent* component)
|
||||
{
|
||||
if (!component)
|
||||
return;
|
||||
if (m_engine) {
|
||||
// we have an engine - force the other component in the same
|
||||
m_engine->insert(component);
|
||||
return;
|
||||
}
|
||||
if (component->engine())
|
||||
// insert ourselves in the other's engine
|
||||
component->engine()->insert(this);
|
||||
}
|
||||
|
||||
void SignallingComponent::detach()
|
||||
{
|
||||
if (m_engine) {
|
||||
|
@ -46,7 +83,7 @@ void SignallingComponent::timerTick(const Time& when)
|
|||
|
||||
|
||||
SignallingEngine::SignallingEngine()
|
||||
: Mutex(true)
|
||||
: Mutex(true), m_thread(0), m_listChanged(true)
|
||||
{
|
||||
debugName("signalling");
|
||||
}
|
||||
|
@ -54,10 +91,17 @@ SignallingEngine::SignallingEngine()
|
|||
SignallingEngine::~SignallingEngine()
|
||||
{
|
||||
lock();
|
||||
stop();
|
||||
m_components.clear();
|
||||
unlock();
|
||||
}
|
||||
|
||||
SignallingComponent* SignallingEngine::find(const String& name)
|
||||
{
|
||||
Lock lock(this);
|
||||
return static_cast<SignallingComponent*>(m_components[name]);
|
||||
}
|
||||
|
||||
void SignallingEngine::insert(SignallingComponent* component)
|
||||
{
|
||||
if (!component)
|
||||
|
@ -82,8 +126,83 @@ void SignallingEngine::remove(SignallingComponent* component)
|
|||
m_components.remove(component,false);
|
||||
}
|
||||
|
||||
bool SignallingEngine::remove(const String& name)
|
||||
{
|
||||
if (name.null())
|
||||
return false;
|
||||
Lock lock(this);
|
||||
SignallingComponent* component = static_cast<SignallingComponent*>(m_components[name]);
|
||||
if (!component)
|
||||
return false;
|
||||
component->m_engine = 0;
|
||||
component->detach();
|
||||
m_components.remove(component);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SignallingEngine::start(const char* name, Thread::Priority prio, unsigned long usec)
|
||||
{
|
||||
Lock lock(this);
|
||||
if (m_thread)
|
||||
return m_thread->running();
|
||||
// sanity check - 20ms is long enough
|
||||
if (usec > 20000)
|
||||
usec = 20000;
|
||||
SignallingThreadPrivate* tmp = new SignallingThreadPrivate(this,name,prio,usec);
|
||||
if (tmp->startup()) {
|
||||
m_thread = tmp;
|
||||
return true;
|
||||
}
|
||||
delete tmp;
|
||||
return false;
|
||||
}
|
||||
|
||||
void SignallingEngine::stop()
|
||||
{
|
||||
lock();
|
||||
SignallingThreadPrivate* tmp = m_thread;
|
||||
m_thread = 0;
|
||||
if (tmp)
|
||||
delete tmp;
|
||||
unlock();
|
||||
}
|
||||
|
||||
Thread* SignallingEngine::thread() const
|
||||
{
|
||||
return m_thread;
|
||||
}
|
||||
|
||||
void SignallingEngine::timerTick(const Time& when)
|
||||
{
|
||||
lock();
|
||||
m_listChanged = false;
|
||||
for (ObjList* l = &m_components; l; l = l->next()) {
|
||||
SignallingComponent* c = static_cast<SignallingComponent*>(l->get());
|
||||
if (c) {
|
||||
c->timerTick(when);
|
||||
// if the list was changed (can be only from this thread) we
|
||||
// break out and get back later - cheaper than using a ListIterator
|
||||
if (m_listChanged)
|
||||
break;
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
void SignallingThreadPrivate::run()
|
||||
{
|
||||
for (;;) {
|
||||
if (m_engine) {
|
||||
Time t;
|
||||
m_engine->timerTick(t);
|
||||
if (m_sleep) {
|
||||
usleep(m_sleep,true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
yield(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* vi: set ts=8 sw=4 sts=4 noet: */
|
||||
|
|
|
@ -156,7 +156,7 @@ Generic interface for transporting signalling over SCTP/IP
|
|||
- generates network status notifications
|
||||
Inherited by: SS7M2PA, SS7M2UA, SS7M3UA, SS7SUA, ISDNIUA
|
||||
|
||||
CallSignalling
|
||||
SignallingCall
|
||||
--------------
|
||||
This class provides an uniform interface to telephony call control
|
||||
- receive requests for call setup, teardown, transfer, etc.
|
||||
|
@ -193,7 +193,7 @@ SS7ISUP, SS7BISUP, SS7TUP
|
|||
-------------------------
|
||||
These 3 classes implement SS7 telephony call control according to different
|
||||
subprotocols used around the world.
|
||||
Implement: SS7Layer4, CallSignalling
|
||||
Implement: SS7Layer4, SignallingCall
|
||||
|
||||
SS7SCCP
|
||||
-------
|
||||
|
@ -234,7 +234,7 @@ Implements: ISDNLayer2, SignallingReceiver
|
|||
ISDNQ931
|
||||
--------
|
||||
Provides an implementation of ITU Q.931 telephony call control on top of Q.921
|
||||
Implements: ISDNLayer3, CallSignalling
|
||||
Implements: ISDNLayer3, SignallingCall
|
||||
|
||||
ISDNIUA
|
||||
-------
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
namespace TelEngine {
|
||||
|
||||
class SignallingEngine;
|
||||
class SignallingThreadPrivate;
|
||||
class SignallingReceiver;
|
||||
class SCCPUser;
|
||||
class SS7Layer2;
|
||||
|
@ -70,6 +71,12 @@ public:
|
|||
*/
|
||||
virtual ~SignallingComponent();
|
||||
|
||||
/**
|
||||
* Get the component's name so it can be used for list searches
|
||||
* @return A reference to the name by which the component is known to engine
|
||||
*/
|
||||
virtual const String& toString();
|
||||
|
||||
/**
|
||||
* Get the @ref TelEngine::SignallingEngine that manages this component
|
||||
* @return Pointer to engine or NULL if not managed by an engine
|
||||
|
@ -79,14 +86,25 @@ public:
|
|||
|
||||
protected:
|
||||
/**
|
||||
* Default constructor
|
||||
* Constructor with a default empty component name
|
||||
* @param name Name of this component
|
||||
*/
|
||||
inline SignallingComponent()
|
||||
: m_engine(0)
|
||||
inline SignallingComponent(const char* name = 0)
|
||||
: m_engine(0), m_name(name)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Detach this component from all its links - components and engine
|
||||
* Insert another component in the same engine as this one.
|
||||
* This method should be called for every component we attach.
|
||||
* @param component Pointer to component to insert in engine
|
||||
*/
|
||||
void insert(SignallingComponent* component);
|
||||
|
||||
/**
|
||||
* Detach this component from all its links - components and engine.
|
||||
* Reimplement this method in all components that keep pointers to
|
||||
* other components.
|
||||
* The default implementation detaches from the engine.
|
||||
*/
|
||||
virtual void detach();
|
||||
|
||||
|
@ -96,18 +114,27 @@ protected:
|
|||
*/
|
||||
virtual void timerTick(const Time& when);
|
||||
|
||||
/**
|
||||
* Change the name of the component after it was constructed
|
||||
* @param name Name of this component
|
||||
*/
|
||||
inline void setName(const char* name)
|
||||
{ m_name = name; }
|
||||
|
||||
private:
|
||||
SignallingEngine* m_engine;
|
||||
String m_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* The engine is the center of all SS7 or ISDN applications.
|
||||
* It is used as a base to build the protocol stack from components.
|
||||
* @short Main message transfer and application hub
|
||||
* @short Main signalling component holder
|
||||
*/
|
||||
class YSS7_API SignallingEngine : public DebugEnabler, public Mutex
|
||||
{
|
||||
friend class SignallingComponent;
|
||||
friend class SignallingThreadPrivate;
|
||||
public:
|
||||
/**
|
||||
* Constructor of an empty engine
|
||||
|
@ -119,21 +146,55 @@ public:
|
|||
*/
|
||||
virtual ~SignallingEngine();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Insert a component in the engine
|
||||
* Insert a component in the engine, lock the list while doing so
|
||||
* @param component Pointer to component to insert in engine
|
||||
*/
|
||||
void insert(SignallingComponent* component);
|
||||
|
||||
/**
|
||||
* Remove a component from the engine
|
||||
* Remove a component from the engine, lock the list while doing so
|
||||
* @param component Pointer to component to remove from engine
|
||||
*/
|
||||
void remove(SignallingComponent* component);
|
||||
|
||||
/**
|
||||
* Method called periodically by a @ref Thread to keep everything alive
|
||||
* Remove and destroy a component from the engine by name
|
||||
* @param name Name of component to remove from engine
|
||||
* @return True if a component was found and destroyed
|
||||
*/
|
||||
bool remove(const String& name);
|
||||
|
||||
/**
|
||||
* Retrive a component by name, lock the list while searching for it
|
||||
* @param name Name of the component to find
|
||||
* @return Pointer to component found or NULL
|
||||
*/
|
||||
SignallingComponent* find(const String& name);
|
||||
|
||||
/**
|
||||
* Starts the worker thread that keeps components alive
|
||||
* @param name Static name of the thread
|
||||
* @param prio Thread's priority
|
||||
* @param usec How long to sleep between iterations, in microseconds
|
||||
* @return True if (already) started, false if an error occured
|
||||
*/
|
||||
bool start(const char* name = "Signalling", Thread::Priority prio = Thread::Normal, unsigned long usec = 1000);
|
||||
|
||||
/**
|
||||
* Stops and destroys the worker thread if running
|
||||
*/
|
||||
void stop();
|
||||
|
||||
/**
|
||||
* Return a pointer to the worker thread
|
||||
* @return Pointer to running worker thread or NULL
|
||||
*/
|
||||
Thread* thread() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Method called periodically by the @ref Thread to keep everything alive
|
||||
* @param when Time to use as computing base for events and timeouts
|
||||
*/
|
||||
virtual void timerTick(const Time& when);
|
||||
|
@ -142,13 +203,17 @@ protected:
|
|||
* The list of components managed by this engine
|
||||
*/
|
||||
ObjList m_components;
|
||||
|
||||
private:
|
||||
SignallingThreadPrivate* m_thread;
|
||||
bool m_listChanged;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface of protocol independent call signalling
|
||||
* Interface of protocol independent signalling for phone calls
|
||||
* @short Abstract phone call signalling
|
||||
*/
|
||||
class YSS7_API CallSignalling
|
||||
class YSS7_API SignallingCall
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -389,7 +454,7 @@ private:
|
|||
/**
|
||||
* A message router between Transfer and Application layers.
|
||||
* Messages are distributed according to the service type.
|
||||
* @short Message router between Layer 3 and Layer 4
|
||||
* @short Main router for SS7 message transfer and applications
|
||||
*/
|
||||
class YSS7_API SS7Router : public SignallingComponent
|
||||
{
|
||||
|
@ -470,7 +535,7 @@ protected:
|
|||
* Implementation of SS7 ISDN User Part
|
||||
* @short SS7 ISUP implementation
|
||||
*/
|
||||
class YSS7_API SS7ISUP : public CallSignalling, public SS7Layer4
|
||||
class YSS7_API SS7ISUP : public SignallingCall, public SS7Layer4
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -478,7 +543,7 @@ class YSS7_API SS7ISUP : public CallSignalling, public SS7Layer4
|
|||
* Implementation of SS7 Broadband ISDN User Part
|
||||
* @short SS7 BISUP implementation
|
||||
*/
|
||||
class YSS7_API SS7BISUP : public CallSignalling, public SS7Layer4
|
||||
class YSS7_API SS7BISUP : public SignallingCall, public SS7Layer4
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -486,7 +551,7 @@ class YSS7_API SS7BISUP : public CallSignalling, public SS7Layer4
|
|||
* Implementation of SS7 Telephone User Part
|
||||
* @short SS7 TUP implementation
|
||||
*/
|
||||
class YSS7_API SS7TUP : public CallSignalling, public SS7Layer4
|
||||
class YSS7_API SS7TUP : public SignallingCall, public SS7Layer4
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -583,7 +648,7 @@ class YSS7_API ISDNIUA : public ISDNLayer2, public SIGTRAN
|
|||
* Q.931 ISDN Layer 3 implementation on top of a Layer 2
|
||||
* @short ISDN Q.931 implementation on top of Q.921
|
||||
*/
|
||||
class YSS7_API ISDNQ931 : public CallSignalling, public ISDNLayer3
|
||||
class YSS7_API ISDNQ931 : public SignallingCall, public ISDNLayer3
|
||||
{
|
||||
/**
|
||||
* Attach an ISDN Q.921 transport
|
||||
|
|
Loading…
Reference in New Issue