More work mainly on addresses.
git-svn-id: http://yate.null.ro/svn/yate/trunk@778 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
8028e82d16
commit
493efcce33
|
@ -14,7 +14,7 @@ INCFILES := @top_srcdir@/yateclass.h @srcdir@/yatess7.h
|
|||
|
||||
PROGS= yate-ss7test
|
||||
LIBS = libyatess7.a
|
||||
OBJS = engine.o sigcall.o sigtran.o \
|
||||
OBJS = engine.o address.o sigcall.o sigtran.o \
|
||||
interface.o layer2.o layer3.o \
|
||||
router.o sccp.o tcap.o \
|
||||
q921.o q931.o
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/**
|
||||
* address.cpp
|
||||
* Yet Another SS7 Stack
|
||||
* This file is part of the YATE Project http://YATE.null.ro
|
||||
*
|
||||
* Yet Another Telephony Engine - a fully featured software PBX and IVR
|
||||
* Copyright (C) 2006 Null Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "yatess7.h"
|
||||
|
||||
|
||||
using namespace TelEngine;
|
||||
|
||||
unsigned int SS7CodePoint::pack(Type type) const
|
||||
{
|
||||
if (!compatible(type))
|
||||
return 0;
|
||||
switch (type) {
|
||||
case ITU:
|
||||
return ((m_network & 7) << 11) | (m_cluster << 3) | (m_member & 7);
|
||||
case ANSI:
|
||||
return (m_network << 16) | (m_cluster << 8) | m_member;
|
||||
// TODO: handle China and Japan
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool SS7CodePoint::compatible(Type type) const
|
||||
{
|
||||
switch (type) {
|
||||
case ITU:
|
||||
return ((m_network | m_member) & 0xf8) == 0;
|
||||
case ANSI:
|
||||
return true;
|
||||
// TODO: handle China and Japan
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char SS7CodePoint::size(Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case ITU:
|
||||
return 14;
|
||||
case ANSI:
|
||||
case China:
|
||||
return 24;
|
||||
case Japan:
|
||||
return 16;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
String& TelEngine::operator<<(String& str, const SS7CodePoint& cp)
|
||||
{
|
||||
str << (int)cp.network() << "-" << (int)cp.cluster() << "-" << (int)cp.member();
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
bool SS7Label::compatible(SS7CodePoint::Type type) const
|
||||
{
|
||||
switch (type) {
|
||||
case SS7CodePoint::ITU:
|
||||
if (m_sls & 0xf0)
|
||||
return false;
|
||||
break;
|
||||
case SS7CodePoint::ANSI:
|
||||
if (m_sls & 0xe0)
|
||||
return false;
|
||||
break;
|
||||
// TODO: handle China and Japan
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return m_dpc.compatible(type) && m_spc.compatible(type);
|
||||
}
|
||||
|
||||
unsigned char SS7Label::size(SS7CodePoint::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case SS7CodePoint::ITU:
|
||||
return 32;
|
||||
case SS7CodePoint::ANSI:
|
||||
return 53;
|
||||
// TODO: handle China and Japan
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int SS7Label::length(SS7CodePoint::Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case SS7CodePoint::ITU:
|
||||
return 4;
|
||||
case SS7CodePoint::ANSI:
|
||||
return 7;
|
||||
// TODO: handle China and Japan
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
String& TelEngine::operator<<(String& str, const SS7Label& label)
|
||||
{
|
||||
str << label.spc() << ":" << label.dpc() << ":" << (int)label.sls();
|
||||
return str;
|
||||
}
|
||||
|
||||
/* vi: set ts=8 sw=4 sts=4 noet: */
|
|
@ -62,11 +62,18 @@ bool SS7MTP2::control(Operation oper, NamedList* params)
|
|||
{
|
||||
switch (oper) {
|
||||
case Pause:
|
||||
abortAlignment();
|
||||
return true;
|
||||
case Resume:
|
||||
if (aligned())
|
||||
return true;
|
||||
// fall-through
|
||||
case Align:
|
||||
startAlignment();
|
||||
return true;
|
||||
break;
|
||||
case Status:
|
||||
return (m_status == NormalAlignment);
|
||||
return aligned();
|
||||
default:
|
||||
return SignallingReceiver::control((SignallingInterface::Operation)oper,params);
|
||||
}
|
||||
|
@ -76,7 +83,7 @@ bool SS7MTP2::control(Operation oper, NamedList* params)
|
|||
bool SS7MTP2::transmitMSU(const SS7MSU& msu)
|
||||
{
|
||||
if (msu.length() < 3) {
|
||||
Debug(engine(),DebugWarn,"Asked to send MSU of length %u [%p]",
|
||||
Debug(engine(),DebugWarn,"Asked to send too short MSU of length %u [%p]",
|
||||
msu.length(),this);
|
||||
return false;
|
||||
}
|
||||
|
@ -126,9 +133,12 @@ bool SS7MTP2::receivedPacket(const DataBlock& packet)
|
|||
bool ok = true;
|
||||
// packet length is valid, check sequence numbers
|
||||
unsigned char bsn = buf[0] & 0x7f;
|
||||
bool bib = (buf[0] & 0x80) != 0;
|
||||
unsigned char fsn = buf[1] & 0x7f;
|
||||
bool bib = (buf[0] & 0x80) != 0;
|
||||
bool fib = (buf[1] & 0x80) != 0;
|
||||
// lock the object as we modify members
|
||||
lock();
|
||||
unlock();
|
||||
|
||||
//TODO: implement Q.703 6.3.1
|
||||
|
||||
|
@ -201,10 +211,12 @@ bool SS7MTP2::transmitFISU()
|
|||
|
||||
void SS7MTP2::startAlignment()
|
||||
{
|
||||
m_status = OutOfAlignment;
|
||||
}
|
||||
|
||||
void SS7MTP2::abortAlignment()
|
||||
{
|
||||
m_status = OutOfService;
|
||||
}
|
||||
|
||||
/* vi: set ts=8 sw=4 sts=4 noet: */
|
||||
|
|
|
@ -394,21 +394,27 @@ public:
|
|||
*/
|
||||
enum Services {
|
||||
// Signalling Network Management
|
||||
SNM = 0,
|
||||
SNM = 0,
|
||||
// Maintenance
|
||||
MTN = 1,
|
||||
MTN = 1,
|
||||
// Maintenance special
|
||||
MTNS = 2,
|
||||
MTNS = 2,
|
||||
// Signalling Connection Control Part
|
||||
SCCP = 3,
|
||||
SCCP = 3,
|
||||
// Telephone User Part
|
||||
TUP = 4,
|
||||
TUP = 4,
|
||||
// ISDN User Part
|
||||
ISUP = 5,
|
||||
ISUP = 5,
|
||||
// Data User Part - call and circuit related
|
||||
DUP_C = 6,
|
||||
DUP_C = 6,
|
||||
// Data User Part - facility messages
|
||||
DUP_F = 7,
|
||||
DUP_F = 7,
|
||||
// MTP Testing User Part (reserved)
|
||||
MTP_T = 8,
|
||||
// Broadband ISDN User Part
|
||||
BISUP = 9,
|
||||
// Satellite ISDN User Part
|
||||
SISUP = 10,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -533,6 +539,17 @@ public:
|
|||
class YSS7_API SS7CodePoint
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Different incompatible types of codepoints
|
||||
*/
|
||||
enum Type {
|
||||
Other = 0,
|
||||
ITU = 1,
|
||||
ANSI = 2,
|
||||
China = 3,
|
||||
Japan = 4,
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor from components
|
||||
* @param network ANSI Network Identifier / ITU-T Zone Identification
|
||||
|
@ -543,6 +560,14 @@ public:
|
|||
: m_network(network), m_cluster(cluster), m_member(member)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
* @param original Code point to be copied
|
||||
*/
|
||||
inline SS7CodePoint(const SS7CodePoint& original)
|
||||
: m_network(original.network()), m_cluster(original.cluster()), m_member(original.member())
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
|
@ -580,26 +605,31 @@ public:
|
|||
{ m_network = network; m_cluster = cluster; m_member = member; }
|
||||
|
||||
/**
|
||||
* Check if the codepoint is compatible with ITU-T
|
||||
* @return True if the Network and Member fit in the ITU 3 bit storage
|
||||
* Assignment operator
|
||||
* @param original Code point to be copied
|
||||
*/
|
||||
inline bool ituCompatible() const
|
||||
{ return ((m_network | m_member) & 0xf8) == 0; }
|
||||
inline SS7CodePoint& operator=(const SS7CodePoint& original)
|
||||
{ assign(original.network(),original.cluster(),original.member()); return *this; }
|
||||
|
||||
/**
|
||||
* Return the code point as compact bits in ITU-T format. No error check is
|
||||
* performed so data truncation may occur if not checked in advance.
|
||||
* @return Compact code point as 14-bit integer
|
||||
* Check if the codepoint is compatible with a packing type
|
||||
* @return True if the Network and Member fit in the packing format
|
||||
*/
|
||||
inline unsigned int packITU() const
|
||||
{ return ((m_network & 7) << 11) | (m_cluster << 3) | (m_member & 7); }
|
||||
bool compatible(Type type) const;
|
||||
|
||||
/**
|
||||
* Return the code point as compact bits in ANSI format
|
||||
* @return Compact code point as 24-bit integer
|
||||
* Pack the code point into a single integer number.
|
||||
* @param type Type of the packing desired
|
||||
* @return Compact code point as integer or zero if the packing type is not supported
|
||||
*/
|
||||
inline unsigned int packANSI() const
|
||||
{ return (m_network << 16) | (m_cluster << 8) | m_member; }
|
||||
unsigned int pack(Type type) const;
|
||||
|
||||
/**
|
||||
* Get the size (in bits) of a packed code point according to its type
|
||||
* @param type Type of the packing
|
||||
* @return Number of bits required to represent the code point, zero if unknown
|
||||
*/
|
||||
static unsigned char size(Type type);
|
||||
|
||||
private:
|
||||
unsigned char m_network;
|
||||
|
@ -612,8 +642,7 @@ private:
|
|||
* @param str String to append to
|
||||
* @param cp Codepoint to append to the string
|
||||
*/
|
||||
inline String& operator<<(String& str, const SS7CodePoint& cp)
|
||||
{ str << (int)cp.network() << "-" << (int)cp.cluster() << "-" << (int)cp.member(); return str; }
|
||||
String& operator<<(String& str, const SS7CodePoint& cp);
|
||||
|
||||
/**
|
||||
* A SS7 Layer 3 routing label, both ANSI and ITU capable
|
||||
|
@ -621,9 +650,76 @@ inline String& operator<<(String& str, const SS7CodePoint& cp)
|
|||
*/
|
||||
class YSS7_API SS7Label
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Check if the label is compatible with another packing type
|
||||
* @return True if the DLC, SLC and SLS fit in the new packing format
|
||||
*/
|
||||
bool compatible(SS7CodePoint::Type type) const;
|
||||
|
||||
/**
|
||||
* Get the type (SS7 dialect) of the routing label
|
||||
* @return Dialect of the routing label as enumeration
|
||||
*/
|
||||
inline SS7CodePoint::Type type() const
|
||||
{ return m_type; }
|
||||
|
||||
/**
|
||||
* Get the Destination Code Point inside the label
|
||||
* @return Reference of the destination code point
|
||||
*/
|
||||
inline const SS7CodePoint& dpc() const
|
||||
{ return m_dpc; }
|
||||
|
||||
/**
|
||||
* Get the Source Code Point inside the label
|
||||
* @return Reference of the source code point
|
||||
*/
|
||||
inline const SS7CodePoint& spc() const
|
||||
{ return m_spc; }
|
||||
|
||||
/**
|
||||
* Get the Signalling Link Selection inside the label
|
||||
* @return Value of the SLS field
|
||||
*/
|
||||
inline unsigned char sls() const
|
||||
{ return m_sls; }
|
||||
|
||||
/**
|
||||
* Get the length (in bytes) of this routing label
|
||||
* @return Number of bytes required to represent the label, zero if unknown
|
||||
*/
|
||||
inline unsigned int length() const
|
||||
{ return length(m_type); }
|
||||
|
||||
/**
|
||||
* Get the length (in bytes) of a packed routing label according to its type
|
||||
* @param type Type of the packing
|
||||
* @return Number of bytes required to represent the label, zero if unknown
|
||||
*/
|
||||
static unsigned int length(SS7CodePoint::Type type);
|
||||
|
||||
/**
|
||||
* Get the size (in bits) of a packed routing label according to its type
|
||||
* @param type Type of the packing
|
||||
* @return Number of bits required to represent the label, zero if unknown
|
||||
*/
|
||||
static unsigned char size(SS7CodePoint::Type type);
|
||||
|
||||
private:
|
||||
SS7CodePoint::Type m_type;
|
||||
SS7CodePoint m_dpc;
|
||||
SS7CodePoint m_spc;
|
||||
unsigned char m_sls;
|
||||
};
|
||||
|
||||
/**
|
||||
* Operator to write a routing label to a string
|
||||
* @param str String to append to
|
||||
* @param cp Label to append to the string
|
||||
*/
|
||||
String& operator<<(String& str, const SS7Label& label);
|
||||
|
||||
/**
|
||||
* An interface to a Signalling Transport component
|
||||
* @short Abstract SIGTRAN component
|
||||
|
@ -783,9 +879,13 @@ public:
|
|||
* Control primitives
|
||||
*/
|
||||
enum Operation {
|
||||
// take link out of service
|
||||
Pause = 0x100,
|
||||
// start link operation, align if it needs to
|
||||
Resume = 0x200,
|
||||
// start link, force realignment
|
||||
Align = 0x300,
|
||||
// get operational status
|
||||
Status = 0x400,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue