From c15e569065e80f91b4c9c77b86640aac72aa0a47 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Tue, 8 Sep 2009 17:06:47 +0200 Subject: Make endianity swapping simpler. --- proto/ospf/ospf.h | 75 +++++++++++++++++-------------------------------------- 1 file changed, 23 insertions(+), 52 deletions(-) (limited to 'proto/ospf/ospf.h') diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h index 4bcb7a0..d85ebdc 100644 --- a/proto/ospf/ospf.h +++ b/proto/ospf/ospf.h @@ -389,17 +389,28 @@ struct ospf_lsa_header struct ospf_lsa_rt { +#ifdef CPU_BIG_ENDIAN u16 options; /* VEB flags only */ u16 links; +#else + u16 links; + u16 options; /* VEB flags only */ +#endif }; struct ospf_lsa_rt_link { u32 id; u32 data; +#ifdef CPU_BIG_ENDIAN u8 type; - u8 notos; + u8 padding; u16 metric; +#else + u16 metric; + u8 padding; + u8 type; +#endif }; struct ospf_lsa_net @@ -438,9 +449,15 @@ struct ospf_lsa_rt struct ospf_lsa_rt_link { +#ifdef CPU_BIG_ENDIAN u8 type; u8 padding; u16 metric; +#else + u16 metric; + u8 padding; + u8 type; +#endif u32 lif; /* Local interface ID */ u32 nif; /* Neighbor interface ID */ u32 id; /* Neighbor router ID */ @@ -481,8 +498,13 @@ struct ospf_lsa_link struct ospf_lsa_prefix { +#ifdef CPU_BIG_ENDIAN u16 pxcount; u16 ref_type; +#else + u16 ref_type; + u16 pxcount; +#endif u32 ref_id; u32 ref_rt; u32 rest[]; @@ -514,57 +536,6 @@ static inline unsigned lsa_net_count(struct ospf_lsa_header *lsa) } -/* -struct ospf_lsa_ext_etos -{ -#ifdef CPU_BIG_ENDIAN - u8 ebit:1; - u8 tos:7; - u8 padding1; - u16 padding2; -#else - u16 padding2; - u8 padding1; - u8 tos:7; - u8 ebit:1; -#endif -}; - - -struct ospf_lsa_sum_tos -{ -#ifdef CPU_BIG_ENDIAN - u8 tos; - u8 padding1; - u16 padding2; -#else - u16 padding2; - u8 padding1; - u8 tos; -#endif -}; - -union ospf_lsa_sum_tm -{ - struct ospf_lsa_sum_tos tos; - u32 metric; -}; - -union ospf_lsa_ext_etm -{ - struct ospf_lsa_ext_etos etos; - u32 metric; -}; - -struct ospf_lsa_ext_tos -{ - union ospf_lsa_ext_etm etm; - ip_addr fwaddr; - u32 tag; -}; - -*/ - struct ospf_lsreq_header { u32 type; -- cgit v1.2.3