OSPF endianess fix

Martin Mares mj at ucw.cz
Sat Sep 6 11:44:24 CEST 2003


Hello!

> 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).

| +#ifdef CPU_LITTLE_ENDIAN
|    chsum= x + (y << 8);
| +#else
| +  chsum= y + (x << 8);
| +#endif
|   h->checksum = chsum;

Yes, htons should be here.

| +#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
|  };

I don't really understand this piece -- either it's a piece of packet as seen
on the wire and then it must not depend on CPU endianity or it's already
converted to host order somewhere else and then the conversion is wrong.
I'd understand such a construction if it were in a union with a longer integer
field, but it doesn't seem to be the case here.

				Have a nice fortnight
-- 
Martin `MJ' Mares   <mj at ucw.cz>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Weather forecast for tonight: dark.



More information about the Bird-users mailing list