2014-02-05 11:42:17 +00:00
|
|
|
/**
|
2015-04-07 10:07:44 +00:00
|
|
|
* yateradio.h
|
|
|
|
* Radio library
|
2013-12-13 11:27:09 +00:00
|
|
|
* This file is part of the YATE Project http://YATE.null.ro
|
|
|
|
*
|
|
|
|
* Yet Another Telephony Engine - a fully featured software PBX and IVR
|
2014-02-05 11:42:17 +00:00
|
|
|
* Copyright (C) 2011-2014 Null Team
|
2013-12-13 11:27:09 +00:00
|
|
|
*
|
|
|
|
* This software is distributed under multiple licenses;
|
|
|
|
* see the COPYING file in the main directory for licensing
|
|
|
|
* information for this specific distribution.
|
|
|
|
*
|
|
|
|
* This use of this software may be subject to additional restrictions.
|
|
|
|
* See the LEGAL file in the main directory for details.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2015-04-07 10:07:44 +00:00
|
|
|
#ifndef __YATERADIO_H
|
|
|
|
#define __YATERADIO_H
|
2013-12-13 11:27:09 +00:00
|
|
|
|
|
|
|
#include <yateclass.h>
|
|
|
|
#include <yatexml.h>
|
|
|
|
|
|
|
|
#ifdef _WINDOWS
|
|
|
|
|
2015-04-07 10:07:44 +00:00
|
|
|
#ifdef LIBYRADIO_EXPORTS
|
|
|
|
#define YRADIO_API __declspec(dllexport)
|
2013-12-13 11:27:09 +00:00
|
|
|
#else
|
2015-04-07 10:07:44 +00:00
|
|
|
#ifndef LIBYRADIO_STATIC
|
|
|
|
#define YRADIO_API __declspec(dllimport)
|
2013-12-13 11:27:09 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _WINDOWS */
|
|
|
|
|
2015-04-07 10:07:44 +00:00
|
|
|
#ifndef YRADIO_API
|
|
|
|
#define YRADIO_API
|
2013-12-13 11:27:09 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace TelEngine {
|
|
|
|
|
2015-04-07 10:07:44 +00:00
|
|
|
class YRADIO_API GSML3Codec
|
2013-12-13 11:27:09 +00:00
|
|
|
{
|
2013-12-13 11:44:15 +00:00
|
|
|
YNOCOPY(GSML3Codec);
|
2013-12-13 11:27:09 +00:00
|
|
|
public:
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* Codec flags
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
enum Flags {
|
|
|
|
XmlDumpMsg = 0x01,
|
|
|
|
XmlDumpIEs = 0x02,
|
2014-01-08 15:57:05 +00:00
|
|
|
MSCoder = 0x04,
|
2013-12-13 11:27:09 +00:00
|
|
|
};
|
2013-12-13 16:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Codec return status
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
enum Status {
|
|
|
|
NoError = 0,
|
|
|
|
MsgTooShort,
|
|
|
|
UnknownProto,
|
|
|
|
ParserErr,
|
2013-12-16 15:54:54 +00:00
|
|
|
MissingParam,
|
2013-12-17 16:05:12 +00:00
|
|
|
IncorrectOptionalIE,
|
|
|
|
IncorrectMandatoryIE,
|
2013-12-20 16:14:53 +00:00
|
|
|
MissingMandatoryIE,
|
2013-12-18 15:56:49 +00:00
|
|
|
UnknownMsgType,
|
2013-12-13 11:27:09 +00:00
|
|
|
};
|
2013-12-13 16:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Protocol discriminator according to ETSI TS 124 007 V11.0.0, section 11.2.3.1.1
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
enum Protocol {
|
|
|
|
GCC = 0x00, // Group Call Control
|
|
|
|
BCC = 0x01, // Broadcast Call Control
|
|
|
|
EPS_SM = 0x02, // EPS Session Management
|
|
|
|
CC = 0x03, // Call Control; Call Related SS messages
|
|
|
|
GTTP = 0x04, // GPRS Transparent Transport Protocol (GTTP)
|
|
|
|
MM = 0x05, // Mobility Management
|
|
|
|
RRM = 0x06, // Radio Resources Management
|
2014-02-05 11:42:17 +00:00
|
|
|
EPS_MM = 0x07, // EPS Mobility Management
|
2013-12-13 11:27:09 +00:00
|
|
|
GPRS_MM = 0x08, // GPRS Mobility Management
|
|
|
|
SMS = 0x09, // SMS
|
|
|
|
GPRS_SM = 0x0a, // GPRS Session Management
|
|
|
|
SS = 0x0b, // Non Call Related SS messages
|
|
|
|
LCS = 0x0c, // Location services
|
|
|
|
Extension = 0x0e, // reserved for extension of the PD to one octet length
|
|
|
|
Test = 0x0f, // used by tests procedures described in 3GPP TS 44.014, 3GPP TS 34.109 and 3GPP TS 36.509
|
|
|
|
Unknown = 0xff,
|
|
|
|
};
|
2013-12-13 16:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IE types
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
enum Type {
|
|
|
|
NoType = 0,
|
|
|
|
T,
|
|
|
|
V,
|
|
|
|
TV,
|
|
|
|
LV,
|
|
|
|
TLV,
|
|
|
|
LVE,
|
|
|
|
TLVE,
|
|
|
|
};
|
2013-12-13 16:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Type of XML data to generate
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
enum XmlType {
|
|
|
|
Skip,
|
|
|
|
XmlElem,
|
2013-12-20 16:14:53 +00:00
|
|
|
XmlRoot,
|
2013-12-13 11:27:09 +00:00
|
|
|
};
|
2013-12-13 16:01:53 +00:00
|
|
|
|
2013-12-16 15:54:54 +00:00
|
|
|
/**
|
|
|
|
* EPS Security Headers
|
|
|
|
*/
|
|
|
|
enum EPSSecurityHeader {
|
|
|
|
PlainNAS = 0x00,
|
|
|
|
IntegrityProtect = 0x01,
|
|
|
|
IntegrityProtectCiphered = 0x02,
|
|
|
|
IntegrityProtectNewEPSCtxt = 0x03,
|
|
|
|
IntegrityProtectCipheredNewEPSCtxt = 0x04,
|
|
|
|
ServiceRequestHeader = 0xa0,
|
|
|
|
};
|
|
|
|
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*/
|
|
|
|
GSML3Codec(DebugEnabler* dbg = 0);
|
2014-02-05 11:42:17 +00:00
|
|
|
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* Decode layer 3 message payload
|
|
|
|
* @param in Input buffer containing the data to be decoded
|
|
|
|
* @param len Length of input buffer
|
|
|
|
* @param out XmlElement into which the decoded data is returned
|
2013-12-16 15:54:54 +00:00
|
|
|
* @param params Encoder parameters
|
2013-12-13 16:01:53 +00:00
|
|
|
* @return Parsing result: 0 (NoError) if succeeded, error status otherwise
|
|
|
|
*/
|
2013-12-16 15:54:54 +00:00
|
|
|
unsigned int decode(const uint8_t* in, unsigned int len, XmlElement*& out, const NamedList& params = NamedList::empty());
|
2013-12-13 16:01:53 +00:00
|
|
|
|
|
|
|
/**
|
2014-02-05 11:42:17 +00:00
|
|
|
* Encode a layer 3 message
|
2013-12-13 16:01:53 +00:00
|
|
|
* @param in Layer 3 message in XML form
|
|
|
|
* @param out Output buffer into which to put encoded data
|
2013-12-16 15:54:54 +00:00
|
|
|
* @param params Encoder parameters
|
2013-12-13 16:01:53 +00:00
|
|
|
* @return Parsing result: 0 (NoError) if succeeded, error status otherwise
|
|
|
|
*/
|
2013-12-16 15:54:54 +00:00
|
|
|
unsigned int encode(const XmlElement* in, DataBlock& out, const NamedList& params = NamedList::empty());
|
2013-12-13 11:27:09 +00:00
|
|
|
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* Decode layer 3 message from an existing XML
|
|
|
|
* @param xml XML which contains layer 3 messages to decode and into which the decoded XML will be put
|
|
|
|
* @param params Decoder parameters
|
|
|
|
* @return Parsing result: 0 (NoError) if succeeded, error status otherwise
|
|
|
|
*/
|
|
|
|
unsigned int decode(XmlElement* xml, const NamedList& params = NamedList::empty());
|
|
|
|
|
|
|
|
/**
|
2014-02-05 11:42:17 +00:00
|
|
|
* Encode a layer 3 message from an existing XML
|
2014-02-28 11:55:58 +00:00
|
|
|
* @param xml XML which contains a layer 3 message in XML form. The message will be replaced with its encoded buffer
|
2013-12-13 16:01:53 +00:00
|
|
|
* @param params Encoder parameters
|
|
|
|
* @return Parsing result: 0 (NoError) if succeeded, error status otherwise
|
|
|
|
*/
|
|
|
|
unsigned int encode(XmlElement* xml, const NamedList& params = NamedList::empty());
|
|
|
|
|
2013-12-13 11:27:09 +00:00
|
|
|
/**
|
|
|
|
* Set data used in debug
|
|
|
|
* @param enabler The DebugEnabler to use (0 to to use the engine)
|
|
|
|
* @param ptr Pointer to print, 0 to use the codec pointer
|
|
|
|
*/
|
|
|
|
void setCodecDebug(DebugEnabler* enabler = 0, void* ptr = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieve codec flags
|
|
|
|
* @return Codec flags
|
|
|
|
*/
|
|
|
|
inline uint8_t flags() const
|
|
|
|
{ return m_flags; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set codec flags
|
|
|
|
* @param flgs Flags to set
|
|
|
|
* @param reset Reset flags before setting these ones
|
|
|
|
*/
|
|
|
|
inline void setFlags(uint8_t flgs, bool reset = false)
|
2014-02-05 11:42:17 +00:00
|
|
|
{
|
2013-12-13 11:27:09 +00:00
|
|
|
if (reset)
|
|
|
|
resetFlags();
|
2014-01-13 14:50:56 +00:00
|
|
|
m_flags |= flgs;
|
2013-12-13 11:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reset codec flags
|
|
|
|
* @param flgs Flags to reset. If 0, all flags are reset
|
|
|
|
*/
|
|
|
|
inline void resetFlags(uint8_t flgs = 0)
|
|
|
|
{
|
|
|
|
if (flgs)
|
|
|
|
m_flags &= ~flgs;
|
|
|
|
else
|
|
|
|
m_flags = 0;
|
|
|
|
}
|
|
|
|
|
2014-01-13 14:50:56 +00:00
|
|
|
/**
|
|
|
|
* Activate printing of debug messages
|
|
|
|
* @param on True to activate, false to disable
|
|
|
|
*/
|
|
|
|
inline void setPrintDbg(bool on = false)
|
|
|
|
{ m_printDbg = on; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get printing of debug messages flag
|
|
|
|
* @return True if debugging is activated, false otherwise
|
|
|
|
*/
|
|
|
|
inline bool printDbg() const
|
|
|
|
{ return m_printDbg; }
|
|
|
|
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* Get DebugEnabler used by this codec
|
|
|
|
* @return DebugEnabler used by the codec
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
inline DebugEnabler* dbg() const
|
|
|
|
{ return m_dbg; }
|
|
|
|
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* Retrieve the codec pointer used for debug messages
|
|
|
|
* @return Codec pointer used for debug messages
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
inline void* ptr() const
|
|
|
|
{ return m_ptr; }
|
|
|
|
|
2014-02-07 08:18:43 +00:00
|
|
|
/**
|
|
|
|
* Decode GSM 7bit buffer
|
|
|
|
* @param buf Input buffer
|
|
|
|
* @param len Input buffer length
|
|
|
|
* @param text Destination text
|
|
|
|
*/
|
|
|
|
static void decodeGSM7Bit(unsigned char* buf, unsigned int len, String& text);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Encode GSM 7bit buffer
|
|
|
|
* @param text Input text
|
|
|
|
* @param buf Destination buffer
|
|
|
|
*/
|
|
|
|
static void encodeGSM7Bit(const String& text, DataBlock& buf);
|
|
|
|
|
2013-12-13 16:01:53 +00:00
|
|
|
/**
|
|
|
|
* IE types dictionary
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
static const TokenDict s_typeDict[];
|
2013-12-13 16:01:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* L3 Protocols dictionary
|
|
|
|
*/
|
2013-12-13 11:27:09 +00:00
|
|
|
static const TokenDict s_protoDict[];
|
2013-12-13 16:01:53 +00:00
|
|
|
|
2013-12-16 15:54:54 +00:00
|
|
|
/**
|
|
|
|
* EPS Security Headers dictionary
|
|
|
|
*/
|
|
|
|
static const TokenDict s_securityHeaders[];
|
|
|
|
|
2013-12-18 15:56:49 +00:00
|
|
|
/**
|
|
|
|
* Errors dictionary
|
|
|
|
*/
|
|
|
|
static const TokenDict s_errorsDict[];
|
|
|
|
|
2014-08-12 11:46:19 +00:00
|
|
|
/**
|
|
|
|
* Mobility Management reject causes dictionary
|
|
|
|
*/
|
|
|
|
static const TokenDict s_mmRejectCause[];
|
|
|
|
|
2015-04-29 08:04:46 +00:00
|
|
|
/**
|
|
|
|
* GPRS Mobility Management reject causes dictionary
|
|
|
|
*/
|
|
|
|
static const TokenDict s_gmmRejectCause[];
|
|
|
|
|
2013-12-13 11:27:09 +00:00
|
|
|
private:
|
2013-12-16 15:54:54 +00:00
|
|
|
|
|
|
|
unsigned int decodeXml(XmlElement* xml, const NamedList& params, const String& pduTag);
|
2013-12-20 16:14:53 +00:00
|
|
|
unsigned int encodeXml(XmlElement* xml, const NamedList& params, const String& pduTag);
|
2014-01-13 14:50:56 +00:00
|
|
|
void printDbg(int dbgLevel, const uint8_t* in, unsigned int len, XmlElement* xml, bool encode = false);
|
2013-12-20 16:14:53 +00:00
|
|
|
|
2013-12-13 11:27:09 +00:00
|
|
|
uint8_t m_flags; // Codec flags
|
|
|
|
// data used for debugging messages
|
|
|
|
DebugEnabler* m_dbg;
|
|
|
|
void* m_ptr;
|
2014-01-13 14:50:56 +00:00
|
|
|
// activate debug
|
|
|
|
bool m_printDbg;
|
2013-12-13 11:27:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}; // namespace TelEngine
|
|
|
|
|
2015-04-07 10:07:44 +00:00
|
|
|
#endif /* __YATERADIO_H */
|
2013-12-13 11:27:09 +00:00
|
|
|
|
|
|
|
/* vi: set ts=8 sw=4 sts=4 noet: */
|