lib: consolidate ntohf/htonf from ospfd/isisd TE to lib/network
* lib/network.{c,h}: Consolidate the ntohf/htonf functions used in ospfd
TE to here, using the value-passing variant that fits with existing
ntoh/hton functions.
* ospfd/ospf_opaque.c: Remove its variants.
* ospfd/ospf_te.c: Update to use the consolidated, by-value variant.
diff --git a/lib/network.c b/lib/network.c
index 3373983..b81d5f8 100644
--- a/lib/network.c
+++ b/lib/network.c
@@ -93,3 +93,25 @@
}
return 0;
}
+
+float
+htonf (float host)
+{
+#ifdef __STDC_IEC_559__
+ u_int32_t lu1, lu2;
+ float convert;
+
+ memcpy (&lu1, &host, sizeof (u_int32_t));
+ lu2 = htonl (lu1);
+ memcpy (&convert, &lu2, sizeof (u_int32_t));
+ return convert;
+#else
+#error "Please supply htonf implementation for this platform"
+#endif
+}
+
+float
+ntohf (float net)
+{
+ return htonf (net);
+}