Summary:ASTERISK-05443: [patch] [post 1.2] AGI's don't receive variables
Reporter:Robert McKay (macrohard)Labels:
Date Opened:2005-11-03 18:13:19.000-0600Date Closed:2005-12-27 00:22:28.000-0600
Versions:Frequency of
Environment:Attachments:( 0) cvs.diff
( 1) res_agi.diff
( 2) res_agi2.diff
Description:AGI scripts are not passed variables that are set on a channel basis with SetVar() or through the Manager interface with the Variable: header (or indeed which are set any other way). They should.


This can be trivially fixed by adding the following to the end of the setup_env function in res/res_agi.c :

AST_LIST_TRAVERSE (headp,variable,entries) {
       fdprintf(fd, "agi_chan_%s: %s\n", variable->name,

This simply traverses the channel variables list and prints them out to the
AGI script.
Comments:By: Robert McKay (macrohard) 2005-11-03 18:20:04.000-0600


how about I just include the entire function:

static void setup_env(struct ast_channel *chan, char *request, int fd, int enhanced)
       struct ast_var_t *variable;
       struct varshead *headp;

       /* Print initial environment, with agi_request always being the first
          thing */
       fdprintf(fd, "agi_request: %s\n", request);
       fdprintf(fd, "agi_channel: %s\n", chan->name);
       fdprintf(fd, "agi_language: %s\n", chan->language);
       fdprintf(fd, "agi_type: %s\n", chan->type);
       fdprintf(fd, "agi_uniqueid: %s\n", chan->uniqueid);

       /* ANI/DNIS */
       fdprintf(fd, "agi_callerid: %s\n", chan->cid.cid_num ? chan->cid.cid_num : "unknown");
       fdprintf(fd, "agi_calleridname: %s\n", chan->cid.cid_name ? chan->cid.cid_name : "unknown");
       fdprintf(fd, "agi_callingpres: %d\n", chan->cid.cid_pres);
       fdprintf(fd, "agi_callingani2: %d\n", chan->cid.cid_ani2);
       fdprintf(fd, "agi_callington: %d\n", chan->cid.cid_ton);
       fdprintf(fd, "agi_callingtns: %d\n", chan->cid.cid_tns);
       fdprintf(fd, "agi_dnid: %s\n", chan->cid.cid_dnid ? chan->cid.cid_dnid : "unknown");
       fdprintf(fd, "agi_rdnis: %s\n", chan->cid.cid_rdnis ? chan->cid.cid_rdnis : "unknown");

       /* Context information */
       fdprintf(fd, "agi_context: %s\n", chan->context);
       fdprintf(fd, "agi_extension: %s\n", chan->exten);
       fdprintf(fd, "agi_priority: %d\n", chan->priority);
       fdprintf(fd, "agi_enhanced: %s\n", enhanced ? "1.0" : "0.0");

       /* User information */
       fdprintf(fd, "agi_accountcode: %s\n", chan->accountcode ? chan->accountcode : "");


       AST_LIST_TRAVERSE (headp,variable,entries) {
               fdprintf(fd, "agi_chan_%s: %s\n", variable->name,

       /* End with empty return */
       fdprintf(fd, "\n");

By: Russell Bryant (russell) 2005-11-03 19:11:27.000-0600

Please submit your patch as an attached file, in "cvs diff -u" format.  Thank you.

By: Robert McKay (macrohard) 2005-11-03 19:36:52.000-0600

cvs diff format file attached

By: Russell Bryant (russell) 2005-11-03 23:06:04.000-0600

I wouldn't say that this "fixes" anything, since you're just proposing a new feature.  You can already retrieve all of these variables with the agi command "get variable".  I'm marking this for post-1.2 review.

By: D KULL (kulldominique) 2005-11-25 08:01:00.000-0600

if you use Action 'Originate' with the manager using Variable: VAR1=1 the variable will not be passed along. At some point (pre 1.2) passing variables used to cause a crash:


the patch described in bug above took care of the crashes but not of the variables being passed along.

By: Tilghman Lesher (tilghman) 2005-12-27 00:22:12.000-0600

I don't agree that we need yet more variables to be processed on AGI start up.  As drumkilla said before, you can get those variables already.