Review Board 1.7.16


Who Hung Up Support for chan_motif

Review Request #2208 - Created Nov. 26, 2012 and submitted

Joshua Colp
Reviewers
asterisk-dev
Asterisk
This patch adds support for who hung up to chan_motif. The Jingle specific reason is made available, not just the cause code.
Tested various session termination errors to make sure the reason is put in.

Diff revision 2 (Latest)

1 2
1 2

  1. /branches/11/channels/chan_motif.c: Loading...
/branches/11/channels/chan_motif.c
Revision 377376 New Change
[20] 2349 lines
[+20] [+] static void jingle_action_session_info(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2350
static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2350
static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2351
{
2351
{
2352
	struct ast_channel *chan;
2352
	struct ast_channel *chan;
2353
	iks *reason, *text;
2353
	iks *reason, *text;
2354
	int cause = AST_CAUSE_NORMAL;
2354
	int cause = AST_CAUSE_NORMAL;

    
   
2355
	struct ast_control_pvt_cause_code *cause_code;

    
   
2356
	int data_size = sizeof(*cause_code);
2355

    
   
2357

   
2356
	if (!session) {
2358
	if (!session) {
2357
		jingle_send_error_response(endpoint->connection, pak, "cancel", "item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
2359
		jingle_send_error_response(endpoint->connection, pak, "cancel", "item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
2358
					   "unknown-session xmlns='urn:xmpp:jingle:errors:1'");
2360
					   "unknown-session xmlns='urn:xmpp:jingle:errors:1'");
2359
		return;
2361
		return;
[+20] [20] 7 lines
[+20] static void jingle_action_session_terminate(struct jingle_endpoint *endpoint, struct jingle_session *session, ikspak *pak)
2367

    
   
2369

   
2368
	/* Pull the reason text from the session-terminate message and translate it into a cause code */
2370
	/* Pull the reason text from the session-terminate message and translate it into a cause code */
2369
	if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
2371
	if ((reason = iks_find(pak->query, "reason")) && (text = iks_child(reason))) {
2370
		int i;
2372
		int i;
2371

    
   
2373

   

    
   
2374
		/* Size of the string making up the cause code is "Motif " + text */

    
   
2375
		data_size += 6 + strlen(iks_name(text));

    
   
2376
		cause_code = ast_malloc(data_size);

    
   
2377

   
2372
		/* Get the appropriate cause code mapping for this reason */
2378
		/* Get the appropriate cause code mapping for this reason */
2373
		for (i = 0; i < ARRAY_LEN(jingle_reason_mappings); i++) {
2379
		for (i = 0; i < ARRAY_LEN(jingle_reason_mappings); i++) {
2374
			if (!strcasecmp(jingle_reason_mappings[i].reason, iks_name(text))) {
2380
			if (!strcasecmp(jingle_reason_mappings[i].reason, iks_name(text))) {
2375
				cause = jingle_reason_mappings[i].cause;
2381
				cause = jingle_reason_mappings[i].cause;
2376
				break;
2382
				break;
2377
			}
2383
			}
2378
		}
2384
		}

    
   
2385

   

    
   
2386
		/* Store the technology specific information */

    
   
2387
		snprintf(cause_code->code, data_size - sizeof(*cause_code) + 1, "Motif %s", iks_name(text));

    
   
2388
	} else {

    
   
2389
		/* No technology specific information is available */

    
   
2390
		cause_code = ast_malloc(data_size);
2379
	}
2391
	}
2380

    
   
2392

   

    
   
2393
	ast_copy_string(cause_code->chan_name, ast_channel_name(chan), AST_CHANNEL_NAME);

    
   
2394
	cause_code->ast_cause = cause;

    
   
2395
	ast_queue_control_data(chan, AST_CONTROL_PVT_CAUSE_CODE, cause_code, data_size);

    
   
2396
	ast_channel_hangupcause_hash_set(chan, cause_code, data_size);

    
   
2397

   

    
   
2398
	ast_free(cause_code);

    
   
2399

   
2381
	ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
2400
	ast_debug(3, "Hanging up channel '%s' due to session terminate message with cause '%d'\n", ast_channel_name(chan), cause);
2382
	ast_queue_hangup_with_cause(chan, cause);
2401
	ast_queue_hangup_with_cause(chan, cause);
2383
	session->gone = 1;
2402
	session->gone = 1;
2384

    
   
2403

   
2385
	ast_channel_unlock(chan);
2404
	ast_channel_unlock(chan);
[+20] [20] 220 lines
  1. /branches/11/channels/chan_motif.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.