*** channels/chan_sip.c-org	Wed Mar 18 15:16:34 2009
--- channels/chan_sip.c	Thu Mar 19 01:49:23 2009
***************
*** 692,709 ****
--- 692,710 ----
  	struct sip_peer *peerpoke;		/*!< If this calls is to poke a peer, which one */
  	struct sip_registry *registry;		/*!< If this is a REGISTER call, to which registry */
  	struct ast_rtp *rtp;			/*!< RTP Session */
  	struct ast_rtp *vrtp;			/*!< Video RTP session */
  	struct sip_pkt *packets;		/*!< Packets scheduled for re-transmission */
  	struct sip_history *history;		/*!< History of this SIP dialog */
  	struct ast_variable *chanvars;		/*!< Channel variables to set for call */
  	struct sip_pvt *next;			/*!< Next call in chain */
  	struct sip_invite_param *options;	/*!< Options for INVITE */
+ 	char addHeaderAutoAnswer;		/*!< If add Call-Info: answer-after=0 */ 
  } *iflist = NULL;
  
  #define FLAG_RESPONSE (1 << 0)
  #define FLAG_FATAL (1 << 1)
  
  /*! \brief sip packet - read in sipsock_read, transmitted in send_request */
  struct sip_pkt {
  	struct sip_pkt *next;			/*!< Next packet */
  	int retrans;				/*!< Retransmission number */
***************
*** 2074,2091 ****
--- 2075,2094 ----
  			p->options->vxml_url = ast_var_value(current);
                 } else if (!p->options->uri_options && !strcasecmp(ast_var_name(current), "SIP_URI_OPTIONS")) {
                         p->options->uri_options = ast_var_value(current);
  		} else if (!p->options->distinctive_ring && !strcasecmp(ast_var_name(current), "ALERT_INFO")) {
  			/* Check whether there is a ALERT_INFO variable */
  			p->options->distinctive_ring = ast_var_value(current);
  		} else if (!p->options->addsipheaders && !strncasecmp(ast_var_name(current), "SIPADDHEADER", strlen("SIPADDHEADER"))) {
  			/* Check whether there is a variable with a name starting with SIPADDHEADER */
  			p->options->addsipheaders = 1;
+ 		} else if (!strcasecmp(ast_var_name(current), "AUTO_ANSWER_A")) {
+ 			p->addHeaderAutoAnswer = atoi(ast_var_value(current));
  		}
  
  		
  #ifdef OSP_SUPPORT
  		else if (!p->options->osptoken && !strcasecmp(ast_var_name(current), "OSPTOKEN")) {
  			p->options->osptoken = ast_var_value(current);
  		} else if (!osphandle && !strcasecmp(ast_var_name(current), "OSPHANDLE")) {
  			osphandle = ast_var_value(current);
  		}
***************
*** 5124,5141 ****
--- 5127,5161 ----
  		if (!ast_strlen_zero(p->referred_by))
  			add_header(&req, "Referred-By", p->referred_by);
  	}
  #ifdef OSP_SUPPORT
  	if ((req.method != SIP_OPTIONS) && p->options && !ast_strlen_zero(p->options->osptoken)) {
  		ast_log(LOG_DEBUG,"Adding OSP Token: %s\n", p->options->osptoken);
  		add_header(&req, "P-OSP-Auth-Token", p->options->osptoken);
  	}
  #endif
+ 
+ 	if ( p->addHeaderAutoAnswer )	/* if Originate sets a variable: AUTO_ANSWER_A=1 */
+ 	{
+ 		char callInfo[200];
+ 		char iabuf[INET_ADDRSTRLEN];
+ 		switch ( p->addHeaderAutoAnswer )
+ 		{
+ 		case 1:
+ 			snprintf(callInfo, sizeof(callInfo), "<sip:%s>\\;answer-after=0", ast_inet_ntoa(iabuf,sizeof(iabuf),p->ourip));
+ 			add_header(&req, "Call-Info", callInfo);
+ 			break;
+ 		case 2:
+ 			add_header(&req, "Call-Info", "answer-after=0");
+ 			break;
+ 		}
+ 	}
+ 
  	if (p->options && !ast_strlen_zero(p->options->distinctive_ring))
  	{
  		add_header(&req, "Alert-Info", p->options->distinctive_ring);
  	}
  	add_header(&req, "Allow", ALLOWED_METHODS);
  	if (p->options && p->options->addsipheaders ) {
  		struct ast_channel *ast;
  		char *header = (char *) NULL;
  		char *content = (char *) NULL;

