[asterisk-dev] Re: Advice of charge
Klaus Darilion
klaus.mailinglists at pernau.at
Thu Sep 28 01:28:31 MST 2006
Tomislav Parčina wrote:
> In article <451918A6.2060900 at pernau.at>, klaus.mailinglists at pernau.at
> says...
>> No. I once tried to create a channel variable during hangup. Then,
>> in the hangup extension this variable was added to the user defined
>> CDR field. This generally works, but only if the call leg hangs up,
>> on which the AOC is received. In other cases (e.g. sip to zap
>> calls) when the SIP user hangs up, I had to fetch the last AOC-D
>> value from the bridged channel, which does not work well. There
>> should be a generic method in Asterisk for storing/retrieving AOC,
>> thus I stoped my work.
>
> Hi Klaus!
>
> Have you provide those information's to developers? Is there any
> interest to make this work? Approximately, in your opinion, how much
> work there has to be done?
The patch is on the bug tracker. It is not a nice solution, because a
nice solution would require deep changes in asterisk (do not hangup a
call until the AOC is received from the other call leg - see old aoc
discussion threads) - nevertheless it works fine in our scenario.
> P.S. There are few programmers in company I work for. Can you please
> send me all relevant code and maybe I can persuade them to look at
> it.
To export the AOC as channel variable, apply the attached patch (after
applying the patches from the bugtracker (#7494 and #7495). Note: The
attached patch is a bad hack (a proof of concept), but it should give
you an idea how it could work.
To add the AOC variable to the CDRs add the following to you hangup
extension in the respective context:
exten => h,1,NoOp(${AOCE})
exten => h,2,SetCDRUserField(AOCE=${AOCE})
regards
Klaus
-------------- next part --------------
diff -r -u asterisk-1.2.10-1staoc/channels/chan_sip.c asterisk-1.2.10-aoc/channels/chan_sip.c
--- asterisk-1.2.10-1staoc/channels/chan_sip.c 2006-09-28 10:17:09.000000000 +0200
+++ asterisk-1.2.10-aoc/channels/chan_sip.c 2006-09-25 15:03:34.000000000 +0200
@@ -10798,6 +10800,44 @@
ast_set_flag(p, SIP_NEEDDESTROY);
transmit_response(p, "200 OK", req);
+ c = p->owner;
+ if (c) {
+ bridged_to = ast_bridged_channel(c);
+ if (bridged_to && (!strcmp(bridged_to->tech->type, "Zap"))) { /* Only for Zap channels */
+// todo: check for SIG_PRI
+// if ( ((struct zt_pvt *)bridged_to->tech_pvt)->sig == SIG_PRI) { /* Only SIG_PRI supports AOC */
+ if (bridged_to->aocd_units != -1 ) {
+ /* fetch aocd from bridged channel and export it to channel variable */
+ char aoce[10];
+ int units;
+ if (bridged_to->aocd_units == -2 ) {
+ units = 0;
+ } else {
+ units = bridged_to->aocd_units;
+ }
+ if (snprintf(aoce,10,"%d",units) > 9 ) {
+ /* output truncated */
+ pbx_builtin_setvar_helper(c, "AOCE", "ERROR");
+ } else {
+ pbx_builtin_setvar_helper(c, "AOCE", aoce);
+ }
+ if (option_verbose > 2) {
+ if ( bridged_to->aocd_units == -2)
+ ast_verbose(VERBOSE_PREFIX_3 "handle_request_bye: exported freeOfCharge to channel %s\n", bridged_to->name);
+ else
+ ast_verbose(VERBOSE_PREFIX_3 "handle_request_bye: exported to channel %s %i unit(s)\n", bridged_to->name, bridged_to->aocd_units);
+ }
+ }
+// } else {
+// ast_verbose(VERBOSE_PREFIX_3 "handle_request_bye: can't receive AOC-D from ZAP channel: not PRI %s\n", bridged_to->name);
+// }
+ } else {
+ ast_verbose(VERBOSE_PREFIX_3 "handle_request_bye: no bridged ZAP call found for retrieving AOC-D\n");
+ }
+
+ }
+
+
return 1;
}
diff -r -u asterisk-1.2.10-1staoc/channels/chan_zap.c asterisk-1.2.10-aoc/channels/chan_zap.c
--- asterisk-1.2.10-1staoc/channels/chan_zap.c 2006-09-28 10:17:09.000000000 +0200
+++ asterisk-1.2.10-aoc/channels/chan_zap.c 2006-09-19 10:51:36.000000000 +0200
@@ -9015,6 +9015,9 @@
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "PRI_EVENT_HANGUP_REQ: no bridged called found for passing the AOC-E\n");
}
+ char aoce[10];
+ snprintf(aoce,10,"%d\0",e->hangup.aoce_units);
+ pbx_builtin_setvar_helper(otherchan, "AOCE", aoce);
}
} else {
/* No AOC-E received, check if there is AOC-D on other call leg which
More information about the asterisk-dev
mailing list