[Asterisk-Dev] Re: Asterisk-Dev digest, Vol 1 #199 - 1 msg

Jose Ildefonso Camargo Tolosa icamargo at unet.edu.ve
Tue Jul 29 06:22:25 MST 2003


Hi!

Ok, I'll comment.

>From: "Sergey S. Stasyuk" <stas at onlineua.net>
>To: asterisk-dev at lists.digium.com
>Date: 22 Jul 2003 21:08:03 +0300
>Subject: [Asterisk-Dev] chan_sip.c patch
>Reply-To: asterisk-dev at lists.digium.com
>
>Hi all!
>I have already written that there are some problems with chan sip on my
>machine. Problem is because of incorrect copy of bindaddr to __ourip
>instead of bindaddr.sin_addr. I wonder why this problems are only on my
>machine?
>

I have had some weird problems with SIP too, but I had not time to take 
a look at it.

I also had problems with alsa, with version 0.9.4. I made a patch, and 
send it to Mark, no answer this far.  I have noticed in the style of 
programming that they often use the value of a constant instead of the 
constant's name, and sometimes they do the same with data types.

I made some comments on the patch.

>I awfully sorry of reposting same message, but would be at least any
>comments on this diff?
>
>Best regards,
>Sergey Stasyuk
>
>================== Cut here ==============================
>diff -u -r1.132 chan_sip.c
>--- chan_sip.c  17 Jul 2003 18:49:05 -0000      1.132
>+++ chan_sip.c  22 Jul 2003 18:26:24 -0000
>@@ -456,7 +456,7 @@
>        pkt->seqno = seqno;
>        pkt->resp = resp;
>        /* Schedule retransmission */
>-       pkt->retransid = ast_sched_add(sched, 1000, retrans_pkt, pkt);
>+       pkt->retransid = ast_sched_add(sched, DEFAULT_RETRANS,
>retrans_pkt, pkt);
>

The typical "use value instead of constant's name".

>        pkt->next = p->packets;
>        p->packets = pkt;
>        __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
>@@ -5512,7 +5512,7 @@
>        }
>  
>        if (ntohl(bindaddr.sin_addr.s_addr)) {
>-               memcpy(&__ourip, &bindaddr, sizeof(__ourip));
>+               memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip));
>

The problem can be the ordening of data members on the structure, the 
"-" line copy the first sizeof(__ourip) bytes from binaddr, wich happend 
to be sin_addr in almost every system, maybe in yours the ordening is 
different, your patch make it independent of the position of the 
sin_addr member inside the structure.

>        } else {
>                hp = gethostbyname(ourhost);
>                if (!hp) {
>
>  
>

Hope this help,

Sincerely,

Ildefonso Camargo
Network Administrator - UNET
icamargo at unet.edu.ve
ildefonso_camargo at yahoo.com





More information about the asterisk-dev mailing list