[Asterisk-cvs] asterisk/channels chan_sip.c,1.482,1.483
markster at lists.digium.com
markster at lists.digium.com
Mon Aug 30 01:18:00 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv21971/channels
Modified Files:
chan_sip.c
Log Message:
Track extra parameters in contact (bug #732)
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.482
retrieving revision 1.483
diff -u -d -r1.482 -r1.483
--- chan_sip.c 29 Aug 2004 18:58:30 -0000 1.482
+++ chan_sip.c 30 Aug 2004 05:21:34 -0000 1.483
@@ -312,6 +312,7 @@
char callerid[256]; /* Caller*ID */
int restrictcid; /* hide presentation from remote user */
char via[256];
+ char extraparams[80]; /* Extra parameters to go in the "To" header */
char accountcode[20]; /* Account code */
char our_contact[256]; /* Our contact header */
char realm[256]; /* Authorization realm */
@@ -423,6 +424,7 @@
char tohost[80];
char fromuser[80];
char fromdomain[80];
+ char extraparams[80];
char mailbox[AST_MAX_EXTENSION];
char language[MAX_LANGUAGE];
char musicclass[MAX_LANGUAGE]; /* Music on Hold class */
@@ -3687,11 +3689,17 @@
/* If there is a VXML URL append it to the SIP URL */
if (vxml_url)
{
- snprintf(to, sizeof(to), "<%s>;%s", invite, vxml_url);
+ if (strlen(p->extraparams))
+ snprintf(to, sizeof(to), "<%s;%s>;%s", invite, p->extraparams, vxml_url);
+ else
+ snprintf(to, sizeof(to), "<%s>;%s", invite, vxml_url);
}
else
{
- snprintf(to, sizeof(to), "<%s>", invite );
+ if (strlen(p->extraparams))
+ snprintf(to, sizeof(to), "<%s;%s>", invite, p->extraparams);
+ else
+ snprintf(to, sizeof(to), "<%s>", invite);
}
memset(req, 0, sizeof(struct sip_request));
init_req(req, cmd, invite);
@@ -4227,7 +4235,7 @@
char data[80];
char iabuf[INET_ADDRSTRLEN];
struct in_addr in;
- char *c, *d, *u;
+ char *c, *d, *u, *e;
int expiry;
if (!ast_db_get("SIP/Registry", p->name, data, sizeof(data))) {
c = strchr(data, ':');
@@ -4243,7 +4251,14 @@
if (u) {
*u = '\0';
u++;
+ e = strchr(u, ':');
+ if (e) {
+ *e = '\0';
+ e++;
+ strncpy(p->extraparams, e, sizeof(p->extraparams) - 1);
+ }
strncpy(p->username, u, sizeof(p->username) - 1);
+
}
ast_verbose(VERBOSE_PREFIX_3 "SIP Seeding '%s' at %s@%s:%d for %d\n", p->name,
p->username, ast_inet_ntoa(iabuf, sizeof(iabuf), in), atoi(c), atoi(d));
@@ -4320,8 +4335,12 @@
c += 4;
/* Ditch q */
n = strchr(c, ';');
- if (n)
+ if (n) {
*n = '\0';
+ n++;
+ strncpy(p->extraparams, n, sizeof(p->extraparams) - 1);
+ } else
+ strncpy(p->extraparams, "", sizeof(p->extraparams) - 1);
/* Grab host */
n = strchr(c, '@');
if (!n) {
@@ -4365,7 +4384,7 @@
if (!p->temponly)
p->expire = ast_sched_add(sched, (expiry + 10) * 1000, expire_register, p);
pvt->expiry = expiry;
- snprintf(data, sizeof(data), "%s:%d:%d:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username);
+ snprintf(data, sizeof(data), "%s:%d:%d:%s:%s", ast_inet_ntoa(iabuf, sizeof(iabuf), p->addr.sin_addr), ntohs(p->addr.sin_port), expiry, p->username, p->extraparams);
ast_db_put("SIP/Registry", p->name, data);
if (inaddrcmp(&p->addr, &oldsin)) {
sip_poke_peer(p);
@@ -5351,6 +5370,7 @@
strncpy(p->username, peer->username, sizeof(p->username) - 1);
strncpy(p->authname, peer->username, sizeof(p->authname) - 1);
}
+ strncpy(p->extraparams, peer->extraparams, sizeof(p->extraparams) - 1);
if (!ast_strlen_zero(peer->context))
strncpy(p->context, peer->context, sizeof(p->context) - 1);
strncpy(p->peersecret, peer->secret, sizeof(p->peersecret) - 1);
@@ -5710,6 +5730,7 @@
strncpy(status, "UNKNOWN", sizeof(status) - 1);
ast_cli(fd, "%s\n",status);
ast_cli(fd, " Useragent : %s\n", peer->useragent);
+ ast_cli(fd, " Extra Params : %s\n", peer->extraparams);
ast_cli(fd,"\n");
} else {
ast_cli(fd,"Peer %s not found.\n", argv[3]);
More information about the svn-commits
mailing list