Patch below:
Credit goes to dtm for the algorithm and teddy_b for mjproxy, the main part
is just a rip-off from his code.
The patch adds the new MJ auth. routine to chan_sip, good for using (multi)
MJ as native trunk to make/receive calls and eliminate the needs for
additional programs. Never messed with Asterisk source code before, lucky
enough to get it working on the first try.
8/19:
Patch updated, fix a bug since Asterisk verifies(!!) the return auth. hash
value. I missed this part at first. Tested on several versions of Asterisk
1.4.21+, including 1.6 branch, also work for OpenWrt build.
8/22:
Another bug fixed, thanks bent.
Note
For old versions, the first part is in function check_auth() and the second
in build_reply_digest(). Try to add them manually...
The forum converts all TABs in source code to spaces, so if the patch
doesn't apply, try to use "patch -l" instead of "patch".
Code:
----------------------------------------------------------------------------
------------------------------------------------------------------------
--- old/channels/chan_sip.c 2009-08-13 10:24:40.000000000 -0700
+++ new/channels/chan_sip.c 2009-08-22 13:47:29.000000000 -0700
@@ -8535,6 +8535,32 @@
ast_md5_hash(a2_hash, a2);
snprintf(resp, sizeof(resp), "%s:%s:%s", a1_hash, usednonce,
a2_hash);
ast_md5_hash(resp_hash, resp);
+
+
+ /* To a Magicjack domain */
+ if (strstr(uri,"talk4free.com"))
+ {
+ char callid[256];
+ char newnonce[256];
+ char *c;
+ int i;
+ ast_copy_string(callid, p->callid, sizeof(callid));
+ ast_copy_string(newnonce, p->nonce, sizeof(newnonce));
+
+ strcat(newnonce, "_");
+ c = newnonce + strlen(newnonce);
+ char hex[2];
+ hex[1] = 0;
+ for (i = 0; i < 8; i++) {
+ hex[0] = newnonce[i];
+ int x = strtol(hex, NULL, 16);
+ *c++ = callid[x];
+ }
+ *c++ = 0;
+
+ snprintf(resp,sizeof(resp),"%s:%s:%s", a1_hash, newnonce,
a2_hash);
+ ast_md5_hash(resp_hash, resp);
+ }
}
good_response = keys[K_RESP].s &&
@@ -11658,6 +11684,31 @@
snprintf(resp,sizeof(resp),"%s:%s:%s", a1_hash, p->nonce,
a2_hash);
ast_md5_hash(resp_hash, resp);
+ /* To a Magicjack domain */
+ if (strstr(uri,"talk4free.com"))
+ {
+ char callid[256];
+ char newnonce[256];
+ char *c;
+ int i;
+ ast_copy_string(callid, p->callid, sizeof(callid));
+ ast_copy_string(newnonce, p->nonce, sizeof(newnonce));
+
+ strcat(newnonce, "_");
+ c = newnonce + strlen(newnonce);
+ char hex[2];
+ hex[1] = 0;
+ for (i = 0; i < 8; i++) {
+ hex[0] = newnonce[i];
+ int x = strtol(hex, NULL, 16);
+ *c++ = callid[x];
+ }
+ *c++ = 0;
+
+ snprintf(resp,sizeof(resp),"%s:%s:%s", a1_hash, newnonce,
a2_hash);
+ ast_md5_hash(resp_hash, resp);
+ }
+
/* only include the opaque string if it's set */
if (!ast_strlen_zero(p->opaque)) {
snprintf(opaque, sizeof(opaque), ", opaque=\"%s\"", p->opaque);
----------------------------------------------------------------------------
----------------------------------------------------------------------
-----Original Message-----
From: Darrick Hartman [mailto:[email protected]]
Sent: Saturday, August 29, 2009 12:50 PM
To: [email protected]; AstLinux Users Mailing List
Subject: Re: [Astlinux-users] MagicJack patch
Do you have a patch? Can you at least provide a link?
Mark Phillips wrote:
> Hi all,
>
> Has the MagicJack patch been incorporated into the latest build yet?
>
> Thanks
>
> Mark
>
>
----------------------------------------------------------------------------
--
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Astlinux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/astlinux-users
Donations to support AstLinux are graciously accepted via PayPal to
[email protected].
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Astlinux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/astlinux-users
Donations to support AstLinux are graciously accepted via PayPal to
[email protected].