Merged revisions 379021,379023 via svnmerge from

file:///srv/subversion/repos/asterisk/trunk

................
  r379021 | dlee | 2013-01-14 09:29:22 -0600 (Mon, 14 Jan 2013) | 15 lines
  
  Fix XML encoding of 'identity display' in NOTIFY messages, continued.
  
  When r378933 was merged into 1.8, it should have also escaped
  remote_display, since it will have the same XML encoding problem when
  the caller/callee roles are reversed.
  
  (closes issue ABE-2902)
  Reported by: Guenther Kelleter
  ........
  
  Merged revisions 379001 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 379020 from http://svn.asterisk.org/svn/asterisk/branches/11
................
  r379023 | dlee | 2013-01-14 09:58:01 -0600 (Mon, 14 Jan 2013) | 20 lines
  
  Masquerades are an insane implementation detail within Asterisk. It generates
  a number of useless and confusing events, and manipulates channels in a way
  that semantically doesn't make sense. I've given a fairly thorough review of
  masquerade code and its usage on the wiki at
  https://wiki.asterisk.org/wiki/x/IwBRAQ.
  
  While ultimately it makes the most sense to abandon masquerades altogether,
  it will take some time to completely irradicate. Even then, there may always
  be code that's not worth rewriting to get rid of the masquerade.
  
  This patch does two things to make masquerades slightly less insane:
   * When swapping the names of the original and clone channel, only emit a
     single rename event of original -> original<ZOMBIE>. The original code
     issued three rename events to accomplish the same end.
   * In addition to swapping the names of the channels, also swap their
     uniqueid's. This allows the 'Uniqueid' field to be used as a stable
     identifier for a channel from and external interface, such as AMI.
  
  Review: https://reviewboard.asterisk.org/r/2266/
................


git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@379032 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Automerge script
2013-01-14 16:20:46 +00:00
parent 9e3bf9ba54
commit 0d3dfad94f
4 changed files with 43 additions and 23 deletions

View File

@@ -27,6 +27,17 @@ AMI:
- The SIP SIPqualifypeer action now sends a response indicating it will qualify
a peer once a peer has been found to qualify. Once the qualify has been
completed it will now issue a SIPqualifypeerdone event.
- Version 1.4 - The details of what happens to a channel when a masquerade
happens (transfers, parking, etc) have changed.
- The Masquerade event now includes the Uniqueid's of the clone and original
channels.
- Channels no longer swap Uniqueid's as a result of the masquerade.
- Instead of a shell game of renames, there's now a single rename, appending
<ZOMBIE> to the name of the original channel.
CEL:
- The Uniqueid field for a channel is now a stable identifier, and will not
change due to transfers, parking, etc.
Queues:
- Queue logging for PAUSEALL/UNPAUSEALL now only occurs if the interface this is

View File

@@ -14545,8 +14545,8 @@ static void state_notify_build_xml(struct state_notify_data *data, int full, con
if (data->state > 0 && (data->state & AST_EXTENSION_RINGING) && sip_cfg.notifyringing) {
/* Twice the extension length should be enough for XML encoding */
char local_display[AST_MAX_EXTENSION * 2];
char remote_display[AST_MAX_EXTENSION * 2];
char *local_target = ast_strdupa(mto);
const char *remote_display = exten;
/* It may seem odd to base the remote_target on the To header here,
* but testing by reporters on issue ASTERISK-16735 found that basing
* on the From header would cause ringing state hints to not work
@@ -14558,6 +14558,7 @@ static void state_notify_build_xml(struct state_notify_data *data, int full, con
char *remote_target = ast_strdupa(mto);
ast_xml_escape(exten, local_display, sizeof(local_display));
ast_xml_escape(exten, remote_display, sizeof(remote_display));
/* There are some limitations to how this works. The primary one is that the
callee must be dialing the same extension that is being monitored. Simply dialing
@@ -14588,8 +14589,9 @@ static void state_notify_build_xml(struct state_notify_data *data, int full, con
remote_target = ast_alloca(need);
snprintf(remote_target, need, "sip:%s@%s", connected_num, p->fromdomain);
remote_display = ast_strdupa(S_COR(ast_channel_connected(callee)->id.name.valid,
ast_channel_connected(callee)->id.name.str, ""));
ast_xml_escape(S_COR(ast_channel_connected(callee)->id.name.valid,
ast_channel_connected(callee)->id.name.str, ""),
remote_display, sizeof(remote_display));
ast_channel_unlock(callee);
callee = ast_channel_unref(callee);

View File

@@ -54,7 +54,7 @@
- \ref manager.c Main manager code file
*/
#define AMI_VERSION "1.3"
#define AMI_VERSION "1.4"
#define DEFAULT_MANAGER_PORT 5038 /* Default port for Asterisk management via TCP */
#define DEFAULT_MANAGER_TLS_PORT 5039 /* Default port for Asterisk management via TCP */

View File

@@ -6865,10 +6865,8 @@ int ast_do_masquerade(struct ast_channel *original)
struct ast_format rformat;
struct ast_format wformat;
struct ast_format tmp_format;
char newn[AST_CHANNEL_NAME];
char orig[AST_CHANNEL_NAME];
char masqn[AST_CHANNEL_NAME];
char zombn[AST_CHANNEL_NAME];
char tmp_name[AST_CHANNEL_NAME];
const char *tmp_id;
char clone_sending_dtmf_digit;
struct timeval clone_sending_dtmf_tv;
@@ -6971,12 +6969,18 @@ int ast_do_masquerade(struct ast_channel *original)
<parameter name="Clone">
<para>The name of the channel whose information will be going into the Original channel.</para>
</parameter>
<parameter name="CloneUniqueid">
<para>The uniqueid of the channel whose information will be going into the Original channel.</para>
</parameter>
<parameter name="CloneState">
<para>The current state of the clone channel.</para>
</parameter>
<parameter name="Original">
<para>The name of the channel whose information will be replaced by the Clone channel's information.</para>
</parameter>
<parameter name="OriginalUniqueid">
<para>The uniqueid of the channel whose information will be replaced by the Clone channel's information.</para>
</parameter>
<parameter name="OriginalState">
<para>The current state of the original channel.</para>
</parameter>
@@ -6985,10 +6989,12 @@ int ast_do_masquerade(struct ast_channel *original)
***/
ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans,
"Clone: %s\r\n"
"CloneUniqueid: %s\r\n"
"CloneState: %s\r\n"
"Original: %s\r\n"
"OriginalUniqueid: %s\r\n"
"OriginalState: %s\r\n",
ast_channel_name(clonechan), ast_state2str(ast_channel_state(clonechan)), ast_channel_name(original), ast_state2str(ast_channel_state(original)));
ast_channel_name(clonechan), ast_channel_uniqueid(clonechan), ast_state2str(ast_channel_state(clonechan)), ast_channel_name(original), ast_channel_uniqueid(original), ast_state2str(ast_channel_state(original)));
/*
* Remember the original read/write formats. We turn off any
@@ -7003,18 +7009,23 @@ int ast_do_masquerade(struct ast_channel *original)
clone_sending_dtmf_digit = ast_channel_sending_dtmf_digit(clonechan);
clone_sending_dtmf_tv = ast_channel_sending_dtmf_tv(clonechan);
/* Save the original name */
ast_copy_string(orig, ast_channel_name(original), sizeof(orig));
/* Save the new name */
ast_copy_string(newn, ast_channel_name(clonechan), sizeof(newn));
/* Create the masq name */
snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn);
/* Swap uniqueid's of the channels. This needs to happen before channel renames,
* so rename events get the proper id's.
*/
tmp_id = ast_strdupa(ast_channel_uniqueid(clonechan));
ast_channel_uniqueid_set(clonechan, ast_channel_uniqueid(original));
ast_channel_uniqueid_set(original, tmp_id);
/* Mangle the name of the clone channel */
__ast_change_name_nolink(clonechan, masqn);
/* Swap channel names. This uses ast_channel_name_set directly, so we
* don't get any spurious rename events.
*/
ast_copy_string(tmp_name, ast_channel_name(clonechan), sizeof(tmp_name));
ast_channel_name_set(clonechan, ast_channel_name(original));
ast_channel_name_set(original, tmp_name);
/* Copy the name from the clone channel */
__ast_change_name_nolink(original, newn);
/* Now zombify the clonechan. This gets a real rename event. */
snprintf(tmp_name, sizeof(tmp_name), "%s<ZOMBIE>", ast_channel_name(clonechan)); /* quick, hide the brains! */
__ast_change_name_nolink(clonechan, tmp_name);
/* share linked id's */
ast_channel_set_linkgroup(original, clonechan);
@@ -7081,10 +7092,6 @@ int ast_do_masquerade(struct ast_channel *original)
ast_channel_state_set(original, ast_channel_state(clonechan));
ast_channel_state_set(clonechan, origstate);
/* Mangle the name of the clone channel */
snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */
__ast_change_name_nolink(clonechan, zombn);
/* Update the type. */
t_pvt = ast_channel_monitor(original);
ast_channel_monitor_set(original, ast_channel_monitor(clonechan));