[Asterisk-cvs] asterisk/channels chan_sip.c,1.330,1.331
markster at lists.digium.com
markster at lists.digium.com
Mon Apr 5 01:12:02 CDT 2004
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv17523/channels
Modified Files:
chan_sip.c
Log Message:
Support some more SIP idiocies
Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.330
retrieving revision 1.331
diff -u -d -r1.330 -r1.331
--- chan_sip.c 4 Apr 2004 22:54:35 -0000 1.330
+++ chan_sip.c 5 Apr 2004 05:12:00 -0000 1.331
@@ -256,6 +256,7 @@
char realm[256]; /* Authorization realm */
char nonce[256]; /* Authorization nonce */
char opaque[256]; /* Opaque nonsense */
+ char qop[80]; /* Quality of Protection, since SIP wasn't complicated enough yet. */
char domain[256]; /* Authorization nonce */
char lastmsg[256]; /* Last Message sent/received */
int amaflags; /* AMA Flags */
@@ -4727,6 +4728,7 @@
char *nonce = "";
char *domain = "";
char *opaque = "";
+ char *qop = "";
char *c;
@@ -4772,6 +4774,17 @@
if ((c = strchr(c,',')))
*c = '\0';
}
+ } else if (!strncasecmp(c, "qop=", strlen("qop="))) {
+ c+=strlen("qop=");
+ if ((*c == '\"')) {
+ qop=++c;
+ if ((c = strchr(c,'\"')))
+ *c = '\0';
+ } else {
+ qop = c;
+ if ((c = strchr(c,',')))
+ *c = '\0';
+ }
} else if (!strncasecmp(c, "domain=", strlen("domain="))) {
c+=strlen("domain=");
if ((*c == '\"')) {
@@ -4796,6 +4809,7 @@
strncpy(p->nonce, nonce, sizeof(p->nonce)-1);
strncpy(p->domain, domain, sizeof(p->domain)-1);
strncpy(p->opaque, opaque, sizeof(p->opaque)-1);
+ strncpy(p->qop, qop, sizeof(p->qop)-1);
build_reply_digest(p, orig_header, digest, digest_len);
return 0;
}
@@ -4809,6 +4823,7 @@
char resp[256];
char resp_hash[256];
char uri[256] = "";
+ char cnonce[80];
if (strlen(p->domain))
strncpy(uri, p->domain, sizeof(uri) - 1);
@@ -4817,6 +4832,8 @@
else
snprintf(uri, sizeof(uri), "sip:%s@%s",p->username, inet_ntoa(p->sa.sin_addr));
+ snprintf(cnonce, sizeof(cnonce), "%08x", rand());
+
snprintf(a1,sizeof(a1),"%s:%s:%s",p->peername,p->realm,p->peersecret);
snprintf(a2,sizeof(a2),"%s:%s",orig_header,uri);
if (strlen(p->peermd5secret))
@@ -4824,10 +4841,18 @@
else
md5_hash(a1_hash,a1);
md5_hash(a2_hash,a2);
- snprintf(resp,sizeof(resp),"%s:%s:%s",a1_hash,p->nonce,a2_hash);
+ /* XXX We hard code the nonce-number to 1... What are the odds? Are we seriously going to keep
+ track of every nonce we've seen? Also we hard code to "auth"... XXX */
+ if (strlen(p->qop))
+ snprintf(resp,sizeof(resp),"%s:%s:%s:%s:%s:%s",a1_hash,p->nonce, "00000001", cnonce, "auth", a2_hash);
+ else
+ snprintf(resp,sizeof(resp),"%s:%s:%s",a1_hash,p->nonce,a2_hash);
md5_hash(resp_hash,resp);
-
- snprintf(digest,digest_len,"Digest username=\"%s\", realm=\"%s\", algorithm=\"MD5\", uri=\"%s\", nonce=\"%s\", response=\"%s\", opaque=\"%s\"",p->peername,p->realm,uri,p->nonce,resp_hash, p->opaque);
+ /* XXX We hard code our qop to "auth" for now. XXX */
+ if (strlen(p->qop))
+ snprintf(digest,digest_len,"Digest username=\"%s\", realm=\"%s\", algorithm=\"MD5\", uri=\"%s\", nonce=\"%s\", response=\"%s\", opaque=\"%s\", qop=\"%s\", cnonce=\"%s\", nc=%s",p->peername,p->realm,uri,p->nonce,resp_hash, p->opaque, "auth", cnonce, "00000001");
+ else
+ snprintf(digest,digest_len,"Digest username=\"%s\", realm=\"%s\", algorithm=\"MD5\", uri=\"%s\", nonce=\"%s\", response=\"%s\", opaque=\"%s\"",p->peername,p->realm,uri,p->nonce,resp_hash, p->opaque);
return 0;
}
More information about the svn-commits
mailing list