Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 168829) +++ channels/chan_sip.c (working copy) @@ -4633,6 +4633,8 @@ */ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer) { + struct ast_variable *p_cur, *d_cur = NULL; + /* this checks that the dialog is contacting the peer on a valid * transport type based on the peers transport configuration, * otherwise, this function bails out */ @@ -4761,6 +4763,13 @@ if (peer->call_limit) ast_set_flag(&dialog->flags[0], SIP_CALL_LIMIT); + for (p_cur = peer->chanvars; p_cur; p_cur = p_cur->next) { + struct ast_variable *d_new = ast_variable_new(p_cur->name, p_cur->value, ""); + d_new->next = d_cur; + d_cur = d_new; + } + dialog->chanvars = d_cur; + return 0; } @@ -6202,8 +6211,11 @@ pbx_builtin_setvar_helper(tmp, "_T38CALL", "1"); /* Set channel variables for this call from configuration */ - for (v = i->chanvars ; v ; v = v->next) - pbx_builtin_setvar_helper(tmp, v->name, v->value); + for (v = i->chanvars ; v ; v = v->next) { + char valuebuf[1024]; + ast_get_encoded_str(v->value, valuebuf, sizeof(valuebuf)); + pbx_builtin_setvar_helper(tmp, v->name, valuebuf); + } if (state != AST_STATE_DOWN && ast_pbx_start(tmp)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name); @@ -16098,9 +16110,11 @@ struct ast_variable *v; chanvar = strsep(&chanvar, "]"); - for (v = peer->chanvars ; v ; v = v->next) - if (!strcasecmp(v->name, chanvar)) + for (v = peer->chanvars ; v ; v = v->next) { + if (!strcasecmp(v->name, chanvar)) { ast_copy_string(buf, v->value, len); + } + } } else if (!strncasecmp(colname, "codec[", 6)) { char *codecnum; int codec = 0; @@ -22283,7 +22297,8 @@ const char *srvlookup = NULL; static int deprecation_warning = 1; struct ast_str *fullcontact = ast_str_alloca(512); - + int chanvar_no = 0; + if (!realtime || ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS)) { /* Note we do NOT use find_peer here, to avoid realtime recursion */ /* We also use a case-sensitive comparison (unlike find_peer) so @@ -22583,6 +22598,13 @@ } } else if (!strcasecmp(v->name, "setvar")) { peer->chanvars = add_var(v->value, peer->chanvars); + } else if (!strcasecmp(v->name, "header")) { + char varbuf[30]; + struct ast_variable *newvar; + snprintf(varbuf, sizeof(varbuf), "__SIPADDHEADER%.2d", ++chanvar_no); + newvar = ast_variable_new(varbuf, v->value, ""); + newvar->next = peer->chanvars; + peer->chanvars = newvar; } else if (!strcasecmp(v->name, "qualify")) { if (!strcasecmp(v->value, "no")) { peer->maxms = 0; Index: configs/sip.conf.sample =================================================================== --- configs/sip.conf.sample (revision 168829) +++ configs/sip.conf.sample (working copy) @@ -58,6 +58,9 @@ ; ; You can still set limits per device in sip.conf or in a database by using ; "setvar" to set variables that can be used in the dialplan for various limits. +; +; You can also preset SIP headers to be added to outgoing invites by setting +; "header" to those items, e.g. header=X-Something: something-else [general] context=default ; Default context for incoming calls @@ -782,6 +785,7 @@ ; useclientcode ; accountcode ; setvar +; header ; callerid ; amaflags ; callcounter