From 1ba13718fc46527587e3dc87e776858c472bb2d2 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Thu, 20 Mar 2014 16:35:57 +0000 Subject: assigned-uniqueids: Miscellaneous cleanup and fixes. * Fix memory leak in ast_unreal_new_channels(). Made it generate the ;2 uniqueid on a stack variable instead of mallocing it. * Made send error response to ARI and AMI requests instead of just logging excessive uniqueid length and allowing truncation. action_originate() and ari_channels_handle_originate_with_id(). * Fixed minor truncating uniqueid hole when generating the ;2 uniqueid string length. Created public and internal lengths of uniqueid. The internal length can handle a max public uniqueid plus an appended ;2. * free() and ast_free() are NULL tolerant so they don't need a NULL test before calling. * Made use better struct initialization format instead of the position dependent initialization format. Also anything not explicitly initialized in the struct is initialized to zero by the compiler. * Made ast_channel_internal_set_fake_ids() use the safer ast_copy_string() instead of strncpy(). Review: https://reviewboard.asterisk.org/r/3371/ ........ Merged revisions 410949 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410950 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/channel.h | 31 +++++++++++++++++++++++++------ include/asterisk/rtp_engine.h | 11 +++++++---- 2 files changed, 32 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index aa2f8634b..497ef0bd3 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -133,12 +133,31 @@ extern "C" { #define AST_MAX_EXTENSION 80 /*!< Max length of an extension */ #define AST_MAX_CONTEXT 80 /*!< Max length of a context */ -#define AST_MAX_UNIQUEID 150 /*!< Max length of a channel uniqueid */ -/* 150 = 127 (max systemname) + "-" + 10 (epoch - * timestamp) + "." + 10 (monotonically incrementing - * integer) + NULL. Note that if this value is ever - * changed, MAX_CHANNEL_ID should be updated in - * rtp_engine.h */ + +/*! + * Max length of a channel uniqueid reported to the outside world. + * + * \details + * 149 = 127 (max systemname) + "-" + 10 (epoch timestamp) + * + "." + 10 (monotonically incrementing integer). + * + * \note If this value is ever changed, MAX_CHANNEL_ID should + * be updated in rtp_engine.h. + */ +#define AST_MAX_PUBLIC_UNIQUEID 149 + +/*! + * Maximum size of an internal Asterisk channel unique ID. + * + * \details + * Add two for the Local;2 channel to append a ';2' if needed + * plus nul terminator. + * + * \note If this value is ever changed, MAX_CHANNEL_ID should + * be updated in rtp_engine.h. + */ +#define AST_MAX_UNIQUEID (AST_MAX_PUBLIC_UNIQUEID + 2 + 1) + #define AST_MAX_ACCOUNT_CODE 20 /*!< Max length of an account code */ #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */ #define MAX_LANGUAGE 40 /*!< Max length of the language setting */ diff --git a/include/asterisk/rtp_engine.h b/include/asterisk/rtp_engine.h index 9d6c7b4f4..677a59c31 100644 --- a/include/asterisk/rtp_engine.h +++ b/include/asterisk/rtp_engine.h @@ -86,11 +86,14 @@ extern "C" { /* Maximum number of generations */ #define AST_RED_MAX_GENERATION 5 -/* Maximum size of an Asterisk channel unique ID. Should match AST_MAX_UNIQUEID. - * Note that we don't use that defined value directly here to avoid a hard dependency - * on channel.h +/*! + * Maximum size of an internal Asterisk channel unique ID. + * + * \note Must match the AST_MAX_UNIQUEID(AST_MAX_PUBLIC_UNIQUEID) value. + * We don't use that defined value directly here to avoid a hard + * dependency on channel.h. */ -#define MAX_CHANNEL_ID 150 +#define MAX_CHANNEL_ID 152 struct ast_rtp_instance; struct ast_rtp_glue; -- cgit v1.2.3