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);
+}
diff --git a/lib/network.h b/lib/network.h
index 4d9c228..0fcb575 100644
--- a/lib/network.h
+++ b/lib/network.h
@@ -37,4 +37,7 @@
 #define ERRNO_IO_RETRY(EN) \
 	(((EN) == EAGAIN) || ((EN) == EWOULDBLOCK) || ((EN) == EINTR))
 
+extern float htonf (float);
+extern float ntohf (float);
+
 #endif /* _ZEBRA_NETWORK_H */
diff --git a/ospfd/ospf_opaque.c b/ospfd/ospf_opaque.c
index 697655d..988a2e5 100644
--- a/ospfd/ospf_opaque.c
+++ b/ospfd/ospf_opaque.c
@@ -2138,28 +2138,6 @@
  * Followings are util functions; probably be used by Opaque-LSAs only...
  *------------------------------------------------------------------------*/
 
-void
-htonf (float *src, float *dst)
-{
-  u_int32_t lu1, lu2;
-
-  memcpy (&lu1, src, sizeof (u_int32_t));
-  lu2 = htonl (lu1);
-  memcpy (dst, &lu2, sizeof (u_int32_t));
-  return;
-}
-
-void
-ntohf (float *src, float *dst)
-{
-  u_int32_t lu1, lu2;
-
-  memcpy (&lu1, src, sizeof (u_int32_t));
-  lu2 = ntohl (lu1);
-  memcpy (dst, &lu2, sizeof (u_int32_t));
-  return;
-}
-
 struct ospf *
 oi_to_top (struct ospf_interface *oi)
 {
diff --git a/ospfd/ospf_opaque.h b/ospfd/ospf_opaque.h
index b9490a0..2affa91 100644
--- a/ospfd/ospf_opaque.h
+++ b/ospfd/ospf_opaque.h
@@ -137,8 +137,6 @@
 extern void ospf_opaque_self_originated_lsa_received (struct ospf_neighbor
 						      *nbr,
 						      struct ospf_lsa *lsa);
-extern void htonf (float *src, float *dst);
-extern void ntohf (float *src, float *dst);
 extern struct ospf *oi_to_top (struct ospf_interface *oi);
 
 #endif /* _ZEBRA_OSPF_OPAQUE_H */
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 125a46f..e750933 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -38,6 +38,7 @@
 #include "thread.h"
 #include "hash.h"
 #include "sockunion.h"		/* for inet_aton() */
+#include "network.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_interface.h"
@@ -451,30 +452,30 @@
 }
 
 static void
-set_linkparams_max_bw (struct mpls_te_link *lp, float *fp)
+set_linkparams_max_bw (struct mpls_te_link *lp, float fp)
 {
   lp->max_bw.header.type   = htons (TE_LINK_SUBTLV_MAX_BW);
   lp->max_bw.header.length = htons (sizeof (lp->max_bw.value));
-  htonf (fp, &lp->max_bw.value);
+  lp->max_bw.value = htonf (fp);
   return;
 }
 
 static void
-set_linkparams_max_rsv_bw (struct mpls_te_link *lp, float *fp)
+set_linkparams_max_rsv_bw (struct mpls_te_link *lp, float fp)
 {
   lp->max_rsv_bw.header.type   = htons (TE_LINK_SUBTLV_MAX_RSV_BW);
   lp->max_rsv_bw.header.length = htons (sizeof (lp->max_rsv_bw.value));
-  htonf (fp, &lp->max_rsv_bw.value);
+  lp->max_rsv_bw.value = htonf (fp);
   return;
 }
 
 static void
-set_linkparams_unrsv_bw (struct mpls_te_link *lp, int priority, float *fp)
+set_linkparams_unrsv_bw (struct mpls_te_link *lp, int priority, float fp)
 {
   /* Note that TLV-length field is the size of array. */
   lp->unrsv_bw.header.type   = htons (TE_LINK_SUBTLV_UNRSV_BW);
   lp->unrsv_bw.header.length = htons (sizeof (lp->unrsv_bw.value));
-  htonf (fp, &lp->unrsv_bw.value [priority]);
+  lp->unrsv_bw.value [priority] = htonf (fp);
   return;
 }
 
@@ -511,11 +512,11 @@
   fval = (float)((ifp->bandwidth ? ifp->bandwidth
                                  : OSPF_DEFAULT_BANDWIDTH) * 1000 / 8);
 
-  set_linkparams_max_bw (lp, &fval);
-  set_linkparams_max_rsv_bw (lp, &fval);
+  set_linkparams_max_bw (lp, fval);
+  set_linkparams_max_rsv_bw (lp, fval);
 
   for (i = 0; i < 8; i++)
-    set_linkparams_unrsv_bw (lp, i, &fval);
+    set_linkparams_unrsv_bw (lp, i, fval);
 
   return;
 }
@@ -1246,7 +1247,7 @@
   float fval;
 
   top = (struct te_link_subtlv_max_bw *) tlvh;
-  ntohf (&top->value, &fval);
+  fval = ntohf (top->value);
 
   if (vty != NULL)
     vty_out (vty, "  Maximum Bandwidth: %g (Bytes/sec)%s", fval, VTY_NEWLINE);
@@ -1263,7 +1264,7 @@
   float fval;
 
   top = (struct te_link_subtlv_max_rsv_bw *) tlvh;
-  ntohf (&top->value, &fval);
+  fval = ntohf (top->value);
 
   if (vty != NULL)
     vty_out (vty, "  Maximum Reservable Bandwidth: %g (Bytes/sec)%s", fval, VTY_NEWLINE);
@@ -1283,7 +1284,7 @@
   top = (struct te_link_subtlv_unrsv_bw *) tlvh;
   for (i = 0; i < 8; i++)
     {
-      ntohf (&top->value[i], &fval);
+      fval = ntohf (top->value[i]);
       if (vty != NULL)
         vty_out (vty, "  Unreserved Bandwidth (pri %d): %g (Bytes/sec)%s", i, fval, VTY_NEWLINE);
       else
@@ -1434,17 +1435,17 @@
       vty_out (vty, " mpls-te link metric %u%s",
                (u_int32_t) ntohl (lp->te_metric.value), VTY_NEWLINE);
 
-      ntohf (&lp->max_bw.value, &fval);
+      fval = ntohf (lp->max_bw.value);
       if (fval >= MPLS_TE_MINIMUM_BANDWIDTH)
         vty_out (vty, " mpls-te link max-bw %g%s", fval, VTY_NEWLINE);
 
-      ntohf (&lp->max_rsv_bw.value, &fval);
+      fval = ntohf (lp->max_rsv_bw.value);
       if (fval >= MPLS_TE_MINIMUM_BANDWIDTH)
         vty_out (vty, " mpls-te link max-rsv-bw %g%s", fval, VTY_NEWLINE);
 
       for (i = 0; i < 8; i++)
         {
-          ntohf (&lp->unrsv_bw.value[i], &fval);
+          fval = ntohf (lp->unrsv_bw.value[i]);
           if (fval >= MPLS_TE_MINIMUM_BANDWIDTH)
             vty_out (vty, " mpls-te link unrsv-bw %d %g%s",
                      i, fval, VTY_NEWLINE);
@@ -1637,7 +1638,7 @@
       return CMD_WARNING;
     }
 
-  ntohf (&lp->max_bw.value, &f1);
+  f1 = ntohf (lp->max_bw.value);
   if (sscanf (argv[0], "%g", &f2) != 1)
     {
       vty_out (vty, "mpls_te_link_maxbw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
@@ -1647,7 +1648,7 @@
   if (ntohs (lp->max_bw.header.type) == 0
   ||  f1 != f2)
     {
-      set_linkparams_max_bw (lp, &f2);
+      set_linkparams_max_bw (lp, f2);
 
       if (OspfMplsTE.status == enabled)
         if (lp->area != NULL)
@@ -1679,7 +1680,7 @@
       return CMD_WARNING;
     }
 
-  ntohf (&lp->max_rsv_bw.value, &f1);
+  f1 = ntohf (lp->max_rsv_bw.value);
   if (sscanf (argv[0], "%g", &f2) != 1)
     {
       vty_out (vty, "mpls_te_link_max_rsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
@@ -1689,7 +1690,7 @@
   if (ntohs (lp->max_rsv_bw.header.type) == 0
   ||  f1 != f2)
     {
-      set_linkparams_max_rsv_bw (lp, &f2);
+      set_linkparams_max_rsv_bw (lp, f2);
 
       if (OspfMplsTE.status == enabled)
         if (lp->area != NULL)
@@ -1730,7 +1731,7 @@
       return CMD_WARNING;
     }
 
-  ntohf (&lp->unrsv_bw.value [priority], &f1);
+  f1 = ntohf (lp->unrsv_bw.value [priority]);
   if (sscanf (argv[1], "%g", &f2) != 1)
     {
       vty_out (vty, "mpls_te_link_unrsv_bw: fscanf: %s%s", safe_strerror (errno), VTY_NEWLINE);
@@ -1740,7 +1741,7 @@
   if (ntohs (lp->unrsv_bw.header.type) == 0
   ||  f1 != f2)
     {
-      set_linkparams_unrsv_bw (lp, priority, &f2);
+      set_linkparams_unrsv_bw (lp, priority, f2);
 
       if (OspfMplsTE.status == enabled)
         if (lp->area != NULL)