Magicjack Patch for Asterisk(updated)

magicJack Tips and Tricks

Moderators: Bill Smith, Pilot

VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

lowno wrote:How do you patch the chan_sip.so?
There are many different ways but below is to the best of my recollection the way I did it.

22 Aug 2009 - Edited Instructions to fix a bug and make them more general purpose

1) {login to your Asterisk box using the 'root' account - you can use putty to do this remotly}

2) {Backup the original version of chan_sip:}
{Hint: you can copy the following commands to the clip board, one at a time, and then right click on the putty window and the command will be copied there. Then just hit enter to execute the command in putty}

cp -p /usr/src/asterisk/channels/chan_sip.c /usr/src/asterisk/channels/chan_sip.c.b4patch
cp -p /usr/src/asterisk/channels/chan_sip.c.orig /usr/src/asterisk/channels/chan_sip.c.orig.b4patch
cp -p /usr/src/asterisk/channels/chan_sip.so /usr/src/asterisk/channels/chan_sip.so.b4patch
cp -p /usr/lib/asterisk/modules/chan_sip.so /usr/lib/asterisk/modules/chan_sip.so.b4patch
mv /usr/src/asterisk/channels/chan_sip.c.orig /usr/src/asterisk/channels/chan_sip.c.orig.b4patch

{used mv here to rename the chan_sip.c.orig if there was one so it won't interfer with the application of the patch later on}

3) {Navigate to the Asterisk source directory where chan_sip.c is located}

cd /usr/src/asterisk/channels

4) {highlight the patch text from the webpage here and copy the text to your clipboard}

5) {open a blank text file named chan_sip_mj_patch.txt}

cat > chan_sip_mj_patch.txt

6) {right click the mouse on the putty window to paste the text into the open chan_sip_mj_patch.txt}

7) {use the keyboard command below to close and save the chan_sip_mj_patch.txt file}
{Edit: 22 Aug 2009 - After pasting the text into putty hit return once before the Cntrl-d to eliminate the unexpected end in middle of line warning during patch}

Cntrl-D

8) {Apply the patch}
{Edit: 22 Aug 2009 modified the patch command to assist with tab vs. spaces in patch file}

patch -l <chan_sip_mj_patch.txt

9) {move up one level to the asterisk source directory}

cd ..

10) {Compile your new chan_sip.so...saving a copy of the compilation messages to /tmp/make.all}
{Edit: If you have problems with the following command on your distro then just use the plain make command.}

make all 2>&1|tee /tmp/make.all

{If no errors during the compilation then stop asterisk and install the new chan_sip.so}

11) {stop asterisk}

/usr/sbin/asterisk -rx "stop gracefully"

12) {Copy the new chan_sip.so to the asterisk modules directory}

cp -p /usr/src/asterisk/channels/chan_sip.so /usr/lib/asterisk/modules/chan_sip.so

13) {Restart Asterisk}

/usr/sbin/asterisk
Last edited by VaHam on Sun Aug 23, 2009 11:41 am, edited 5 times in total.
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
lowno
MagicJack Newbie
Posts: 7
Joined: Mon Mar 09, 2009 7:18 pm

Post by lowno »

Wow, thanks a ton VaHam. I appreciate the detailed instructions.
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

lowno wrote:Wow, thanks a ton VaHam. I appreciate the detailed instructions.
Your welcome let us know how you make out!
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
bent
MagicJack Newbie
Posts: 4
Joined: Wed Jun 10, 2009 6:47 pm

Post by bent »

Hi!
To pagemen
I think the first part of patch (check_auth) is not need, it's used only for incoming authentications with your peers.
And there is a little bug in code: variable newnonce is longer than necessary, it's need cut :)

Code: Select all

for (i = 0; i < 8; i++) {
                       hex[0] = newnonce[i];
                       int x = strtol(hex, NULL, 16);
                       *c++ = callid[x];
                       }
*c++ = 0;
^^^^^^^
Now working on incoming/outgoing calls w/o mjproxy.
lowno
MagicJack Newbie
Posts: 7
Joined: Mon Mar 09, 2009 7:18 pm

Post by lowno »

I am working on it as per the instructions, I am currently stuck with at the following error in terminal:

File to patch: chan_sip.c
patching file chan_sip.c
Hunk #1 FAILED at 8535.
patch unexpectedly ends in middle of line
Hunk #2 FAILED at 11683.
2 out of 2 hunks FAILED -- saving rejects to file chan_sip.c.rej

I am trying to do this on my trixbox distro that has asterisk 1.4.22. Trixbox doesn't include sources, so I downloaded the sources from digium.

I'll keep hacking away at it.

Could someone possible post their recompiled chan_sip.so for 1.4.22?
pagemen
Dan isn't smart enough to hire me
Posts: 128
Joined: Mon Dec 15, 2008 6:36 am

Post by pagemen »

bent wrote:Hi!
To pagemen
I think the first part of patch (check_auth) is not need, it's used only for incoming authentications with your peers.
And there is a little bug in code: variable newnonce is longer than necessary, it's need cut :)

Code: Select all

for (i = 0; i < 8; i++) {
                       hex[0] = newnonce[i];
                       int x = strtol(hex, NULL, 16);
                       *c++ = callid[x];
                       }
*c++ = 0;
^^^^^^^
Now working on incoming/outgoing calls w/o mjproxy.
First part is necessary or you'll see "Got 200 OK on REGISTER that isn't a register" warning message in log -- basically, server accepts our new md5 hash and return "200 OK" but Asterisk still checks the value against old routine thus thinks the return value is wrong.

And thanks for pointing out "*c++ = 0" part, will update the first post later. Seems that one works because the complier initializes all elements in the char array with '\0'...
bent
MagicJack Newbie
Posts: 4
Joined: Wed Jun 10, 2009 6:47 pm

Post by bent »

pagemen wrote:
First part is necessary or you'll see "Got 200 OK on REGISTER that isn't a register" warning message in log -- basically, server accepts our new md5 hash and return "200 OK" but Asterisk still checks the value against old routine thus thinks the return value is wrong.
About message "Got 200..." see, for example: http://forum.voxilla.com/asterisk-suppo ... 23269.html

I noticed magicjack not required auth on Registry, only on Invite.
Last edited by bent on Sat Aug 22, 2009 5:04 pm, edited 1 time in total.
pagemen
Dan isn't smart enough to hire me
Posts: 128
Joined: Mon Dec 15, 2008 6:36 am

Post by pagemen »

lowno wrote:I am working on it as per the instructions, I am currently stuck with at the following error in terminal:

File to patch: chan_sip.c
patching file chan_sip.c
Hunk #1 FAILED at 8535.
patch unexpectedly ends in middle of line
Hunk #2 FAILED at 11683.
2 out of 2 hunks FAILED -- saving rejects to file chan_sip.c.rej

I am trying to do this on my trixbox distro that has asterisk 1.4.22. Trixbox doesn't include sources, so I downloaded the sources from digium.

I'll keep hacking away at it.

Could someone possible post their recompiled chan_sip.so for 1.4.22?
Seems that you have some problem when retrieving the patch. Also please notice that, the original code using TAB for indent while the forum converts all TABs to spaces when posting the code, and the patch might fail when you c/p directly from the post. Try to use "patch -l" instead of "patch" when applying it.
pagemen
Dan isn't smart enough to hire me
Posts: 128
Joined: Mon Dec 15, 2008 6:36 am

Post by pagemen »

bent wrote:
pagemen wrote:
First part is necessary or you'll see "Got 200 OK on REGISTER that isn't a register" warning message in log -- basically, server accepts our new md5 hash and return "200 OK" but Asterisk still checks the value against old routine thus thinks the return value is wrong.
About message "Got 200..." see, for example: http://forum.voxilla.com/asterisk-suppo ... 23269.html

I noticed magicjack not required auth on Registry, only on Invite.
I'm not familar with * code, so whatever :) Anyway, is there any side effect by adding the first part? if not, maybe we can just leave it there?
lowno
MagicJack Newbie
Posts: 7
Joined: Mon Mar 09, 2009 7:18 pm

Post by lowno »

Thanks for the tip. i think it patched correctly. I fixed the tabs, then tried it with the "patch -l". I received the following response, but no error;s or anything like that.

patching file chan_sip.c
Hunk #1 succeeded at 8907 (offset 372 lines).
patch unexpectedly ends in middle of line
Hunk #2 succeeded at 11803 with fuzz 1 (offset 120 lines).

I am stuck at the compiling part now. I went up a directory and ran "make all 2>&1|tee /tmp/make.all", but get the following response:
make: *** No rule to make target `all'. Stop.

Thanks for all the help. I really appreciate it. I am trying to find a solution via google, sometimes it is a lot faster to just ask the experts.
pagemen wrote:
lowno wrote:I am working on it as per the instructions, I am currently stuck with at the following error in terminal:

File to patch: chan_sip.c
patching file chan_sip.c
Hunk #1 FAILED at 8535.
patch unexpectedly ends in middle of line
Hunk #2 FAILED at 11683.
2 out of 2 hunks FAILED -- saving rejects to file chan_sip.c.rej

I am trying to do this on my trixbox distro that has asterisk 1.4.22. Trixbox doesn't include sources, so I downloaded the sources from digium.

I'll keep hacking away at it.

Could someone possible post their recompiled chan_sip.so for 1.4.22?
Seems that you have some problem when retrieving the patch. Also please notice that, the original code using TAB for indent while the forum converts all TABs to spaces when posting the code, and the patch might fail when you c/p directly from the post. Try to use "patch -l" instead of "patch" when applying it.
bent
MagicJack Newbie
Posts: 4
Joined: Wed Jun 10, 2009 6:47 pm

Post by bent »

I am stuck at the compiling part now. I went up a directory and ran "make all 2>&1|tee /tmp/make.all", but get the following response:
make: *** No rule to make target `all'. Stop.
Try simple "make".
I'm not familar with * code, so whatever Smile Anyway, is there any side effect by adding the first part? if not, maybe we can just leave it there?
No any side effect, except for extra code :)
lowno
MagicJack Newbie
Posts: 7
Joined: Mon Mar 09, 2009 7:18 pm

Post by lowno »

So I realized that the distro didn't have a compiler. Ran yum install gcc-c++ to get the compiler. The ran the make and got a gagillion errors. I would post it the output, but it would seriously annoy anyone looking at this thread. I think I may give up on this one.

Thanks for all the help guys.
bent wrote:
I am stuck at the compiling part now. I went up a directory and ran "make all 2>&1|tee /tmp/make.all", but get the following response:
make: *** No rule to make target `all'. Stop.
Try simple "make".
I'm not familar with * code, so whatever Smile Anyway, is there any side effect by adding the first part? if not, maybe we can just leave it there?
No any side effect, except for extra code :)
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

lowno wrote:So I realized that the distro didn't have a compiler. Ran yum install gcc-c++ to get the compiler. The ran the make and got a gagillion errors. I would post it the output, but it would seriously annoy anyone looking at this thread. I think I may give up on this one.

Thanks for all the help guys.
bent wrote:
I am stuck at the compiling part now. I went up a directory and ran "make all 2>&1|tee /tmp/make.all", but get the following response:
make: *** No rule to make target `all'. Stop.
Try simple "make".
I'm not familar with * code, so whatever Smile Anyway, is there any side effect by adding the first part? if not, maybe we can just leave it there?
No any side effect, except for extra code :)
I am a linux newbie but the makefile which gives instructions for make may be the problem. The reason for running make from /usr/src/asterisk is because that is where the makefile is stored at least in my distro. Could there be some cross up between your original makefile and one which would be appropriate for the new 1.4.22 asterisk version?
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

I guess i am just a little slow when it comes to some Asterisk CLI.

I had this working. then I proceeded to clean up my AvantFax install by finishing configuring it. did a reboot and BAM... now the MJ's don't work.


I just dont get it.

i am getting a 400 response / congestion back!

anybody got a clue as to wtf happened?

I cant seem to find anything. so what I did is copy the old file back. then start all over with the last post of the first page of this thread. as it says it was updated.

I am running PIAF
Asterisk 1.4.21.2 and of course it has CentOS 5. on it.

thanks for the help! :?: :shock: :?: :shock:
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

completetech wrote:I guess i am just a little slow when it comes to some Asterisk CLI.

I had this working. then I proceeded to clean up my AvantFax install by finishing configuring it. did a reboot and BAM... now the MJ's don't work.


I just dont get it.

i am getting a 400 response / congestion back!

anybody got a clue as to wtf happened?

I cant seem to find anything. so what I did is copy the old file back. then start all over with the last post of the first page of this thread. as it says it was updated.

I am running PIAF
Asterisk 1.4.21.2 and of course it has CentOS 5. on it.

thanks for the help! :?: :shock: :?: :shock:
The congestion error shows up when MJ is not getting authorized. Just a guess but sounds like during your cleanup you reverted to a old chan_sip.so perhaps.

The last post of the first page is a patch for Asterisk ver 1.4.15 and is updated as noted but still only applies for version 1.4.15. I am going to go add a second notice at the bottom of the post regarding that that post applies to version 1.4.15.

If your running Asterisk version 1.4.21.2 the updated patch for version 1.4.21 is in the first post of the thread. pagemen has been keeping the first post updated with fixes for the later versions there.

I don't think the patch for ver 1.4.15 could have been applied to ver 4.1.21.2 successfully. Didn't you get errors when applying the patch and recompiling?

How did you wind up with Asterisk version 1.4.21.2 as your Asterisk version in PIAF? My PIAF install admittedly was done many months ago, but has been updated to FreePBX 2.5.1.5 using the automated update features. The updates are all current and have only brought Asterisk up to version 1.4.15 on my system. Did you manually upgrade Asterisk outside of the FreePBX update system or something? The reason I ask is because the only reason I posted the patch for the older version is because I believe the very popular PIAF distro is not yet up to the latest version of Asterisk yet even with all current automatic updates applied.
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

i just run the updates as directed on pbxinaflash.com/forum

i have ver 1.4.21.2

I ran all the commands again and copied the entire part of the code.

I just dont get how it was just fine and now after a reboot it is toast!!!!

any ideas

I guess can you maybe walk me through it again like the idiot i am. maybe the lack of sleep is wtf the issue is. lol....

if you got a step by step idea that would be great!
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

completetech wrote:i just run the updates as directed on pbxinaflash.com/forum

i have ver 1.4.21.2

I ran all the commands again and copied the entire part of the code.

I just dont get how it was just fine and now after a reboot it is toast!!!!

any ideas

I guess can you maybe walk me through it again like the idiot i am. maybe the lack of sleep is wtf the issue is. lol....

if you got a step by step idea that would be great!
I posted as close to step by step as I know of IN THIS POST EARLIER for applying the patch.

If you scroll back in the thread you can see my PBXIAF setup which works as well.

By the entire part of the code do you mean you tried it again with pagmen's code in the first post of this thread? Did you get any errors during the patch or recompile?
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
pagemen
Dan isn't smart enough to hire me
Posts: 128
Joined: Mon Dec 15, 2008 6:36 am

Post by pagemen »

run "strings chan_sip.so | grep talk4free.com"
to check if the binary is patched or not.
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

ok I will give that a try when i get back to the office where it is at.

if not then how should I start all over and re-patch it?

I would really love to get this going so that I can use a MJ as a specific trunk for something.

thanks a bunch guys for all of yer work in getting this going.
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

completetech wrote:ok I will give that a try when i get back to the office where it is at.

if not then how should I start all over and re-patch it?

I would really love to get this going so that I can use a MJ as a specific trunk for something.

thanks a bunch guys for all of yer work in getting this going.
chan_sip.so should be in two places if all is well.

/usr/src/asterisk/channels/chan_sip.so

and

/usr/lib/asterisk/modules/chan_sip.so

The latter is the one Asterisk uses at run time.
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

so bad news is that it is located in both.

any quick run down of how to start all over and get it going again. I am a little lost here!
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

VaHam wrote:
completetech wrote:i just run the updates as directed on pbxinaflash.com/forum

i have ver 1.4.21.2

I ran all the commands again and copied the entire part of the code.

I just dont get how it was just fine and now after a reboot it is toast!!!!

any ideas

I guess can you maybe walk me through it again like the idiot i am. maybe the lack of sleep is wtf the issue is. lol....

if you got a step by step idea that would be great!
I posted as close to step by step as I know of IN THIS POST EARLIER for applying the patch.

If you scroll back in the thread you can see my PBXIAF setup which works as well.

By the entire part of the code do you mean you tried it again with pagmen's code in the first post of this thread? Did you get any errors during the patch or recompile?
yes i re-ran it.

what I did was remove teh newly edited version. then started all over. I am still getting a error 400 and congestion
pagemen
Dan isn't smart enough to hire me
Posts: 128
Joined: Mon Dec 15, 2008 6:36 am

Post by pagemen »

Quick checklist:

1. strings /usr/lib/asterisk/modules/chan_sip.so | grep talk4free.com

you should see an output of "talk4free.com" so you know the chan_sip.so is patched

2. Use mjmd5/mjproxy with ATA or softphone to check if the password is correct and unchanged

3. If both look good, post your configuration and see if someone can get a hint on it.
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

I guess that from the few hours I had it working the password could have changed. I doubt it though. possible.

at this point I guess it is off to the router proxy add-on in order to get it to work. :(
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

completetech wrote:I guess that from the few hours I had it working the password could have changed. I doubt it though. possible.

at this point I guess it is off to the router proxy add-on in order to get it to work. :(
check your PM's - I can walk you thru this either via MSN or a MJ call - let me know
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

slightly off topic.... but now for some reason i can not do

areacode+NXXXXXX and have it allow me 7 digit dialing..

any idea?
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

completetech wrote:slightly off topic.... but now for some reason i can not do

areacode+NXXXXXX and have it allow me 7 digit dialing..

any idea?
try 1|areacodeNXXNXXXX

or 1NXXNXXNXXXX

to force a 1 dial?
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

no i mean i want to dial seven digits.

i.e.... 222-2222

so my dial rule should look like

123+NXXXXXX
so that it passes
123-222-2222 when ?i dial 222-2222

but when i do that like I did before when it worked it will not let it pass
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

check your dial patterns on BOTH your trunks and outbound routes.

I dont use them on the trunks, i configure mine in the outbound routes so I can pick what trunk I need by how i dial
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Post by completetech »

i tried it that way and still get the message of your call can not be completed please try again later
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

I will try it when I get home
DarwinPeru
magicJack Apprentice
Posts: 28
Joined: Tue Feb 03, 2009 2:39 am

Post by DarwinPeru »

lowno wrote:I am stuck at the compiling part now. I went up a directory and ran "make all 2>&1|tee /tmp/make.all", but get the following response:
make: *** No rule to make target `all'. Stop.
Sorry if my english is not good, but Iowno: where are you doing make all 2>&1|tee /tmp/make.all ???

You have eject that in : The asterisk source directory (/usr/src/asteriskxxxx)

bye
DarwinPeru
magicJack Apprentice
Posts: 28
Joined: Tue Feb 03, 2009 2:39 am

Thanks

Post by DarwinPeru »

Thanks for this tutorial, for me it is working good, I have Debian 5.0, Asterisk 1.6.0.13 and used the first patch.

now I can use my 5 MJ´s in the same time.

thanks

but....

I have a problem, I can´t to recive calls, I can make calls but I can´t recive calls, some one know why????????

my SIP:

register => ENUMBER01:[email protected]:5070/1234


[magicjack]
context=Gerente
username=ENUMBER01
type=friend
secret=XXXPASSWORDXXX
port=5070
nat=yes
insecure=very
host=proxy1.SanFrancisco.talk4free.com
fromuser=ENUMBER01
dtmfmode=inband
qualify=2500
dtmfmode=rfc2833
;disallow=all
;allow=g729


MY EXTENSIONS.CONF:

[Gerente]

exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@magicjack,30,tTr)
exten => _1NXXNXXXXXX,2,congestion()
exten => _1NXXNXXXXXX,102,busy()
exten => i,1,Hangup()
exten => t,1,Hangup()
exten => h,1,Hangup()


exten => 1234,1,Answer
exten => 1234,2,Dial(SIP/200,30,Ttr)
exten => 1234,3,Hangup()


and when I make a call to my MJ number my CLI show this message:

[Aug 28 14:19:44] WARNING[2645]: chan_sip.c:10502 check_auth: username mismatch, have <MYMJNUMBER>, digest has <EMYMJNUMBER01>
[Aug 28 14:19:44] NOTICE[2645]: chan_sip.c:17282 handle_request_invite: Failed to authenticate user <sip:[email protected]:5070>;tag=3584d42c-co6406-INS024


Please Help me...

Thanks a lot from Lima Perú
mykroft
MagicJack User
Posts: 47
Joined: Sun Oct 19, 2008 12:28 am

Post by mykroft »

On my inbound routes I had to add E and 01 to my DID number, dunno when MJ starting doing this - but it has changed....
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Re: Thanks

Post by VaHam »

DarwinPeru wrote:Thanks for this tutorial, for me it is working good, I have Debian 5.0, Asterisk 1.6.0.13 and used the first patch.

and when I make a call to my MJ number my CLI show this message:

[Aug 28 14:19:44] WARNING[2645]: chan_sip.c:10502 check_auth: username mismatch, have <MYMJNUMBER>, digest has <EMYMJNUMBER01>
[Aug 28 14:19:44] NOTICE[2645]: chan_sip.c:17282 handle_request_invite: Failed to authenticate user <sip:[email protected]:5070>;tag=3584d42c-co6406-INS024
Hopefully mykroft's hint about matching the inbound exactly with your fromuser got you going.

I think you could also have set the global parameter to accept anonymous sip calls and that would have worked as well. If you use ENUM to allow incoming sip calls I think you need to set the allow anonymous sip for that to work as well.
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
RonV
magicJack Apprentice
Posts: 14
Joined: Mon Dec 08, 2008 2:13 pm

Post by RonV »

Well I took the drive from the Linux mjproxy to recompiling the sip module for my version of asterisk and it works great. Thank you for providing the patched code to handle the authentication of the MJ account. Thats one less piece of software that I need to run on my PBX.

If anyone is interested I can post the compiled sip module. Mine was from the Trixbox 2.4.2 distribution of Asterisk so its version 1.4.22.
completetech
magicJack Apprentice
Posts: 16
Joined: Sun Jul 26, 2009 1:11 am

Re: Thanks

Post by completetech »

VaHam wrote:
DarwinPeru wrote:Thanks for this tutorial, for me it is working good, I have Debian 5.0, Asterisk 1.6.0.13 and used the first patch.

and when I make a call to my MJ number my CLI show this message:

[Aug 28 14:19:44] WARNING[2645]: chan_sip.c:10502 check_auth: username mismatch, have <MYMJNUMBER>, digest has <EMYMJNUMBER01>
[Aug 28 14:19:44] NOTICE[2645]: chan_sip.c:17282 handle_request_invite: Failed to authenticate user <sip:[email protected]:5070>;tag=3584d42c-co6406-INS024
Hopefully mykroft's hint about matching the inbound exactly with your fromuser got you going.

I think you could also have set the global parameter to accept anonymous sip calls and that would have worked as well. If you use ENUM to allow incoming sip calls I think you need to set the allow anonymous sip for that to work as well.
I do think you are correct
sgarringer
MagicJack Newbie
Posts: 1
Joined: Sat Sep 05, 2009 1:30 am

Problems with Registration

Post by sgarringer »

Edit: Gave up, and am just forwarding my Magic Jack calls to another number which works fine in Asterisk.

I wish there were more VoIP providers that offered 319 area codes!
patppp
MagicJack Newbie
Posts: 5
Joined: Fri May 15, 2009 1:39 pm

Post by patppp »

RonV wrote: If anyone is interested I can post the compiled sip module. Mine was from the Trixbox 2.4.2 distribution of Asterisk so its version 1.4.22.
I've the compiled sip module for Asterisk 1.4.26.1 on Centos 5 (32bits).
Worked on my Elastix distrib.

PM if needed.
tvland
magicJack Apprentice
Posts: 23
Joined: Tue Mar 11, 2008 3:05 pm

Post by tvland »

I have trixbox 2.8.0.1 with asterisk 1.6.0.9 and recompiling asterisk for MJMD5 breaks the system. A number of problems happen after the recompile. I fixed everything except the CDR. The CDR no longer logs calls.

If I just patch chan_sip.so, I get a bunch of errors in the frePBX interface and everything to do with SIP is broken. I used the source package with the same version from the asterisk site.


Any suggestions on this?

Update: I have figured out that the Asterisk version in trixbox is a custom patched version. My version is not available in a source package. This patch won't be possible unless trixbox uses a release version of Asterisk.
azuretech
MagicJack Newbie
Posts: 1
Joined: Wed Oct 07, 2009 2:04 pm

Patch not working for me...

Post by azuretech »

I applied the patch, used Passwordfinder 2.2 to get my password, entered everything in, but for some reason I'm still getting:

NOTICE[3193] chan_sip.c: Failed to authenticate on REGISTER to '[email protected]' (Tries 3)

(obviously NXXNXXXXXX is my MJ phone number and MY20CHARPASSWORD is my password obtained through password finder)

Only thing I can figure is passwordfinder isn't pulling the correct password.... is there another way to find it?

register=ENXXNXXXXXX01:[email protected]:5070/NXXNXXXXXX

[MagicJack]
username=ENXXNXXXXXX01
authuser=ENXXNXXXXXX01
type=friend
secret=MY20CHARPASSWORD
qualify=2000
port=5070
insecure=port,invite
host=proxy01.boston.talk4free.com
fromuser=ENXXNXXXXXX01
useragent=MagicJack/1.80.499b (SJ Labs)
context=from-trunk
disallow=all
allow=ulaw
dtmfmode=rfc2833
nat=yes


Am I missing anything?
Is there a better way to obtain the sip password than Passwordfinder 2.2? I'm using the only one it came up with.... Passwordfinder 2.1 came up with a few other possibilities, but I tried all of them, also with no success.
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Re: Patch not working for me...

Post by VaHam »

azuretech wrote:I applied the patch, used Passwordfinder 2.2 to get my password, entered everything in, but for some reason I'm still getting:

NOTICE[3193] chan_sip.c: Failed to authenticate on REGISTER to '[email protected]' (Tries 3)

(obviously NXXNXXXXXX is my MJ phone number and MY20CHARPASSWORD is my password obtained through password finder)

Only thing I can figure is passwordfinder isn't pulling the correct password.... is there another way to find it?

register=ENXXNXXXXXX01:[email protected]:5070/NXXNXXXXXX

[MagicJack]
username=ENXXNXXXXXX01
authuser=ENXXNXXXXXX01
type=friend
secret=MY20CHARPASSWORD
qualify=2000
port=5070
insecure=port,invite
host=proxy01.boston.talk4free.com
fromuser=ENXXNXXXXXX01
useragent=MagicJack/1.80.499b (SJ Labs)
context=from-trunk
disallow=all
allow=ulaw
dtmfmode=rfc2833
nat=yes


Am I missing anything?
Is there a better way to obtain the sip password than Passwordfinder 2.2? I'm using the only one it came up with.... Passwordfinder 2.1 came up with a few other possibilities, but I tried all of them, also with no success.
I don't see a thing wrong with your settings. In fact I copied them exactly and substituted my # and PW and can verify they work.

I am sure it is just the way you represented the register string but of coarse it would not really include the "register=" as a part of it.

Did the patch, recompile and copying files etc. go ok?

Which version of Asterisk are you using?

You may want to setup a MJMD5 proxy and try using as softphone to register to test your credentials so you know they are correct.
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
CharlesNY
MagicJack Newbie
Posts: 1
Joined: Thu Oct 08, 2009 8:24 am

How did dtm get the new algorithm?

Post by CharlesNY »

MagicJack changed their SIP authentication to non-standard. But how did dtm figured out the new algorithm to calculate the new nonce which involves the call-ID.

Thank you dtm for sharing the algorithm otherwise I would never figure it out.

Thanks,
Charles
crackerjack
Dan Should Pay Me
Posts: 784
Joined: Fri Nov 16, 2007 9:32 pm

Re: How did dtm get the new algorithm?

Post by crackerjack »

CharlesNY wrote: how did dtm figured out the new algorithm to calculate the new nonce which involves the call-ID.
He found a 'bone' that was thrown his way.....

Crackerjack
Good Luck

CrackerJack

MagicJack Customer #73
MagicJack user since May 2007
MagicJack abuser since June 2007
"I gots mo' numbers than a Lotto machine!!!"
vicos
MagicJack Newbie
Posts: 5
Joined: Wed Sep 17, 2008 5:03 am

Post by vicos »

Any one have an Idea of why i get this output when patching chan_sip?

The text leading up to this was:
--------------------------
|--- 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
--------------------------
File to patch: channels/chan_sip.c
patching file channels/chan_sip.c
Hunk #1 succeeded at 8413 (offset -122 lines).
Hunk #2 FAILED at 11562.
1 out of 2 hunks FAILED -- saving rejects to file channels/chan_sip.c.rej

the command I run was : patch -l -p0 < chan_sip.patch

Thanks
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

vicos wrote:Any one have an Idea of why i get this output when patching chan_sip?

The text leading up to this was:
--------------------------
|--- 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
--------------------------
File to patch: channels/chan_sip.c
patching file channels/chan_sip.c
Hunk #1 succeeded at 8413 (offset -122 lines).
Hunk #2 FAILED at 11562.
1 out of 2 hunks FAILED -- saving rejects to file channels/chan_sip.c.rej

the command I run was : patch -l -p0 < chan_sip.patch

Thanks
Are you sure the version of Asterisk your patching is the same as the one the patch is for?
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
vicos
MagicJack Newbie
Posts: 5
Joined: Wed Sep 17, 2008 5:03 am

Post by vicos »

well my version is plain asterisk 1.4.18.1 , don't know what the problem seems to be...


Thanks
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

vicos wrote:well my version is plain asterisk 1.4.18.1 , don't know what the problem seems to be...


Thanks
And what patch did you use?
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
vicos
MagicJack Newbie
Posts: 5
Joined: Wed Sep 17, 2008 5:03 am

Post by vicos »

Well, I used the one in the first page, would the one in the bottom of the page work for me?


Thanks
VaHam
Dan Should Pay Me
Posts: 851
Joined: Wed Feb 13, 2008 8:02 pm

Post by VaHam »

vicos wrote:Well, I used the one in the first page, would the one in the bottom of the page work for me?


Thanks
Thats why I asked with the version your using I think neither match. You may want to try manually editing the source yourself for your version instead of using the patch. But you could try the one at the bottom and see if it gives you errors.
Sad Times Ahead for this Obamanation !!!! Psalms 109:8
Post Reply