Add the network utility file

Moving utility functions from network manager to
util.cpp.

Added few more utility functions.

Change-Id: I2e73c873e9a3bea543d6979463b2181e8374e12e
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/util.hpp b/util.hpp
new file mode 100644
index 0000000..c305724
--- /dev/null
+++ b/util.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <unistd.h>
+
+namespace phosphor
+{
+namespace network
+{
+
+/* @brief converts the given subnet into prefix notation.
+ * @param[in] addressFamily - IP address family(AF_INET/AF_INET6).
+ * @param[in] mask - Subnet Mask.
+ * @returns prefix.
+ */
+uint8_t toCidr(int addressFamily, const std::string& mask);
+
+/* @brief converts the prefix into subnetmask.
+ * @param[in] addressFamily - IP address family(AF_INET/AF_INET6).
+ * @param[in] prefix - prefix length.
+ * @returns subnet mask.
+ */
+std::string toMask(int addressFamily, uint8_t prefix);
+
+/* @brief checks that the given ip address is link local or not.
+ * @param[in] address - IP address.
+ * @returns true if it is linklocal otherwise false.
+ */
+bool isLinkLocal(const std::string& address);
+
+} //namespace network
+
+class Descriptor
+{
+    private:
+        /** default value */
+        int fd = -1;
+
+    public:
+        Descriptor() = delete;
+        Descriptor(const Descriptor&) = delete;
+        Descriptor& operator=(const Descriptor&) = delete;
+        Descriptor(Descriptor&&) = delete;
+        Descriptor& operator=(Descriptor&&) = delete;
+
+        Descriptor(int fd) : fd(fd) {}
+
+        ~Descriptor()
+        {
+            if (fd >= 0)
+            {
+                close(fd);
+            }
+        }
+
+        int operator()() const
+        {
+            return fd;
+        }
+};
+
+} //namespace phosphor