OSPF endianess fix

David Rohleder davro at ics.muni.cz
Fri Sep 5 16:26:04 CEST 2003


Rani Assaf <rani at paname.org> writes:

> Hello,
>
> The attached  patch fixes two  (big-)endianess issues in OSPF  which lead
> bird to stuck in EXSTART state.
>
> Patch tested on a PPC machine against a Cisco router.

I think that preffered way would be to use correct ntoh(3) library
call while receiving LSA packet. Still doesn't matter, because BIRD
doesn't support multiple OSPF areas :-( (as far as i know).


>
> Regards,
> Rani
>
> diff -ru bird-1.0.7/proto/ospf/lsalib.c bird-1.0.7-debian/proto/ospf/lsalib.c
> --- bird-1.0.7/proto/ospf/lsalib.c	2003-08-14 10:13:14.000000000 +0200
> +++ bird-1.0.7-debian/proto/ospf/lsalib.c	2003-09-02 03:54:22.000000000 +0200
> @@ -7,6 +7,7 @@
>   */
>  
>  #include "ospf.h"
> +#include <stdlib.h>
>  
>  void
>  flush_lsa(struct top_hash_entry *en, struct ospf_area *oa)
> @@ -376,7 +377,11 @@
>    y = 510 - c0 - x;
>    if (y > 255) y -= 255;
>  
> +#ifdef CPU_LITTLE_ENDIAN
>    chsum= x + (y << 8);
> +#else
> +  chsum= y + (x << 8);
> +#endif
>    h->checksum = chsum;
>    return chsum;
>  }
> diff -ru bird-1.0.7/proto/ospf/ospf.h bird-1.0.7-debian/proto/ospf/ospf.h
> --- bird-1.0.7/proto/ospf/ospf.h	2003-08-14 10:13:14.000000000 +0200
> +++ bird-1.0.7-debian/proto/ospf/ospf.h	2003-09-02 03:14:10.000000000 +0200
> @@ -178,10 +178,17 @@
>  };
>  
>  struct immsb {
> +#ifdef CPU_LITTLE_ENDIAN
>    u8 ms:1;
>    u8 m:1;
>    u8 i:1;
>    u8 padding:5;
> +#else
> +  u8 padding:5;
> +  u8 i:1;
> +  u8 m:1;
> +  u8 ms:1;
> +#endif
>  };
>  
>  union imms {
> @@ -223,10 +230,17 @@
>  };
>  
>  struct vebb {
> +#ifdef CPU_LITTLE_ENDIAN
>    u8 b:1;
>    u8 e:1;
>    u8 v:1;
>    u8 padding:5;
> +#else
> +  u8 padding:5;
> +  u8 v:1;
> +  u8 e:1;
> +  u8 b:1;
> +#endif
>  };
>  
>  union veb {
>
>

-- 
-------------------------------------------------------------------------
David Rohleder						davro at ics.muni.cz
Institute of Computer Science, Masaryk University
Brno, Czech Republic
-------------------------------------------------------------------------



More information about the Bird-users mailing list