[Asterisk-Dev] Patch: SIP bindaddr not always used
Mark Spencer
markster at digium.com
Tue May 13 14:21:27 MST 2003
Another is that there are severl places this is used. Since __ourip is
copied from bindaddr, perhaps we should simply reverse the logic, along th
elines if if (__ourip.sin_addr) else...
Mark
On Tue, 13 May 2003, Tilghman Lesher wrote:
> On Tuesday 13 May 2003 02:07 pm, matt at overloaded.net wrote:
> --- channels/chan_sip.c.default 2003-05-12 18:26:50.000000000 -0400
> +++ channels/chan_sip.c 2003-05-12 20:24:26.000000000 -0400
> @@ -1276,7 +1276,9 @@
> #endif
> if (sin) {
> memcpy(&p->sa, sin, sizeof(p->sa));
> - if (ast_ouraddrfor(&p->sa.sin_addr,&p->ourip))
> + if (&bindaddr)
> + memcpy(&p->ourip, &bindaddr.sin_addr, sizeof(p->ourip));
> + else if (ast_ouraddrfor(&p->sa.sin_addr,&p->ourip))
> memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
> } else {
> memcpy(&p->ourip, &__ourip, sizeof(p->ourip));
>
>
> There is a slight problem with the patch: the address of anything is
> true in C (because nothing is ever allowed to be located at memory
> location 0). Therefore, the second condition will never be evaluated.
>
> Instead, try:
> + if (bindaddr.sin_addr)
>
> This presumes that nobody will ever have an IPv4 address in the
> range 0.0.0.1-0.255.255.255 (fairly reasonable assumption, I think).
>
> -Tilghman
>
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
More information about the asterisk-dev
mailing list