[Olsr-dev] Strange shift behaviour (ipcalc.c)

Alina Friedrichsen (spam-protected)
Sun Nov 30 06:10:47 CET 2008


Hello Markus!

> therefore a patch like following is really required for ipcalc.c
> .
> --- ../../olsrd-54b2ca51a0b1/src/ipcalc.c 2008-11-28 10:00:21.000000000
> +0100
> +++ ipcalc.c 2008-11-30 03:30:09.000000000 +0100
> @@ -119,8 +119,12 @@
>  {
>   int rv;
>   if(olsr_cnf->ip_version == AF_INET) {
> - uint32_t netmask = ntohl(~0 << (32 - net->prefix_len));
> - rv = (ipaddr->v4.s_addr & netmask) == (net->prefix.v4.s_addr & netmask);
> + if (net->prefix_len < 1) {
> + rv = true;
> + } else {
> + uint32_t netmask = ~0 << (32 - net->prefix_len);
> + rv = (ipaddr->v4.s_addr & netmask) == (net->prefix.v4.s_addr & netmask);
> + }
>   } else {
>   /* IPv6 */
>   uint32_t netmask;

Removing ntohl() will break the code on little endian machines.

Regards
Alina

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

-- 
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger




More information about the Olsr-dev mailing list