[asterisk-commits] kpfleming: branch oej/videocaps r148466 - in /team/oej/videocaps: ./ apps/ ch...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Oct 13 05:44:39 CDT 2008
Author: kpfleming
Date: Mon Oct 13 05:44:39 2008
New Revision: 148466
URL: http://svn.digium.com/view/asterisk?view=rev&rev=148466
Log:
fix conflict, restore automerge
Modified:
team/oej/videocaps/ (props changed)
team/oej/videocaps/CHANGES
team/oej/videocaps/apps/app_voicemail.c
team/oej/videocaps/channels/chan_dahdi.c
team/oej/videocaps/channels/chan_h323.c
team/oej/videocaps/channels/chan_iax2.c
team/oej/videocaps/channels/chan_misdn.c
team/oej/videocaps/channels/chan_oss.c
team/oej/videocaps/channels/chan_sip.c
team/oej/videocaps/channels/chan_usbradio.c
team/oej/videocaps/channels/console_gui.c
team/oej/videocaps/channels/console_video.c
team/oej/videocaps/channels/vcodecs.c
team/oej/videocaps/configs/extensions.conf.sample
team/oej/videocaps/configs/phoneprov.conf.sample
team/oej/videocaps/configs/res_ldap.conf.sample
team/oej/videocaps/configs/sip.conf.sample
team/oej/videocaps/configure
team/oej/videocaps/configure.ac
team/oej/videocaps/doc/CODING-GUIDELINES
team/oej/videocaps/include/asterisk.h
team/oej/videocaps/include/asterisk/autoconfig.h.in
team/oej/videocaps/include/asterisk/endian.h
team/oej/videocaps/main/astobj2.c
team/oej/videocaps/main/cli.c
team/oej/videocaps/main/config.c
team/oej/videocaps/main/cryptostub.c
team/oej/videocaps/main/features.c
team/oej/videocaps/main/manager.c
team/oej/videocaps/main/pbx.c
team/oej/videocaps/main/rtp.c
team/oej/videocaps/main/tdd.c
team/oej/videocaps/main/translate.c
team/oej/videocaps/pbx/pbx_config.c
team/oej/videocaps/phoneprov/000000000000.cfg
team/oej/videocaps/res/res_agi.c
team/oej/videocaps/res/res_config_sqlite.c
team/oej/videocaps/res/res_phoneprov.c
team/oej/videocaps/sounds/Makefile
team/oej/videocaps/sounds/sounds.xml
team/oej/videocaps/utils/extconf.c
Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
automerge = edvina
Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.
Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/oej/videocaps/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Oct 13 05:44:39 2008
@@ -1,1 +1,1 @@
-/trunk:1-147753
+/trunk:1-148464
Modified: team/oej/videocaps/CHANGES
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/CHANGES?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/CHANGES (original)
+++ team/oej/videocaps/CHANGES Mon Oct 13 05:44:39 2008
@@ -7,6 +7,8 @@
* Added support for SUBSCRIBE/NOTIFY with dialog-info based call pickups.
Snom phones use this for call pickup of extensions that the phone is
subscribed to.
+ * Added support for subscribing to a voice mailbox on a remote server and
+ making the new/old message count available to local devices.
Dialplan Functions
------------------
@@ -26,6 +28,11 @@
* res_jabber: autoprune has been disabled by default, to avoid misconfiguration
that would end up being interpreted as a bug once Asterisk started removing
the contacts from a user list.
+ * extensions.conf now allows you to use keyword "same" to define an extension
+ without actually specifying an extension. It uses exactly the same pattern
+ as previously used on the last "exten" line. For example:
+ exten => 123,1,NoOp(something)
+ same => n,SomethingElse()
------------------------------------------------------------------------------
--- Functionality changes from Asterisk 1.6.0 to Asterisk 1.6.1 -------------
Modified: team/oej/videocaps/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/apps/app_voicemail.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/apps/app_voicemail.c (original)
+++ team/oej/videocaps/apps/app_voicemail.c Mon Oct 13 05:44:39 2008
@@ -63,12 +63,8 @@
</category>
***/
-/* It is important to include the IMAP_STORAGE related headers
- * before asterisk.h since asterisk.h includes logger.h. logger.h
- * and c-client.h have conflicting definitions for AST_LOG_WARNING and
- * AST_LOG_DEBUG, so it's important that we use Asterisk's definitions
- * here instead of the c-client's
- */
+#include "asterisk.h"
+
#ifdef IMAP_STORAGE
#include <ctype.h>
#include <signal.h>
@@ -88,8 +84,6 @@
#endif
#endif
-#include "asterisk.h"
-
ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/paths.h" /* use ast_config_AST_SPOOL_DIR */
@@ -99,6 +93,7 @@
#include <time.h>
#include <dirent.h>
+#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
@@ -1520,9 +1515,9 @@
fprintf(text_file_ptr, "%s\n", "[message]");
+ get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Name:", buf, sizeof(buf));
+ fprintf(text_file_ptr, "callerid=\"%s\" ", S_OR(buf, ""));
get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Num:", buf, sizeof(buf));
- fprintf(text_file_ptr, "callerid=\"%s\" ", S_OR(buf, ""));
- get_header_by_tag(header_content, "X-Asterisk-VM-Caller-ID-Name:", buf, sizeof(buf));
fprintf(text_file_ptr, "<%s>\n", S_OR(buf, ""));
get_header_by_tag(header_content, "X-Asterisk-VM-Context:", buf, sizeof(buf));
fprintf(text_file_ptr, "context=%s\n", S_OR(buf, ""));
@@ -1532,6 +1527,8 @@
fprintf(text_file_ptr, "duration=%s\n", S_OR(buf, ""));
get_header_by_tag(header_content, "X-Asterisk-VM-Category:", buf, sizeof(buf));
fprintf(text_file_ptr, "category=%s\n", S_OR(buf, ""));
+ get_header_by_tag(header_content, "X-Asterisk-VM-Flag:", buf, sizeof(buf));
+ fprintf(text_file_ptr, "flag=%s\n", S_OR(buf, ""));
fclose(text_file_ptr);
exit:
@@ -3677,7 +3674,8 @@
pbx_builtin_setvar_helper(ast, "VM_MSGNUM", passdata);
pbx_builtin_setvar_helper(ast, "VM_CONTEXT", context);
pbx_builtin_setvar_helper(ast, "VM_MAILBOX", mailbox);
- pbx_builtin_setvar_helper(ast, "VM_CALLERID", ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, "Unknown Caller"));
+ pbx_builtin_setvar_helper(ast, "VM_CALLERID", (!ast_strlen_zero(cidname) || !ast_strlen_zero(cidnum)) ?
+ ast_callerid_merge(callerid, sizeof(callerid), cidname, cidnum, NULL) : "an unknown caller");
pbx_builtin_setvar_helper(ast, "VM_CIDNAME", (!ast_strlen_zero(cidname) ? cidname : "an unknown caller"));
pbx_builtin_setvar_helper(ast, "VM_CIDNUM", (!ast_strlen_zero(cidnum) ? cidnum : "an unknown caller"));
pbx_builtin_setvar_helper(ast, "VM_DATE", date);
@@ -7758,8 +7756,11 @@
/* Notify the user that the temp greeting is set and give them the option to remove it */
snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
if (ast_test_flag(vmu, VM_TEMPGREETWARN)) {
- if (ast_fileexists(prefile, NULL, NULL) > 0)
+ RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
+ if (ast_fileexists(prefile, NULL, NULL) > 0) {
ast_play_and_wait(chan, "vm-tempgreetactive");
+ }
+ DISPOSE(prefile, -1);
}
/* Play voicemail intro - syntax is different for different languages */
@@ -8097,9 +8098,11 @@
default:
cmd = 0;
snprintf(prefile, sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
+ RETRIEVE(prefile, -1, vmu->mailbox, vmu->context);
if (ast_fileexists(prefile, NULL, NULL)) {
cmd = ast_play_and_wait(chan, "vm-tmpexists");
}
+ DISPOSE(prefile, -1);
if (!cmd) {
cmd = ast_play_and_wait(chan, "vm-options");
}
Modified: team/oej/videocaps/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_dahdi.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_dahdi.c (original)
+++ team/oej/videocaps/channels/chan_dahdi.c Mon Oct 13 05:44:39 2008
@@ -11654,7 +11654,7 @@
int level = 0;
switch (cmd) {
case CLI_INIT:
- e->command = "pri set debug {<level>|on|off} span";
+ e->command = "pri set debug [on|off] span";
e->usage =
"Usage: pri set debug <level|on|off> span <span>\n"
" Enables debugging on a given PRI span\n";
Modified: team/oej/videocaps/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_h323.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_h323.c (original)
+++ team/oej/videocaps/channels/chan_h323.c Mon Oct 13 05:44:39 2008
@@ -2625,6 +2625,9 @@
if (!strcasecmp(a->argv[3], "off")) {
h323_debug(0, 0);
ast_cli(a->fd, "H.323 Trace Disabled\n");
+ } else if (!strcasecmp(a->argv[3], "on")) {
+ h323_debug(1, 1);
+ ast_cli(a->fd, "H.323 Trace Enabled\n");
} else {
int tracelevel = atoi(a->argv[3]);
h323_debug(1, tracelevel);
Modified: team/oej/videocaps/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_iax2.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_iax2.c (original)
+++ team/oej/videocaps/channels/chan_iax2.c Mon Oct 13 05:44:39 2008
@@ -6590,7 +6590,7 @@
memset(&ied, 0, sizeof(ied));
if (ies->apparent_addr)
- bcopy(ies->apparent_addr, &new, sizeof(new));
+ memmove(&new, ies->apparent_addr, sizeof(new));
if (ies->callno)
newcall = ies->callno;
if (!newcall || !new.sin_addr.s_addr || !new.sin_port) {
@@ -6728,7 +6728,7 @@
memset(&us, 0, sizeof(us));
if (ies->apparent_addr)
- bcopy(ies->apparent_addr, &us, sizeof(us));
+ memmove(&us, ies->apparent_addr, sizeof(us));
if (ies->username)
ast_copy_string(peer, ies->username, sizeof(peer));
if (ies->refresh)
Modified: team/oej/videocaps/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_misdn.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_misdn.c (original)
+++ team/oej/videocaps/channels/chan_misdn.c Mon Oct 13 05:44:39 2008
@@ -737,7 +737,7 @@
switch (cmd) {
case CLI_INIT:
- e->command = "misdn set debug {on|off|<level>}";
+ e->command = "misdn set debug [on|off]";
e->usage =
"Usage: misdn set debug {on|off|<level>} [only] | [port <port> [only]]\n"
" Set the debug level of the mISDN channel.\n";
Modified: team/oej/videocaps/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_oss.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_oss.c (original)
+++ team/oej/videocaps/channels/chan_oss.c Mon Oct 13 05:44:39 2008
@@ -701,7 +701,7 @@
/* XXX can be simplified returning &ast_null_frame */
/* prepare a NULL frame in case we don't have enough data to return */
- bzero(f, sizeof(struct ast_frame));
+ memset(f, '\0', sizeof(struct ast_frame));
f->frametype = AST_FRAME_NULL;
f->src = oss_tech.type;
Modified: team/oej/videocaps/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_sip.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_sip.c (original)
+++ team/oej/videocaps/channels/chan_sip.c Mon Oct 13 05:44:39 2008
@@ -223,6 +223,7 @@
#define DEFAULT_DEFAULT_EXPIRY 120
#define DEFAULT_MIN_EXPIRY 60
#define DEFAULT_MAX_EXPIRY 3600
+#define DEFAULT_MWI_EXPIRY 3600
#define DEFAULT_REGISTRATION_TIMEOUT 20
#define DEFAULT_MAX_FORWARDS "70"
@@ -242,6 +243,7 @@
static int min_expiry = DEFAULT_MIN_EXPIRY; /*!< Minimum accepted registration time */
static int max_expiry = DEFAULT_MAX_EXPIRY; /*!< Maximum accepted registration time */
static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
+static int mwi_expiry = DEFAULT_MWI_EXPIRY;
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -1405,6 +1407,8 @@
struct sip_st_dlg *stimer; /*!< SIP Session-Timers */
int red;
+
+ struct sip_subscription_mwi *mwi; /*!< If this is a subscription MWI dialog, to which subscription */
};
/*! Max entires in the history list for a sip_pvt */
@@ -1643,6 +1647,25 @@
AST_LIST_ENTRY(sip_threadinfo) list;
};
+/*! \brief Definition of an MWI subscription to another server */
+struct sip_subscription_mwi {
+ ASTOBJ_COMPONENTS_FULL(struct sip_subscription_mwi,1,1);
+ AST_DECLARE_STRING_FIELDS(
+ AST_STRING_FIELD(username); /*!< Who we are sending the subscription as */
+ AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */
+ AST_STRING_FIELD(hostname); /*!< Domain or host we subscribe to */
+ AST_STRING_FIELD(secret); /*!< Password in clear text */
+ AST_STRING_FIELD(mailbox); /*!< Mailbox store to put MWI into */
+ );
+ enum sip_transport transport; /*!< Transport to use */
+ int portno; /*!< Optional port override */
+ int resub; /*!< Sched ID of resubscription */
+ unsigned int subscribed:1; /*!< Whether we are currently subscribed or not */
+ struct sip_pvt *call; /*!< Outbound subscription dialog */
+ struct ast_dnsmgr_entry *dnsmgr; /*!< DNS refresh manager for subscription */
+ struct sockaddr_in us; /*!< Who the server thinks we are */
+};
+
/* --- Hash tables of various objects --------*/
#ifdef LOW_MEMORY
@@ -1667,6 +1690,11 @@
ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry);
int recheck;
} regl;
+
+/*! \brief The MWI subscription list */
+static struct ast_subscription_mwi_list {
+ ASTOBJ_CONTAINER_COMPONENTS(struct sip_subscription_mwi);
+} submwil;
/*! \brief
* \note The only member of the peer used here is the name field
@@ -2058,6 +2086,7 @@
static char *sip_show_registry(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *sip_unregister(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *sip_show_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *sip_show_mwi(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static const char *subscription_type2str(enum subscriptiontype subtype) attribute_pure;
static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
static char *complete_sip_peer(const char *word, int state, int flags2);
@@ -2215,6 +2244,7 @@
static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
static void handle_response_notify(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
static void handle_response_refer(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
+static void handle_response_subscribe(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
static int handle_response_register(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
@@ -2247,6 +2277,12 @@
static enum st_mode st_get_mode(struct sip_pvt *);
static struct sip_st_dlg* sip_st_alloc(struct sip_pvt *const p);
+/*!--- SIP MWI Subscription support */
+static int sip_subscribe_mwi(const char *value, int lineno);
+static void sip_subscribe_mwi_destroy(struct sip_subscription_mwi *mwi);
+static void sip_send_all_mwi_subscriptions(void);
+static int sip_subscribe_mwi_do(const void *data);
+static int __sip_subscribe_mwi_do(struct sip_subscription_mwi *mwi);
/*! \brief Definition of this channel for PBX channel registration */
static const struct ast_channel_tech sip_tech = {
@@ -4589,6 +4625,20 @@
}
+/*! \brief Destroy MWI subscription object */
+static void sip_subscribe_mwi_destroy(struct sip_subscription_mwi *mwi)
+{
+ if (mwi->call) {
+ mwi->call->mwi = NULL;
+ sip_destroy(mwi->call);
+ }
+
+ AST_SCHED_DEL(sched, mwi->resub);
+ ast_string_field_free_memory(mwi);
+ ast_dnsmgr_release(mwi->dnsmgr);
+ ast_free(mwi);
+}
+
/*! \brief Execute destruction of SIP dialog structure, release memory */
static void __sip_destroy(struct sip_pvt *p, int lockowner, int lockdialoglist)
{
@@ -4742,13 +4792,13 @@
/* incoming and outgoing affects the inUse counter */
case DEC_CALL_LIMIT:
/* Decrement inuse count if applicable */
- if (inuse && ast_test_flag(&fup->flags[0], SIP_INC_COUNT)) {
+ if (inuse && *inuse > 0 && ast_test_flag(&fup->flags[0], SIP_INC_COUNT)) {
ast_atomic_fetchadd_int(inuse, -1);
ast_clear_flag(&fup->flags[0], SIP_INC_COUNT);
} else
*inuse = 0;
/* Decrement ringing count if applicable */
- if (inringing && ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
+ if (inringing && *inringing > 0 && ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
ast_atomic_fetchadd_int(inringing, -1);
ast_clear_flag(&fup->flags[0], SIP_INC_RINGING);
}
@@ -4786,7 +4836,7 @@
break;
case DEC_CALL_RINGING:
- if (inringing && ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
+ if (inringing && *inringing > 0 && ast_test_flag(&fup->flags[0], SIP_INC_RINGING)) {
ast_atomic_fetchadd_int(inringing, -1);
ast_clear_flag(&fup->flags[0], SIP_INC_RINGING);
}
@@ -5847,9 +5897,9 @@
}
/*! \brief Reads one line of SIP message body */
-static char *get_body_by_line(const char *line, const char *name, int nameLen)
-{
- if (!strncasecmp(line, name, nameLen) && line[nameLen] == '=')
+static char *get_body_by_line(const char *line, const char *name, int nameLen, char delimiter)
+{
+ if (!strncasecmp(line, name, nameLen) && line[nameLen] == delimiter)
return ast_skip_blanks(line + nameLen + 1);
return "";
@@ -5864,7 +5914,7 @@
int len = strlen(name);
while (*start < req->sdp_end) {
- const char *r = get_body_by_line(req->line[(*start)++], name, len);
+ const char *r = get_body_by_line(req->line[(*start)++], name, len, '=');
if (r[0] != '\0')
return r;
}
@@ -5881,14 +5931,14 @@
}
/*! \brief Get a specific line from the message body */
-static char *get_body(struct sip_request *req, char *name)
+static char *get_body(struct sip_request *req, char *name, char delimiter)
{
int x;
int len = strlen(name);
char *r;
for (x = 0; x < req->lines; x++) {
- r = get_body_by_line(req->line[x], name, len);
+ r = get_body_by_line(req->line[x], name, len, delimiter);
if (r[0] != '\0')
return r;
}
@@ -6549,6 +6599,80 @@
reg->ocseq = INITIAL_CSEQ;
ASTOBJ_CONTAINER_LINK(®l, reg); /* Add the new registry entry to the list */
registry_unref(reg, "unref the reg pointer"); /* release the reference given by ASTOBJ_INIT. The container has another reference */
+ return 0;
+}
+
+/*! \brief Parse mwi=> line in sip.conf and add to list */
+static int sip_subscribe_mwi(const char *value, int lineno)
+{
+ struct sip_subscription_mwi *mwi;
+ int portnum = 0;
+ enum sip_transport transport = SIP_TRANSPORT_UDP;
+ char buf[256] = "";
+ char *username = NULL, *hostname = NULL, *secret = NULL, *authuser = NULL, *porta = NULL, *mailbox = NULL;
+
+ if (!value) {
+ return -1;
+ }
+
+ ast_copy_string(buf, value, sizeof(buf));
+
+ sip_parse_host(buf, lineno, &username, &portnum, &transport);
+
+ if ((hostname = strrchr(username, '@'))) {
+ *hostname++ = '\0';
+ }
+
+ if ((secret = strchr(username, ':'))) {
+ *secret++ = '\0';
+ if ((authuser = strchr(secret, ':'))) {
+ *authuser++ = '\0';
+ }
+ }
+
+ if ((mailbox = strchr(hostname, '/'))) {
+ *mailbox++ = '\0';
+ }
+
+ if (ast_strlen_zero(username) || ast_strlen_zero(hostname) || ast_strlen_zero(mailbox)) {
+ ast_log(LOG_WARNING, "Format for MWI subscription is user[:secret[:authuser]]@host[:port][/mailbox] at line %d\n", lineno);
+ return -1;
+ }
+
+ if ((porta = strchr(hostname, ':'))) {
+ *porta++ = '\0';
+ if (!(portnum = atoi(porta))) {
+ ast_log(LOG_WARNING, "%s is not a valid port number at line %d\n", porta, lineno);
+ return -1;
+ }
+ }
+
+ if (!(mwi = ast_calloc(1, sizeof(*mwi)))) {
+ return -1;
+ }
+
+ if (ast_string_field_init(mwi, 256)) {
+ ast_free(mwi);
+ return -1;
+ }
+
+ ASTOBJ_INIT(mwi);
+ ast_string_field_set(mwi, username, username);
+ if (secret) {
+ ast_string_field_set(mwi, secret, secret);
+ }
+ if (authuser) {
+ ast_string_field_set(mwi, authuser, authuser);
+ }
+ ast_string_field_set(mwi, hostname, hostname);
+ ast_string_field_set(mwi, mailbox, mailbox);
+ mwi->resub = -1;
+ mwi->portno = portnum;
+ mwi->transport = transport;
+
+ ASTOBJ_CONTAINER_LINK(&submwil, mwi);
+ ASTOBJ_UNREF(mwi, sip_subscribe_mwi_destroy);
+
return 0;
}
@@ -9741,7 +9865,7 @@
add_header(req, "Remote-Party-ID", p->rpid);
}
-/*! \brief Build REFER/INVITE/OPTIONS message and transmit it
+/*! \brief Build REFER/INVITE/OPTIONS/SUBSCRIBE message and transmit it
\param init 0 = Prepare request within dialog, 1= prepare request, new branch, 2= prepare new request and new dialog. do_proxy_auth calls this with init!=2
\param p sip_pvt structure
\param sdp unknown
@@ -9782,7 +9906,15 @@
} else if ((siptransfer = pbx_builtin_getvar_helper(p->owner, "SIPTRANSFER"))) {
if (!strcasecmp(siptransfer, "yes") && (transferred_by = pbx_builtin_getvar_helper(p->owner, "SIPTRANSFER_REFERER")))
add_header(&req, "Referred-By", transferred_by);
- }
+ } else if (sipmethod == SIP_SUBSCRIBE) { /* We only support sending MWI subscriptions right now */
+ char buf[SIPBUFSIZE];
+
+ add_header(&req, "Event", "message-summary");
+ add_header(&req, "Accept", "application/simple-message-summary");
+ snprintf(buf, sizeof(buf), "%d", mwi_expiry);
+ add_header(&req, "Expires", buf);
+ }
+
/* This new INVITE is part of an attended transfer. Make sure that the
other end knows and replace the current call with this new call */
if (p->options && !ast_strlen_zero(p->options->replaces)) {
@@ -9872,6 +10004,94 @@
initialize_initreq(p, &req);
p->lastinvite = p->ocseq;
return send_request(p, &req, init ? XMIT_CRITICAL : XMIT_RELIABLE, p->ocseq);
+}
+
+/*! \brief Send a subscription or resubscription for MWI */
+static int sip_subscribe_mwi_do(const void *data)
+{
+ struct sip_subscription_mwi *mwi = ASTOBJ_REF((struct sip_subscription_mwi *) data);
+
+ if (!mwi) {
+ return -1;
+ }
+
+ mwi->resub = -1;
+ __sip_subscribe_mwi_do(mwi);
+ ASTOBJ_UNREF(mwi, sip_subscribe_mwi_destroy);
+
+ return 0;
+}
+
+/*! \brief Actually setup an MWI subscription or resubscribe */
+static int __sip_subscribe_mwi_do(struct sip_subscription_mwi *mwi)
+{
+ /* If we have no DNS manager let's do a lookup */
+ if (!mwi->dnsmgr) {
+ char transport[MAXHOSTNAMELEN];
+ snprintf(transport, sizeof(transport), "_sip._%s", get_transport(mwi->transport));
+ ast_dnsmgr_lookup(mwi->hostname, &mwi->us, &mwi->dnsmgr, global_srvlookup ? transport : NULL);
+ }
+
+ /* If we already have a subscription up simply send a resubscription */
+ if (mwi->call) {
+ transmit_invite(mwi->call, SIP_SUBSCRIBE, 0, 0);
+ return 0;
+ }
+
+ /* Create a dialog that we will use for the subscription */
+ if (!(mwi->call = sip_alloc(NULL, NULL, 0, SIP_SUBSCRIBE))) {
+ return -1;
+ }
+
+ mwi->call->outboundproxy = obproxy_get(mwi->call, NULL);
+
+ if (!mwi->us.sin_port && mwi->portno) {
+ mwi->us.sin_port = htons(mwi->portno);
+ }
+
+ /* Setup the destination of our subscription */
+ if (create_addr(mwi->call, mwi->hostname, &mwi->us, 0)) {
+ dialog_unlink_all(mwi->call, TRUE, TRUE);
+ mwi->call = dialog_unref(mwi->call, "unref dialog after unlink_all");
+ return 0;
+ }
+
+ if (!mwi->dnsmgr && mwi->portno) {
+ mwi->call->sa.sin_port = htons(mwi->portno);
+ mwi->call->recv.sin_port = htons(mwi->portno);
+ } else {
+ mwi->portno = ntohs(mwi->call->sa.sin_port);
+ }
+
+ /* Set various other information */
+ if (!ast_strlen_zero(mwi->authuser)) {
+ ast_string_field_set(mwi->call, peername, mwi->authuser);
+ ast_string_field_set(mwi->call, authname, mwi->authuser);
+ ast_string_field_set(mwi->call, fromuser, mwi->authuser);
+ } else {
+ ast_string_field_set(mwi->call, peername, mwi->username);
+ ast_string_field_set(mwi->call, authname, mwi->username);
+ ast_string_field_set(mwi->call, fromuser, mwi->username);
+ }
+ ast_string_field_set(mwi->call, username, mwi->username);
+ if (!ast_strlen_zero(mwi->secret)) {
+ ast_string_field_set(mwi->call, peersecret, mwi->secret);
+ }
+ mwi->call->socket.type = mwi->transport;
+ mwi->call->socket.port = htons(mwi->portno);
+ ast_sip_ouraddrfor(&mwi->call->sa.sin_addr, &mwi->call->ourip);
+ build_contact(mwi->call);
+ build_via(mwi->call);
+ build_callid_pvt(mwi->call);
+ ast_set_flag(&mwi->call->flags[0], SIP_OUTGOING);
+
+ /* Associate the call with us */
+ mwi->call->mwi = ASTOBJ_REF(mwi);
+
+ /* Actually send the packet */
+ transmit_invite(mwi->call, SIP_SUBSCRIBE, 0, 2);
+
+ return 0;
}
/*! \brief Used in the SUBSCRIBE notification subsystem (RFC3265) */
@@ -12440,13 +12660,7 @@
/* For subscribes, match on device name only; for other methods,
* match on IP address-port of the incoming request.
*/
- /* First find device on name */
- peer = find_peer(of, NULL, TRUE, FALSE, FALSE);
-
- /* If not found, then find device on IP (if it's not a SUBSCRIBE) */
- if (!peer && sipmethod != SIP_SUBSCRIBE) {
- peer = find_peer(NULL, &p->recv, TRUE, FALSE, FALSE);
- }
+ peer = (sipmethod == SIP_SUBSCRIBE) ? find_peer(of, NULL, TRUE, FALSE, FALSE) : find_peer(NULL, &p->recv, TRUE, FALSE, FALSE);
if (!peer) {
if (debug)
@@ -14406,6 +14620,36 @@
return CLI_SUCCESS;
}
+static char *sip_show_mwi(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+#define FORMAT "%-30.30s %-12.12s %-10.10s %-10.10s\n"
+ char host[80];
+
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "sip show mwi";
+ e->usage =
+ "Usage: sip show mwi\n"
+ " Provides a list of MWI subscriptions and status.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ ast_cli(a->fd, FORMAT, "Host", "Username", "Mailbox", "Subscribed");
+
+ ASTOBJ_CONTAINER_TRAVERSE(&submwil, 1, do {
+ ASTOBJ_RDLOCK(iterator);
+ snprintf(host, sizeof(host), "%s:%d", iterator->hostname, iterator->portno ? iterator->portno : STANDARD_SIP_PORT);
+ ast_cli(a->fd, FORMAT, host, iterator->username, iterator->mailbox, iterator->subscribed ? "Yes" : "No");
+ ASTOBJ_UNLOCK(iterator);
+ } while(0));
+
+ return CLI_SUCCESS;
+#undef FORMAT
+}
+
+
/*! \brief Show subscription type in string format */
static const char *subscription_type2str(enum subscriptiontype subtype)
{
@@ -14886,7 +15130,7 @@
}
/* Try getting the "signal=" part */
- if (ast_strlen_zero(c = get_body(req, "Signal")) && ast_strlen_zero(c = get_body(req, "d"))) {
+ if (ast_strlen_zero(c = get_body(req, "Signal", '=')) && ast_strlen_zero(c = get_body(req, "d", '='))) {
ast_log(LOG_WARNING, "Unable to retrieve DTMF signal from INFO message from %s\n", p->callid);
transmit_response(p, "200 OK", req); /* Should return error */
return;
@@ -14894,7 +15138,7 @@
ast_copy_string(buf, c, sizeof(buf));
}
- if (!ast_strlen_zero((c = get_body(req, "Duration"))))
+ if (!ast_strlen_zero((c = get_body(req, "Duration", '='))))
duration = atoi(c);
if (!duration)
duration = 100; /* 100 ms */
@@ -16283,6 +16527,63 @@
}
}
+/* \brief Handle SIP response in SUBSCRIBE transaction */
+static void handle_response_subscribe(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
+{
+ if (!p->mwi) {
+ return;
+ }
+
+ switch (resp) {
+ case 200: /* Subscription accepted */
+ ast_debug(3, "Got 200 OK on subscription for MWI\n");
+ if (p->options) {
+ ast_free(p->options);
+ p->options = NULL;
+ }
+ p->mwi->subscribed = 1;
+ p->mwi->resub = ast_sched_add(sched, mwi_expiry * 1000, sip_subscribe_mwi_do, p->mwi);
+ break;
+ case 401:
+ case 407:
+ ast_string_field_set(p, theirtag, NULL);
+ if (p->authtries > 1 || do_proxy_auth(p, req, resp, SIP_SUBSCRIBE, 0)) {
+ ast_log(LOG_NOTICE, "Failed to authenticate on SUBSCRIBE to '%s'\n", get_header(&p->initreq, "From"));
+ p->mwi->call = NULL;
+ ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy);
+ p->needdestroy = 1;
+ }
+ break;
+ case 403:
+ transmit_response_with_date(p, "200 OK", req);
+ ast_log(LOG_WARNING, "Authentication failed while trying to subscribe for MWI.\n");
+ p->mwi->call = NULL;
+ ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy);
+ p->needdestroy = 1;
+ sip_alreadygone(p);
+ break;
+ case 404:
+ ast_log(LOG_WARNING, "Subscription failed for MWI. The remote side said that a mailbox may not have been configured.\n");
+ p->mwi->call = NULL;
+ ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy);
+ p->needdestroy = 1;
+ break;
+ case 481:
+ ast_log(LOG_WARNING, "Subscription failed for MWI. The remote side said that our dialog did not exist.\n");
+ p->mwi->call = NULL;
+ ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy);
+ p->needdestroy = 1;
+ break;
+ case 500:
+ case 501:
+ ast_log(LOG_WARNING, "Subscription failed for MWI. The remote side may have suffered a heart attack.\n");
+ p->mwi->call = NULL;
+ ASTOBJ_UNREF(p->mwi, sip_subscribe_mwi_destroy);
+ p->needdestroy = 1;
+ break;
+ }
+}
+
/* \brief Handle SIP response in REFER transaction
We've sent a REFER, now handle responses to it
*/
@@ -16631,13 +16932,14 @@
handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_NOTIFY) {
handle_response_notify(p, resp, rest, req, seqno);
- } else if (sipmethod == SIP_REGISTER)
+ } else if (sipmethod == SIP_REGISTER) {
res = handle_response_register(p, resp, rest, req, seqno);
- else if (sipmethod == SIP_BYE) { /* Ok, we're ready to go */
+ } else if (sipmethod == SIP_SUBSCRIBE) {
+ ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
+ handle_response_subscribe(p, resp, rest, req, seqno);
+ } else if (sipmethod == SIP_BYE) { /* Ok, we're ready to go */
p->needdestroy = 1;
ast_clear_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
- } else if (sipmethod == SIP_SUBSCRIBE) {
- ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
}
break;
case 202: /* Transfer accepted */
@@ -16652,6 +16954,8 @@
handle_response_notify(p, resp, rest, req, seqno);
else if (sipmethod == SIP_REFER)
handle_response_refer(p, resp, rest, req, seqno);
+ else if (sipmethod == SIP_SUBSCRIBE)
+ handle_response_subscribe(p, resp, rest, req, seqno);
else if (p->registry && sipmethod == SIP_REGISTER)
res = handle_response_register(p, resp, rest, req, seqno);
else if (sipmethod == SIP_BYE) {
@@ -16673,6 +16977,8 @@
case 403: /* Forbidden - we failed authentication */
if (sipmethod == SIP_INVITE)
handle_response_invite(p, resp, rest, req, seqno);
+ else if (sipmethod == SIP_SUBSCRIBE)
+ handle_response_subscribe(p, resp, rest, req, seqno);
else if (p->registry && sipmethod == SIP_REGISTER)
res = handle_response_register(p, resp, rest, req, seqno);
else {
@@ -16685,6 +16991,8 @@
res = handle_response_register(p, resp, rest, req, seqno);
else if (sipmethod == SIP_INVITE)
handle_response_invite(p, resp, rest, req, seqno);
+ else if (sipmethod == SIP_SUBSCRIBE)
+ handle_response_subscribe(p, resp, rest, req, seqno);
else if (owner)
ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
break;
@@ -16718,6 +17026,8 @@
handle_response_invite(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_REFER) {
handle_response_refer(p, resp, rest, req, seqno);
+ } else if (sipmethod == SIP_SUBSCRIBE) {
+ handle_response_subscribe(p, resp, rest, req, seqno);
} else if (sipmethod == SIP_BYE) {
/* The other side has no transaction to bye,
just assume it's all right then */
@@ -16801,6 +17111,9 @@
case 500: /* Server error */
if (sipmethod == SIP_REFER) {
handle_response_refer(p, resp, rest, req, seqno);
+ break;
+ } else if (sipmethod == SIP_SUBSCRIBE) {
+ handle_response_subscribe(p, resp, rest, req, seqno);
break;
}
/* Fall through */
@@ -17250,12 +17563,7 @@
if (sipdebug)
ast_debug(2, "Got NOTIFY Event: %s\n", event);
- if (strcmp(event, "refer")) {
- /* We don't understand this event. */
- /* Here's room to implement incoming voicemail notifications :-) */
- transmit_response(p, "489 Bad event", req);
- res = -1;
- } else {
+ if (!strcmp(event, "refer")) {
/* Save nesting depth for now, since there might be other events we will
support in the future */
@@ -17355,7 +17663,33 @@
/* Confirm that we received this packet */
transmit_response(p, "200 OK", req);
- };
+ } else if (p->mwi && !strcmp(event, "message-summary")) {
+ char *c = ast_strdupa(get_body(req, "Voice-Message", ':'));
+
+ if (!ast_strlen_zero(c)) {
+ char *old = strsep(&c, " ");
+ char *new = strsep(&old, "/");
+ struct ast_event *event;
+
+ if ((event = ast_event_new(AST_EVENT_MWI,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, p->mwi->mailbox,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, "SIP_Remote",
+ AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(new),
+ AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, atoi(old),
+ AST_EVENT_IE_END))) {
+ ast_event_queue_and_cache(event,
+ AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR,
+ AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR,
+ AST_EVENT_IE_END);
+ }
+ }
+
+ transmit_response(p, "200 OK", req);
+ } else {
+ /* We don't understand this event. */
+ transmit_response(p, "489 Bad event", req);
+ res = -1;
+ }
if (!p->lastinvite)
sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
@@ -22443,6 +22777,10 @@
default_expiry = atoi(v->value);
if (default_expiry < 1)
default_expiry = DEFAULT_DEFAULT_EXPIRY;
+ } else if (!strcasecmp(v->name, "mwiexpiry") || !strcasecmp(v->name, "mwiexpirey")) {
+ mwi_expiry = atoi(v->value);
+ if (mwi_expiry < 1)
+ mwi_expiry = DEFAULT_MWI_EXPIRY;
} else if (!strcasecmp(v->name, "sipdebug")) {
if (ast_true(v->value))
sipdebug |= sip_debug_config;
@@ -22523,6 +22861,8 @@
} else if (!strcasecmp(v->name, "register")) {
if (sip_register(v->value, v->lineno) == 0)
registry_count++;
+ } else if (!strcasecmp(v->name, "mwi")) {
+ sip_subscribe_mwi(v->value, v->lineno);
} else if (!strcasecmp(v->name, "tos_sip")) {
if (ast_str2tos(v->value, &global_tos_sip))
ast_log(LOG_WARNING, "Invalid tos_sip value at line %d, refer to QoS documentation\n", v->lineno);
@@ -23370,6 +23710,17 @@
);
}
+/*! \brief Send all MWI subscriptions */
+static void sip_send_all_mwi_subscriptions(void)
+{
+ ASTOBJ_CONTAINER_TRAVERSE(&submwil, 1, do {
+ ASTOBJ_WRLOCK(iterator);
+ AST_SCHED_DEL(sched, iterator->resub);
+ iterator->resub = ast_sched_add(sched, 1, sip_subscribe_mwi_do, iterator);
+ ASTOBJ_UNLOCK(iterator);
+ } while (0));
+}
+
/*! \brief Reload module */
static int sip_do_reload(enum channelreloadreason reason)
{
@@ -23389,6 +23740,9 @@
/* Register with all services */
sip_send_all_registers();
+
+ sip_send_all_mwi_subscriptions();
+
end_poke = time(0);
ast_debug(4, "do_reload finished. peer poke/prune reg contact time = %d sec.\n", (int)(end_poke-start_poke));
@@ -23446,6 +23800,7 @@
AST_CLI_DEFINE(sip_show_registry, "List SIP registration status"),
AST_CLI_DEFINE(sip_unregister, "Unregister (force expiration) a SIP peer from the registry"),
AST_CLI_DEFINE(sip_show_settings, "Show SIP global settings"),
+ AST_CLI_DEFINE(sip_show_mwi, "Show MWI subscriptions"),
AST_CLI_DEFINE(sip_cli_notify, "Send a notify packet to a SIP peer"),
AST_CLI_DEFINE(sip_show_channel, "Show detailed SIP channel info"),
AST_CLI_DEFINE(sip_show_history, "Show SIP dialog history"),
@@ -23470,6 +23825,7 @@
dialogs = ao2_t_container_alloc(hash_dialog_size, dialog_hash_cb, dialog_cmp_cb, "allocate dialogs");
ASTOBJ_CONTAINER_INIT(®l); /* Registry object list -- not searched for anything */
+ ASTOBJ_CONTAINER_INIT(&submwil); /* MWI subscription object list */
if (!(sched = sched_context_create())) {
ast_log(LOG_ERROR, "Unable to create scheduler context\n");
@@ -23534,7 +23890,8 @@
"Send a SIP notify", mandescr_sipnotify);
sip_poke_all_peers();
sip_send_all_registers();
-
+ sip_send_all_mwi_subscriptions();
+
/* And start the monitor for the first time */
restart_monitor();
@@ -23651,6 +24008,8 @@
ASTOBJ_CONTAINER_DESTROYALL(®l, sip_registry_destroy);
ASTOBJ_CONTAINER_DESTROY(®l);
+ ASTOBJ_CONTAINER_DESTROYALL(&submwil, sip_subscribe_mwi_destroy);
+ ASTOBJ_CONTAINER_DESTROY(&submwil);
ao2_t_ref(peers, -1, "unref the peers table");
ao2_t_ref(peers_by_ip, -1, "unref the peers_by_ip table");
Modified: team/oej/videocaps/channels/chan_usbradio.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/chan_usbradio.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/chan_usbradio.c (original)
+++ team/oej/videocaps/channels/chan_usbradio.c Mon Oct 13 05:44:39 2008
@@ -1411,7 +1411,7 @@
l = FRAME_SIZE - ofs;
if (l > s->datalen - start) /* don't overflow the source */
l = s->datalen - start;
- bcopy(s->data + start, myframe + ofs, l * 2);
+ memmove(myframe + ofs, s->data + start, l * 2);
if (0)
ast_log(LOG_WARNING, "send_sound sound %d/%d of %d into %d\n", l_sampsent, l, s->samplen, ofs);
l_sampsent += l;
@@ -1422,14 +1422,14 @@
if (l > 0) {
if (l > FRAME_SIZE - ofs)
l = FRAME_SIZE - ofs;
- bcopy(silence, myframe + ofs, l * 2);
+ memmove(myframe + ofs, silence, l * 2);
l_sampsent += l;
} else { /* silence is over, restart sound if loop */
if (s->repeat == 0) { /* last block */
o->cursound = -1;
o->nosound = 0; /* allow audio data */
if (ofs < FRAME_SIZE) /* pad with silence */
- bcopy(silence, myframe + ofs, (FRAME_SIZE - ofs) * 2);
+ memmove(myframe + ofs, silence, (FRAME_SIZE - ofs) * 2);
}
l_sampsent = 0;
}
@@ -1813,7 +1813,7 @@
}
/* XXX can be simplified returning &ast_null_frame */
/* prepare a NULL frame in case we don't have enough data to return */
- bzero(f, sizeof(struct ast_frame));
+ memset(f, '\0', sizeof(struct ast_frame));
f->frametype = AST_FRAME_NULL;
f->src = usbradio_tech.type;
Modified: team/oej/videocaps/channels/console_gui.c
URL: http://svn.digium.com/view/asterisk/team/oej/videocaps/channels/console_gui.c?view=diff&rev=148466&r1=148465&r2=148466
==============================================================================
--- team/oej/videocaps/channels/console_gui.c (original)
+++ team/oej/videocaps/channels/console_gui.c Mon Oct 13 05:44:39 2008
@@ -204,7 +204,7 @@
if (gui->win[i].bmp)
SDL_FreeYUVOverlay(gui->win[i].bmp);
}
- bzero(gui, sizeof(gui));
+ memset(gui, '\0', sizeof(gui));
/* deallocates the space allocated for the keypad message boards */
if (gui->bd_dialed)
@@ -290,7 +290,7 @@
bmp = gui->win[out].bmp;
SDL_LockYUVOverlay(bmp);
/* output picture info - this is sdl, YUV420P */
- bzero(&p_out, sizeof(p_out));
[... 788 lines stripped ...]
More information about the asterisk-commits
mailing list