Work in proggress. Added test program.

git-svn-id: http://yate.null.ro/svn/yate/trunk@765 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2006-04-29 11:51:39 +00:00
parent dcc31af41e
commit c938ff39ac
10 changed files with 290 additions and 18 deletions

View File

@ -1,6 +1,7 @@
Makefile
YateLocal.mak
core*
yate-*
*.o
*.a
*.orig

View File

@ -6,12 +6,13 @@ DEBUG :=
CXX := @CXX@ -Wall
AR := ar
DEFS :=
LIBTHR := -lpthread
INCLUDES := -I@top_srcdir@ -I../.. -I@srcdir@
CFLAGS := -O2 @MODULE_CPPFLAGS@ @INLINE_FLAGS@
LDFLAGS:= -L../.. -lyate
INCFILES := @top_srcdir@/yateclass.h @srcdir@/yatess7.h
PROGS=
PROGS= yate-ss7test
LIBS = libyatess7.a
OBJS = engine.o sigcall.o sigtran.o \
interface.o layer2.o layer3.o \
@ -55,5 +56,10 @@ clean:
Makefile: @srcdir@/Makefile.in ../../config.status
cd ../.. && ./config.status
yate-%: @srcdir@/main-%.cpp $(MKDEPS) libyatess7.a ../../libyate.so $(INCFILES)
$(COMPILE) -o $@ $(LOCALFLAGS) $< $(LIBTHR) $(LDFLAGS) $(LOCALLIBS)
libyatess7.a: $(OBJS)
$(AR) rcs $@ $^
yate-ss7test: LOCALLIBS += -L. -lyatess7

View File

@ -47,6 +47,7 @@ using namespace TelEngine;
SignallingComponent::~SignallingComponent()
{
DDebug(engine(),DebugAll,"Component '%s' deleted [%p]",toString().c_str(),this);
detach();
}
@ -79,6 +80,8 @@ void SignallingComponent::detach()
void SignallingComponent::timerTick(const Time& when)
{
XDebug(engine(),DebugAll,"Timer ticked for component '%s' [%p]",
toString().c_str(),this);
}
@ -109,6 +112,8 @@ void SignallingEngine::insert(SignallingComponent* component)
if (component->engine() == this)
return;
Lock lock(this);
DDebug(this,DebugAll,"Engine inserting component '%s' @%p [%p]",
component->toString().c_str(),component,this);
component->detach();
component->m_engine = this;
m_components.append(component);
@ -121,6 +126,8 @@ void SignallingEngine::remove(SignallingComponent* component)
if (component->engine() != this)
return;
Lock lock(this);
DDebug(this,DebugAll,"Engine removing component '%s' @%p [%p]",
component->toString().c_str(),component,this);
component->m_engine = 0;
component->detach();
m_components.remove(component,false);
@ -134,6 +141,8 @@ bool SignallingEngine::remove(const String& name)
SignallingComponent* component = static_cast<SignallingComponent*>(m_components[name]);
if (!component)
return false;
DDebug(this,DebugAll,"Engine removing component '%s' @%p [%p]",
component->toString().c_str(),component,this);
component->m_engine = 0;
component->detach();
m_components.remove(component);
@ -151,9 +160,11 @@ bool SignallingEngine::start(const char* name, Thread::Priority prio, unsigned l
SignallingThreadPrivate* tmp = new SignallingThreadPrivate(this,name,prio,usec);
if (tmp->startup()) {
m_thread = tmp;
DDebug(this,DebugInfo,"Engine started worker thread [%p]",this);
return true;
}
delete tmp;
Debug(this,DebugGoOn,"Engine failed to start worker thread [%p]",this);
return false;
}
@ -162,8 +173,10 @@ void SignallingEngine::stop()
lock();
SignallingThreadPrivate* tmp = m_thread;
m_thread = 0;
if (tmp)
if (tmp) {
delete tmp;
DDebug(this,DebugInfo,"Engine stopped worker thread [%p]",this);
}
unlock();
}

View File

@ -26,4 +26,39 @@
using namespace TelEngine;
SignallingInterface::~SignallingInterface()
{
Debug("STUB",DebugWarn,"Please implement SignallingInterface::~");
}
void SignallingInterface::attach(SignallingReceiver* receiver)
{
if (m_receiver == receiver)
return;
Debug("STUB",DebugWarn,"Please implement SignallingReceiver::attach()");
}
bool SignallingInterface::control(Operation oper, NamedList* params)
{
return false;
}
bool SignallingInterface::receivedPacket()
{
return m_receiver && m_receiver->receivedPacket();
}
SignallingReceiver::~SignallingReceiver()
{
Debug("STUB",DebugWarn,"Please implement SignallingReceiver::~");
}
void SignallingReceiver::attach(SignallingInterface* iface)
{
if (m_interface == iface)
return;
Debug("STUB",DebugWarn,"Please implement SignallingReceiver::attach()");
}
/* vi: set ts=8 sw=4 sts=4 noet: */

View File

@ -26,4 +26,19 @@
using namespace TelEngine;
bool SS7MTP2::receivedMSU()
{
Debug("STUB",DebugWarn,"Please implement SS7MTP2::receivedMSU()");
}
bool SS7MTP2::transmitMSU()
{
Debug("STUB",DebugWarn,"Please implement SS7MTP2::transmitMSU()");
}
bool SS7MTP2::receivedPacket()
{
Debug("STUB",DebugWarn,"Please implement SS7MTP2::receivedPacket()");
}
/* vi: set ts=8 sw=4 sts=4 noet: */

View File

@ -26,4 +26,15 @@
using namespace TelEngine;
void SS7MTP3::attach(SS7Layer2* link)
{
Debug("STUB",DebugWarn,"Please implement SS7MTP3::attach()");
SignallingComponent::insert(link);
}
bool SS7MTP3::receivedMSU()
{
Debug("STUB",DebugWarn,"Please implement SS7MTP3::receivedMSU()");
}
/* vi: set ts=8 sw=4 sts=4 noet: */

View File

@ -0,0 +1,20 @@
#include "yatess7.h"
using namespace TelEngine;
int main()
{
debugLevel(DebugAll);
Output("SS7 library test starting");
SignallingEngine* engine = new SignallingEngine;
SS7Router* router = new SS7Router;
engine->insert(router);
SS7MTP3* network = new SS7MTP3;
router->attach(network);
SS7MTP2* link = new SS7MTP2;
network->attach(link);
engine->start("SS7test",Thread::Normal,20000);
Thread::msleep(100);
delete engine;
Output("SS7 library test stopped");
}

View File

@ -26,4 +26,16 @@
using namespace TelEngine;
void SS7Router::attach(SS7Layer3* network)
{
Debug("STUB",DebugWarn,"Please implement SS7Router::attach()");
SignallingComponent::insert(network);
}
void SS7Router::attach(SS7Layer4* service)
{
Debug("STUB",DebugWarn,"Please implement SS7Router::attach()");
SignallingComponent::insert(service);
}
/* vi: set ts=8 sw=4 sts=4 noet: */

10
contrib/yss7/run-ss7test Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Script to run the SS7 test from the build directory
exefile="yate-ss7test"
if [ -x "$exefile" -a -x ../../run ]; then
cd ../..; exec ./run --executable "contrib/yss7/$exefile" "$@"
else
echo "Could not find '$exefile' executable or run script" >&2
fi

View File

@ -223,7 +223,32 @@ class YSS7_API SignallingCall
*/
class YSS7_API SignallingInterface : virtual public SignallingComponent
{
friend class SignallingReceiver;
public:
/**
* Interface control operations
*/
enum Operation {
Specific = 0,
EnableTx = 0x01,
EnableRx = 0x02,
Enable = 0x03,
DisableTx = 0x04,
DisableRx = 0x08,
Disable = 0x0c,
FlushTx = 0x10,
FlushRx = 0x20,
Flush = 0x30,
QueryTx = 0x40,
QueryRx = 0x80,
Query = 0xc0
};
/**
* Destructor, stops and detaches the interface
*/
virtual ~SignallingInterface();
/**
* Attach a receiver to the interface
* @param iface Pointer to receiver to attach
@ -237,17 +262,48 @@ public:
inline SignallingReceiver* receiver() const
{ return m_receiver; }
/**
* Execute a control operation. Operations can enable, disable or flush
* the transmitter, receiver or both. The status (enabled/disabled) can
* be queried and also interface-specific operations can be executed.
* @param oper Operation to execute
* @param params Optional parameters for the operation
* @return True if the command completed successfully, for query operations
* also indicates the interface is enabled and operational
*/
virtual bool control(Operation oper, NamedList* params = 0);
protected:
/**
* Transmit a packet over the hardware interface
* @return True if the interface accepted the packet
*/
virtual bool transmitPacket() = 0;
/**
* Push a received Signalling Packet up the protocol stack
* @return True if packet was successfully delivered to the receiver
*/
bool receivedPacket();
private:
SignallingReceiver* m_receiver;
};
/**
* An interface to an abstraction of a Layer 2 data receiver
* @short Abstract Layer 2 data receiver
* An interface to an abstraction of a Layer 2 packet data receiver
* @short Abstract Layer 2 packet data receiver
*/
class YSS7_API SignallingReceiver
{
friend class SignallingInterface;
public:
/**
* Destructor, stops the interface and detaches from it
*/
virtual ~SignallingReceiver();
/**
* Attach a hardware interface to the data link
* @param iface Pointer to interface to attach
@ -261,6 +317,30 @@ public:
inline SignallingInterface* iface() const
{ return m_interface; }
/**
* Execute a control operation on the attached interface.
* @param oper Operation to execute
* @param params Optional parameters for the operation
* @return True if the command completed successfully, for query operations
* also indicates the interface is enabled and operational
*/
inline bool control(SignallingInterface::Operation oper, NamedList* params = 0)
{ return m_interface && m_interface->control(oper,params); }
protected:
/**
* Send a packet to the attached interface for transmission
* @return True if the interface accepted the packet
*/
inline bool transmitPacket()
{ return m_interface && m_interface->transmitPacket(); }
/**
* Process a Signalling Packet received by the interface
* @return True if message was successfully processed
*/
virtual bool receivedPacket() = 0;
private:
SignallingInterface* m_interface;
};
@ -320,6 +400,11 @@ protected:
class YSS7_API SCCPUser
{
public:
/**
* Destructor, detaches from the SCCP implementation
*/
virtual ~SCCPUser();
/**
* Attach as user to a SCCP
* @param sccp Pointer to the SCCP to use
@ -344,6 +429,11 @@ private:
class YSS7_API TCAPUser
{
public:
/**
* Destructor, detaches from the TCAP implementation
*/
virtual ~TCAPUser();
/**
* Attach as user to a SS7 TCAP
* @param tcap Pointer to the TCAP to use
@ -367,6 +457,20 @@ private:
*/
class YSS7_API SS7L2User : virtual public SignallingComponent
{
friend class SS7Layer2;
public:
/**
* Attach a SS7 Layer 2 (data link) to the user component
* @param link Pointer to data link to attach
*/
virtual void attach(SS7Layer2* link) = 0;
protected:
/**
* Process a MSU received from the Layer 2 component
* @return True if the MSU was processed
*/
virtual bool receivedMSU() = 0;
};
/**
@ -376,6 +480,18 @@ class YSS7_API SS7L2User : virtual public SignallingComponent
class YSS7_API SS7Layer2 : virtual public SignallingComponent
{
public:
enum Primitive {
Pause,
Resume,
Status
};
/**
* Push a Message Signalling Unit down the protocol stack
* @return True if message was successfully queued
*/
virtual bool transmitMSU() = 0;
/**
* Attach a Layer 2 user component to the data link
* @param l2user Pointer to Layer 2 user component to attach
@ -389,6 +505,15 @@ public:
inline SS7L2User* user() const
{ return m_l2user; }
protected:
/**
* Push a received Message Signalling Unit up the protocol stack
* @return True if message was successfully delivered to the user component
*/
inline bool receivedMSU()
{ return m_l2user && m_l2user->receivedMSU(); }
private:
SS7L2User* m_l2user;
};
@ -399,8 +524,6 @@ private:
*/
class YSS7_API SS7L3User : virtual public SignallingComponent
{
private:
SS7Layer3* m_layer3;
};
/**
@ -431,24 +554,24 @@ private:
* An interface to a Layer 4 (application) SS7 protocol
* @short Abstract SS7 layer 4 (application) protocol
*/
class YSS7_API SS7Layer4 : virtual public SignallingComponent
class YSS7_API SS7Layer4 : public SS7L3User
{
public:
/**
* Attach a SS7 router to this service
* @param router Pointer to router to attach
* Attach a SS7 network or router to this service
* @param router Pointer to network or router to attach
*/
void attach(SS7Router* router);
void attach(SS7Layer3* network);
/**
* Retrive the SS7 Message Router to which this service is attached
* @return Pointer to the router this service is attached to
* Retrive the SS7 network or router to which this service is attached
* @return Pointer to the network or router this service is attached to
*/
inline SS7Router* router() const
{ return m_router; }
inline SS7Layer3* network() const
{ return m_layer3; }
private:
SS7Router* m_router;
SS7Layer3* m_layer3;
};
/**
@ -456,7 +579,7 @@ private:
* Messages are distributed according to the service type.
* @short Main router for SS7 message transfer and applications
*/
class YSS7_API SS7Router : public SignallingComponent
class YSS7_API SS7Router : public SS7L3User, public SS7Layer3
{
public:
/**
@ -512,22 +635,48 @@ class YSS7_API SS7M3UA : public SS7Layer3, public SIGTRAN
*/
class YSS7_API SS7MTP2 : public SS7Layer2, public SignallingReceiver
{
public:
/**
* Push a Message Signalling Unit down the protocol stack
* @return True if message was successfully queued
*/
virtual bool transmitMSU();
protected:
/**
* Process a MSU received from the Layer 2 component
* @return True if the MSU was processed
*/
virtual bool receivedMSU();
/**
* Process a Signalling Packet received by the hardware interface
* @return True if message was successfully processed
*/
virtual bool receivedPacket();
};
/**
* Q.704 SS7 Layer 3 (Network) implementation on top of SS7 Layer 2
* @short SS7 Layer 3 implementation on top of Layer 2
*/
class YSS7_API SS7MTP3 : public SS7Layer3
class YSS7_API SS7MTP3 : public SS7Layer3, public SS7L2User
{
public:
/**
* Attach a SS7 Layer 2 (data link) to the network transport
* @param link Pointer to data link to attach
*/
void attach(SS7Layer2* link);
virtual void attach(SS7Layer2* link);
protected:
/**
* Process a MSU received from the Layer 2 component
* @return True if the MSU was processed
*/
virtual bool receivedMSU();
ObjList m_links;
};