SIPCallPickup()
Version comments
- This is not in ANY version of Asterisk. See notes for more info.
- Patch below developed for Asterisk 1.0.7 with SIPGetHeader patch. (See bug 2838 for patch.)
- Stability: UNKNOWN Not recommended for a production environment.
- Developed by: flobi
- Nearly the same functionality is now available as patch for app_directed_pickup in 1.2 and 1.4: via Digium Bugtracker here: Issue #10404
Synopsis
Intercept a call ringing on a phone in the same callgroup as the current channel.
Description
SIPCallPickup([pickupgroup])
This is an unofficial and barely tested patch to intercept incoming calls from the dialplan instead of the built-in interception that normally occurs before the dialplan is reached in the call flow.
Parameters:
Optional parameter pickupgroup specifies the group to check for an incoming call that should be picked up. If this is omitted, the group specified in sip.conf will be used.
Return codes
Always returns 0.
Notes
- You might want to change the pickupexten in the features.conf file if you plan on continuing to use *8 for call pickups.
Install:
In any text editor, open the chan_sip.c insert as follows. With the text below, search for the lines indicated by the label “FIND:” and insert the lines labled “INSERT:” directly below them.
INSERT: static char *app_sipcallpickup = “SIPCallPickup”;
INSERT:static char *synopsis_sipcallpickup = “Pickup a ringing SIP phone in pickup group.”;
” SIPGetHeader(var=headername): \n”
“Sets a channel variable to the content of a SIP header\n”
“Skips to priority+101 if header does not exist\n”
“Otherwise returns 0\n”;
INSERT: static char *descrip_sipcallpickup = “”
” SIPCallPickup(): \n”
“Pick up a ringing call in the pickup group.\n”
“Skips to priority+101 if call does not exist\n”
“Otherwise returns 0\n”;
FIND: static int sip_getheader(struct ast_channel *chan, void *data)
{
struct sip_pvt *p;
char *argv, *varname = (char *) NULL, *header = (char *) NULL, *content;
… truncated …
ast_mutex_unlock(&chan->lock);
return 0;
}
INSERT: static int sip_callpickup(struct ast_channel *chan, void *data)
{
struct sip_pvt *p;
unsigned int pickupgroup, tmpgroup;
tmpgroup = 0;
pickupgroup = 0;
if (data) {
pickupgroup = ast_get_group(data);
}
if (pickupgroup) {
tmpgroup = chan->pickupgroup;
chan->pickupgroup = pickupgroup;
}
ast_mutex_lock(&chan->lock);
if (chan->type != type) {
ast_log(LOG_WARNING, “Call this application only on incoming SIP calls\n”);
ast_mutex_unlock(&chan->lock);
return 0;
}
p = chan->pvt->pvt;
ast_mutex_unlock(&chan->lock);
if (ast_pickup_call(chan)) {
ast_log(LOG_NOTICE, “Nothing to pick up\n”);
p->alreadygone = 1;
if (tmpgroup) {
pickupgroup = chan->pickupgroup;
chan->pickupgroup = tmpgroup;
}
return -1;
}
if (tmpgroup) {
pickupgroup = chan->pickupgroup;
chan->pickupgroup = tmpgroup;
}
ast_mutex_unlock(&chan->lock);
return 0;
}
INSERT: ast_register_application(app_sipcallpickup, sip_callpickup, synopsis_sipcallpickup, descrip_sipcallpickup);
INSERT: ast_unregister_application(app_sipcallpickup);
After inserting all this into your chan_sip.c file in the channels folder, you are going to have to recompile it. This is easily enough done by deleting the chan_sip.o and chan_sip.so files then execute
make
make install
from the root source directory (/path/to/asterisk-1.0.7/). You are, of course, going to have to restart Asterisk to enable this.
CVS Version
Patched by Alessandro Viganà ²- Movinfo
There are some changes to do to make it working with cvs version:
FIND: static int sip_getheader(struct ast_channel *chan, void *data)
{
struct sip_pvt *p;
char *argv, *varname = (char *) NULL, *header = (char *) NULL, *content;
… truncated …
ast_mutex_unlock(&chan->lock);
return 0;
}
INSERT: static int sip_callpickup(struct ast_channel *chan, void *data)
struct sip_pvt *p;
unsigned int pickupgroup, tmpgroup;
tmpgroup = 0;
pickupgroup = 0;
if (data) {
pickupgroup = ast_get_group(data);
}
if (pickupgroup) {
tmpgroup = chan->pickupgroup;
chan->pickupgroup = pickupgroup;
}
ast_mutex_lock(&chan->lock);
if (chan->type != channeltype) {
ast_log(LOG_WARNING, “Call this application only on incoming SIP calls\n”);
ast_mutex_unlock(&chan->lock);
return 0;
}
p = chan->tech_pvt;
ast_mutex_unlock(&chan->lock);
if (ast_pickup_call(chan)) {
ast_log(LOG_NOTICE, “Nothing to pick up\n”);
ast_set_flag(p, SIP_ALREADYGONE);
if (tmpgroup) {
pickupgroup = chan->pickupgroup;
chan->pickupgroup = tmpgroup;
}
return -1;
}
if (tmpgroup) {
pickupgroup = chan->pickupgroup;
chan->pickupgroup = tmpgroup;
}
ast_mutex_unlock(&chan->lock);
return 0;
}
See also
- Asterisk callgroups and pickupgroups
- PickUp from bristuff
Asterisk | Configuration | The Dialplan – extensions.conf | Dialplan Commands