Merge (for the time being) the alert code...

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1107 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2003-06-18 22:34:55 +00:00
parent a5cee9d917
commit 4c021fb727
2 changed files with 40 additions and 7 deletions

View File

@@ -515,6 +515,25 @@ static int dial_exec(struct ast_channel *chan, void *data)
} }
} }
} }
/* Check for ALERT_INFO in the SetVar list. This is for */
/* SIP distinctive ring as per the RFC. For Cisco 7960s, */
/* SetVar(ALERT_INFO=<x>) where x is an integer. However, */
/* the RFC says it should be a URL. -- km- */
if (strcasecmp(tech,"SIP")==0)
{
headp=&chan->varshead;
AST_LIST_TRAVERSE(headp,current,entries) {
/* Search for ALERT_INFO */
if (strcasecmp(ast_var_name(current),"ALERT_INFO")==0)
{
newvar=ast_var_assign(ast_var_name(current),ast_var_value(current));
newheadp=&tmp->chan->varshead;
AST_LIST_INSERT_HEAD(newheadp,newvar,entries);
break;
}
}
}
tmp->chan->appl = "AppDial"; tmp->chan->appl = "AppDial";
tmp->chan->data = "(Outgoing Line)"; tmp->chan->data = "(Outgoing Line)";

View File

@@ -365,7 +365,7 @@ static int transmit_response_with_sdp(struct sip_pvt *p, char *msg, struct sip_r
static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, char *rand, int reliable); static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, char *rand, int reliable);
static int transmit_request(struct sip_pvt *p, char *msg, int inc, int reliable); static int transmit_request(struct sip_pvt *p, char *msg, int inc, int reliable);
static int transmit_request_with_auth(struct sip_pvt *p, char *msg, int inc, int reliable); static int transmit_request_with_auth(struct sip_pvt *p, char *msg, int inc, int reliable);
static int transmit_invite(struct sip_pvt *p, char *msg, int sendsdp, char *auth, char *vxml_url); static int transmit_invite(struct sip_pvt *p, char *msg, int sendsdp, char *auth, char *vxml_url,char *distinctive_ring);
static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp); static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp);
static int transmit_info_with_digit(struct sip_pvt *p, char digit); static int transmit_info_with_digit(struct sip_pvt *p, char digit);
static int transmit_message_with_text(struct sip_pvt *p, char *text); static int transmit_message_with_text(struct sip_pvt *p, char *text);
@@ -774,6 +774,7 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
int res; int res;
struct sip_pvt *p; struct sip_pvt *p;
char *vxml_url = NULL; char *vxml_url = NULL;
char *distinctive_ring = NULL;
struct varshead *headp; struct varshead *headp;
struct ast_var_t *current; struct ast_var_t *current;
@@ -782,20 +783,27 @@ static int sip_call(struct ast_channel *ast, char *dest, int timeout)
ast_log(LOG_WARNING, "sip_call called on %s, neither down nor reserved\n", ast->name); ast_log(LOG_WARNING, "sip_call called on %s, neither down nor reserved\n", ast->name);
return -1; return -1;
} }
/* Check whether there is vxml_url, distinctive ring variables */
/* Check whether there is a VXML_URL variable */
headp=&ast->varshead; headp=&ast->varshead;
AST_LIST_TRAVERSE(headp,current,entries) { AST_LIST_TRAVERSE(headp,current,entries) {
/* Check whether there is a VXML_URL variable */
if (strcasecmp(ast_var_name(current),"VXML_URL")==0) if (strcasecmp(ast_var_name(current),"VXML_URL")==0)
{ {
vxml_url = ast_var_value(current); vxml_url = ast_var_value(current);
break; break;
} }
/* Check whether there is a ALERT_INFO variable */
if (strcasecmp(ast_var_name(current),"ALERT_INFO")==0)
{
distinctive_ring = ast_var_value(current);
break;
}
} }
res = 0; res = 0;
p->outgoing = 1; p->outgoing = 1;
transmit_invite(p, "INVITE", 1, NULL, vxml_url); transmit_invite(p, "INVITE", 1, NULL, vxml_url,distinctive_ring);
if (p->maxtime) { if (p->maxtime) {
/* Initialize auto-congest time */ /* Initialize auto-congest time */
p->initid = ast_sched_add(sched, p->maxtime * 2, auto_congest, p); p->initid = ast_sched_add(sched, p->maxtime * 2, auto_congest, p);
@@ -2380,18 +2388,24 @@ static void initreqprep(struct sip_request *req, struct sip_pvt *p, char *cmd, c
add_header(req, "User-Agent", "Asterisk PBX"); add_header(req, "User-Agent", "Asterisk PBX");
} }
static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, char *vxml_url) static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, char *vxml_url, char *distinctive_ring)
{ {
struct sip_request req; struct sip_request req;
initreqprep(&req, p, cmd, vxml_url); initreqprep(&req, p, cmd, vxml_url);
if (auth) if (auth)
add_header(&req, "Proxy-Authorization", auth); add_header(&req, "Proxy-Authorization", auth);
if (distinctive_ring)
{
add_header(&req, "Alert-info",distinctive_ring);
}
if (sdp) { if (sdp) {
add_sdp(&req, p, NULL); add_sdp(&req, p, NULL);
} else { } else {
add_header(&req, "Content-Length", "0"); add_header(&req, "Content-Length", "0");
add_blank_header(&req); add_blank_header(&req);
} }
if (!p->initreq.headers) { if (!p->initreq.headers) {
/* Use this as the basis */ /* Use this as the basis */
copy_request(&p->initreq, &req); copy_request(&p->initreq, &req);
@@ -3761,7 +3775,7 @@ static int do_proxy_auth(struct sip_pvt *p, struct sip_request *req) {
/* No way to authenticate */ /* No way to authenticate */
return -1; return -1;
} }
return transmit_invite(p,"INVITE",1,digest, NULL); return transmit_invite(p,"INVITE",1,digest, NULL,NULL);
} }
static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, char *orig_header, char *digest, int digest_len) { static int reply_digest(struct sip_pvt *p, struct sip_request *req, char *header, char *orig_header, char *digest, int digest_len) {
@@ -4830,9 +4844,9 @@ static int sip_poke_peer(struct sip_peer *peer)
p->outgoing = 1; p->outgoing = 1;
#ifdef VOCAL_DATA_HACK #ifdef VOCAL_DATA_HACK
strncpy(p->username, "__VOCAL_DATA_SHOULD_READ_THE_SIP_SPEC__", sizeof(p->username)); strncpy(p->username, "__VOCAL_DATA_SHOULD_READ_THE_SIP_SPEC__", sizeof(p->username));
transmit_invite(p, "INVITE", 0, NULL, NULL); transmit_invite(p, "INVITE", 0, NULL, NULL,NULL);
#else #else
transmit_invite(p, "OPTIONS", 0, NULL, NULL); transmit_invite(p, "OPTIONS", 0, NULL, NULL,NULL);
#endif #endif
gettimeofday(&peer->ps, NULL); gettimeofday(&peer->ps, NULL);
peer->pokeexpire = ast_sched_add(sched, DEFAULT_MAXMS * 2, sip_poke_noanswer, peer); peer->pokeexpire = ast_sched_add(sched, DEFAULT_MAXMS * 2, sip_poke_noanswer, peer);