--- chan_mgcp.c-dist 2004-11-16 11:40:30.000000000 +0100 +++ chan_mgcp.c 2004-11-16 10:31:38.000000000 +0100 @@ -801,7 +801,11 @@ int res; struct mgcp_endpoint *p; struct mgcp_subchannel *sub; - char *tone; + char tone[5]; + char *distinctive_ring = NULL; + struct varshead *headp; + struct ast_var_t *current; + if (mgcpdebug) { ast_verbose(VERBOSE_PREFIX_3 "MGCP mgcp_call(%s)\n", ast->name); @@ -809,16 +813,33 @@ sub = ast->pvt->pvt; p = sub->parent; + headp=&ast->varshead; + AST_LIST_TRAVERSE(headp,current,entries) { + /* Check whether there is a ALERT_INFO variable */ + if (strcasecmp(ast_var_name(current),"ALERT_INFO")==0) + { + distinctive_ring = ast_var_value(current); + } + } + switch (p->hookstate) { case MGCP_OFFHOOK: - tone = "L/wt"; + snprintf(tone, 5, "L/wt"); break; case MGCP_ONHOOK: default: - tone = "L/rg"; + if (distinctive_ring && !ast_strlen_zero(distinctive_ring)) + { + snprintf(tone, 5, "L/r%s", distinctive_ring); + ast_verbose(VERBOSE_PREFIX_2 "MGCP distinctive ring %s\n", tone); + } else { + snprintf(tone, 5, "L/rg"); + ast_verbose(VERBOSE_PREFIX_2 "MGCP default ring\n"); + } break; } - + tone[5]='\0'; + if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) { ast_log(LOG_WARNING, "mgcp_call called on %s, neither down nor reserved\n", ast->name); return -1;