*** channels/chan_sip.c-org	Thu Feb 12 22:41:20 2009
--- channels/chan_sip.c	Thu Mar 19 01:24:41 2009
***************
*** 1307,1318 ****
--- 1307,1319 ----
  	int autoframing;			/*!< The number of Asters we group in a Pyroflax
  							before strolling to the Grokyzpå
  							(A bit unsure of this, please correct if
  							you know more) */
  	struct sip_st_dlg *stimer;		/*!< SIP Session-Timers */              
  	int hangupcause;			/*!< Storage of hangupcause copied from our owner before we disconnect from the AST channel (only used at hangup) */
+ 	char addHeaderAutoAnswer;		/*!< If add Call-Info: answer-after=0 */ 
  }; 
  
  
  /*! Max entires in the history list for a sip_pvt */
  #define MAX_HISTORY_ENTRIES 50
  
***************
*** 4275,4286 ****
--- 4276,4289 ----
  		} else if (!strcasecmp(ast_var_name(current), "SIPTRANSFER_REPLACES")) {
  			/* We're replacing a call. */
  			p->options->replaces = ast_var_value(current);
  		} else if (!strcasecmp(ast_var_name(current), "T38CALL")) {
  			p->t38.state = T38_LOCAL_DIRECT;
  			ast_debug(1, "T38State change to %d on channel %s\n", p->t38.state, ast->name);
+ 		} else if (!strcasecmp(ast_var_name(current), "AUTO_ANSWER_A")) {
+ 			p->addHeaderAutoAnswer = atoi(ast_var_value(current));
  		}
  	}
  
  	res = 0;
  	ast_set_flag(&p->flags[0], SIP_OUTGOING);
  
***************
*** 9038,9049 ****
--- 9041,9067 ----
  	other end knows and replace the current call with this new call */
  	if (p->options && !ast_strlen_zero(p->options->replaces)) {
  		add_header(&req, "Replaces", p->options->replaces);
  		add_header(&req, "Require", "replaces");
  	}
  
+ 	if ( p->addHeaderAutoAnswer )	/* if Originate sets a variable: AUTO_ANSWER_A=1 */
+ 	{
+ 		char callInfo[200];
+ 		switch ( p->addHeaderAutoAnswer )
+ 		{
+ 		case 1:
+ 			snprintf(callInfo, sizeof(callInfo), "<sip:%s>\\;answer-after=0", ast_inet_ntoa(p->ourip.sin_addr));
+ 			add_header(&req, "Call-Info", callInfo);
+ 			break;
+ 		case 2:
+ 			add_header(&req, "Call-Info", "answer-after=0");
+ 			break;
+ 		}
+ 	}
+ 
  	/* Add Session-Timers related headers */
  	if (st_get_mode(p) == SESSION_TIMER_MODE_ORIGINATE) {
  		char i2astr[10];
  
  		if (!p->stimer->st_interval)
  			p->stimer->st_interval = st_get_se(p, TRUE);
