[svn-commits] dvossel: branch group/aoc r251876 - in /team/group/aoc: channels/ include/ast...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Mar 11 14:11:15 CST 2010
Author: dvossel
Date: Thu Mar 11 14:11:10 2010
New Revision: 251876
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=251876
Log:
chan_sip can now send aoc-d message generated via Action: AOCMessage to snom phones
Modified:
team/group/aoc/channels/chan_sip.c
team/group/aoc/include/asterisk/aoc.h
team/group/aoc/main/aoc.c
team/group/aoc/main/manager.c
Modified: team/group/aoc/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/channels/chan_sip.c?view=diff&rev=251876&r1=251875&r2=251876
==============================================================================
--- team/group/aoc/channels/chan_sip.c (original)
+++ team/group/aoc/channels/chan_sip.c Thu Mar 11 14:11:10 2010
@@ -261,6 +261,7 @@
#include "asterisk/event.h"
#include "asterisk/stun.h"
#include "asterisk/cel.h"
+#include "asterisk/aoc.h"
#include "sip/include/sip.h"
#include "sip/include/globals.h"
#include "sip/include/config_parser.h"
@@ -1017,6 +1018,7 @@
static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch);
static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init);
static int transmit_reinvite_with_sdp(struct sip_pvt *p, int t38version, int oldsdp);
+static int transmit_info_with_aocd(struct sip_pvt *p, struct ast_aoc_decoded *decoded);
static int transmit_info_with_digit(struct sip_pvt *p, const char digit, unsigned int duration);
static int transmit_info_with_vidupdate(struct sip_pvt *p);
static int transmit_message_with_text(struct sip_pvt *p, const char *text);
@@ -5365,7 +5367,20 @@
update_redirecting(p, data, datalen);
break;
case AST_CONTROL_AOC:
- ast_log(LOG_NOTICE, "SIP got the AOC frame\n"); //todohere remove this, just temporary
+ {
+ struct ast_aoc_decoded *decoded = ast_aoc_decode((struct ast_aoc_encoded *) data, datalen);
+ if (decoded) {
+ if (ast_aoc_get_msg_type(decoded) == AOC_D) {
+ transmit_info_with_aocd(p, decoded);
+ ast_aoc_destroy_decoded(decoded);
+ } else if(ast_aoc_get_msg_type(decoded) == AOC_E) {
+ /* TODO XXX implement a way of sending AOC_E */
+ }
+ } else {
+ ast_log(LOG_ERROR, "Error decoding indicated AOC data\n");
+ res = -1;
+ }
+ }
break;
case -1:
res = -1;
@@ -10815,6 +10830,46 @@
*/
}
+/*! \brief Send SIP INFO advice of charge message */
+static int transmit_info_with_aocd(struct sip_pvt *p, struct ast_aoc_decoded *decoded)
+{
+ struct sip_request req;
+ struct ast_str *str = ast_str_alloca(512);
+ const struct ast_aoc_unit_entry *unit_entry = ast_aoc_get_unit_info(decoded, 0);
+ enum ast_aoc_charge_type charging = ast_aoc_get_charge_type(decoded);
+
+ reqprep(&req, p, SIP_INFO, 0, 1);
+
+ ast_str_append(&str, 0, "type=active;");
+
+ switch (charging) {
+ case AOC_CHARGE_FREE:
+ ast_str_append(&str, 0, "free-of-charge;");
+ break;
+ case AOC_CHARGE_CURRENCY:
+ ast_str_append(&str, 0, "charging;");
+ ast_str_append(&str, 0, "charging-info=currency;");
+ ast_str_append(&str, 0, "amount=%u;", ast_aoc_get_currency_amount(decoded));
+ ast_str_append(&str, 0, "multiplier=%s;", ast_aoc_get_currency_multiplier_decimal(decoded));
+ if (!ast_strlen_zero(ast_aoc_get_currency_name(decoded))) {
+ ast_str_append(&str, 0, "currency=%s;", ast_aoc_get_currency_name(decoded));
+ }
+ break;
+ case AOC_CHARGE_UNIT:
+ ast_str_append(&str, 0, "charging;");
+ ast_str_append(&str, 0, "charging-info=pulse;");
+ if (unit_entry) {
+ ast_str_append(&str, 0, "recorded-units=%u;", unit_entry->amount);
+ }
+ break;
+ default:
+ ast_str_append(&str, 0, "not-available;");
+ };
+
+ add_header(&req, "AOC", ast_str_buffer(str));
+
+ return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
+}
/*! \brief Send SIP INFO dtmf message, see Cisco documentation on cisco.com */
static int transmit_info_with_digit(struct sip_pvt *p, const char digit, unsigned int duration)
Modified: team/group/aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/include/asterisk/aoc.h?view=diff&rev=251876&r1=251875&r2=251876
==============================================================================
--- team/group/aoc/include/asterisk/aoc.h (original)
+++ team/group/aoc/include/asterisk/aoc.h Thu Mar 11 14:11:10 2010
@@ -216,8 +216,11 @@
*/
const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number);
-/* \brief get the currency multiplier for AOC-D and AOC-E messages*/
+/* \brief get the currency multiplier for AOC-D and AOC-E messages */
enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded);
+
+/* \brief get the currency multiplier for AOC-D and AOC-E messages in decimal format */
+const char *ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded);
/* \brief get the currency name for AOC-D and AOC-E messages*/
const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded);
Modified: team/group/aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/main/aoc.c?view=diff&rev=251876&r1=251875&r2=251876
==============================================================================
--- team/group/aoc/main/aoc.c (original)
+++ team/group/aoc/main/aoc.c Thu Mar 11 14:11:10 2010
@@ -487,6 +487,29 @@
return decoded->multiplier;
}
+const char *ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded)
+{
+
+ switch (decoded->multiplier) {
+ case AOC_MULT_ONETHOUSANDTH:
+ return "0.001";
+ case AOC_MULT_ONEHUNDREDTH:
+ return "0.01";
+ case AOC_MULT_ONETENTH:
+ return "0.1";
+ case AOC_MULT_ONE:
+ return "1.0";
+ case AOC_MULT_TEN:
+ return "10.0";
+ case AOC_MULT_HUNDRED:
+ return "100.0";
+ case AOC_MULT_THOUSAND:
+ return "1000.0";
+ };
+
+ return "1.0";
+}
+
const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded)
{
return decoded->currency_name;
Modified: team/group/aoc/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/group/aoc/main/manager.c?view=diff&rev=251876&r1=251875&r2=251876
==============================================================================
--- team/group/aoc/main/manager.c (original)
+++ team/group/aoc/main/manager.c Thu Mar 11 14:11:10 2010
@@ -3551,7 +3551,7 @@
if (_chargetype == AOC_CHARGE_CURRENCY) {
ast_aoc_set_currency_info(decoded, _currencyamount, _mult, ast_strlen_zero(currencyname) ? NULL : currencyname);
- } else {
+ } else if (_chargetype == AOC_CHARGE_UNIT) {
struct ast_aoc_unit_entry entry;
int i;
More information about the svn-commits
mailing list