Added SNMP support.

git-svn-id: http://voip.null.ro/svn/yate@3776 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
oana 2010-11-03 16:27:30 +00:00
parent 1d9e0f3256
commit 55813dcbe3
42 changed files with 17644 additions and 41 deletions

View File

@ -0,0 +1,154 @@
; configure monitor module
[general]
; restart_alarm=
; after how many Yate restarts should the monitor send an alarm.
; default is 1
;restart_alarm=1
; time (in seconds) for specifying for how long cached data should be kept or with which the cache time is increased on each access
;cache=1
[database]
; enable or disable database monitoring. Default is false
;monitor=false
;[yate]
; this section is an example on how to configure a database account to be monitored
; name of the section is the database account
; type=
; specify that this section is for database monitoring
;type=database
;interval in seconds at which statistic data should be sent. Defaults to 3600 (1 hour)
;notiftime=3600
; alarm threshold for maximum number of queries. Defaults to 1000
;maxqueries=1000
; alarm threshold for maximum number of failed queries. Defaults to 500
;maxfailed=500
; alarm threshold for maximum number of queries returned with an error status. Defaults to 500
;maxerrors=500
; alarm threshold for time took to execute a query. In miliseconds, defaults to 10 seconds.
;maxtimeperquery=10000
[call_qos]
; this is the configuration section for call monitoring
; to disable call monitoring comment this entire section or set monitor to false. Defaults to false.
;monitor=false
; specify the call.cdr parameter based on which route monitoring should be done. Defaults to address.
;route=address
; time_interval=
; Time interval in seconds at which the monitored values should be sent as notifications.
; Default value is 3600 (1 hour)
;time_interval=3600
;[192.168.168.185]
; this section is an example on how to configure a routing direction to be monitor for ASR/NER values and call statistics
; name of this section is the routing direction name. It should match the value of the route param from the call.cdr message
; specify that this section is for call QOS monitoring on a given route
;type=call_qos
; minASR=
; lower threshold at which the low ASR alarm is set for the current time interval. Value can be 0..100
; Default is 0 ( to mean that no low ASR alarm will be sent)
;minASR=0
; maxASR=
; upper threshold at which the high ASR alarm is set for the current time interval.
; Default is 101 ( to mean that no high ASR alarm will be sent)
;maxASR=101
; minNER=
; threshold at which the low NER alarm should be set.
; Defaults to 0
;minNER=0
; minimum number of calls received before calculating ASR and NER
; Defaults to 1
;mincalls=1
[sip]
; monitoring SIP parameters
; list of gateways of which state to monitor
; It is a list of IP:port addresses separated by ';'
; If port is not present, the default SIP (5060) port will be added
;gateways=
; threshold for sending an alarm signalling to many failed SIP authentications. Default is 0 (no alarm)
;max_failed_auths=0
; threshold for sending an alarm signalling that too many SIP transactions have timed out. Default is 0 (no alarm)
;max_transaction_timeouts=0
;threshold for sending an alarm signalling that too many SIP BYE transactions have not been acknowledged. Default is 0 (no alarm)
;max_byes_timeouts=0
; reset interval for alarms in seconds. Default is 0 (meaning alarms are not reset)
;reset_time=0
[sig]
; enable monitoring for signalling components. Defaults to false.
;monitor=false
; monitor trunks. Overrides the monitor value. Defaults to the monitor value.
;trunk=
; monitor linkset. Overrides the monitor value. Defaults to the monitor value.
;linkset=
; monitor links. Overrides the monitor value. Defaults to the monitor value.
;link=
; monitor physical interfaces. Overrides the monitor value. Defaults to the monitor value.
;interface=
; monitor ISDN. Overrides the monitor value. Defaults to the monitor value.
;isdn=
[rtp]
; enable RTP monitoring? Defaults to false.
;monitor=false
; RTP destinations to be monitored. Should be a comma separated list.
; i.e. rtp_directions=192.168.168.185,127.0.0.1
;rtp_directions=
; interval in secconds at which collected data should be reset. Defaults to 3600 seconds.
;reset_interval=3600
[mgcp]
; send notification if a MGCP gateway goes offline/back online? Defaults to false.
;gw_monitor=false
; threshold for sending an alarm signalling that too many MGCP transactions have timed out. Default is 0 (no alarm)
;max_transaction_timeouts=0
; threshold for sending an alarm signalling that too many MGCP DLCX transactions have timed out. Default is 0 (no alarm)
;max_deletes_timeouts=0
; reset interval in seconds. Defaults to 0 (no reset)
;reset_time=0

View File

@ -0,0 +1,86 @@
[general]
; general SNMP configuration
; port on which the module listens for SNMP messages. Defaults to 161.
;port=161
;thread priority for SNMP message processing. Defaults to normal.
;thread=normal
[snmp_v2]
; SNMPv2 configuration
; read only access community string. Mandatory.
ro_community=
; read write access community string. Mandatory.
rw_community=
; read create access community string.
rc_community=
[snmp_v3]
; SNMPv3 configuration
; format for generating the snmpEngineID
; values are
; 1 = IPv4 address format,
; 2 = IPv6 address format,
; 3 = MAC address format,
; 4 = TEXT format,
; 5 = OCTETS format,
; 128 = ENTERPRISE specific format
; Defaults to 4 (TEXT)
;engine_format=4
; information for generating the snmpEngineID. Must correspond to the format set (i.e. if engine_format=1, engine_info must be a IPv4 address)
; NOTE! IPv6 address must not use the IPv6 short format. Mandatory.
; NOTE! OCTETS format must be a hexified string
engine_info=
[traps]
; SNMP traps configuration
;enable or disable all_notifications. Defaults to true.
;enable_traps=true
; list traps to disable. Must be separated by ','.
; An entire substree of traps can be disabled by ending the name of the trap with ".*"
; (e.g. disable the whole database status traps by adding database.*)
disable_traps=
; IP address to which the traps are sent. Defaults to localhost.
;remote_ip=localhost
; port for the remote IP. Defaults to 162.
;remote_port=162
;SNMP protocol version to use for sending traps (values are SNMPv2c or SNMPv3). Defaults to SNMPv2c.
;proto_version=SNMPv2c
; if SNMPv2 is used, set the community string used for the remote SNMP entity. Mandatory if SNMPv2c traps are used.
community=
; if SNMPv3 is used, specify which configured user should be used for sending traps (there must be a section named like the given value to trap_user)
; see the example bellow (section [userV3]) for configuring a SNMPv3 user
; the specified user will not allowed to interrogate this SNMP agent, it will only be used to send traps to the configured traps receiver
;trap_user=
;[userV3]
; Configure a section for a SNMPv3 user. The name of the user is the name of the section.
; To allow SNMPv3 interrogation, at least one SNMPv3 user must be configured
; authentication pass phrase. If it is not set, authentication will not be required
;auth_password=
; authentication method ( MD5 | SHA1 ) in case it is used.
;auth_protocol=MD5
; privacy pass phrase. If it is not set, encryption will not be required
;priv_password=
; privacy encryption method ( DES | AES). Default is DES.
;priv_protocol=DES
; user access level. Mandatory. Acceptable values are: readonly, readwrite, readcreate.
;access=

View File

@ -1272,11 +1272,14 @@ AC_CONFIG_FILES([packing/rpm/yate.spec
libs/ysig/Makefile
libs/ypbx/Makefile
libs/ymodem/Makefile
libs/yasn/Makefile
libs/ysnmp/Makefile
share/Makefile
share/scripts/Makefile
share/skins/Makefile
share/sounds/Makefile
share/help/Makefile
share/data/Makefile
conf.d/Makefile])
AC_CONFIG_FILES([yate-config],[chmod +x yate-config])
AC_CONFIG_FILES([run],[chmod +x run])

56
libs/yasn/Makefile.in Normal file
View File

@ -0,0 +1,56 @@
# Makefile
# This file holds the make rules for the libyasn
DEBUG :=
CXX := @CXX@ -Wall
AR := ar
DEFS :=
INCLUDES := -I@top_srcdir@ -I../.. -I@srcdir@
CFLAGS := @CFLAGS@ @MODULE_CPPFLAGS@ @INLINE_FLAGS@
LDFLAGS:= @LDFLAGS@ -L../.. -lyate
INCFILES := @top_srcdir@/yateclass.h @srcdir@/yateasn.h
PROGS=
LIBS = libyasn.a
OBJS = asn.o
LOCALFLAGS =
LOCALLIBS =
COMPILE = $(CXX) $(DEFS) $(DEBUG) $(INCLUDES) $(CFLAGS)
LINK = $(CXX) $(LDFLAGS)
prefix = @prefix@
exec_prefix = @exec_prefix@
# include optional local make rules
-include YateLocal.mak
.PHONY: all debug ddebug xdebug
all: $(LIBS) $(LIBD) $(PROGS)
debug:
$(MAKE) all DEBUG=-g3 MODSTRIP=
ddebug:
$(MAKE) all DEBUG='-g3 -DDEBUG' MODSTRIP=
xdebug:
$(MAKE) all DEBUG='-g3 -DXDEBUG' MODSTRIP=
.PHONY: strip
strip: all
strip --strip-debug --discard-locals $(PROGS)
.PHONY: clean
clean:
@-$(RM) $(PROGS) $(LIBS) $(OBJS) core 2>/dev/null
%.o: @srcdir@/%.cpp $(INCFILES)
$(COMPILE) -c $<
Makefile: @srcdir@/Makefile.in ../../config.status
cd ../.. && ./config.status
libyasn.a: $(OBJS)
$(AR) rcs $@ $^

1431
libs/yasn/asn.cpp Normal file

File diff suppressed because it is too large Load Diff

938
libs/yasn/yateasn.h Normal file
View File

@ -0,0 +1,938 @@
/**
* yateasn.h
* This file is part of the YATE Project http://YATE.null.ro
*
* ASN.1 Library
*
* Yet Another Telephony Engine - a fully featured software PBX and IVR
* Copyright (C) 2004-2010 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __YATEASN_H
#define __YATEASN_H
#include <yatengine.h>
#ifdef _WINDOWS
#ifdef LIBYASN_EXPORTS
#define YASN_API __declspec(dllexport)
#else
#ifndef LIBYASN_STATIC
#define YASN_API __declspec(dllimport)
#endif
#endif
#endif /* _WINDOWS */
#ifndef YASN_API
#define YASN_API
#endif
namespace TelEngine {
#define ASN_LONG_LENGTH 0x80
#define ASN_BIT8 0x80
#define ASN_EXTENSION_ID 31
#define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
class AsnObject;
class AsnValue;
class AsnMibTree;
class ASNObjId;
class ASNLib;
class ASNError;
/**
* Helper class for operations with octet strings. Helps with conversions from String to/from DataBlock
* @short Helper class for operations with octet strings
*/
class OctetString : public DataBlock
{
public:
/**
* Get the String contained in this buffer
* @return String containing the internal data
*/
inline String getString()
{
String str((const char*)data(),length());
return str;
}
inline DataBlock& operator=(const String& value)
{
clear();
append(value);
return *this;
}
inline DataBlock& operator=(const DataBlock& value)
{
clear();
append(value);
return *this;
}
/**
* Get the content of the buffer in form of a hexified string
* @return Hexified string
*/
inline const String toHexString() const
{
String str;
str = str.hexify(data(),length());
return str;
}
/**
* Builed this DataBlock from a hexified string
* @return The DataBlock built from the given hexified string
*/
inline DataBlock& fromHexString(const String& value)
{
unHexify(value,value.length());
return *this;
}
};
/**
* Abstract class implemented by all ASN.1 type objects
* @short Base Class for ASN.1 objects
*/
class YASN_API AsnObject : public GenObject {
YCLASS(AsnObject, GenObject)
public:
/**
* Constructor
*/
inline AsnObject()
{}
/**
* Constructor
* @param data Data from which the object is built
* @param len Length of the given data
*/
AsnObject(void* data, int len)
{}
/**
* Destructor
*/
virtual inline ~AsnObject()
{}
/**
* Function to decode the parameters of this object from given data
* @param data DataBlock from which the object is decoded
*/
virtual int decode(DataBlock& data) = 0;
/**
* Function to encode this object into a datablock
* @param data The DataBlock in which the object should be encoded
*/
virtual int encode(DataBlock& data) = 0;
/**
* Function for obtaining this object's data
* @param params NamedList in which this object's data should be put
*/
virtual void getParams(NamedList* params) = 0;
/**
* Function for setting this object's data
* @param params NamedList containing the values to which this object's data should be set
*/
virtual void setParams(NamedList* params) = 0;
};
/**
* Class wrapper for different types of ASN.1 values
* @short An ASN.1 value
*/
class YASN_API AsnValue : public GenObject {
YCLASS(AsnValue, GenObject)
public:
/**
* Type of value
*/
enum ValType {
INTEGER = 1,
STRING = 2,
OBJECT_ID = 3,
IPADDRESS = 4,
COUNTER = 5,
TIMETICKS = 6,
ARBITRARY = 7,
BIG_COUNTER = 8,
UNSIGNED_INTEGER = 9
};
/**
* Constructor
*/
inline AsnValue()
: m_type(0), m_data("")
{}
/**
* Constructor
* @param value Object value
* @param type AsnValue type, default is String
*/
inline AsnValue(const String& value, int type = STRING)
: m_type(type), m_data(value)
{ }
/**
* Destructor
*/
virtual inline ~AsnValue()
{}
/**
* Get the value in the form of a string
* @return String containing the internal data
*/
inline String getValue()
{ return m_data;}
/**
* Get the type of the data so that we know how to interpret it
* @return The type of the data
*/
inline int type()
{ return m_type;}
/**
* Assign operator
*/
inline AsnValue& operator=( AsnValue* val)
{
if (!val)
return *this;
m_data = val->getValue();
m_type = val->type();
return *this;
}
/**
* Assign operator
*/
inline AsnValue& operator=( AsnValue val)
{
m_data = val.getValue();
m_type = val.type();
return *this;
}
/**
* Set data
* @param data The data to which the internal data will be set
*/
inline void setValue(const String& data)
{ m_data.clear();m_data = data; }
/**
* Set data type
* @param type The type assigned
*/
inline void setType(int type)
{ m_type = type; }
private:
int m_type;
String m_data;
};
/**
* Class describing an ASN.1 OID
*/
class YASN_API AsnMib : public GenObject {
YCLASS(AsnMib, GenObject)
public:
/**
* Access levels
*/
enum Access {
notAccessible = 0,
accessibleForNotify = 1,
readOnly = 2,
readWrite = 3,
readCreate = 4
};
/**
* Constructor
*/
inline AsnMib()
: m_access(""), m_accessVal(0), m_index(0)
{}
/**
* Constructor
* @param params NamedList containing data for building this object, it should contain name, access level, value type
*/
AsnMib(NamedList* params);
/**
* Destructor
*/
inline ~AsnMib()
{}
/**
* Get OID access level in string form
* @return String containing the access level for this OID. It's one of the following values : not-accessible, read-only, read-write,
read-create, accessible-for-notify.
*/
inline String& getAccess()
{ return m_access;}
/**
* Get OID access level
* @return String containing the access level for this OID. It's one of the following values : not-accessible, read-only, read-write,
read-create, accessible-for-notify.
*/
inline int getAccessValue()
{ return m_accessVal;}
/**
* Get the name of this OID
* @return Name of the OID
*/
inline String& getName()
{ return m_name;}
/**
* Get the oid
* @return The OID
*/
inline String getOID()
{ String str = ".";
str += m_index;
return m_oid + str;}
/**
* Get the type of the value of this OID
* @return String containing the type of value
*/
inline String& getType()
{ return m_type;}
/**
* Get the revision of this OID
* @return String containing the revision string
*/
inline String& getRevision()
{ return m_revision; }
/**
* Get the string representation of this OID
* @return String representation of this OID
*/
inline const String& toString() const
{ return m_oid;}
/**
* Set the index of an OID in case this OID is part of a table.
* @param ind Given index
*/
inline void setIndex(unsigned int ind)
{ m_index = ind;}
/**
* Obtain the index of this OID
* @return This OID's index in the OID table
*/
inline unsigned int index()
{ return m_index;}
/**
* Compare this object ID with another
* @param mib The object ID with which this object should be compared
* @return 0 if they're equal, -1 if this object is less lexicographically then the given parameter, 1 if it's greater
*/
int compareTo(AsnMib* mib);
/**
* Get the parent object ID of this object
* @return String version of the parent ID
*/
inline String getParent()
{
int pos = m_oid.rfind('.');
return m_oid.substr(0,pos);
}
private:
String m_name;
String m_oid;
String m_access;
int m_accessVal;
String m_type;
String m_revision;
int size;
int maxVal;
int minVal;
unsigned int m_index;
static TokenDict s_access[];
};
/**
* Tree of OIDs.
*/
class YASN_API AsnMibTree : public GenObject {
YCLASS(AsnMibTree, GenObject)
public:
/**
* Constructor
*/
inline AsnMibTree()
{}
/**
* Constructor
* @param fileName File from which the tree is to be built
*/
AsnMibTree(const String& fileName);
/**
* Destructor
*/
virtual ~AsnMibTree();
/**
* Find a MIB object given the object id
* @param id The object id
* @return A pointer to the MIB with the searched object id, 0 if not found
*/
AsnMib* find(const ASNObjId& id);
/**
* Find a MIB given the MIB name
* @param name The name of the MIB object
* @return A pointer to the MIB with the searched object id, 0 if not found
*/
AsnMib* find(const String& name);
/**
* Find the next MIB object in the tree
* @param id Object id of the current MIB object
* @return A pointer to the next MIB object in the tree, 0 if there is no next
*/
AsnMib* findNext(const ASNObjId& id);
/**
* Get access level for the given object id
* @param oid Object id for which the access level is required
* @return Enum value describing the access level required for this object
*/
int getAccess(const ASNObjId& oid);
/**
* Build the tree of MIB objects
*/
void buildTree();
/**
* Find the module revision of which this OID is part of
* @param name Name of the OID
* @return String value of the module revision
*/
String findRevision(const String& name);
private:
Configuration m_treeConf;
ObjList m_mibs;
};
/**
* Class for holding only an OID
*/
class YASN_API ASNObjId : public GenObject {
YCLASS(ASNObjId, GenObject)
public:
/**
* Constructor
*/
ASNObjId();
/**
* Constructor
* @param val OID value in string format
*/
ASNObjId(const String& val);
/**
* Constructor
* @param name Name of the OID
* @param val OID value in string format
*/
ASNObjId(const String& name, const String& val);
/**
* Constructor
* @param mib Mib used for creating this OID
*/
ASNObjId(AsnMib* mib);
/**
* Destructor
*/
~ASNObjId();
/**
* Assign operator from a string value
*/
ASNObjId& operator=(const String& val);
/**
* Assign operator from a const char* value
*/
ASNObjId& operator=(const char* val);
/**
* Transform the value of this OID from a string value to a sequence of numbers
*/
void toDataBlock();
/**
* Get the sequence form of the OID
* @return Datablock sequence of ids
*/
DataBlock getIds();
/**
* String representation of the OID
*/
inline const String& toString() const
{ return m_value; }
/**
* Get the name of the OID
* @return String representation of the name
*/
inline const String& getName() const
{ return m_name; }
/**
* Set the OID value
* @param value OID value
*/
inline void setValue(const String& value)
{ m_value = value; toDataBlock();}
private:
String m_value;
String m_name;
DataBlock m_ids;
};
/**
* Class ASNLib
* @short Class containing functions for decoding/encoding ASN.1 basic data types
*/
class YASN_API ASNLib {
public:
/**
* ASN.1 Type tags
*/
enum TypeTag {
UNIVERSAL = 0x00,
BOOLEAN = 0x01,
INTEGER = 0x02,
BIT_STRING = 0x03,
OCTET_STRING = 0x04,
NULL_ID = 0x05,
OBJECT_ID = 0x06,
REAL = 0x09, //not implemented
UTF8_STR = 0x0c,
SEQUENCE = 0x30,
SET = 0x31,
NUMERIC_STR = 0x12,
PRINTABLE_STR = 0x13,
IA5_STR = 0x16,
UTC_TIME = 0x17,
GENERALIZED_TIME = 0x18,
VISIBLE_STR = 0x1a,
GENERAL_STR = 0x1b, // not implemented
UNIVERSAL_STR = 0x1c, // not implemented
CHARACTER_STR = 0x1d, // not implemented
BMP_STR = 0x1e, // not implemented
CHOICE = 0x1f, // does not have a value
DEFINED = 0x2d
};
// values not implemented
// 10 ENUMERATED
// 11 EMBEDDED PDV
// 13 RELATIVE-OID
// 20 TeletexString, T61String
// 21 VideotexString
// 25 GraphicString
// 27 GeneralString
// 28 UniversalString
// 29 CHARACTER STRING
// 30 BMPString
/**
* Error types
*/
enum Error {
InvalidLengthOrTag = -1,
ConstraintBreakError = -2,
ParseError,
InvalidContentsError
};
/**
* Constructor
*/
ASNLib();
/**
* Destructor
*/
~ASNLib();
/**
* Decode the length of the block data containing the ASN.1 type data
* @param data Input block from which to extract the length
* @return The length of the data block containing data, -1 if it couldn't be decoded
*/
static int decodeLength(DataBlock& data);
/**
* Decode a boolean value from the encoded data
* @param data Input block from which the boolean value should be extracted
* @param val Pointer to a boolean to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for boolean (0x01) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the boolean value could not be decoded
*/
static int decodeBoolean(DataBlock& data, bool* val, bool tagCheck);
/**
* Decode an integer value from the encoded data
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param bytes Width of the decoded integer field
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeInteger(DataBlock& data, u_int64_t& intVal, unsigned int bytes, bool tagCheck);
/**
* Decode an unsigned integer value from the encoded data - helper function for casting from u_int64_t to u_int8_t in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeUINT8(DataBlock& data, u_int8_t* intVal, bool tagCheck);
/**
* Decode an unsigned integer value from the encoded data - helper function for casting from u_int64_t to u_int16_t in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeUINT16(DataBlock& data, u_int16_t* intVal, bool tagCheck);
/**
* Decode an unsigned integer value from the encoded data - helper function for casting from u_int64_t to u_int32_t in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeUINT32(DataBlock& data, u_int32_t* intVal, bool tagCheck);
/**
* Decode an unsigned integer value from the encoded data - helper function for casting in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeUINT64(DataBlock& data, u_int64_t* intVal, bool tagCheck);
/**
* Decode an integer value from the encoded data - helper function for casting from u_int64_t to int8_t in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeINT8(DataBlock& data, int8_t* intVal, bool tagCheck);
/**
* Decode an integer value from the encoded data - helper function for casting from u_int64_t to int16_t in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeINT16(DataBlock& data, int16_t* intVal, bool tagCheck);
/**
* Decode an integer value from the encoded data - helper function for casting from u_int64_t to int32_t in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeINT32(DataBlock& data, int32_t* intVal, bool tagCheck);
/**
* Decode an integer value from the encoded data - helper function for casting in case of size constraints
* @param data Input block from which the integer value should be extracted
* @param intVal Integer to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x02) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeINT64(DataBlock& data, int64_t* intVal, bool tagCheck);
/**
* Decode a bitstring value from the encoded data
* @param data Input block from which the bitstring value should be extracted
* @param val String to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x03) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeBitString(DataBlock& data, String* val, bool tagCheck);
/**
* Decode a string value from the encoded data
* @param data Input block from which the octet string value should be extracted
* @param strVal String to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x04) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeOctetString(DataBlock& data, OctetString* strVal, bool tagCheck);
/**
* Decode a null value from the encoded data
* @param data Input block from which the null value should be extracted
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x05) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeNull(DataBlock& data, bool tagCheck);
/**
* Decode an object id value from the encoded data
* @param data Input block from which the OID value should be extracted
* @param obj ASNObjId to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x06) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeOID(DataBlock& data, ASNObjId* obj, bool tagCheck);
/**
* Decode a real value from the encoded data - not implemented
* @param data Input block from which the real value should be extracted
* @param realVal Float to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag for integer (0x09) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeReal(DataBlock& data, float* realVal, bool tagCheck);
/**
* Decode other types of ASN.1 strings from the encoded data (NumericString, PrintableString, VisibleString, IA5String)
* @param data Input block from which the string value should be extracted
* @param str String to be filled with the decoded value
* @param type Integer to be filled with the value indicating which type of string has been decoded
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeString(DataBlock& data, String* str, int* type, bool tagCheck);
/**
* Decode an UTF8 string from the encoded data
* @param data Input block from which the string value should be extracted
* @param str String to be filled with the decoded value
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x0c) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeUtf8(DataBlock& data, String* str, bool tagCheck);
/**
* Decode a GeneralizedTime value from the encoded data
* @param data Input block from which the value should be extracted
* @param time Integer to be filled with time in seconds since epoch
* @param fractions Integer to be filled with fractions of a second
* @param utc Flag indicating if the decode time value represent local time or UTC time
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x18) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeGenTime(DataBlock& data, unsigned int* time, unsigned int* fractions, bool* utc, bool tagCheck);
/**
* Decode a UTC time value from the encoded data
* @param data Input block from which the value should be extracted
* @param time Integer to be filled with time in seconds since epoch
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 tag (0x17) should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeUTCTime(DataBlock& data, unsigned int* time, bool tagCheck);
/**
* Decode a block of arbitrary data
* @param data Input block from which the value should be extracted
* @param val DataBlock in which the data shoulb be copied
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 should be verified
* @return Length of data consumed from the input data it the decoding was successful, -1 if the integer value could not be decoded
*/
static int decodeAny(DataBlock data, DataBlock* val, bool tagCheck);
/**
* Decode the header of an ASN.1 sequence ( decodes the tag and the length of the sequence)
* @param data Input block from which the header should be extracted
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 (0x30) should be verified
* @return Length of data consumed from the input data it the decoding was succesful, -1 if the integer value could not be decoded
*/
static int decodeSequence(DataBlock& data, bool tagCheck);
/**
* Decode the header of an ASN.1 set ( decodes the tag and the length of the sequence)
* @param data Input block from which the header should be extracted
* @param tagCheck Flag for indicating if in the process of decoding the value the presence of the ASN.1 (0x31) should be verified
* @return Length of data consumed from the input data it the decoding was succesful, -1 if the integer value could not be decoded
*/
static int decodeSet(DataBlock& data, bool tagCheck);
/**
* Encode the length of the given data
* @param data The data for which the length should be encoded
* @return The data block which now contains the length encoding
*/
static DataBlock buildLength(DataBlock& data);
/**
* Encode the given boolean value
* @param val The boolean value to encode
* @param tagCheck Flag to specify if the boolean type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeBoolean(bool val, bool tagCheck);
/**
* Encode the given integer value
* @param intVal The integer value to encode
* @param tagCheck Flag to specify if the integer type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeInteger(u_int64_t intVal, bool tagCheck);
/**
* Encode the given octet string value
* @param strVal The octet string value to encode
* @param tagCheck Flag to specify if the octet string type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeOctetString(OctetString strVal, bool tagCheck);
/**
* Encode a null value
* @param tagCheck Flag to specify if the null tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeNull(bool tagCheck);
/**
* Encode the given bitstring value
* @param val The bitstring value to encode
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeBitString(String val, bool tagCheck);
/**
* Encode the given OID value
* @param obj The OID value to encode
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeOID(ASNObjId obj, bool tagCheck);
/**
* Encode the given real value - not implemented
* @param val The real value to encode
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeReal(float val, bool tagCheck);
/**
* Encode the given string value to NumericString, PrintableString, IA5String, VisibleString
* @param str The string value to encode
* @param type The type of the encoding
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeString(String str, int type, bool tagCheck);
/**
* Encode the UTF8 string value
* @param str The string value to encode
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeUtf8(String str, bool tagCheck);
/**
* Encode the given time value into a GeneralizedTime format
* @param time Time in seconds since epoch to encode
* @param fractions Fractions of a seconds to encode
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeGenTime(unsigned int time, unsigned int fractions, bool tagCheck);
/**
* Encode the given time value into an UTCTime format
* @param time Time in seconds since epoch to encode
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeUTCTime(unsigned int time, bool tagCheck);
/**
* Encode an arbitrary block a data
* @param data data
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The data block encoding of the value
*/
static DataBlock encodeAny(DataBlock data, bool tagCheck);
/**
* Encode the header for a sequence
* @param data Sequence data for which the header is encoded
* @param tagCheck Flag to specify if the ype tag should be inserted in the encoding
* @return The length of the data block length encoding
*/
static int encodeSequence(DataBlock& data, bool tagCheck);
/**
* Encode the header for a set
* @param data Sequence data for which the header is encoded
* @param tagCheck Flag to specify if the type tag should be inserted in the encoding
* @return The length of the data block length encoding
*/
static int encodeSet(DataBlock& data, bool tagCheck);
};
}
#endif /* __YATEASN_H */
/* vi: set ts=8 sw=4 sts=4 noet: */

View File

@ -2151,6 +2151,13 @@ public:
JBClientStream* create(const String& account, const NamedList& params,
const String& name = String::empty());
/**
* Retrieve the list of streams of a given type
* @param list The destination list to set
* @param type Stream type
*/
virtual void getStreamList(RefPointer<JBStreamSetList>& list, int type);
protected:
/**
* Add a stream to one of the stream lists
@ -2172,13 +2179,6 @@ protected:
*/
virtual void stopStreamSets(bool waitTerminate = true);
/**
* Retrieve the list of streams of a given type
* @param list The destination list to set
* @param type Stream type
*/
virtual void getStreamList(RefPointer<JBStreamSetList>& list, int type);
JBStreamSetList* m_receive; // Streams receive list
JBStreamSetList* m_process; // Streams process list
};

View File

@ -394,6 +394,8 @@ MGCPEvent* MGCPTransaction::checkTimeout(u_int64_t time)
}
m_timeout = (state() == Initiated || state() == Trying);
if (m_timeout)
engine()->timeout(this);
return terminate();
}

View File

@ -1014,6 +1014,13 @@ public:
static inline int defaultPort(bool gateway)
{ return gateway ? 2427 : 2727; }
/**
* Handle a transaction that has timed out
* @param tr The transaction that has timed out
*/
virtual void timeout(MGCPTransaction* tr)
{ }
/**
* The list of commands defined in RFC 3435
*/

View File

@ -184,6 +184,7 @@ void RTPReceiver::rtpData(const void* data, int len)
Debug(DebugWarn,"RTP Received SSRC %08X but expecting %08X [%p]",
ss,m_ssrc,this);
}
m_wrongSSRC++;
return;
}
// SSRC accepted, sync sequence and resync the timestamp offset
@ -196,6 +197,8 @@ void RTPReceiver::rtpData(const void* data, int len)
// substraction with overflow
int16_t ds = seq - m_seq;
if (ds != 1)
m_seqLost++;
// check if we received duplicate or delayed packet
// be much more tolerant when authenticating as we cannot resync
if ((ds <= 0) || ((ds > SEQ_DESYNC_COUNT) && !secPtr)) {
@ -212,6 +215,7 @@ void RTPReceiver::rtpData(const void* data, int len)
m_ts = ts - m_tsLast;
m_seqCount = 0;
m_warn = true;
m_syncLost++;
// drop this packet, next packet will come in correctly
return;
}
@ -377,6 +381,15 @@ bool RTPReceiver::rtpCheckIntegrity(const unsigned char* data, int len, const vo
: true;
}
void RTPReceiver::stats(NamedList& stat) const
{
if (m_session)
stat.setParam("remoteip",m_session->UDPSession::transport()->remoteAddr().host());
stat.setParam("lostpkts",String(m_ioLostPkt));
stat.setParam("synclost",String(m_syncLost));
stat.setParam("wrongssrc",String(m_wrongSSRC));
stat.setParam("seqslost",String(m_seqLost));
}
RTPSender::RTPSender(RTPSession* session, bool randomTs)
: RTPBaseIO(session), m_evTime(0), m_padding(0)
@ -551,6 +564,9 @@ void RTPSender::rtpAddIntegrity(const unsigned char* data, int len, unsigned cha
m_secure->rtpAddIntegrity(data,len,authData);
}
void RTPSender::stats(NamedList& stat) const
{
}
UDPSession::UDPSession()
: m_transport(0), m_timeoutTime(0), m_timeoutInterval(0)
@ -872,6 +888,15 @@ void RTPSession::setReports(int interval)
m_reportTime = 0;
}
void RTPSession::getStats(NamedList& stats) const
{
if (m_send)
m_send->stats(stats);
if (m_recv)
m_recv->stats(stats);
stats.setParam("wrongsrc",String(m_wrongSrc));
}
static void store32(unsigned char* buf, unsigned int& len, u_int32_t val)
{
buf[len++] = (unsigned char)(val >> 24);
@ -945,6 +970,11 @@ void RTPSession::sendRtcpBye()
static_cast<RTPProcessor*>(m_transport)->rtcpData(buf,8);
}
void RTPSession::incWrongSrc()
{
Debug(DebugAll,"RTPSession::incWrongSrc() [%p]",this);
m_wrongSrc++;
}
UDPTLSession::UDPTLSession(u_int16_t maxLen, u_int8_t maxSec)
: m_rxSeq(0xffff), m_txSeq(0xffff),

View File

@ -126,7 +126,7 @@ void RTPGroup::setMinSleep(int msec)
RTPProcessor::RTPProcessor()
: m_group(0)
: m_wrongSrc(0), m_group(0)
{
DDebug(DebugAll,"RTPProcessor::RTPProcessor() [%p]",this);
}
@ -218,6 +218,8 @@ void RTPTransport::timerTick(const Time& when)
if (m_monitor)
m_monitor->rtpData(buf,len);
}
else
m_processor->incWrongSrc();
}
m_rtpSock.timerTick(when);
}

View File

@ -105,6 +105,19 @@ public:
*/
virtual void getStats(String& stats) const;
/**
* Increase the counter for number of RTP packets received from a wrong source
*/
virtual inline void incWrongSrc()
{ }
/**
* Get the number of RTP packets that were received from a wrong source
* @return Number of RTP packets received from a wrong source
*/
inline unsigned int wrongSrc()
{ return m_wrongSrc; }
protected:
/**
* Set a new RTP group for this processor
@ -118,6 +131,8 @@ protected:
*/
virtual void timerTick(const Time& when) = 0;
unsigned int m_wrongSrc;
private:
RTPGroup* m_group;
};
@ -578,7 +593,8 @@ public:
inline RTPReceiver(RTPSession* session = 0)
: RTPBaseIO(session),
m_ioLostPkt(0), m_dejitter(0),
m_seqSync(0), m_seqCount(0), m_warn(true)
m_seqSync(0), m_seqCount(0), m_warn(true),
m_seqLost(0), m_wrongSSRC(0), m_syncLost(0)
{ }
/**
@ -662,6 +678,12 @@ public:
*/
virtual void rtpNewSSRC(u_int32_t newSsrc, bool marker);
/**
* Retrieve the statistical data from this receiver in a NamedList. Reset all the data.
* @<