[asterisk-commits] seanbright: branch seanbright/resolve-shadow-warnings r114685 - in /team/sean...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Apr 25 22:52:58 CDT 2008
Author: seanbright
Date: Fri Apr 25 22:52:54 2008
New Revision: 114685
URL: http://svn.digium.com/view/asterisk?view=rev&rev=114685
Log:
Merged revisions 114674,114676,114678,114683 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r114674 | russell | 2008-04-25 18:00:35 -0400 (Fri, 25 Apr 2008) | 11 lines
Merged revisions 114673 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r114673 | russell | 2008-04-25 16:54:40 -0500 (Fri, 25 Apr 2008) | 3 lines
Use consistent logic for checking to see if a call number has been chosen yet.
Also, remove some redundant logic I recently added in a fix.
........
................
r114676 | russell | 2008-04-25 18:04:46 -0400 (Fri, 25 Apr 2008) | 7 lines
Lock the channel around datastore access
(closes issue #12527)
Reported by: mnicholson
Patches:
pbx_lua4.diff uploaded by mnicholson (license 96)
................
r114678 | mmichelson | 2008-04-25 18:24:32 -0400 (Fri, 25 Apr 2008) | 11 lines
Adding a new option, 'B' to app_chanspy. This option allows the spy to
barge on the call. It is like the existing whisper option, except that
it allows the spy to talk to both sides of the conversation on which
he is spying.
This feature has existed in Switchvox, and this merges the functionality
into Asterisk.
(AST-32)
................
r114683 | tilghman | 2008-04-25 22:48:56 -0400 (Fri, 25 Apr 2008) | 8 lines
Add 'sip qualify peer <peer>' command (with AMI SIPqualifypeer)
(closes issue #12524)
Reported by: ctooley
Patches:
sip_qualify_peer.diff.2 uploaded by ctooley (license 136)
some modifications for trunk by Corydon76
Tested by: Corydon76
................
Modified:
team/seanbright/resolve-shadow-warnings/ (props changed)
team/seanbright/resolve-shadow-warnings/CHANGES
team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c
team/seanbright/resolve-shadow-warnings/channels/chan_iax2.c
team/seanbright/resolve-shadow-warnings/channels/chan_sip.c
team/seanbright/resolve-shadow-warnings/pbx/pbx_lua.c
Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Apr 25 22:52:54 2008
@@ -1,1 +1,1 @@
-/trunk:1-114668
+/trunk:1-114684
Modified: team/seanbright/resolve-shadow-warnings/CHANGES
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/CHANGES?view=diff&rev=114685&r1=114684&r2=114685
==============================================================================
--- team/seanbright/resolve-shadow-warnings/CHANGES (original)
+++ team/seanbright/resolve-shadow-warnings/CHANGES Fri Apr 25 22:52:54 2008
@@ -33,6 +33,9 @@
* ChanSpy and ExtenSpy have a new option, 's' which suppresses speaking the
technology name (e.g. SIP, IAX, etc) of the channel being spied on.
* The Jack application now has a c() option to supply a custom client name.
+ * Chanspy has a new option, 'B', which can be used to "barge" on a call. This is
+ like the pre-existing whisper mode, except that the spy can also talk to the
+ participant on the bridged channel as well.
SIP Changes
-----------
Modified: team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c?view=diff&rev=114685&r1=114684&r2=114685
==============================================================================
--- team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c (original)
+++ team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c Fri Apr 25 22:52:54 2008
@@ -148,6 +148,7 @@
OPTION_EXIT = (1 << 8), /* Exit to a valid single digit extension */
OPTION_ENFORCED = (1 << 9), /* Enforced mode */
OPTION_NOTECH = (1 << 10), /* Skip technology name playback */
+ OPTION_BARGE = (1 << 11), /* Barge mode (whisper to both channels) */
} chanspy_opt_flags;
enum {
@@ -161,6 +162,7 @@
AST_APP_OPTIONS(spy_opts, {
AST_APP_OPTION('q', OPTION_QUIET),
AST_APP_OPTION('b', OPTION_BRIDGED),
+ AST_APP_OPTION('B', OPTION_BARGE),
AST_APP_OPTION('w', OPTION_WHISPER),
AST_APP_OPTION('W', OPTION_PRIVATE),
AST_APP_OPTION_ARG('v', OPTION_VOLUME, OPT_ARG_VOLUME),
@@ -177,6 +179,7 @@
/* spy data */
struct ast_audiohook spy_audiohook;
struct ast_audiohook whisper_audiohook;
+ struct ast_audiohook bridge_whisper_audiohook;
int fd;
int volfactor;
};
@@ -230,7 +233,7 @@
.generate = spy_generate,
};
-static int start_spying(struct ast_channel *chan, const char *spychan_name, struct ast_audiohook *audiohook)
+static int start_spying(struct ast_channel *chan, const char *spychan_name, struct ast_audiohook *audiohook)
{
int res = 0;
struct ast_channel *peer = NULL;
@@ -296,10 +299,15 @@
return 0;
}
- if (ast_test_flag(flags, OPTION_WHISPER)) {
+ if (ast_test_flag(flags, OPTION_BARGE)) {
+ ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
+ ast_audiohook_init(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "Chanspy");
+ start_spying(spyee, spyer_name, &csth.whisper_audiohook); /* Unlocks spyee */
+ start_spying(ast_bridged_channel(spyee), spyer_name, &csth.bridge_whisper_audiohook);
+ } else if (ast_test_flag(flags, OPTION_WHISPER)) {
ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
- start_spying(spyee, spyer_name, &csth.whisper_audiohook);
- }
+ start_spying(spyee, spyer_name, &csth.whisper_audiohook); /* Unlocks spyee */
+ }
ast_channel_unlock(spyee);
spyee = NULL;
@@ -338,7 +346,16 @@
break;
}
- if (ast_test_flag(flags, OPTION_WHISPER) && f->frametype == AST_FRAME_VOICE) {
+ if (ast_test_flag(flags, OPTION_BARGE) && f->frametype == AST_FRAME_VOICE) {
+ ast_audiohook_lock(&csth.whisper_audiohook);
+ ast_audiohook_lock(&csth.bridge_whisper_audiohook);
+ ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
+ ast_audiohook_write_frame(&csth.bridge_whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
+ ast_audiohook_unlock(&csth.whisper_audiohook);
+ ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
+ ast_frfree(f);
+ continue;
+ } else if (ast_test_flag(flags, OPTION_WHISPER) && f->frametype == AST_FRAME_VOICE) {
ast_audiohook_lock(&csth.whisper_audiohook);
ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
ast_audiohook_unlock(&csth.whisper_audiohook);
@@ -400,7 +417,16 @@
else
ast_deactivate_generator(chan);
- if (ast_test_flag(flags, OPTION_WHISPER)) {
+ if (ast_test_flag(flags, OPTION_BARGE)) {
+ ast_audiohook_lock(&csth.whisper_audiohook);
+ ast_audiohook_detach(&csth.whisper_audiohook);
+ ast_audiohook_unlock(&csth.whisper_audiohook);
+ ast_audiohook_destroy(&csth.whisper_audiohook);
+ ast_audiohook_lock(&csth.bridge_whisper_audiohook);
+ ast_audiohook_detach(&csth.bridge_whisper_audiohook);
+ ast_audiohook_unlock(&csth.bridge_whisper_audiohook);
+ ast_audiohook_destroy(&csth.bridge_whisper_audiohook);
+ } else if (ast_test_flag(flags, OPTION_WHISPER)) {
ast_audiohook_lock(&csth.whisper_audiohook);
ast_audiohook_detach(&csth.whisper_audiohook);
ast_audiohook_unlock(&csth.whisper_audiohook);
Modified: team/seanbright/resolve-shadow-warnings/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/chan_iax2.c?view=diff&rev=114685&r1=114684&r2=114685
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/chan_iax2.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/chan_iax2.c Fri Apr 25 22:52:54 2008
@@ -1501,7 +1501,7 @@
char host[80];
if (new <= NEW_ALLOW) {
- for (x=1;(res < 1) && (x<maxnontrunkcall);x++) {
+ for (x = 1; !res && x < maxnontrunkcall; x++) {
ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
@@ -1509,10 +1509,10 @@
res = x;
}
}
- if (!res || (res && !return_locked))
+ if (!res || !return_locked)
ast_mutex_unlock(&iaxsl[x]);
}
- for (x=TRUNK_CALL_START;(res < 1) && (x<maxtrunkcall);x++) {
+ for (x = TRUNK_CALL_START; !res && x < maxtrunkcall; x++) {
ast_mutex_lock(&iaxsl[x]);
if (iaxs[x]) {
/* Look for an exact match */
@@ -1520,11 +1520,11 @@
res = x;
}
}
- if (!res || (res && !return_locked))
+ if (!res || !return_locked)
ast_mutex_unlock(&iaxsl[x]);
}
}
- if ((res < 1) && (new >= NEW_ALLOW)) {
+ if (!res && (new >= NEW_ALLOW)) {
int start, found = 0;
/* It may seem odd that we look through the peer list for a name for
Modified: team/seanbright/resolve-shadow-warnings/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/channels/chan_sip.c?view=diff&rev=114685&r1=114684&r2=114685
==============================================================================
--- team/seanbright/resolve-shadow-warnings/channels/chan_sip.c (original)
+++ team/seanbright/resolve-shadow-warnings/channels/chan_sip.c Fri Apr 25 22:52:54 2008
@@ -1944,7 +1944,7 @@
static int cb_extensionstate(char *context, char* exten, int state, void *data);
static int sip_devicestate(void *data);
static int sip_poke_noanswer(const void *data);
-static int sip_poke_peer(struct sip_peer *peer);
+static int sip_poke_peer(struct sip_peer *peer, int force);
static void sip_poke_all_peers(void);
static void sip_peer_hold(struct sip_pvt *p, int hold);
static void mwi_event_cb(const struct ast_event *, void *);
@@ -1973,6 +1973,8 @@
static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[]);
static char *sip_show_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
static char *sip_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
+static char *_sip_qualify_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[]);
+static char *sip_qualify_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
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);
@@ -2024,7 +2026,6 @@
static void sip_destroy_peer_fn(void *peer);
static void sip_destroy_user(struct sip_user *user);
static void sip_destroy_user_fn(void *user);
-static int sip_poke_peer(struct sip_peer *peer);
static void set_peer_defaults(struct sip_peer *peer);
static struct sip_peer *temp_peer(const char *name);
static void register_peer_exten(struct sip_peer *peer, int onoff);
@@ -9977,7 +9978,7 @@
struct sip_peer *peer = (struct sip_peer *)data;
peer->pokeexpire = -1;
- sip_poke_peer(peer);
+ sip_poke_peer(peer, 0);
return 0;
}
@@ -10030,8 +10031,9 @@
if (sipsock < 0) {
/* SIP isn't up yet, so schedule a poke only, pretty soon */
AST_SCHED_REPLACE(peer->pokeexpire, sched, ast_random() % 5000 + 1, sip_poke_peer_s, peer);
- } else
- sip_poke_peer(peer);
+ } else {
+ sip_poke_peer(peer, 0);
+ }
AST_SCHED_REPLACE(peer->expire, sched, (expire + 10) * 1000, expire_register, peer);
register_peer_exten(peer, TRUE);
}
@@ -10236,7 +10238,7 @@
/* Is this a new IP address for us? */
if (inaddrcmp(&peer->addr, &oldsin)) {
- sip_poke_peer(peer);
+ sip_poke_peer(peer, 0);
ast_verb(3, "Registered SIP '%s' at %s port %d expires %d\n", peer->name, ast_inet_ntoa(peer->addr.sin_addr), ntohs(peer->addr.sin_port), expire);
register_peer_exten(peer, TRUE);
}
@@ -13314,6 +13316,64 @@
return complete_sip_show_peer(a->line, a->word, a->pos, a->n);
}
return _sip_show_peer(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
+}
+
+/*! \brief Show one peer in detail (main function) */
+static char *_sip_qualify_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
+{
+ struct sip_peer *peer;
+ int load_realtime;
+
+ if (argc < 4)
+ return CLI_SHOWUSAGE;
+
+ load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE;
+ if ((peer = find_peer(argv[3], NULL, load_realtime))) {
+ sip_poke_peer(peer, 1);
+ } else if (type == 0) {
+ ast_cli(fd, "Peer '%s' not found\n", argv[3]);
+ } else {
+ astman_send_error(s, m, "Peer not found\n");
+ }
+ return CLI_SUCCESS;
+}
+
+/*! \brief Qualify SIP peers in the manager API */
+static int manager_sip_qualify_peer(struct mansession *s, const struct message *m)
+{
+ const char *a[4];
+ const char *peer;
+
+ peer = astman_get_header(m, "Peer");
+ if (ast_strlen_zero(peer)) {
+ astman_send_error(s, m, "Peer: <name> missing.\n");
+ return 0;
+ }
+ a[0] = "sip";
+ a[1] = "qualify";
+ a[2] = "peer";
+ a[3] = peer;
+
+ _sip_qualify_peer(1, -1, s, m, 4, a);
+ astman_append(s, "\r\n\r\n" );
+ return 0;
+}
+
+/*! \brief Send an OPTIONS packet to a SIP peer */
+static char *sip_qualify_peer(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "sip qualify peer";
+ e->usage =
+ "Usage: sip qualify peer <name> [load]\n"
+ " Requests a response from one SIP peer and the current status.\n"
+ " Option \"load\" forces lookup of peer in realtime storage.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return complete_sip_show_peer(a->line, a->word, a->pos, a->n);
+ }
+ return _sip_qualify_peer(0, a->fd, NULL, NULL, a->argc, (const char **) a->argv);
}
/*! \brief list peer mailboxes to CLI */
@@ -13605,7 +13665,6 @@
return CLI_SUCCESS;
}
-
/*! \brief Show one user in detail */
static char *sip_show_user(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
@@ -14169,8 +14228,9 @@
/*! \brief Support routine for 'sip show peer' CLI */
static char *complete_sip_show_peer(const char *line, const char *word, int pos, int state)
{
- if (pos == 3)
+ if (pos == 3) {
return complete_sip_peer(word, state, 0);
+ }
return NULL;
}
@@ -19865,12 +19925,12 @@
/*! \brief Check availability of peer, also keep NAT open
\note This is done with the interval in qualify= configuration option
Default is 2 seconds */
-static int sip_poke_peer(struct sip_peer *peer)
+static int sip_poke_peer(struct sip_peer *peer, int force)
{
struct sip_pvt *p;
int xmitres = 0;
- if (!peer->maxms || !peer->addr.sin_addr.s_addr) {
+ if ((!peer->maxms && !force) || !peer->addr.sin_addr.s_addr) {
/* IF we have no IP, or this isn't to be monitored, return
immediately after clearing things out */
AST_SCHED_DEL(sched, peer->pokeexpire);
@@ -19926,9 +19986,9 @@
xmitres = transmit_invite(p, SIP_OPTIONS, 0, 2); /* sinks the p refcount */
#endif
peer->ps = ast_tvnow();
- if (xmitres == XMIT_ERROR)
+ if (xmitres == XMIT_ERROR) {
sip_poke_noanswer(peer); /* Immediately unreachable, network problems */
- else {
+ } else if (!force) {
AST_SCHED_REPLACE(peer->pokeexpire, sched,
peer->maxms * 2, sip_poke_noanswer, peer);
}
@@ -22476,6 +22536,7 @@
AST_CLI_DEFINE(sip_show_channel, "Show detailed SIP channel info"),
AST_CLI_DEFINE(sip_show_history, "Show SIP dialog history"),
AST_CLI_DEFINE(sip_show_peer, "Show details on specific SIP peer"),
+ AST_CLI_DEFINE(sip_qualify_peer, "Send an OPTIONS packet to a peer"),
AST_CLI_DEFINE(sip_show_users, "List defined SIP users"),
AST_CLI_DEFINE(sip_show_user, "Show details on specific SIP user"),
AST_CLI_DEFINE(sip_show_sched, "Present a report on the status of the sched queue"),
@@ -22554,6 +22615,8 @@
"List SIP peers (text format)", mandescr_show_peers);
ast_manager_register2("SIPshowpeer", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_show_peer,
"Show SIP peer (text format)", mandescr_show_peer);
+ ast_manager_register2("SIPqualifypeer", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_sip_qualify_peer,
+ "Show SIP peer (text format)", mandescr_show_peer);
ast_manager_register2("SIPshowregistry", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_show_registry,
"Show SIP registrations (text format)", mandescr_show_registry);
sip_poke_all_peers();
@@ -22600,6 +22663,7 @@
/* Unregister AMI actions */
ast_manager_unregister("SIPpeers");
ast_manager_unregister("SIPshowpeer");
+ ast_manager_unregister("SIPqualifypeer");
ast_manager_unregister("SIPshowregistry");
/* Kill TCP/TLS server threads */
Modified: team/seanbright/resolve-shadow-warnings/pbx/pbx_lua.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/pbx/pbx_lua.c?view=diff&rev=114685&r1=114684&r2=114685
==============================================================================
--- team/seanbright/resolve-shadow-warnings/pbx/pbx_lua.c (original)
+++ team/seanbright/resolve-shadow-warnings/pbx/pbx_lua.c Fri Apr 25 22:52:54 2008
@@ -982,7 +982,9 @@
}
return L;
} else {
+ ast_channel_lock(chan);
datastore = ast_channel_datastore_find(chan, &lua_datastore, NULL);
+ ast_channel_unlock(chan);
if (!datastore) {
/* nothing found, allocate a new lua state */
More information about the asterisk-commits
mailing list