mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Handle call forward on SIP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@715 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -39,21 +39,18 @@ static MYSQL *mysql;
|
|||||||
static int mysql_log(struct ast_cdr *cdr)
|
static int mysql_log(struct ast_cdr *cdr)
|
||||||
{
|
{
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
struct timeval *tv;
|
struct timeval tv;
|
||||||
struct timezone *tz;
|
struct timezone tz;
|
||||||
char *sqlcmd, *timestr;
|
char *sqlcmd, timestr[128];
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
||||||
|
|
||||||
tv = (struct timeval *)malloc(sizeof(struct timeval));
|
|
||||||
tz = (struct timezone *)malloc(sizeof(struct timezone));
|
|
||||||
sqlcmd = (char *)malloc(2048);
|
sqlcmd = (char *)malloc(2048);
|
||||||
timestr = (char*)malloc(128);
|
|
||||||
memset(sqlcmd,0,2048);
|
memset(sqlcmd,0,2048);
|
||||||
|
|
||||||
|
|
||||||
gettimeofday(tv,tz);
|
gettimeofday(&tv,&tz);
|
||||||
t = tv->tv_sec;
|
t = tv.tv_sec;
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
strftime(timestr,128,DATE_FORMAT,tm);
|
strftime(timestr,128,DATE_FORMAT,tm);
|
||||||
|
|
||||||
|
@@ -3189,6 +3189,22 @@ static int sip_poke_peer_s(void *data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void parse_moved_contact(struct sip_pvt *p, struct sip_request *req)
|
||||||
|
{
|
||||||
|
char tmp[256] = "";
|
||||||
|
char *s, *e;
|
||||||
|
strncpy(tmp, get_header(req, "Contact"), sizeof(tmp) - 1);
|
||||||
|
s = tmp;
|
||||||
|
e = strchr(tmp, '@');
|
||||||
|
if (e)
|
||||||
|
*e = '\0';
|
||||||
|
if (!strncasecmp(s, "sip:", 4))
|
||||||
|
s += 4;
|
||||||
|
ast_log(LOG_DEBUG, "Found 302 Redirect to extension '%s'\n", s);
|
||||||
|
if (p->owner)
|
||||||
|
strncpy(p->owner->call_forward, s, sizeof(p->owner->call_forward) - 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req)
|
static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_request *req)
|
||||||
{
|
{
|
||||||
char *to;
|
char *to;
|
||||||
@@ -3361,6 +3377,11 @@ retrylock:
|
|||||||
}
|
}
|
||||||
/* XXX Locking issues?? XXX */
|
/* XXX Locking issues?? XXX */
|
||||||
switch(resp) {
|
switch(resp) {
|
||||||
|
case 302: /* Moved temporarily */
|
||||||
|
parse_moved_contact(p, req);
|
||||||
|
if (p->owner)
|
||||||
|
ast_queue_control(p->owner, AST_CONTROL_BUSY, 0);
|
||||||
|
break;
|
||||||
case 486: /* Busy here */
|
case 486: /* Busy here */
|
||||||
case 600: /* Busy everywhere */
|
case 600: /* Busy everywhere */
|
||||||
if (p->owner)
|
if (p->owner)
|
||||||
|
4
pbx.c
4
pbx.c
@@ -504,7 +504,7 @@ int ast_extension_match(char *pattern, char *data)
|
|||||||
{
|
{
|
||||||
int match;
|
int match;
|
||||||
/* If they're the same return */
|
/* If they're the same return */
|
||||||
if (!strcasecmp(pattern, data))
|
if (!strcmp(pattern, data))
|
||||||
return 1;
|
return 1;
|
||||||
EXTENSION_MATCH_CORE(data,pattern,match);
|
EXTENSION_MATCH_CORE(data,pattern,match);
|
||||||
/* Must be at the end of both */
|
/* Must be at the end of both */
|
||||||
@@ -611,7 +611,7 @@ static struct ast_exten *pbx_find_extension(struct ast_channel *chan, char *cont
|
|||||||
tmp = contexts;
|
tmp = contexts;
|
||||||
while(tmp) {
|
while(tmp) {
|
||||||
/* Match context */
|
/* Match context */
|
||||||
if (!strcasecmp(tmp->name, context)) {
|
if (!strcmp(tmp->name, context)) {
|
||||||
if (*status < STATUS_NO_EXTENSION)
|
if (*status < STATUS_NO_EXTENSION)
|
||||||
*status = STATUS_NO_EXTENSION;
|
*status = STATUS_NO_EXTENSION;
|
||||||
eroot = tmp->root;
|
eroot = tmp->root;
|
||||||
|
Reference in New Issue
Block a user