[asterisk-commits] tilghman: branch tilghman/codec_bits3 r227508 - in /team/tilghman/codec_bits3...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 3 17:34:40 CST 2009
Author: tilghman
Date: Tue Nov 3 17:34:34 2009
New Revision: 227508
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=227508
Log:
Merged revisions 227049,227091,227162,227167,227237-227238,227276-227277,227298,227361,227368,227372,227424,227435,227448,227462-227464 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r227049 | tilghman | 2009-11-02 16:29:19 -0600 (Mon, 02 Nov 2009) | 7 lines
Add PacketCable NCS 1.0 support for Docsis/Eurodocsis networks
(closes issue #12950)
Reported by: alea-soluciones
Patches:
ncs-pktccops-12950-r206803.patch uploaded by alea-soluciones (license 514)
Tested by: alea-soluciones, adomjan, urtho, nahuelgreco
................
r227091 | oej | 2009-11-03 05:11:15 -0600 (Tue, 03 Nov 2009) | 15 lines
Merged revisions 227088 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r227088 | oej | 2009-11-03 11:29:59 +0100 (Tis, 03 Nov 2009) | 7 lines
Use proper response code when violating Contact ACL's.
https://reviewboard.asterisk.org/r/415/
Thanks kpfleming for a quick review.
(EDVX-003)
........
................
r227162 | lmadsen | 2009-11-03 09:19:47 -0600 (Tue, 03 Nov 2009) | 7 lines
Update extensions.conf.sample file to fix incorrect extensions.
(closes issue #15857)
Reported by: pprindeville
Patches:
stdexten.patch#2 uploaded by pprindeville (license 347)
Tested by: pprindeville
................
r227167 | file | 2009-11-03 09:37:08 -0600 (Tue, 03 Nov 2009) | 12 lines
Merged revisions 227166 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r227166 | file | 2009-11-03 11:36:16 -0400 (Tue, 03 Nov 2009) | 5 lines
Fix a bug where an RPID header could be generated with a blank username in the URI.
(closes issue #15909)
Reported by: kobaz
........
................
r227237 | oej | 2009-11-03 10:56:48 -0600 (Tue, 03 Nov 2009) | 5 lines
Adding some clarifications to func_speex doxygen docs.
The functions needed doesn't exist in Speex 1.05 which is what a lot of distros use.
1.2 seems to have been in beta status for years, and does include the sexy functions needed for func_speex to work.
................
r227238 | dvossel | 2009-11-03 11:12:52 -0600 (Tue, 03 Nov 2009) | 5 lines
user.conf entries in SIP were not having their peer type set.
(closes issue #16120)
Reported by: jsmith
................
r227276 | tilghman | 2009-11-03 11:56:41 -0600 (Tue, 03 Nov 2009) | 2 lines
Code guidelines fixes only
................
r227277 | rmudgett | 2009-11-03 11:58:38 -0600 (Tue, 03 Nov 2009) | 11 lines
Recorded merge of revisions 227275 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r227275 | rmudgett | 2009-11-03 11:55:47 -0600 (Tue, 03 Nov 2009) | 4 lines
Make sure the outgoing flag is cleared if a new channel fails to get created for outgoing calls.
This is the relevant portion of asterisk/trunk -r226648
........
................
r227298 | mnicholson | 2009-11-03 12:22:28 -0600 (Tue, 03 Nov 2009) | 2 lines
Fixed a spelling error in the q850 reason header option in the output of sip show settings.
................
r227361 | lmadsen | 2009-11-03 13:25:18 -0600 (Tue, 03 Nov 2009) | 11 lines
Additional fixes to the extensions.conf.sample file.
Update the extensions.conf.sample [stdexten] context so that we use the
variable instead of requiring it to be passed explicitly. Also updated uses of
the [stdexten] context throughout.
(closes issue #15858)
Reported by: pprindeville
Patches:
stdexten-context-update.txt uploaded by lmadsen (license 10)
Tested by: pprindeville
................
r227368 | lmadsen | 2009-11-03 13:48:53 -0600 (Tue, 03 Nov 2009) | 8 lines
Change warning message to debug message.
app_controlplayback outputs a warning, when in fact it is normal.
(closes issue #16071)
Reported by: atis
Patches:
controlplayback_warning.patch uploaded by atis (license 242)
................
r227372 | qwell | 2009-11-03 13:59:46 -0600 (Tue, 03 Nov 2009) | 9 lines
Fix some build issues on Solaris.
(closes issue #14517)
(SWP-109)
Reported by: asgaroth
Patches:
bug_14517.diff uploaded by snuffy (license 35)
Tested by: asgaroth, snuffy, dougm, qwell
................
r227424 | file | 2009-11-03 15:16:14 -0600 (Tue, 03 Nov 2009) | 7 lines
Add support for using a hint when configuring a state interface using the format hint:<extension>@<context>.
(closes issue #15168)
Reported by: p_lindheimer
Patches:
queue_extenstate5_1.4.svn.patch uploaded by GameGamer43 (license 894)
................
r227435 | mnicholson | 2009-11-03 15:21:09 -0600 (Tue, 03 Nov 2009) | 8 lines
This patch adds a sequence field to CDRs that can be combined with the linkedid or uniqueid field to uniquely identify a CDR.
(closes issue #15180)
Reported by: Nick_Lewis
Patches:
cdr-sequence10.diff uploaded by mnicholson (license 96)
Tested by: mnicholson
................
r227448 | dbrooks | 2009-11-03 15:26:28 -0600 (Tue, 03 Nov 2009) | 11 lines
AMI hook interface
This patch, originally submitted by jozza, enables custom modules to send actions to AMI
and receive messages from AMI via a hook interface. Included is a simple test module to
illustrate the interface.
(closes issue #14635)
Reported by: jozza
Review: https://reviewboard.asterisk.org/r/412/
................
r227462 | russell | 2009-11-03 16:05:31 -0600 (Tue, 03 Nov 2009) | 2 lines
Resolve some dev-mode warnings.
................
r227463 | russell | 2009-11-03 16:08:46 -0600 (Tue, 03 Nov 2009) | 2 lines
Resolve a warning from gcc 4.4.1.
................
r227464 | russell | 2009-11-03 16:13:25 -0600 (Tue, 03 Nov 2009) | 2 lines
Resolve another warning.
................
Added:
team/tilghman/codec_bits3/configs/res_pktccops.conf.sample
- copied unchanged from r227464, trunk/configs/res_pktccops.conf.sample
team/tilghman/codec_bits3/include/asterisk/pktccops.h
- copied unchanged from r227464, trunk/include/asterisk/pktccops.h
team/tilghman/codec_bits3/res/res_pktccops.c
- copied unchanged from r227464, trunk/res/res_pktccops.c
team/tilghman/codec_bits3/tests/test_amihooks.c
- copied unchanged from r227464, trunk/tests/test_amihooks.c
Modified:
team/tilghman/codec_bits3/ (props changed)
team/tilghman/codec_bits3/CHANGES
team/tilghman/codec_bits3/Makefile
team/tilghman/codec_bits3/apps/app_controlplayback.c
team/tilghman/codec_bits3/apps/app_forkcdr.c
team/tilghman/codec_bits3/apps/app_queue.c
team/tilghman/codec_bits3/channels/chan_mgcp.c
team/tilghman/codec_bits3/channels/chan_sip.c
team/tilghman/codec_bits3/configs/cdr_custom.conf.sample
team/tilghman/codec_bits3/configs/extensions.conf.sample
team/tilghman/codec_bits3/configs/mgcp.conf.sample
team/tilghman/codec_bits3/configs/queues.conf.sample
team/tilghman/codec_bits3/funcs/func_cdr.c
team/tilghman/codec_bits3/funcs/func_speex.c
team/tilghman/codec_bits3/include/asterisk/cdr.h
team/tilghman/codec_bits3/include/asterisk/manager.h
team/tilghman/codec_bits3/main/Makefile
team/tilghman/codec_bits3/main/cdr.c
team/tilghman/codec_bits3/main/features.c
team/tilghman/codec_bits3/main/manager.c
team/tilghman/codec_bits3/pbx/pbx_config.c
Propchange: team/tilghman/codec_bits3/
------------------------------------------------------------------------------
automerge = *
Propchange: team/tilghman/codec_bits3/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/tilghman/codec_bits3/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Nov 3 17:34:34 2009
@@ -1,1 +1,1 @@
-/trunk:1-227040
+/trunk:1-227501
Modified: team/tilghman/codec_bits3/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/CHANGES?view=diff&rev=227508&r1=227507&r2=227508
==============================================================================
--- team/tilghman/codec_bits3/CHANGES (original)
+++ team/tilghman/codec_bits3/CHANGES Tue Nov 3 17:34:34 2009
@@ -67,6 +67,8 @@
* Added ability to preset channel variables on indicated lines with the setvar
configuration option. Also, clearvars=all resets the list of variables back
to none.
+ * PacketCable NCS 1.0 support has been added for Docsis/Eurodocsis Networks.
+ See configs/res_pktccops.conf for more information.
Applications
------------
@@ -275,6 +277,8 @@
* Multiple files and formats can now be specified in cdr_custom.conf.
* cdr_syslog has been added which allows CDRs to be written directly to syslog.
See configs/cdr_syslog.conf.sample for more information.
+ * A 'sequence' field has been added to CDRs which can be combined with
+ linkedid or uniqueid to uniquely identify a CDR.
Calendaring for Asterisk
------------------------
Modified: team/tilghman/codec_bits3/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/Makefile?view=diff&rev=227508&r1=227507&r2=227508
==============================================================================
--- team/tilghman/codec_bits3/Makefile (original)
+++ team/tilghman/codec_bits3/Makefile Tue Nov 3 17:34:34 2009
@@ -276,7 +276,7 @@
endif
ifeq ($(OSARCH),SunOS)
- _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2
+ _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
endif
ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
@@ -306,7 +306,7 @@
ifneq ($(findstring darwin,$(OSARCH)),)
_ASTCFLAGS+=-D__Darwin__
SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace /usr/lib/bundle1.o
- _ASTLDFLAGS+= /usr/lib/bundle1.o -L/usr/local/lib
+ _ASTLDFLAGS+= -L/usr/local/lib
else
# These are used for all but Darwin
SOLINK=-shared
Modified: team/tilghman/codec_bits3/apps/app_controlplayback.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/apps/app_controlplayback.c?view=diff&rev=227508&r1=227507&r2=227508
==============================================================================
--- team/tilghman/codec_bits3/apps/app_controlplayback.c (original)
+++ team/tilghman/codec_bits3/apps/app_controlplayback.c Tue Nov 3 17:34:34 2009
@@ -175,7 +175,7 @@
else
args.rev = NULL;
}
- ast_log(LOG_WARNING, "args.fwd = %s, args.rew = %s\n", args.fwd, args.rev);
+ ast_debug(1, "Forward key = %s, Rewind key = %s\n", args.fwd, args.rev);
if (args.stop && !is_on_phonepad(*args.stop))
args.stop = NULL;
if (args.pause && !is_on_phonepad(*args.pause))
Modified: team/tilghman/codec_bits3/apps/app_forkcdr.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/apps/app_forkcdr.c?view=diff&rev=227508&r1=227507&r2=227508
==============================================================================
--- team/tilghman/codec_bits3/apps/app_forkcdr.c (original)
+++ team/tilghman/codec_bits3/apps/app_forkcdr.c Tue Nov 3 17:34:34 2009
@@ -184,7 +184,7 @@
while (cdr->next)
cdr = cdr->next;
- if (!(newcdr = ast_cdr_dup(cdr)))
+ if (!(newcdr = ast_cdr_dup_unique(cdr)))
return;
ast_cdr_append(cdr, newcdr);
Modified: team/tilghman/codec_bits3/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/apps/app_queue.c?view=diff&rev=227508&r1=227507&r2=227508
==============================================================================
--- team/tilghman/codec_bits3/apps/app_queue.c (original)
+++ team/tilghman/codec_bits3/apps/app_queue.c Tue Nov 3 17:34:34 2009
@@ -824,20 +824,22 @@
};
struct member {
- char interface[80]; /*!< Technology/Location to dial to reach this member*/
- char state_interface[80]; /*!< Technology/Location from which to read devicestate changes */
- char membername[80]; /*!< Member name to use in queue logs */
- int penalty; /*!< Are we a last resort? */
- int calls; /*!< Number of calls serviced by this member */
- int dynamic; /*!< Are we dynamically added? */
- int realtime; /*!< Is this member realtime? */
- int status; /*!< Status of queue member */
- int paused; /*!< Are we paused (not accepting calls)? */
- time_t lastcall; /*!< When last successful call was hungup */
- struct call_queue *lastqueue; /*!< Last queue we received a call */
- unsigned int dead:1; /*!< Used to detect members deleted in realtime */
- unsigned int delme:1; /*!< Flag to delete entry on reload */
- char rt_uniqueid[80]; /*!< Unique id of realtime member entry */
+ char interface[80]; /*!< Technology/Location to dial to reach this member*/
+ char state_exten[AST_MAX_EXTENSION]; /*!< Extension to get state from (if using hint) */
+ char state_context[AST_MAX_CONTEXT]; /*!< Context to use when getting state (if using hint) */
+ char state_interface[80]; /*!< Technology/Location from which to read devicestate changes */
+ char membername[80]; /*!< Member name to use in queue logs */
+ int penalty; /*!< Are we a last resort? */
+ int calls; /*!< Number of calls serviced by this member */
+ int dynamic; /*!< Are we dynamically added? */
+ int realtime; /*!< Is this member realtime? */
+ int status; /*!< Status of queue member */
+ int paused; /*!< Are we paused (not accepting calls)? */
+ time_t lastcall; /*!< When last successful call was hungup */
+ struct call_queue *lastqueue; /*!< Last queue we received a call */
+ unsigned int dead:1; /*!< Used to detect members deleted in realtime */
+ unsigned int delme:1; /*!< Flag to delete entry on reload */
+ char rt_uniqueid[80]; /*!< Unique id of realtime member entry */
};
enum empty_conditions {
@@ -1258,6 +1260,81 @@
}
}
+/*! \brief Helper function which converts from extension state to device state values */
+static int extensionstate2devicestate(int state)
+{
+ switch (state) {
+ case AST_EXTENSION_NOT_INUSE:
+ state = AST_DEVICE_NOT_INUSE;
+ break;
+ case AST_EXTENSION_INUSE:
+ state = AST_DEVICE_INUSE;
+ break;
+ case AST_EXTENSION_BUSY:
+ state = AST_DEVICE_BUSY;
+ break;
+ case AST_EXTENSION_RINGING:
+ state = AST_DEVICE_RINGING;
+ break;
+ case AST_EXTENSION_ONHOLD:
+ state = AST_DEVICE_ONHOLD;
+ break;
+ case AST_EXTENSION_UNAVAILABLE:
+ state = AST_DEVICE_UNAVAILABLE;
+ break;
+ case AST_EXTENSION_REMOVED:
+ case AST_EXTENSION_DEACTIVATED:
+ default:
+ state = AST_DEVICE_INVALID;
+ break;
+ }
+
+ return state;
+}
+
+static int extension_state_cb(char *context, char *exten, enum ast_extension_states state, void *data)
+{
+ struct ao2_iterator miter, qiter;
+ struct member *m;
+ struct call_queue *q;
+ int found = 0, device_state = extensionstate2devicestate(state);
+
+ qiter = ao2_iterator_init(queues, 0);
+ while ((q = ao2_iterator_next(&qiter))) {
+ ao2_lock(q);
+
+ miter = ao2_iterator_init(q->members, 0);
+ for (; (m = ao2_iterator_next(&miter)); ao2_ref(m, -1)) {
+ if (!strcmp(m->state_context, context) && !strcmp(m->state_exten, exten)) {
+ update_status(q, m, device_state);
+ ao2_ref(m, -1);
+ found = 1;
+ break;
+ }
+ }
+ ao2_iterator_destroy(&miter);
+
+ ao2_unlock(q);
+ ao2_ref(q, -1);
+ }
+ ao2_iterator_destroy(&qiter);
+
+ if (found) {
+ ast_debug(1, "Extension '%s@%s' changed to state '%d' (%s)\n", exten, context, device_state, ast_devstate2str(device_state));
+ } else {
+ ast_debug(3, "Extension '%s@%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n",
+ exten, context, device_state, ast_devstate2str(device_state));
+ }
+
+ return 0;
+}
+
+/*! \brief Return the current state of a member */
+static int get_queue_member_status(struct member *cur)
+{
+ return ast_strlen_zero(cur->state_exten) ? ast_device_state(cur->state_interface) : extensionstate2devicestate(ast_extension_state(NULL, cur->state_context, cur->state_exten));
+}
+
/*! \brief allocate space for new queue member and set fields based on parameters passed */
static struct member *create_queue_member(const char *interface, const char *membername, int penalty, int paused, const char *state_interface)
{
@@ -1277,7 +1354,14 @@
ast_copy_string(cur->membername, interface, sizeof(cur->membername));
if (!strchr(cur->interface, '/'))
ast_log(LOG_WARNING, "No location at interface '%s'\n", interface);
- cur->status = ast_device_state(cur->state_interface);
+ if (!strncmp(state_interface, "hint:", 5)) {
+ char *tmp = ast_strdupa(state_interface), *context = tmp;
+ char *exten = strsep(&context, "@") + 5;
+
+ ast_copy_string(cur->state_exten, exten, sizeof(cur->state_exten));
+ ast_copy_string(cur->state_context, S_OR(context, "default"), sizeof(cur->state_context));
+ }
+ cur->status = get_queue_member_status(cur);
}
return cur;
@@ -2677,7 +2761,7 @@
tmp->stillgoing = 0;
ao2_lock(qe->parent);
- update_status(qe->parent, tmp->member, ast_device_state(tmp->member->state_interface));
+ update_status(qe->parent, tmp->member, get_queue_member_status(tmp->member));
qe->parent->rrpos++;
qe->linpos++;
ao2_unlock(qe->parent);
@@ -2760,7 +2844,7 @@
ast_channel_unlock(qe->chan);
do_hang(tmp);
(*busies)++;
- update_status(qe->parent, tmp->member, ast_device_state(tmp->member->state_interface));
+ update_status(qe->parent, tmp->member, get_queue_member_status(tmp->member));
return 0;
} else if (qe->parent->eventwhencalled) {
char vars[2048];
@@ -2788,7 +2872,7 @@
ast_channel_unlock(tmp->chan);
ast_channel_unlock(qe->chan);
- update_status(qe->parent, tmp->member, ast_device_state(tmp->member->state_interface));
+ update_status(qe->parent, tmp->member, get_queue_member_status(tmp->member));
return 1;
}
@@ -6093,7 +6177,7 @@
*/
q->membercount++;
}
- member->status = ast_device_state(member->state_interface);
+ member->status = get_queue_member_status(member);
return 0;
} else {
q->membercount--;
@@ -7480,6 +7564,8 @@
if (device_state_sub)
ast_event_unsubscribe(device_state_sub);
+ ast_extension_state_del(0, extension_state_cb);
+
if ((con = ast_context_find("app_queue_gosub_virtual_context"))) {
ast_context_remove_extension2(con, "s", 1, NULL, 0);
ast_context_destroy(con, "app_queue"); /* leave no trace */
@@ -7553,6 +7639,8 @@
res = -1;
}
+ ast_extension_state_add(NULL, NULL, extension_state_cb, NULL);
+
ast_realtime_require_field("queue_members", "paused", RQ_INTEGER1, 1, "uniqueid", RQ_UINTEGER2, 5, SENTINEL);
return res ? AST_MODULE_LOAD_DECLINE : 0;
Modified: team/tilghman/codec_bits3/channels/chan_mgcp.c
URL: http://svnview.digium.com/svn/asterisk/team/tilghman/codec_bits3/channels/chan_mgcp.c?view=diff&rev=227508&r1=227507&r2=227508
==============================================================================
--- team/tilghman/codec_bits3/channels/chan_mgcp.c (original)
+++ team/tilghman/codec_bits3/channels/chan_mgcp.c Tue Nov 3 17:34:34 2009
@@ -71,6 +71,7 @@
#include "asterisk/abstract_jb.h"
#include "asterisk/event.h"
#include "asterisk/chanvars.h"
+#include "asterisk/pktccops.h"
/*
* Define to work around buggy dlink MGCP phone firmware which
@@ -150,6 +151,9 @@
static int dtmfmode = 0;
static int nat = 0;
+static int ncs = 0;
+static int pktcgatealloc = 0;
+static int hangupongateremove = 0;
static ast_group_t cur_callergroup = 0;
static ast_group_t cur_pickupgroup = 0;
@@ -206,7 +210,8 @@
AST_MUTEX_DEFINE_STATIC(monlock);
/*! This is the thread for the monitor which checks for input on the channels
- which are not currently in use. */
+ * which are not currently in use.
+ */
static pthread_t monitor_thread = AST_PTHREADT_NULL;
static int restart_monitor(void);
@@ -222,9 +227,10 @@
static struct sched_context *sched;
static struct io_context *io;
-/*! The private structures of the mgcp channels are linked for
- ! selecting outgoing channels */
-
+/*! The private structures of the mgcp channels are linked for
+ * selecting outgoing channels
+ */
+
#define MGCP_MAX_HEADERS 64
#define MGCP_MAX_LINES 64
@@ -272,20 +278,20 @@
#define SUB_ALT 1
struct mgcp_subchannel {
- /*! subchannel magic string.
- Needed to prove that any subchannel pointer passed by asterisk
+ /*! subchannel magic string.
+ Needed to prove that any subchannel pointer passed by asterisk
really points to a valid subchannel memory area.
Ugly.. But serves the purpose for the time being.
*/
#define MGCP_SUBCHANNEL_MAGIC "!978!"
- char magic[6];
+ char magic[6];
ast_mutex_t lock;
int id;
struct ast_channel *owner;
struct mgcp_endpoint *parent;
struct ast_rtp_instance *rtp;
struct sockaddr_in tmpdest;
- char txident[80]; /*! \todo FIXME txident is replaced by rqnt_ident in endpoint.
+ char txident[80]; /*! \todo FIXME txident is replaced by rqnt_ident in endpoint.
This should be obsoleted */
char cxident[80];
char callid[80];
@@ -296,6 +302,8 @@
int iseq; /*!< Not used? RTP? */
int outgoing;
int alreadygone;
+ int sdpsent;
+ struct cops_gate *gate;
struct mgcp_subchannel *next; /*!< for out circular linked list */
};
@@ -338,6 +346,9 @@
int hidecallerid;
int dtmfmode;
int amaflags;
+ int ncs;
+ int pktcgatealloc;
+ int hangupongateremove;
int type;
int slowsequence; /*!< MS: Sequence the endpoint as a whole */
int group;
@@ -388,12 +399,13 @@
/* Wildcard endpoint name */
char wcardep[30];
struct mgcp_message *msgs; /*!< gw msg queue */
- ast_mutex_t msgs_lock; /*!< queue lock */
+ ast_mutex_t msgs_lock; /*!< queue lock */
int retransid; /*!< retrans timer id */
int delme; /*!< needed for reload */
+ int realtime;
struct mgcp_response *responses;
struct mgcp_gateway *next;
-} *gateways;
+} *gateways = NULL;
AST_MUTEX_DEFINE_STATIC(mgcp_reload_lock);
static int mgcp_reloading = 0;
@@ -409,12 +421,13 @@
static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp_request *req, char *msgrest);
static int transmit_notify_request(struct mgcp_subchannel *sub, char *tone);
static int transmit_modify_request(struct mgcp_subchannel *sub);
+static int transmit_connect(struct mgcp_subchannel *sub);
static int transmit_notify_request_with_callerid(struct mgcp_subchannel *sub, char *tone, char *callernum, char *callername);
static int transmit_modify_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp, format_t codecs);
static int transmit_connection_del(struct mgcp_subchannel *sub);
static int transmit_audit_endpoint(struct mgcp_endpoint *p);
static void start_rtp(struct mgcp_subchannel *sub);
-static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
+static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
int result, unsigned int ident, struct mgcp_request *resp);
static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub);
static char *mgcp_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
@@ -431,14 +444,18 @@
static int mgcp_senddigit_begin(struct ast_channel *ast, char digit);
static int mgcp_senddigit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int mgcp_devicestate(void *data);
-static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp);
+static void add_header_offhook(struct mgcp_subchannel *sub, struct mgcp_request *resp, char *tone);
+static int transmit_connect_with_sdp(struct mgcp_subchannel *sub, struct ast_rtp_instance *rtp);
+static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v);
+static int mgcp_alloc_pktcgate(struct mgcp_subchannel *sub);
+static int acf_channel_read(struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen);
static struct ast_variable *add_var(const char *buf, struct ast_variable *list);
static struct ast_variable *copy_vars(struct ast_variable *src);
static const struct ast_channel_tech mgcp_tech = {
.type = "MGCP",
.description = tdesc,
- .capabilities = AST_FORMAT_ULAW,
+ .capabilities = AST_FORMAT_ULAW | AST_FORMAT_ALAW,
.properties = AST_CHAN_TP_WANTSJITTER | AST_CHAN_TP_CREATESJITTER,
.requester = mgcp_request,
.devicestate = mgcp_devicestate,
@@ -452,6 +469,7 @@
.send_digit_begin = mgcp_senddigit_begin,
.send_digit_end = mgcp_senddigit_end,
.bridge = ast_rtp_instance_bridge,
+ .func_channel_read = acf_channel_read,
};
static void mwi_event_cb(const struct ast_event *event, void *userdata)
@@ -510,7 +528,7 @@
ast_rtp_instance_destroy(sub->rtp);
sub->rtp = NULL;
}
- dump_cmd_queues(NULL, sub); /* SC */
+ dump_cmd_queues(NULL, sub);
return 0;
}
@@ -520,7 +538,7 @@
int res;
if (gw->addr.sin_addr.s_addr)
res=sendto(mgcpsock, data, len, 0, (struct sockaddr *)&gw->addr, sizeof(struct sockaddr_in));
- else
+ else
res=sendto(mgcpsock, data, len, 0, (struct sockaddr *)&gw->defaddr, sizeof(struct sockaddr_in));
if (res != len) {
ast_log(LOG_WARNING, "mgcp_xmit returned %d: %s\n", res, strerror(errno));
@@ -532,9 +550,7 @@
{
struct mgcp_endpoint *p = sub->parent;
int res;
- if (mgcpdebug) {
- ast_verbose("Retransmitting:\n%s\n to %s:%d\n", resp->buf, ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
- }
+ ast_debug(1, "Retransmitting:\n%s\n to %s:%d\n", resp->buf, ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
res = __mgcp_xmit(p->parent, resp->buf, resp->len);
if (res > 0)
res = 0;
@@ -545,9 +561,7 @@
{
struct mgcp_endpoint *p = sub->parent;
int res;
- if (mgcpdebug) {
- ast_verbose("Transmitting:\n%s\n to %s:%d\n", req->data, ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
- }
+ ast_debug(1, "Transmitting:\n%s\n to %s:%d\n", req->data, ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
res = __mgcp_xmit(p->parent, req->data, req->len);
if (res > 0)
res = 0;
@@ -560,27 +574,24 @@
struct mgcp_message *cur, *q = NULL, *w, *prev;
ast_mutex_lock(&gw->msgs_lock);
- prev = NULL, cur = gw->msgs;
- while (cur) {
+ for (prev = NULL, cur = gw->msgs; cur; prev = cur, cur = cur->next) {
if (!p || cur->owner_ep == p) {
- if (prev)
+ if (prev) {
prev->next = cur->next;
- else
+ } else {
gw->msgs = cur->next;
-
- ast_log(LOG_NOTICE, "Removing message from %s transaction %u\n",
+ }
+
+ ast_log(LOG_NOTICE, "Removing message from %s transaction %u\n",
gw->name, cur->seqno);
w = cur;
- cur = cur->next;
if (q) {
w->next = q;
} else {
w->next = NULL;
}
q = w;
- } else {
- prev = cur, cur=cur->next;
}
}
ast_mutex_unlock(&gw->msgs_lock);
@@ -594,7 +605,7 @@
static void mgcp_queue_frame(struct mgcp_subchannel *sub, struct ast_frame *f)
{
- for(;;) {
+ for (;;) {
if (sub->owner) {
if (!ast_channel_trylock(sub->owner)) {
ast_queue_frame(sub->owner, f);
@@ -603,14 +614,15 @@
} else {
DEADLOCK_AVOIDANCE(&sub->lock);
}
- } else
+ } else {
break;
+ }
}
}
static void mgcp_queue_hangup(struct mgcp_subchannel *sub)
{
- for(;;) {
+ for (;;) {
if (sub->owner) {
if (!ast_channel_trylock(sub->owner)) {
ast_queue_hangup(sub->owner);
@@ -619,8 +631,9 @@
} else {
DEADLOCK_AVOIDANCE(&sub->lock);
}
- } else
+ } else {
break;
+ }
}
}
@@ -639,18 +652,12 @@
/* find out expired msgs */
ast_mutex_lock(&gw->msgs_lock);
- prev = NULL, cur = gw->msgs;
- while (cur) {
+ for (prev = NULL, cur = gw->msgs; cur; prev = cur, cur = cur->next) {
if (cur->retrans < MAX_RETRANS) {
cur->retrans++;
- if (mgcpdebug) {
- ast_verbose("Retransmitting #%d transaction %u on [%s]\n",
- cur->retrans, cur->seqno, gw->name);
- }
+ ast_debug(1, "Retransmitting #%d transaction %u on [%s]\n",
+ cur->retrans, cur->seqno, gw->name);
__mgcp_xmit(gw, cur->buf, cur->len);
-
- prev = cur;
- cur = cur->next;
} else {
if (prev)
prev->next = cur->next;
@@ -661,7 +668,6 @@
cur->seqno, gw->name);
w = cur;
- cur = cur->next;
if (exq) {
w->next = exq;
@@ -683,7 +689,7 @@
while (exq) {
cur = exq;
/* time-out transaction */
- handle_response(cur->owner_ep, cur->owner_sub, 406, cur->seqno, NULL);
+ handle_response(cur->owner_ep, cur->owner_sub, 406, cur->seqno, NULL);
exq = exq->next;
ast_free(cur);
}
@@ -692,31 +698,22 @@
}
/* modified for the new transaction mechanism */
-static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
+static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
char *data, int len, unsigned int seqno)
{
struct mgcp_message *msg;
struct mgcp_message *cur;
struct mgcp_gateway *gw;
- struct timeval now;
-
- msg = ast_malloc(sizeof(*msg) + len);
- if (!msg) {
+ struct timeval now;
+
+ if (!(msg = ast_malloc(sizeof(*msg) + len))) {
return -1;
}
- gw = ((p && p->parent) ? p->parent : NULL);
- if (!gw) {
+ if (!(gw = ((p && p->parent) ? p->parent : NULL))) {
ast_free(msg);
return -1;
}
-/* SC
- time(&t);
- if (gw->messagepending && (gw->lastouttime + 20 < t)) {
- ast_log(LOG_NOTICE, "Timeout waiting for response to message:%d, lastouttime: %ld, now: %ld. Dumping pending queue\n",
- gw->msgs ? gw->msgs->seqno : -1, (long) gw->lastouttime, (long) t);
- dump_queue(sub->parent);
- }
-*/
+
msg->owner_sub = sub;
msg->owner_ep = p;
msg->seqno = seqno;
@@ -726,10 +723,8 @@
memcpy(msg->buf, data, msg->len);
ast_mutex_lock(&gw->msgs_lock);
- cur = gw->msgs;
+ for (cur = gw->msgs; cur && cur->next; cur = cur->next);
if (cur) {
- while(cur->next)
- cur = cur->next;
cur->next = msg;
} else {
gw->msgs = msg;
@@ -741,23 +736,13 @@
if (gw->retransid == -1)
gw->retransid = ast_sched_add(sched, DEFAULT_RETRANS, retrans_pkt, (void *)gw);
ast_mutex_unlock(&gw->msgs_lock);
-/* SC
- if (!gw->messagepending) {
- gw->messagepending = 1;
- gw->lastout = seqno;
- gw->lastouttime = t;
-*/
__mgcp_xmit(gw, msg->buf, msg->len);
- /* XXX Should schedule retransmission XXX */
-/* SC
- } else
- ast_debug(1, "Deferring transmission of transaction %d\n", seqno);
-*/
+ /* XXX Should schedule retransmission XXX */
return 0;
}
/* modified for new transport */
-static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
+static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
struct mgcp_request *req, unsigned int seqno)
{
int res = 0;
@@ -777,12 +762,15 @@
ast_mutex_lock(l);
q = sub->cx_queue;
/* delete pending cx cmds */
- while (q) {
- r = q->next;
- ast_free(q);
- q = r;
- }
- *queue = NULL;
+ /* buggy sb5120 */
+ if (!sub->parent->ncs) {
+ while (q) {
+ r = q->next;
+ ast_free(q);
+ q = r;
+ }
+ *queue = NULL;
+ }
break;
case MGCP_CMD_CRCX:
@@ -806,8 +794,7 @@
}
}
- r = ast_malloc(sizeof(*r));
- if (!r) {
+ if (!(r = ast_malloc(sizeof(*r)))) {
ast_log(LOG_WARNING, "Cannot post MGCP request: insufficient memory\n");
ast_mutex_unlock(l);
return -1;
@@ -815,17 +802,13 @@
memcpy(r, req, sizeof(*r));
if (!(*queue)) {
- if (mgcpdebug) {
- ast_verbose("Posting Request:\n%s to %s:%d\n", req->data,
- ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
- }
+ ast_debug(1, "Posting Request:\n%s to %s:%d\n", req->data,
+ ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
res = mgcp_postrequest(p, sub, req->data, req->len, seqno);
} else {
- if (mgcpdebug) {
- ast_verbose("Queueing Request:\n%s to %s:%d\n", req->data,
- ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
- }
+ ast_debug(1, "Queueing Request:\n%s to %s:%d\n", req->data,
+ ast_inet_ntoa(p->parent->addr.sin_addr), ntohs(p->parent->addr.sin_port));
}
/* XXX find tail. We could also keep tail in the data struct for faster access */
@@ -852,9 +835,7 @@
struct varshead *headp;
struct ast_var_t *current;
- if (mgcpdebug) {
- ast_verb(3, "MGCP mgcp_call(%s)\n", ast->name);
- }
+ ast_debug(3, "MGCP mgcp_call(%s)\n", ast->name);
sub = ast->tech_pvt;
p = sub->parent;
headp = &ast->varshead;
@@ -870,28 +851,20 @@
case MGCP_OFFHOOK:
if (!ast_strlen_zero(distinctive_ring)) {
snprintf(tone, sizeof(tone), "L/wt%s", distinctive_ring);
- if (mgcpdebug) {
- ast_verb(3, "MGCP distinctive callwait %s\n", tone);
- }
+ ast_debug(3, "MGCP distinctive callwait %s\n", tone);
} else {
- ast_copy_string(tone, "L/wt", sizeof(tone));
- if (mgcpdebug) {
- ast_verb(3, "MGCP normal callwait %s\n", tone);
- }
+ ast_copy_string(tone, (p->ncs ? "L/wt1" : "L/wt"), sizeof(tone));
+ ast_debug(3, "MGCP normal callwait %s\n", tone);
}
break;
case MGCP_ONHOOK:
default:
if (!ast_strlen_zero(distinctive_ring)) {
snprintf(tone, sizeof(tone), "L/r%s", distinctive_ring);
- if (mgcpdebug) {
- ast_verb(3, "MGCP distinctive ring %s\n", tone);
- }
+ ast_debug(3, "MGCP distinctive ring %s\n", tone);
} else {
ast_copy_string(tone, "L/rg", sizeof(tone));
- if (mgcpdebug) {
- ast_verb(3, "MGCP default ring\n");
- }
+ ast_debug(3, "MGCP default ring\n");
}
break;
}
@@ -905,6 +878,7 @@
res = 0;
sub->outgoing = 1;
sub->cxmode = MGCP_CX_RECVONLY;
+ ast_setstate(ast, AST_STATE_RINGING);
if (p->type == TYPE_LINE) {
if (!sub->rtp) {
start_rtp(sub);
@@ -931,7 +905,6 @@
res = -1;
}
ast_mutex_unlock(&sub->lock);
- ast_queue_control(ast, AST_CONTROL_RINGING);
return res;
}
@@ -950,24 +923,36 @@
return 0;
}
ast_mutex_lock(&sub->lock);
- if (mgcpdebug) {
- ast_verb(3, "MGCP mgcp_hangup(%s) on %s@%s\n", ast->name, p->name, p->parent->name);
- }
+ ast_debug(3, "MGCP mgcp_hangup(%s) on %s@%s\n", ast->name, p->name, p->parent->name);
if ((p->dtmfmode & MGCP_DTMF_INBAND) && p->dsp) {
/* check whether other channel is active. */
if (!sub->next->owner) {
- if (p->dtmfmode & MGCP_DTMF_HYBRID)
+ if (p->dtmfmode & MGCP_DTMF_HYBRID) {
p->dtmfmode &= ~MGCP_DTMF_INBAND;
- if (mgcpdebug) {
- ast_verb(2, "MGCP free dsp on %s@%s\n", p->name, p->parent->name);
- }
+ }
+ ast_debug(2, "MGCP free dsp on %s@%s\n", p->name, p->parent->name);
ast_dsp_free(p->dsp);
p->dsp = NULL;
}
}
sub->owner = NULL;
+
+ /* for deleting gate */
+ if (p->pktcgatealloc && sub->gate) {
+ sub->gate->gate_open = NULL;
+ sub->gate->gate_remove = NULL;
+ sub->gate->got_dq_gi = NULL;
+ sub->gate->tech_pvt = NULL;
+ if (sub->gate->state == GATE_ALLOC_PROGRESS || sub->gate->state == GATE_ALLOCATED) {
+ ast_pktccops_gate_alloc(GATE_DEL, sub->gate, 0, 0, 0, 0, 0, 0, NULL, NULL);
+ } else {
+ sub->gate->deltimer = time(NULL) + 5;
+ }
+ sub->gate = NULL;
+ }
+
if (!ast_strlen_zero(sub->cxident)) {
transmit_connection_del(sub);
}
@@ -975,7 +960,8 @@
if ((sub == p->sub) && sub->next->owner) {
if (p->hookstate == MGCP_OFFHOOK) {
if (sub->next->owner && ast_bridged_channel(sub->next->owner)) {
- transmit_notify_request_with_callerid(p->sub, "L/wt", ast_bridged_channel(sub->next->owner)->cid.cid_num, ast_bridged_channel(sub->next->owner)->cid.cid_name);
+ /* ncs fix! */
+ transmit_notify_request_with_callerid(p->sub, (p->ncs ? "L/wt1" : "L/wt"), ast_bridged_channel(sub->next->owner)->cid.cid_num, ast_bridged_channel(sub->next->owner)->cid.cid_name);
}
} else {
/* set our other connection as the primary and swith over to it */
@@ -988,7 +974,7 @@
}
} else if ((sub == p->sub->next) && p->hookstate == MGCP_OFFHOOK) {
- transmit_notify_request(sub, "L/v");
+ transmit_notify_request(sub, p->ncs ? "" : "L/v");
} else if (p->hookstate == MGCP_OFFHOOK) {
transmit_notify_request(sub, "L/ro");
} else {
@@ -1019,16 +1005,12 @@
p->callwaiting = -1;
}
if (has_voicemail(p)) {
- if (mgcpdebug) {
- ast_verb(3, "MGCP mgcp_hangup(%s) on %s@%s set vmwi(+)\n",
- ast->name, p->name, p->parent->name);
- }
+ ast_debug(3, "MGCP mgcp_hangup(%s) on %s@%s set vmwi(+)\n",
+ ast->name, p->name, p->parent->name);
transmit_notify_request(sub, "L/vmwi(+)");
} else {
- if (mgcpdebug) {
- ast_verb(3, "MGCP mgcp_hangup(%s) on %s@%s set vmwi(-)\n",
- ast->name, p->name, p->parent->name);
- }
+ ast_debug(3, "MGCP mgcp_hangup(%s) on %s@%s set vmwi(-)\n",
+ ast->name, p->name, p->parent->name);
transmit_notify_request(sub, "L/vmwi(-)");
}
}
@@ -1042,7 +1024,6 @@
struct mgcp_endpoint *me;
int hasendpoints = 0;
struct ast_variable * v = NULL;
-
switch (cmd) {
case CLI_INIT:
@@ -1055,14 +1036,13 @@
return NULL;
}
- if (a->argc != 3)
+ if (a->argc != 3) {
return CLI_SHOWUSAGE;
+ }
ast_mutex_lock(&gatelock);
- mg = gateways;
- while(mg) {
- me = mg->endpoints;
- ast_cli(a->fd, "Gateway '%s' at %s (%s)\n", mg->name, mg->addr.sin_addr.s_addr ? ast_inet_ntoa(mg->addr.sin_addr) : ast_inet_ntoa(mg->defaddr.sin_addr), mg->dynamic ? "Dynamic" : "Static");
- while(me) {
+ for (mg = gateways; mg; mg = mg->next) {
+ ast_cli(a->fd, "Gateway '%s' at %s (%s%s)\n", mg->name, mg->addr.sin_addr.s_addr ? ast_inet_ntoa(mg->addr.sin_addr) : ast_inet_ntoa(mg->defaddr.sin_addr), mg->realtime ? "Realtime, " : "", mg->dynamic ? "Dynamic" : "Static");
+ for (me = mg->endpoints; me; me = me->next) {
ast_cli(a->fd, " -- '%s@%s in '%s' is %s\n", me->name, mg->name, me->context, me->sub->owner ? "active" : "idle");
if (me->chanvars) {
ast_cli(a->fd, " Variables:\n");
@@ -1071,12 +1051,10 @@
}
}
hasendpoints = 1;
- me = me->next;
}
if (!hasendpoints) {
ast_cli(a->fd, " << No Endpoints Defined >> ");
}
- mg = mg->next;
}
ast_mutex_unlock(&gatelock);
return CLI_SUCCESS;
@@ -1108,37 +1086,33 @@
return CLI_SHOWUSAGE;
/* split the name into parts by null */
ename = ast_strdupa(a->argv[3]);
- gname = ename;
- while (*gname) {
+ for (gname = ename; *gname; gname++) {
if (*gname == '@') {
*gname = 0;
gname++;
break;
}
+ }
+ if (gname[0] == '[') {
gname++;
}
- if (gname[0] == '[')
- gname++;
- if ((c = strrchr(gname, ']')))
+ if ((c = strrchr(gname, ']'))) {
*c = '\0';
+ }
ast_mutex_lock(&gatelock);
- mg = gateways;
- while(mg) {
+ for (mg = gateways; mg; mg = mg->next) {
if (!strcasecmp(mg->name, gname)) {
- me = mg->endpoints;
- while(me) {
+ for (me = mg->endpoints; me; me = me->next) {
if (!strcasecmp(me->name, ename)) {
found = 1;
transmit_audit_endpoint(me);
break;
}
- me = me->next;
}
if (found) {
break;
}
}
- mg = mg->next;
}
if (!found) {
ast_cli(a->fd, " << Could not find endpoint >> ");
@@ -1268,11 +1242,17 @@
ast_getformatname_multiple(buf, sizeof(buf), ast->nativeformats),
[... 3435 lines stripped ...]
More information about the asterisk-commits
mailing list