OSPF endianess fix

Rani Assaf rani at paname.org
Tue Sep 2 04:49:18 CEST 2003


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.

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 {




More information about the Bird-users mailing list