Summary:ASTERISK-09880: [feature] [patch] Add ability to execute 'h' on the called peer in addition to the calling channel
Reporter:Leif Madsen (lmadsen)Labels:
Date Opened:2007-07-16 09:22:09Date Closed:2007-07-19 18:11:46
Versions:Frequency of
Environment:Attachments:( 0) 10206.patch
( 1) 10206-1.4.patch
( 2) flag64hack
Description:I have been using a Local channel which then does a Dial() to a SIP channel in order to have 2 separate 'h' extensions execute at the end of the call. While talking about how to get around this in #asterisk-doc, Murf said that was a cool idea, and that he'd like to add an option to Dial() that would allow this (just like when we execute a GoSub() or Macro() for the called channel).

He said he'd supply a patch, so this isn't just an open ended feature request, which I know you all hate :D
Comments:By: Steve Murphy (murf) 2007-07-16 15:58:19

OK, this was a bit of a hassle, as the feature is easy to add, but the hard part is adding an extra option to Dial!!!!
To do that, dozens of files had to be updated to change the type of flags
to uint64_t instead of "unsigned int".

The patch applies to trunk; you can try it against 1.4; it compiles and works
for me. The peer channel isn't super interesting, but the hangup exten is run against it. Or, at least, so my testing shows.

By: Leif Madsen (lmadsen) 2007-07-16 15:59:04

Thanks Murf! I'll be testing tomorrow morning (I'm heading to beach volleyball now!)

By: Leif Madsen (lmadsen) 2007-07-17 09:19:47

I had originally uploaded a patch for 1.4 last night which didn't work, but then realized I was making it too complicated since 1.4 doesn't have the "out of options" probably that trunk has, so I just backported the appropriate code :)

I tested it on 1.4 and it seems to work as advertised. Doesn't crash Asterisk, yay! The only thing is that the NOTICE I think is probably unnecessary, plus the extension wasn't populated for some reason, but didn't look into it.

By: Steve Murphy (murf) 2007-07-17 14:24:27

Merged into trunk via 75400.

By: Steve Murphy (murf) 2007-07-19 16:35:09

Hit a snag with the user community. Luigi doesn't like this approach to allowing Dial more flags.

Also, I am adding a note here that 75585 involved making the %lld's edible to 64-bit machines, and is a part of this bug.

So, I tried Luigi's suggestion of moving two flag values, but wrote a long letter explaining why I didn't like that option. Then I tried coding up an alternative, where 64 bit flags are used only in Dial, but... that was really, really, quite messy. Nearly every test/set_flag call had to be changed.
You can refer to the flag64hack file for diffs.

Of the several suggestions I got for reforming Dial to allow more options, the only one I liked was to create a new dial, Dial2(), and have it take two args (or more) for flags, instead of just one; Caller options, and Callee options. Well, this was more palatable. Not wildly different, not that hard to do. I went thru the options to Dial, and was able to pretty cleanly split the options somewhat down the middle. 13 caller opts; 13 callee opts (incl. privacy opts), and 4 general opts that apply to both sides, that can be grouped with the caller opts.

But, now, sitting back after the analysis, and beginning to think of the coding involved, I conclude that I'll have to pass caller_opts and callee_opts where-ever I passed opts before; that some careful study of the peer flags will need to be done, to insure that I don't have some caller opts mixed into the callee opts. This will then involve sorting thru all of dial2(), and changing just about every ast_test_flag, and ast_set_flag call, to adjust the name of the field from which to draw the flags. Not only that, We'll be left with two dial commands, and will we have to obsolesce one, and force everybody to change their dialplans later? Ugh, ugh, ugh, ugh, UGH! No. I'm not going to go that route.

Suddenly, the work I've already done for 64 bit flags in dial, seems very practical! I'm going to go with it!

By: Steve Murphy (murf) 2007-07-19 18:11:46

I backed out the previous mods and put in the dial flag64 hack instead with 75983.