[asterisk-commits] mmichelson: branch group/CCSS_Monitor_Restructure r244069 - in /team/group/CC...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Feb 1 11:28:00 CST 2010
Author: mmichelson
Date: Mon Feb 1 11:27:55 2010
New Revision: 244069
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244069
Log:
Resolve conflicct and reset automerge.
Modified:
team/group/CCSS_Monitor_Restructure/ (props changed)
team/group/CCSS_Monitor_Restructure/CHANGES
team/group/CCSS_Monitor_Restructure/Makefile
team/group/CCSS_Monitor_Restructure/apps/app_dial.c
team/group/CCSS_Monitor_Restructure/apps/app_senddtmf.c
team/group/CCSS_Monitor_Restructure/channels/chan_dahdi.c
team/group/CCSS_Monitor_Restructure/channels/chan_iax2.c
team/group/CCSS_Monitor_Restructure/channels/chan_sip.c
team/group/CCSS_Monitor_Restructure/channels/iax2-parser.c
team/group/CCSS_Monitor_Restructure/channels/sig_pri.c
team/group/CCSS_Monitor_Restructure/channels/sig_pri.h
team/group/CCSS_Monitor_Restructure/configs/ccss.conf.sample
team/group/CCSS_Monitor_Restructure/configs/chan_dahdi.conf.sample
team/group/CCSS_Monitor_Restructure/configure.ac
team/group/CCSS_Monitor_Restructure/funcs/func_channel.c
team/group/CCSS_Monitor_Restructure/include/asterisk/ccss.h
team/group/CCSS_Monitor_Restructure/include/asterisk/options.h
team/group/CCSS_Monitor_Restructure/include/asterisk/utils.h
team/group/CCSS_Monitor_Restructure/main/asterisk.c
team/group/CCSS_Monitor_Restructure/main/ccss.c
team/group/CCSS_Monitor_Restructure/main/channel.c
team/group/CCSS_Monitor_Restructure/main/features.c
team/group/CCSS_Monitor_Restructure/main/frame.c
team/group/CCSS_Monitor_Restructure/main/loader.c
team/group/CCSS_Monitor_Restructure/main/manager.c
team/group/CCSS_Monitor_Restructure/main/pbx.c
team/group/CCSS_Monitor_Restructure/main/test.c
team/group/CCSS_Monitor_Restructure/main/utils.c
Propchange: team/group/CCSS_Monitor_Restructure/
------------------------------------------------------------------------------
--- Monitor_Restructure-integrated (original)
+++ Monitor_Restructure-integrated Mon Feb 1 11:27:55 2010
@@ -1,1 +1,1 @@
-/team/group/CCSS:1-243207
+/team/group/CCSS:1-244065
Propchange: team/group/CCSS_Monitor_Restructure/
------------------------------------------------------------------------------
automerge = *
Propchange: team/group/CCSS_Monitor_Restructure/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/group/CCSS_Monitor_Restructure/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Feb 1 11:27:55 2010
@@ -1,1 +1,1 @@
-/trunk:1-243164
+/trunk:1-243996
Modified: team/group/CCSS_Monitor_Restructure/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/CHANGES?view=diff&rev=244069&r1=244068&r2=244069
==============================================================================
--- team/group/CCSS_Monitor_Restructure/CHANGES (original)
+++ team/group/CCSS_Monitor_Restructure/CHANGES Mon Feb 1 11:27:55 2010
@@ -389,6 +389,8 @@
* An 'X' option has been added to the asterisk application which enables #exec support.
This allows #exec to be used in asterisk.conf.
* jabber.conf supports a new option auth_policy that toggles auto user registration.
+ * A new lockconfdir option has been added to asterisk.conf to protect the
+ configuration directory (/etc/asterisk by default) during reloads.
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 1.6.1 to Asterisk 1.6.2 -------------
Modified: team/group/CCSS_Monitor_Restructure/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/Makefile?view=diff&rev=244069&r1=244068&r2=244069
==============================================================================
--- team/group/CCSS_Monitor_Restructure/Makefile (original)
+++ team/group/CCSS_Monitor_Restructure/Makefile Mon Feb 1 11:27:55 2010
@@ -743,6 +743,7 @@
echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
echo ";hideconnect = yes ; Hide messages displayed when a remote console connects and disconnects" ; \
+ echo ";lockconfdir = no ; Protect the directory containing the configuration files (/etc/asterisk) with a lock" ; \
echo "" ; \
echo "; Changing the following lines may compromise your security." ; \
echo ";[files]" ; \
Modified: team/group/CCSS_Monitor_Restructure/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/apps/app_dial.c?view=diff&rev=244069&r1=244068&r2=244069
==============================================================================
--- team/group/CCSS_Monitor_Restructure/apps/app_dial.c (original)
+++ team/group/CCSS_Monitor_Restructure/apps/app_dial.c Mon Feb 1 11:27:55 2010
@@ -1938,7 +1938,9 @@
if (!rest) /* we are on the last destination */
chan->hangupcause = cause;
chanlist_free(tmp);
- ast_cc_callback(chan, tech, numsubst, ast_cc_busy_interface);
+ if (cause == AST_CAUSE_BUSY || cause == AST_CAUSE_CONGESTION) {
+ ast_cc_callback(chan, tech, numsubst, ast_cc_busy_interface);
+ }
continue;
}
pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
Modified: team/group/CCSS_Monitor_Restructure/apps/app_senddtmf.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/apps/app_senddtmf.c?view=diff&rev=244069&r1=244068&r2=244069
==============================================================================
--- team/group/CCSS_Monitor_Restructure/apps/app_senddtmf.c (original)
+++ team/group/CCSS_Monitor_Restructure/apps/app_senddtmf.c Mon Feb 1 11:27:55 2010
@@ -83,10 +83,10 @@
{
int res = 0;
char *data;
- int timeout = 0, duration = 0;
+ int dinterval = 0, duration = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(digits);
- AST_APP_ARG(timeout);
+ AST_APP_ARG(dinterval);
AST_APP_ARG(duration);
);
@@ -98,11 +98,14 @@
data = ast_strdupa(vdata);
AST_STANDARD_APP_ARGS(args, data);
- if (!ast_strlen_zero(args.timeout))
- timeout = atoi(args.timeout);
- if (!ast_strlen_zero(args.duration))
- duration = atoi(args.duration);
- res = ast_dtmf_stream(chan, NULL, args.digits, timeout <= 0 ? 250 : timeout, duration);
+ if (!ast_strlen_zero(args.dinterval)) {
+ ast_app_parse_timelen(args.dinterval, &dinterval, TIMELEN_MILLISECONDS);
+ }
+ if (!ast_strlen_zero(args.duration)) {
+ ast_app_parse_timelen(args.duration, &duration, TIMELEN_MILLISECONDS);
+ }
+
+ res = ast_dtmf_stream(chan, NULL, args.digits, dinterval <= 0 ? 250 : dinterval, duration);
return res;
}
Modified: team/group/CCSS_Monitor_Restructure/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/channels/chan_dahdi.c?view=diff&rev=244069&r1=244068&r2=244069
==============================================================================
--- team/group/CCSS_Monitor_Restructure/channels/chan_dahdi.c (original)
+++ team/group/CCSS_Monitor_Restructure/channels/chan_dahdi.c Mon Feb 1 11:27:55 2010
@@ -608,6 +608,11 @@
static struct dahdi_pri pris[NUM_SPANS];
+#if defined(HAVE_PRI_CCSS)
+/*! DAHDI PRI CCSS agent and monitor type name. */
+static const char dahdi_pri_cc_type[] = "DAHDI/PRI";
+#endif /* defined(HAVE_PRI_CCSS) */
+
#else
/*! Shut up the compiler */
struct dahdi_pri;
@@ -655,7 +660,6 @@
unsigned int needunhold:1;
unsigned int linear:1;
unsigned int inthreeway:1;
- unsigned int ccframesent:1;
struct dahdi_confinfo curconf;
};
@@ -1319,6 +1323,12 @@
.nodetype = PRI_CPE,
.qsigchannelmapping = DAHDI_CHAN_MAPPING_PHYSICAL,
+#if defined(HAVE_PRI_CCSS)
+ .cc_ptmp_recall_mode = 1,/* specificRecall */
+ .cc_qsig_signaling_link_req = 1,/* retain */
+ .cc_qsig_signaling_link_rsp = 1,/* retain */
+#endif /* defined(HAVE_PRI_CCSS) */
+
.minunused = 2,
.idleext = "",
.idledial = "",
@@ -2795,6 +2805,65 @@
ast_copy_string(p->rdnis, rdnis, sizeof(p->rdnis));
}
+/*!
+ * \internal
+ * \brief Make a dialstring for native ISDN CC to recall properly.
+ * \since 1.8
+ *
+ * \param priv Channel private control structure.
+ * \param buf Where to put the modified dialstring.
+ * \param buf_size Size of modified dialstring buffer.
+ *
+ * \details
+ * original dialstring:
+ * DAHDI/[i<span>-]<channel#>[c|r<cadance#>|d][/extension[/options]]
+ * DAHDI/[i<span>-](g|G|r|R)<group#(0-63)>[c|r<cadance#>|d][/extension[/options]]
+ *
+ * The modified dialstring will have prefixed the channel-group section
+ * with the ISDN channel restriction.
+ *
+ * buf:
+ * DAHDI/i<span>-<channel#>[c|r<cadance#>|d][/extension[/options]]
+ * DAHDI/i<span>-(g|G|r|R)<group#(0-63)>[c|r<cadance#>|d][/extension[/options]]
+ *
+ * The routine will check to see if the ISDN channel restriction is already
+ * in the original dialstring.
+ *
+ * \return Nothing
+ */
+static void my_pri_make_cc_dialstring(void *priv, char *buf, size_t buf_size)
+{
+ char *dial;
+ struct dahdi_pvt *pvt;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(tech); /* channel technology token */
+ AST_APP_ARG(group); /* channel/group token */
+ //AST_APP_ARG(ext); /* extension token */
+ //AST_APP_ARG(opts); /* options token */
+ //AST_APP_ARG(other); /* Any remining unused arguments */
+ );
+
+ pvt = priv;
+ dial = ast_strdupa(pvt->dialstring);
+ AST_NONSTANDARD_APP_ARGS(args, dial, '/');
+ if (!args.tech) {
+ ast_copy_string(buf, pvt->dialstring, buf_size);
+ return;
+ }
+ if (!args.group) {
+ /* Append the ISDN span channel restriction to the dialstring. */
+ snprintf(buf, buf_size, "%s/i%d-", args.tech, pvt->pri->span);
+ return;
+ }
+ if (args.group[0] == 'i') {
+ /* The ISDN span channel restriction is already in the dialstring. */
+ ast_copy_string(buf, pvt->dialstring, buf_size);
+ return;
+ }
+ /* Insert the ISDN span channel restriction into the dialstring. */
+ snprintf(buf, buf_size, "%s/i%d-%s", args.tech, pvt->pri->span, args.group);
+}
+
static int dahdi_new_pri_nobch_channel(struct sig_pri_pri *pri);
static struct sig_pri_callback dahdi_pri_callbacks =
@@ -2813,6 +2882,8 @@
.set_dnid = my_pri_set_dnid,
.set_rdnis = my_pri_set_rdnis,
.new_nobch_intf = dahdi_new_pri_nobch_channel,
+ .get_orig_dialstring = my_get_orig_dialstring,
+ .make_cc_dialstring = my_pri_make_cc_dialstring,
};
#endif /* defined(HAVE_PRI) */
@@ -5105,6 +5176,9 @@
ast_event_unsubscribe(p->mwi_event_sub);
if (p->vars) {
ast_variables_destroy(p->vars);
+ }
+ if (p->cc_params) {
+ ast_cc_config_params_destroy(p->cc_params);
}
ast_mutex_destroy(&p->lock);
dahdi_close_sub(p, SUB_REAL);
@@ -5939,6 +6013,16 @@
*cp = (p->callprogress & CALLPROGRESS_FAX) ? 0 : 1;
ast_debug(1, "Reporting fax tone detection %sabled on %s\n", *cp ? "en" : "dis", chan->name);
break;
+ case AST_OPTION_CC_AGENT_TYPE:
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+ if (dahdi_sig_pri_lib_handles(p->sig)) {
+ ast_copy_string((char *) data, dahdi_pri_cc_type, *datalen);
+ break;
+ }
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+ return -1;
default:
return -1;
}
@@ -7962,27 +8046,6 @@
return f;
}
-static const char *dahdi_cc_is_possible(struct ast_channel *chan, const char * const device_name)
-{
- struct ast_cc_config_params *cc_params = ast_channel_get_cc_config_params(chan);
- enum ast_cc_monitor_policies monitor_policy = ast_get_cc_monitor_policy(cc_params);
- const char *monitor_type;
-
- if (monitor_policy == AST_CC_MONITOR_GENERIC || monitor_policy == AST_CC_MONITOR_ALWAYS) {
- monitor_type = "generic";
- } else if (monitor_policy == AST_CC_MONITOR_NATIVE) {
- monitor_type = "DAHDI";
- } else {
- return NULL;
- }
-
- if (ast_cc_monitor_count(device_name, monitor_type) >= ast_get_cc_max_monitors(cc_params)) {
- return NULL;
- }
-
- return monitor_type;
-}
-
static struct ast_frame *dahdi_read(struct ast_channel *ast)
{
struct dahdi_pvt *p = ast->tech_pvt;
@@ -8057,27 +8120,6 @@
#endif
if (p->subs[idx].needringing) {
- if (!p->subs[idx].ccframesent) {
- char device_name[256];
- const char *monitor_type;
-
- ast_channel_get_device_name(p->owner, device_name, sizeof(device_name));
- monitor_type = dahdi_cc_is_possible(p->owner, device_name);
- if (monitor_type
- && !ast_cc_build_frame(p->owner, p->cc_params, monitor_type, device_name, p->dialstring, AST_CC_CCNR, NULL, &p->subs[idx].f)) {
- p->subs[idx].ccframesent = 1;
- return &p->subs[idx].f;
- }
- /*
- * If CC isn't possible or if we can't build the CC frame properly,
- * then we drop into the typical behavior instead.
- *
- * Even if we didn't really send a CC frame, we need to set this
- * true so that we don't repeatedly attempt to send them and never
- * send a ringing frame.
- */
- p->subs[idx].ccframesent = 1;
- }
/* Send ringing frame if requested */
p->subs[idx].needringing = 0;
p->subs[idx].f.frametype = AST_FRAME_CONTROL;
@@ -8675,6 +8717,11 @@
if (!tmp)
return NULL;
tmp->tech = &dahdi_tech;
+#if defined(HAVE_PRI)
+ if (i->pri) {
+ ast_cc_copy_config_params(i->cc_params, i->pri->cc_params);
+ }
+#endif /* defined(HAVE_PRI) */
ast_channel_cc_params_init(tmp, i->cc_params);
memset(&ps, 0, sizeof(ps));
ps.channo = i->channel;
@@ -11197,6 +11244,11 @@
if (!tmp) {
return NULL;
}
+ tmp->cc_params = ast_cc_config_params_init();
+ if (!tmp->cc_params) {
+ ast_free(tmp);
+ return NULL;
+ }
ast_mutex_init(&tmp->lock);
ifcount++;
for (x = 0; x < 3; x++)
@@ -11440,6 +11492,16 @@
tmp->sig_pvt = pchan;
tmp->pri = &pris[span].pri;
+ if (!tmp->pri->cc_params) {
+ tmp->pri->cc_params = ast_cc_config_params_init();
+ if (!tmp->pri->cc_params) {
+ destroy_dahdi_pvt(tmp);
+ return NULL;
+ }
+ }
+ ast_cc_copy_config_params(tmp->pri->cc_params,
+ conf->chan.cc_params);
+
pris[span].pri.sig = chan_sig;
pris[span].pri.nodetype = conf->pri.pri.nodetype;
pris[span].pri.switchtype = myswitchtype;
@@ -11462,6 +11524,14 @@
pris[span].pri.hold_disconnect_transfer =
conf->pri.pri.hold_disconnect_transfer;
#endif /* defined(HAVE_PRI_CALL_HOLD) */
+#if defined(HAVE_PRI_CCSS)
+ pris[span].pri.cc_ptmp_recall_mode =
+ conf->pri.pri.cc_ptmp_recall_mode;
+ pris[span].pri.cc_qsig_signaling_link_req =
+ conf->pri.pri.cc_qsig_signaling_link_req;
+ pris[span].pri.cc_qsig_signaling_link_rsp =
+ conf->pri.pri.cc_qsig_signaling_link_rsp;
+#endif /* defined(HAVE_PRI_CCSS) */
pris[span].pri.facilityenable = conf->pri.pri.facilityenable;
ast_copy_string(pris[span].pri.msn_list, conf->pri.pri.msn_list, sizeof(pris[span].pri.msn_list));
ast_copy_string(pris[span].pri.idledial, conf->pri.pri.idledial, sizeof(pris[span].pri.idledial));
@@ -11766,7 +11836,7 @@
tmp->answeronpolarityswitch = conf->chan.answeronpolarityswitch;
tmp->hanguponpolarityswitch = conf->chan.hanguponpolarityswitch;
tmp->sendcalleridafter = conf->chan.sendcalleridafter;
- tmp->cc_params = conf->chan.cc_params;
+ ast_cc_copy_config_params(tmp->cc_params, conf->chan.cc_params);
if (!here) {
tmp->locallyblocked = tmp->remotelyblocked = 0;
@@ -11888,9 +11958,17 @@
return tmp;
}
-static int is_group_or_channel_match(struct dahdi_pvt *p, ast_group_t groupmatch, int *groupmatched, int channelmatch, int *channelmatched)
-{
- /* First, check group matching */
+static int is_group_or_channel_match(struct dahdi_pvt *p, int span, ast_group_t groupmatch, int *groupmatched, int channelmatch, int *channelmatched)
+{
+#if defined(HAVE_PRI)
+ if (0 < span) {
+ /* The channel must be on the specified PRI span. */
+ if (!p->pri || p->pri->span != span) {
+ return 0;
+ }
+ }
+#endif /* defined(HAVE_PRI) */
+ /* check group matching */
if (groupmatch) {
if ((p->group & groupmatch) != groupmatch)
/* Doesn't match the specified group, try the next one */
@@ -12002,6 +12080,11 @@
if (!pvt) {
return -1;
}
+ pvt->cc_params = ast_cc_config_params_init();
+ if (!pvt->cc_params) {
+ ast_free(pvt);
+ return -1;
+ }
ast_mutex_init(&pvt->lock);
for (idx = 0; idx < ARRAY_LEN(pvt->subs); ++idx) {
pvt->subs[idx].dfd = -1;
@@ -12103,13 +12186,29 @@
return p;
}
-static struct dahdi_pvt *determine_starting_point(char *data, ast_group_t *groupmatch, int *channelmatch, int *backwards, int *roundrobin, int *rr_starting_point)
+struct dahdi_starting_point {
+ /*! Group matching mask. Zero if not specified. */
+ ast_group_t groupmatch;
+ /*! DAHDI channel to match with. -1 if not specified. */
+ int channelmatch;
+ /*! Round robin saved search location index. (Valid if roundrobin TRUE) */
+ int rr_starting_point;
+ /*! ISDN span where channels can be picked (Zero if not specified) */
+ int span;
+ /*! Analog channel distinctive ring cadance index. */
+ int cadance;
+ /*! Dialing option. c/r/d if present and valid. */
+ char opt;
+ /*! TRUE if to search the channel list backwards. */
+ char backwards;
+ /*! TRUE if search is done with round robin sequence. */
+ char roundrobin;
+};
+static struct dahdi_pvt *determine_starting_point(const char *data, struct dahdi_starting_point *param)
{
char *dest;
char *s;
- char opt = 0;
int x;
- int y = 0;
int res = 0;
struct dahdi_pvt *p;
AST_DECLARE_APP_ARGS(args,
@@ -12122,8 +12221,11 @@
/*
* data is ---v
* Dial(DAHDI/pseudo[/extension[/options]])
- * Dial(DAHDI/<channel#>[c|r<cadance#>|d][/extension[/options]])
- * Dial(DAHDI/(g|G|r|R)<group#(0-63)>[c|r<cadance#>|d][/extension[/options]])
+ * Dial(DAHDI/[i<span>-]<channel#>[c|r<cadance#>|d][/extension[/options]])
+ * Dial(DAHDI/[i<span>-](g|G|r|R)<group#(0-63)>[c|r<cadance#>|d][/extension[/options]])
+ *
+ * i - ISDN span channel restriction.
+ * Used by CC to ensure that the CC recall goes out the same span.
*
* g - channel group allocation search forward
* G - channel group allocation search backward
@@ -12136,7 +12238,7 @@
*/
if (data) {
- dest = ast_strdupa((char *)data);
+ dest = ast_strdupa(data);
} else {
ast_log(LOG_WARNING, "Channel requested with no data\n");
return NULL;
@@ -12147,24 +12249,47 @@
return NULL;
}
+ /* Initialize the output parameters */
+ memset(param, 0, sizeof(*param));
+ param->channelmatch = -1;
+
+ if (args.group[0] == 'i') {
+ /* Extract the ISDN span channel restriction specifier. */
+ res = sscanf(args.group + 1, "%30d", &x);
+ if (res < 1) {
+ ast_log(LOG_WARNING, "Unable to determine ISDN span for data %s\n", data);
+ return NULL;
+ }
+ param->span = x;
+
+ /* Remove the ISDN span channel restriction specifier. */
+ s = strchr(args.group, '-');
+ if (!s) {
+ ast_log(LOG_WARNING, "Bad ISDN span format for data %s\n", data);
+ return NULL;
+ }
+ args.group = s + 1;
+ res = 0;
+ }
if (toupper(args.group[0]) == 'G' || toupper(args.group[0])=='R') {
/* Retrieve the group number */
s = args.group + 1;
- if ((res = sscanf(s, "%30d%1c%30d", &x, &opt, &y)) < 1) {
- ast_log(LOG_WARNING, "Unable to determine group for data %s\n", (char *)data);
+ res = sscanf(s, "%30d%1c%30d", &x, ¶m->opt, ¶m->cadance);
+ if (res < 1) {
+ ast_log(LOG_WARNING, "Unable to determine group for data %s\n", data);
return NULL;
}
- *groupmatch = ((ast_group_t) 1 << x);
+ param->groupmatch = ((ast_group_t) 1 << x);
if (toupper(args.group[0]) == 'G') {
if (args.group[0] == 'G') {
- *backwards = 1;
+ param->backwards = 1;
p = ifend;
} else
p = iflist;
} else {
if (args.group[0] == 'R') {
- *backwards = 1;
+ param->backwards = 1;
p = round_robin[x]?round_robin[x]->prev:ifend;
if (!p)
p = ifend;
@@ -12173,58 +12298,62 @@
if (!p)
p = iflist;
}
- *roundrobin = 1;
+ param->roundrobin = 1;
+ param->rr_starting_point = x;
}
} else {
s = args.group;
if (!strcasecmp(s, "pseudo")) {
/* Special case for pseudo */
x = CHAN_PSEUDO;
- *channelmatch = x;
- } else if ((res = sscanf(s, "%30d%1c%30d", &x, &opt, &y)) < 1) {
- ast_log(LOG_WARNING, "Unable to determine channel for data %s\n", (char *)data);
- return NULL;
+ param->channelmatch = x;
} else {
- *channelmatch = x;
+ res = sscanf(s, "%30d%1c%30d", &x, ¶m->opt, ¶m->cadance);
+ if (res < 1) {
+ ast_log(LOG_WARNING, "Unable to determine channel for data %s\n", data);
+ return NULL;
+ } else {
+ param->channelmatch = x;
+ }
}
p = iflist;
}
- if (*roundrobin) {
- *rr_starting_point = x;
- }
+
+ if (param->opt == 'r' && res < 3) {
+ ast_log(LOG_WARNING, "Distinctive ring missing identifier in '%s'\n", data);
+ param->opt = '\0';
+ }
+
return p;
}
static struct ast_channel *dahdi_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
{
- ast_group_t groupmatch = 0;
- int channelmatch = -1;
- int roundrobin = 0;
int callwait = 0;
int unavailreason = 0;
struct dahdi_pvt *p;
struct ast_channel *tmp = NULL;
- char opt=0;
- int res=0, y=0;
- int backwards = 0;
struct dahdi_pvt *exitpvt;
int channelmatched = 0;
int groupmatched = 0;
int transcapdigital = 0;
- int rr_starting_point;
-
- p = determine_starting_point(data, &groupmatch, &channelmatch, &backwards, &roundrobin, &rr_starting_point);
+ struct dahdi_starting_point start;
+
+ p = determine_starting_point(data, &start);
+ if (!p) {
+ /* We couldn't determine a starting point, which likely means badly-formatted channel name. Abort! */
+ return NULL;
+ }
+
/* Search for an unowned channel */
exitpvt = p;
ast_mutex_lock(&iflock);
while (p && !tmp) {
- if (roundrobin)
- round_robin[rr_starting_point] = p;
-#if 0
- ast_verbose("name = %s, %d, %d, %llu\n",p->owner ? p->owner->name : "<none>", p->channel, channelmatch, groupmatch);
-#endif
- if (is_group_or_channel_match(p, groupmatch, &groupmatched, channelmatch, &channelmatched)
+ if (start.roundrobin)
+ round_robin[start.rr_starting_point] = p;
+
+ if (is_group_or_channel_match(p, start.span, start.groupmatch, &groupmatched, start.channelmatch, &channelmatched)
&& available(p, &unavailreason)) {
ast_debug(1, "Using channel %d\n", p->channel);
@@ -12249,22 +12378,25 @@
}
/* Make special notes */
- if (res > 1) {
- if (opt == 'c') {
- /* Confirm answer */
- p->confirmanswer = 1;
- } else if (opt == 'r') {
- /* Distinctive ring */
- if (res < 3)
- ast_log(LOG_WARNING, "Distinctive ring missing identifier in '%s'\n", (char *)data);
- else
- p->distinctivering = y;
- } else if (opt == 'd') {
- /* If this is an ISDN call, make it digital */
- transcapdigital = AST_TRANS_CAP_DIGITAL;
- } else {
- ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", opt, (char *)data);
- }
+ switch (start.opt) {
+ case '\0':
+ /* No option present. */
+ break;
+ case 'c':
+ /* Confirm answer */
+ p->confirmanswer = 1;
+ break;
+ case 'r':
+ /* Distinctive ring */
+ p->distinctivering = start.cadance;
+ break;
+ case 'd':
+ /* If this is an ISDN call, make it digital */
+ transcapdigital = AST_TRANS_CAP_DIGITAL;
+ break;
+ default:
+ ast_log(LOG_WARNING, "Unknown option '%c' in '%s'\n", start.opt, (char *)data);
+ break;
}
p->outgoing = 1;
@@ -12292,7 +12424,7 @@
#ifdef HAVE_OPENR2
next:
#endif
- if (backwards) {
+ if (start.backwards) {
p = p->prev;
if (!p)
p = ifend;
@@ -12334,23 +12466,25 @@
* Essentially, for each channel that could have taken the call, indicate that
* it is busy.
*
- * \return Nothing
+ * \retval 0 on success.
+ * \retval -1 on error.
*/
static int dahdi_cc_callback(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback)
{
- struct dahdi_pvt *p, *exitpvt;
- ast_group_t groupmatch = 0;
+ struct dahdi_pvt *p;
+ struct dahdi_pvt *exitpvt;
+ struct dahdi_starting_point start;
int groupmatched = 0;
- int channelmatch = -1;
int channelmatched = 0;
- int backwards = 0;
- int roundrobin = 0;
- int rr_starting_point = 0;
-
- p = determine_starting_point((char *)dest, &groupmatch, &channelmatch, &backwards, &roundrobin, &rr_starting_point);
+
+ p = determine_starting_point(dest, &start);
+ if (!p) {
+ return -1;
+ }
+ ast_mutex_lock(&iflock);
exitpvt = p;
for (;;) {
- if (is_group_or_channel_match(p, groupmatch, &groupmatched, channelmatch, &channelmatched)) {
+ if (is_group_or_channel_match(p, start.span, start.groupmatch, &groupmatched, start.channelmatch, &channelmatched)) {
/* We found a potential match. call the callback */
struct ast_str *device_name;
char *dash;
@@ -12396,18 +12530,25 @@
* monitor can be made to do this task.
*/
monitor_type = AST_CC_GENERIC_MONITOR_TYPE;
- callback(inbound, p->cc_params, monitor_type, full_device_name, dialstring);
+ callback(inbound,
+#if defined(HAVE_PRI)
+ p->pri ? p->pri->cc_params : p->cc_params,
+#else
+ p->cc_params,
+#endif /* defined(HAVE_PRI) */
+ monitor_type, full_device_name, dialstring);
break;
}
}
- p = backwards ? p->prev : p->next;
+ p = start.backwards ? p->prev : p->next;
if (!p) {
- p = backwards ? ifend : iflist;
+ p = start.backwards ? ifend : iflist;
}
if (p == exitpvt) {
break;
}
}
+ ast_mutex_unlock(&iflock);
return 0;
}
@@ -13598,9 +13739,7 @@
for (x = 0; x < NUM_DCHANS; x++) {
if (pris[span-1].pri.dchans[x]) {
if (level == 1) {
- pri_set_debug(pris[span-1].pri.dchans[x], PRI_DEBUG_APDU |
- PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
- PRI_DEBUG_Q921_STATE);
+ pri_set_debug(pris[span-1].pri.dchans[x], SIG_PRI_DEBUG_NORMAL);
ast_cli(a->fd, "Enabled debugging on span %d\n", span);
} else if (level == 0) {
pri_set_debug(pris[span-1].pri.dchans[x], 0);
@@ -13611,9 +13750,7 @@
ast_cli(a->fd, "PRI debug output to file disabled\n");
ast_mutex_unlock(&pridebugfdlock);
} else {
- pri_set_debug(pris[span-1].pri.dchans[x], PRI_DEBUG_APDU |
- PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q931_STATE |
- PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_STATE);
+ pri_set_debug(pris[span-1].pri.dchans[x], SIG_PRI_DEBUG_INTENSE);
ast_cli(a->fd, "Enabled debugging on span %d\n", span);
}
}
@@ -15738,6 +15875,168 @@
};
#endif /* defined(HAVE_SS7) */
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+/*!
+ * \internal
+ * \brief CC agent initialization.
+ * \since 1.8
+ *
+ * \param agent CC core agent control.
+ * \param chan Original channel the agent will attempt to recall.
+ *
+ * \details
+ * This callback is called when the CC core is initialized. Agents should allocate
+ * any private data necessary for the call and assign it to the private_data
+ * on the agent. Additionally, if any ast_cc_agent_flags are pertinent to the
+ * specific agent type, they should be set in this function as well.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int dahdi_pri_cc_agent_init(struct ast_cc_agent *agent, struct ast_channel *chan)
+{
+ struct dahdi_pvt *pvt;
+ struct sig_pri_chan *pvt_chan;
+ int res;
+
+ ast_assert(!strcmp(chan->tech->type, "DAHDI"));
+
+ pvt = chan->tech_pvt;
+ if (dahdi_sig_pri_lib_handles(pvt->sig)) {
+ pvt_chan = pvt->sig_pvt;
+ } else {
+ pvt_chan = NULL;
+ }
+ if (!pvt_chan) {
+ return -1;
+ }
+
+ ast_module_ref(ast_module_info->self);
+
+ res = sig_pri_cc_agent_init(agent, pvt_chan);
+ if (res) {
+ ast_module_unref(ast_module_info->self);
+ }
+ return res;
+}
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+/*!
+ * \internal
+ * \brief Destroy private data on the agent.
+ * \since 1.8
+ *
+ * \param agent CC core agent control.
+ *
+ * \details
+ * The core will call this function upon completion
+ * or failure of CC.
+ *
+ * \return Nothing
+ */
+static void dahdi_pri_cc_agent_destructor(struct ast_cc_agent *agent)
+{
+ sig_pri_cc_agent_destructor(agent);
+
+ ast_module_unref(ast_module_info->self);
+}
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+static struct ast_cc_agent_callbacks dahdi_pri_cc_agent_callbacks = {
+ .type = dahdi_pri_cc_type,
+ .init = dahdi_pri_cc_agent_init,
+ .start_offer_timer = sig_pri_cc_agent_start_offer_timer,
+ .stop_offer_timer = sig_pri_cc_agent_stop_offer_timer,
+ .ack = sig_pri_cc_agent_req_ack,
+ .status_request = sig_pri_cc_agent_status_req,
+ .stop_ringing = sig_pri_cc_agent_stop_ringing,
+ .party_b_free = sig_pri_cc_agent_party_b_free,
+ .start_monitoring = sig_pri_cc_agent_start_monitoring,
+ .callee_available = sig_pri_cc_agent_callee_available,
+ .destructor = dahdi_pri_cc_agent_destructor,
+};
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+/*!
+ * \internal
+ * \brief CC monitor initialization.
+ * \since 1.8
+ *
+ * \param monitor CC core monitor control.
+ * \param core_id core_id of the CC transaction.
+ *
+ * \details
+ * Implementers must allocate the monitor's private_data
+ * and initialize it to whatever may be necessary.
+ *
+ * \retval 0 on success
+ * \retval -1 on failure.
+ */
+static int dahdi_pri_cc_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
+{
+ int res;
+
+ ast_module_ref(ast_module_info->self);
+
+ res = sig_pri_cc_monitor_init(monitor, core_id);
+ if (res) {
+ ast_module_unref(ast_module_info->self);
+ }
+ return res;
+}
+
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+/*!
+ * \internal
+ * \brief Destroy private data on the monitor.
+ * \since 1.8
+ *
+ * \param monitor CC core monitor control.
+ *
+ * \details
+ * Implementers of this callback are responsible for destroying
+ * all heap-allocated data in the monitor's private_data pointer, including
+ * the private_data itself.
+ */
+static void dahdi_pri_cc_monitor_destructor(struct ast_cc_monitor *monitor)
+{
+ sig_pri_cc_monitor_destructor(monitor);
+
+ ast_module_unref(ast_module_info->self);
+}
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
+#if defined(HAVE_PRI_CCSS)
+static struct ast_cc_monitor_callbacks dahdi_pri_cc_monitor_callbacks = {
+ .type = dahdi_pri_cc_type,
+ .init = dahdi_pri_cc_monitor_init,
+ .request_cc = sig_pri_cc_monitor_req_cc,
+ .suspend = sig_pri_cc_monitor_suspend,
+ .unsuspend = sig_pri_cc_monitor_unsuspend,
+ .status_response = sig_pri_cc_monitor_status_rsp,
+ .cancel_available_timer = sig_pri_cc_monitor_cancel_available_timer,
+ .destructor = dahdi_pri_cc_monitor_destructor,
+ .instance_destructor = sig_pri_cc_monitor_instance_destructor,
+};
+#endif /* defined(HAVE_PRI_CCSS) */
+#endif /* defined(HAVE_PRI) */
+
static int __unload_module(void)
{
struct dahdi_pvt *p;
@@ -15806,6 +16105,11 @@
dahdi_close_pri_fd(&(pris[i]), j);
}
}
+#if defined(HAVE_PRI_CCSS)
+ ast_cc_agent_unregister(&dahdi_pri_cc_agent_callbacks);
+ ast_cc_monitor_unregister(&dahdi_pri_cc_monitor_callbacks);
+#endif /* defined(HAVE_PRI_CCSS) */
+ sig_pri_unload();
#endif
#if defined(HAVE_SS7)
@@ -16606,6 +16910,34 @@
} else if (!strcasecmp(v->name, "hold_disconnect_transfer")) {
confp->pri.pri.hold_disconnect_transfer = ast_true(v->value);
#endif /* defined(HAVE_PRI_CALL_HOLD) */
+#if defined(HAVE_PRI_CCSS)
+ } else if (!strcasecmp(v->name, "cc_ptmp_recall_mode")) {
+ if (!strcasecmp(v->value, "global")) {
+ confp->pri.pri.cc_ptmp_recall_mode = 0;/* globalRecall */
+ } else if (!strcasecmp(v->value, "specific")) {
+ confp->pri.pri.cc_ptmp_recall_mode = 1;/* specificRecall */
+ } else {
+ confp->pri.pri.cc_ptmp_recall_mode = 1;/* specificRecall */
+ }
+ } else if (!strcasecmp(v->name, "cc_qsig_signaling_link_req")) {
+ if (!strcasecmp(v->value, "release")) {
+ confp->pri.pri.cc_qsig_signaling_link_req = 0;/* release */
+ } else if (!strcasecmp(v->value, "retain")) {
+ confp->pri.pri.cc_qsig_signaling_link_req = 1;/* retain */
+ } else if (!strcasecmp(v->value, "do_not_care")) {
+ confp->pri.pri.cc_qsig_signaling_link_req = 2;/* do-not-care */
+ } else {
+ confp->pri.pri.cc_qsig_signaling_link_req = 1;/* retain */
+ }
+ } else if (!strcasecmp(v->name, "cc_qsig_signaling_link_rsp")) {
+ if (!strcasecmp(v->value, "release")) {
+ confp->pri.pri.cc_qsig_signaling_link_rsp = 0;/* release */
+ } else if (!strcasecmp(v->value, "retain")) {
+ confp->pri.pri.cc_qsig_signaling_link_rsp = 1;/* retain */
+ } else {
+ confp->pri.pri.cc_qsig_signaling_link_rsp = 1;/* retain */
+ }
+#endif /* defined(HAVE_PRI_CCSS) */
#endif /* HAVE_PRI */
#ifdef HAVE_SS7
} else if (!strcasecmp(v->name, "ss7type")) {
@@ -16906,23 +17238,57 @@
*/
struct dahdi_chan_conf conf = dahdi_chan_conf_default();
- tmp = mkintf(CHAN_PSEUDO, &conf, reload);
-
+ if (conf.chan.cc_params) {
+ tmp = mkintf(CHAN_PSEUDO, &conf, reload);
+ } else {
+ tmp = NULL;
+ }
if (tmp) {
ast_verb(3, "Automatically generated pseudo channel\n");
} else {
ast_log(LOG_WARNING, "Unable to register pseudo channel!\n");
}
+ ast_cc_config_params_destroy(conf.chan.cc_params);
}
return 0;
}
-static int setup_dahdi(int reload)
-{
- struct ast_config *cfg, *ucfg;
+/*!
+ * \internal
+ * \brief Deep copy struct dahdi_chan_conf.
+ * \since 1.8
+ *
+ * \param dest Destination.
+ * \param src Source.
+ *
+ * \return Nothing
+ */
+static void deep_copy_dahdi_chan_conf(struct dahdi_chan_conf *dest, const struct dahdi_chan_conf *src)
+{
+ struct ast_cc_config_params *cc_params;
+
+ cc_params = dest->chan.cc_params;
+ memcpy(dest, src, sizeof(dest));
+ dest->chan.cc_params = cc_params;
+ ast_cc_copy_config_params(dest->chan.cc_params, src->chan.cc_params);
+}
+
+/*!
+ * \internal
+ * \brief Setup DAHDI channel driver.
+ *
+ * \param reload enum: load_module(0), reload(1), restart(2).
+ * \param base_conf Default config parameters. So cc_params can be properly destroyed.
+ * \param conf Local config parameters. So cc_params can be properly destroyed.
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int setup_dahdi_int(int reload, struct dahdi_chan_conf *base_conf, struct dahdi_chan_conf *conf)
+{
+ struct ast_config *cfg;
+ struct ast_config *ucfg;
struct ast_variable *v;
- struct dahdi_chan_conf base_conf = dahdi_chan_conf_default();
- struct dahdi_chan_conf conf;
struct ast_flags config_flags = { reload == 1 ? CONFIG_FLAG_FILEUNCHANGED : 0 };
const char *cat;
int res;
@@ -17037,7 +17403,7 @@
mwimonitornotify[0] = '\0';
v = ast_variable_browse(cfg, "channels");
- if ((res = process_dahdi(&base_conf, "", v, reload, 0))) {
+ if ((res = process_dahdi(base_conf, "", v, reload, 0))) {
ast_mutex_unlock(&iflock);
ast_config_destroy(cfg);
if (ucfg) {
@@ -17058,9 +17424,10 @@
continue;
}
- memcpy(&conf, &base_conf, sizeof(conf));
-
- if ((res = process_dahdi(&conf, cat, ast_variable_browse(cfg, cat), reload, PROC_DAHDI_OPT_NOCHAN))) {
+ /* Copy base_conf to conf. */
+ deep_copy_dahdi_chan_conf(conf, base_conf);
+
+ if ((res = process_dahdi(conf, cat, ast_variable_browse(cfg, cat), reload, PROC_DAHDI_OPT_NOCHAN))) {
ast_mutex_unlock(&iflock);
ast_config_destroy(cfg);
if (ucfg) {
@@ -17075,7 +17442,7 @@
if (ucfg) {
const char *chans;
- process_dahdi(&base_conf, "", ast_variable_browse(ucfg, "general"), 1, 0);
+ process_dahdi(base_conf, "", ast_variable_browse(ucfg, "general"), 1, 0);
for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
if (!strcasecmp(cat, "general")) {
@@ -17088,9 +17455,10 @@
continue;
}
- memcpy(&conf, &base_conf, sizeof(conf));
-
- if ((res = process_dahdi(&conf, cat, ast_variable_browse(ucfg, cat), reload, PROC_DAHDI_OPT_NOCHAN | PROC_DAHDI_OPT_NOWARN))) {
+ /* Copy base_conf to conf. */
+ deep_copy_dahdi_chan_conf(conf, base_conf);
+
+ if ((res = process_dahdi(conf, cat, ast_variable_browse(ucfg, cat), reload, PROC_DAHDI_OPT_NOCHAN | PROC_DAHDI_OPT_NOWARN))) {
ast_config_destroy(ucfg);
ast_mutex_unlock(&iflock);
return res;
@@ -17147,6 +17515,32 @@
return 0;
}
+/*!
+ * \internal
+ * \brief Setup DAHDI channel driver.
+ *
+ * \param reload enum: load_module(0), reload(1), restart(2).
+ *
+ * \retval 0 on success.
+ * \retval -1 on error.
+ */
+static int setup_dahdi(int reload)
+{
+ int res;
+ struct dahdi_chan_conf base_conf = dahdi_chan_conf_default();
+ struct dahdi_chan_conf conf = dahdi_chan_conf_default();
+
+ if (base_conf.chan.cc_params && conf.chan.cc_params) {
+ res = setup_dahdi_int(reload, &base_conf, &conf);
+ } else {
+ res = -1;
+ }
+ ast_cc_config_params_destroy(base_conf.chan.cc_params);
+ ast_cc_config_params_destroy(conf.chan.cc_params);
+
+ return res;
+}
+
static int load_module(void)
{
int res;
@@ -17167,6 +17561,23 @@
#ifdef HAVE_PRI_PROG_W_CAUSE
ast_register_application_xml(dahdi_send_callrerouting_facility_app, dahdi_send_callrerouting_facility_exec);
#endif
+#if defined(HAVE_PRI_CCSS)
+ if (ast_cc_agent_register(&dahdi_pri_cc_agent_callbacks)
+ || ast_cc_monitor_register(&dahdi_pri_cc_monitor_callbacks)) {
+ __unload_module();
+ return AST_MODULE_LOAD_FAILURE;
+ }
+#endif /* defined(HAVE_PRI_CCSS) */
+ if (sig_pri_load(
+#if defined(HAVE_PRI_CCSS)
+ dahdi_pri_cc_type
+#else
+ NULL
+#endif /* defined(HAVE_PRI_CCSS) */
+ )) {
+ __unload_module();
+ return AST_MODULE_LOAD_FAILURE;
+ }
#endif
#ifdef HAVE_SS7
memset(linksets, 0, sizeof(linksets));
Modified: team/group/CCSS_Monitor_Restructure/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS_Monitor_Restructure/channels/chan_iax2.c?view=diff&rev=244069&r1=244068&r2=244069
==============================================================================
--- team/group/CCSS_Monitor_Restructure/channels/chan_iax2.c (original)
+++ team/group/CCSS_Monitor_Restructure/channels/chan_iax2.c Mon Feb 1 11:27:55 2010
@@ -1189,7 +1189,6 @@
static void iax2_free_variable_datastore(void *);
static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen);
-static int acf_channel_write(struct ast_channel *chan, const char *function, char *data, const char *value);
static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh, struct ast_frame *f, int *datalen);
static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh, unsigned char *poo, int *datalen);
static void build_ecx_key(const unsigned char *digest, struct chan_iax2_pvt *pvt);
@@ -1222,7 +1221,6 @@
.transfer = iax2_transfer,
.fixup = iax2_fixup,
.func_channel_read = acf_channel_read,
- .func_channel_write = acf_channel_write,
};
static void mwi_event_cb(const struct ast_event *event, void *userdata)
@@ -4990,8 +4988,8 @@
iaxs[callno]->initid = iax2_sched_add(sched, autokill * 2, auto_congest, CALLNO_TO_PTR(callno));
}
- /* Check if there is an OSP token set by IAXCHANINFO function */
- osp_token_ptr = iaxs[callno]->osptoken;
+ /* Check if there is an OSP token */
+ osp_token_ptr = pbx_builtin_getvar_helper(c, "IAX2OSPTOKEN");
if (!ast_strlen_zero(osp_token_ptr)) {
if ((osp_token_length = strlen(osp_token_ptr)) <= IAX_MAX_OSPTOKEN_SIZE) {
osp_block_index = 0;
@@ -13548,34 +13546,6 @@
.read = function_iaxpeer,
};
[... 3384 lines stripped ...]
More information about the asterisk-commits
mailing list