add clang-format to repo for style

Add .clang-format to repo for style.

Change-Id: I286b3b245550d6a736d7df797f0ce21b51d7a235
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..ea71ad6
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,99 @@
+---
+Language:        Cpp
+# BasedOnStyle:  LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands:   true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: true
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+  AfterClass:      true
+  AfterControlStatement: true
+  AfterEnum:       true
+  AfterFunction:   true
+  AfterNamespace:  true
+  AfterObjCDeclaration: true
+  AfterStruct:     true
+  AfterUnion:      true
+  BeforeCatch:     true
+  BeforeElse:      true
+  IndentBraces:    false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: AfterColon
+ColumnLimit:     80
+CommentPragmas:  '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+PointerAlignment: Left
+DisableFormat:   false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeBlocks: Regroup
+IncludeCategories:
+  - Regex:           '^[<"](gtest|gmock)'
+    Priority:        5
+  - Regex:           '^"config.h"'
+    Priority:        -1
+  - Regex:           '^".*\.hpp"'
+    Priority:        1
+  - Regex:           '^<.*\.h>'
+    Priority:        2
+  - Regex:           '^<.*'
+    Priority:        3
+  - Regex:           '.*'
+    Priority:        4
+IndentCaseLabels: true
+IndentWidth:     4
+IndentWrappedFunctionNames: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd:   ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+ReflowComments:  true
+SortIncludes:    true
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles:  false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard:        Cpp11
+TabWidth:        4
+UseTab:          Never
+...
+
diff --git a/endian.hpp b/endian.hpp
index 284fd03..5597a0b 100644
--- a/endian.hpp
+++ b/endian.hpp
@@ -14,7 +14,8 @@
     static T from_network(T) = delete;
 };
 
-template<> struct convert<uint16_t>
+template <>
+struct convert<uint16_t>
 {
     static uint16_t to_network(uint16_t i)
     {
@@ -26,7 +27,8 @@
     };
 };
 
-template<> struct convert<uint32_t>
+template <>
+struct convert<uint32_t>
 {
     static uint32_t to_network(uint32_t i)
     {
@@ -37,13 +39,15 @@
         return be32toh(i);
     };
 };
-}
-template<typename T> T to_network(T i)
+} // namespace details
+template <typename T>
+T to_network(T i)
 {
     return details::convert<T>::to_network(i);
 }
-template<typename T> T from_network(T i)
+template <typename T>
+T from_network(T i)
 {
     return details::convert<T>::from_network(i);
 }
-}
+} // namespace endian
diff --git a/main.cpp b/main.cpp
index c580adc..6a5aaac 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,11 +1,10 @@
-#include <algorithm>
-#include <iomanip>
-
 #include "slp.hpp"
 #include "slp_meta.hpp"
 #include "slp_server.hpp"
 #include "sock_channel.hpp"
 
+#include <algorithm>
+#include <iomanip>
 
 /* Call Back for the sd event loop */
 static int requestHandler(sd_event_source* es, int fd, uint32_t revents,
@@ -30,25 +29,25 @@
     {
         case slp::VERSION_2:
         {
-            //Parse the buffer and construct the req object
+            // Parse the buffer and construct the req object
             std::tie(rc, req) = slp::parser::parseBuffer(recvBuff);
             if (!rc)
             {
-                //Passing the req object to handler to serve it
+                // Passing the req object to handler to serve it
                 std::tie(rc, resp) = slp::handler::processRequest(req);
             }
             break;
         }
         default:
-            std::cout << "SLP Unsupported Request Version="
-                      << (int)recvBuff[0] <<"\n";
+            std::cout << "SLP Unsupported Request Version=" << (int)recvBuff[0]
+                      << "\n";
 
             rc = static_cast<uint8_t>(slp::Error::VER_NOT_SUPPORTED);
             break;
     }
 
-    //if there was error during Parsing of request
-    //or processing of request then handle the error.
+    // if there was error during Parsing of request
+    // or processing of request then handle the error.
     if (rc)
     {
         resp = slp::handler::processError(req, rc);
@@ -58,7 +57,6 @@
     return slp::SUCCESS;
 }
 
-
 int main(int argc, char* argv[])
 {
     slp::udp::Server svr(slp::PORT, requestHandler);
diff --git a/slp.hpp b/slp.hpp
index fa8aad6..3e6d968 100644
--- a/slp.hpp
+++ b/slp.hpp
@@ -1,5 +1,7 @@
 #pragma once
 
+#include "slp_service_info.hpp"
+
 #include <stdio.h>
 
 #include <array>
@@ -11,14 +13,12 @@
 #include <tuple>
 #include <vector>
 
-#include "slp_service_info.hpp"
-
 namespace slp
 {
 
 using buffer = std::vector<uint8_t>;
 
-template<typename T>
+template <typename T>
 using deleted_unique_ptr = std::unique_ptr<T, std::function<void(T*)>>;
 
 namespace request
@@ -49,7 +49,7 @@
     std::string predicate;
     std::string spistr;
 };
-}//namespace request
+} // namespace request
 
 /*
  * @enum FunctionType
@@ -58,13 +58,13 @@
  */
 enum class FunctionType : uint8_t
 {
-    SRVRQST     = 0x01,
-    SRVRPLY     = 0x02,
-    ATTRRQST    = 0x06,
-    ATTRRPLY    = 0x07,
+    SRVRQST = 0x01,
+    SRVRPLY = 0x02,
+    ATTRRQST = 0x06,
+    ATTRRPLY = 0x07,
     SRVTYPERQST = 0x09,
     SRVTYPERPLY = 0x0A,
-    SAADV       = 0x0B,
+    SAADV = 0x0B,
 };
 
 /*
@@ -75,18 +75,18 @@
 enum class Error : uint8_t
 {
     LANGUAGE_NOT_SUPPORTED = 0x01,
-    PARSE_ERROR            = 0x02,
-    INVALID_REGISTRATION   = 0x03,
-    SCOPE_NOT_SUPPORTED    = 0x04,
+    PARSE_ERROR = 0x02,
+    INVALID_REGISTRATION = 0x03,
+    SCOPE_NOT_SUPPORTED = 0x04,
     AUTHENTICATION_UNKNOWN = 0x05,
-    AUTHENTICATION_ABSENT  = 0x06,
-    AUTHENTICATION_FAILED  = 0x07,
-    VER_NOT_SUPPORTED      = 0x09,
-    INTERNAL_ERROR         = 0x0A,
-    DA_BUSY_NOW            = 0x0B,
-    OPTION_NOT_UNDERSTOOD  = 0x0C,
-    INVALID_UPDATE         = 0x0D,
-    MSG_NOT_SUPPORTED      = 0x0E,
+    AUTHENTICATION_ABSENT = 0x06,
+    AUTHENTICATION_FAILED = 0x07,
+    VER_NOT_SUPPORTED = 0x09,
+    INTERNAL_ERROR = 0x0A,
+    DA_BUSY_NOW = 0x0B,
+    OPTION_NOT_UNDERSTOOD = 0x0C,
+    INVALID_UPDATE = 0x0D,
+    MSG_NOT_SUPPORTED = 0x0E,
 };
 
 /*
@@ -104,7 +104,6 @@
     uint16_t xid = 0;
     uint16_t langtagLen = 0;
     std::string langtag;
-
 };
 
 /*
@@ -119,7 +118,6 @@
     request::Service srvrqst;
 };
 
-
 /*
  * @struct Message
  *
@@ -131,7 +129,6 @@
     Payload body;
 };
 
-
 namespace parser
 {
 
@@ -174,20 +171,19 @@
 int parseSrvTypeRqst(const buffer& buf, Message& req);
 
 /** Parse a service request.
-  *
-  * @param[in] buffer - The buffer from which data should be parsed.
-  *
-  * @return Zero on success,and fills the body object inside message.
-  *         non-zero on failure and empty msg object.
-  *
-  * @internal
-  */
+ *
+ * @param[in] buffer - The buffer from which data should be parsed.
+ *
+ * @return Zero on success,and fills the body object inside message.
+ *         non-zero on failure and empty msg object.
+ *
+ * @internal
+ */
 
 int parseSrvRqst(const buffer& buf, Message& req);
 
-}//namespace internal
-}//namespce parser
-
+} // namespace internal
+} // namespace parser
 
 namespace handler
 {
@@ -212,8 +208,7 @@
  * @return the vector populated with the error data
  */
 
-buffer processError(const Message& req,
-                    const uint8_t err);
+buffer processError(const Message& req, const uint8_t err);
 namespace internal
 {
 
@@ -231,7 +226,6 @@
 
 std::tuple<int, buffer> processSrvRequest(const Message& msg);
 
-
 /** Handle the  SrvTypeRequest message.
  *
  * @param[in] msg - The message to process
@@ -277,7 +271,6 @@
  */
 buffer prepareHeader(const Message& req);
 
-
-}//namespace internal
-}//namespce handler
-}//namespce slp
+} // namespace internal
+} // namespace handler
+} // namespace slp
diff --git a/slp_message_handler.cpp b/slp_message_handler.cpp
index 5125b29..a9b6ff0 100644
--- a/slp_message_handler.cpp
+++ b/slp_message_handler.cpp
@@ -1,4 +1,8 @@
+#include "config.h"
+
+#include "endian.hpp"
 #include "slp.hpp"
+#include "slp_meta.hpp"
 
 #include <arpa/inet.h>
 #include <dirent.h>
@@ -8,10 +12,6 @@
 
 #include <algorithm>
 
-#include "config.h"
-#include "endian.hpp"
-#include "slp_meta.hpp"
-
 namespace slp
 {
 namespace handler
@@ -22,52 +22,46 @@
 
 buffer prepareHeader(const Message& req)
 {
-    uint8_t length =  slp::header::MIN_LEN +   /* 14 bytes for header     */
-                      req.header.langtag.length() + /* Actual length of lang tag */
-                      slp::response::SIZE_ERROR; /*  2 bytes for error code */
+    uint8_t length =
+        slp::header::MIN_LEN +        /* 14 bytes for header     */
+        req.header.langtag.length() + /* Actual length of lang tag */
+        slp::response::SIZE_ERROR;    /*  2 bytes for error code */
 
     buffer buff(length, 0);
 
     buff[slp::header::OFFSET_VERSION] = req.header.version;
 
-    //will increment the function id from 1 as reply
+    // will increment the function id from 1 as reply
     buff[slp::header::OFFSET_FUNCTION] = req.header.functionID + 1;
 
     std::copy_n(&length, slp::header::SIZE_LENGTH,
-                buff.data() +
-                slp::header::OFFSET_LENGTH);
+                buff.data() + slp::header::OFFSET_LENGTH);
 
     auto flags = endian::to_network(req.header.flags);
 
     std::copy_n((uint8_t*)&flags, slp::header::SIZE_FLAGS,
-                buff.data() +
-                slp::header::OFFSET_FLAGS);
+                buff.data() + slp::header::OFFSET_FLAGS);
 
     std::copy_n(req.header.extOffset.data(), slp::header::SIZE_EXT,
-                buff.data() +
-                slp::header::OFFSET_EXT);
+                buff.data() + slp::header::OFFSET_EXT);
 
     auto xid = endian::to_network(req.header.xid);
 
     std::copy_n((uint8_t*)&xid, slp::header::SIZE_XID,
-                buff.data() +
-                slp::header::OFFSET_XID);
+                buff.data() + slp::header::OFFSET_XID);
 
     uint16_t langtagLen = req.header.langtag.length();
     langtagLen = endian::to_network(langtagLen);
     std::copy_n((uint8_t*)&langtagLen, slp::header::SIZE_LANG,
-                buff.data() +
-                slp::header::OFFSET_LANG_LEN);
+                buff.data() + slp::header::OFFSET_LANG_LEN);
 
-    std::copy_n((uint8_t*)req.header.langtag.c_str(), req.header.langtag.length(),
-                buff.data() +
-                slp::header::OFFSET_LANG);
+    std::copy_n((uint8_t*)req.header.langtag.c_str(),
+                req.header.langtag.length(),
+                buff.data() + slp::header::OFFSET_LANG);
     return buff;
-
 }
 
-std::tuple<int, buffer> processSrvTypeRequest(
-    const Message& req)
+std::tuple<int, buffer> processSrvTypeRequest(const Message& req)
 {
 
     /*
@@ -84,7 +78,7 @@
 
     buffer buff;
 
-    //read the slp service info from conf and create the service type string
+    // read the slp service info from conf and create the service type string
     slp::handler::internal::ServiceList svcList =
         slp::handler::internal::readSLPServiceInfo();
     if (svcList.size() <= 0)
@@ -97,19 +91,18 @@
     std::string service;
     bool firstIteration = true;
     for_each(svcList.cbegin(), svcList.cend(),
-             [&service, &firstIteration](const auto& svc)
-    {
-        if (firstIteration == true)
-        {
-            service = svc.first;
-            firstIteration = false;
-        }
-        else
-        {
-            service += ",";
-            service += svc.first;
-        }
-    });
+             [&service, &firstIteration](const auto& svc) {
+                 if (firstIteration == true)
+                 {
+                     service = svc.first;
+                     firstIteration = false;
+                 }
+                 else
+                 {
+                     service += ",";
+                     service += svc.first;
+                 }
+             });
 
     buff = prepareHeader(req);
 
@@ -118,17 +111,15 @@
 
     std::cout << "service=" << service.c_str() << "\n";
 
-    uint8_t length =  buff.size() +   /* 14 bytes header + length of langtag */
-                      slp::response::SIZE_ERROR +    /* 2 byte err code */
-                      slp::response::SIZE_SERVICE +  /* 2 byte srvtype len */
-                      service.length();
-
+    uint8_t length = buff.size() + /* 14 bytes header + length of langtag */
+                     slp::response::SIZE_ERROR +   /* 2 byte err code */
+                     slp::response::SIZE_SERVICE + /* 2 byte srvtype len */
+                     service.length();
 
     buff.resize(length);
 
     std::copy_n(&length, slp::header::SIZE_LENGTH,
-                buff.data() +
-                slp::header::OFFSET_LENGTH);
+                buff.data() + slp::header::OFFSET_LENGTH);
 
     /* error code is already set to 0 moving to service type len */
 
@@ -136,19 +127,16 @@
     serviceTypeLen = endian::to_network(serviceTypeLen);
 
     std::copy_n((uint8_t*)&serviceTypeLen, slp::response::SIZE_SERVICE,
-                buff.data() +
-                slp::response::OFFSET_SERVICE_LEN);
+                buff.data() + slp::response::OFFSET_SERVICE_LEN);
 
     /* service type data */
     std::copy_n((uint8_t*)service.c_str(), service.length(),
-                (buff.data() +
-                 slp::response::OFFSET_SERVICE));
+                (buff.data() + slp::response::OFFSET_SERVICE));
 
     return std::make_tuple(slp::SUCCESS, buff);
 }
 
-std::tuple<int, buffer> processSrvRequest(
-    const Message& req)
+std::tuple<int, buffer> processSrvRequest(const Message& req)
 {
 
     /*
@@ -176,7 +164,7 @@
     */
 
     buffer buff;
-    //Get all the services which are registered
+    // Get all the services which are registered
     slp::handler::internal::ServiceList svcList =
         slp::handler::internal::readSLPServiceInfo();
     if (svcList.size() <= 0)
@@ -186,7 +174,7 @@
         return std::make_tuple((int)slp::Error::INTERNAL_ERROR, buff);
     }
 
-    //return error if serice type doesn't match
+    // return error if serice type doesn't match
     auto& svcName = req.body.srvrqst.srvType;
     auto svcIt = svcList.find(svcName);
     if (svcIt == svcList.end())
@@ -195,7 +183,7 @@
         std::cerr << "SLP unable to find the service=" << svcName << "\n";
         return std::make_tuple((int)slp::Error::INTERNAL_ERROR, buff);
     }
-    //Get all the interface address
+    // Get all the interface address
     auto ifaddrList = slp::handler::internal::getIntfAddrs();
     if (ifaddrList.size() <= 0)
     {
@@ -205,34 +193,30 @@
     }
 
     buff = prepareHeader(req);
-    //Calculate the length and resize the buffer
-    uint8_t length =  buff.size() + /* 14 bytes header + length of langtag */
-                      slp::response::SIZE_ERROR +    /* 2 bytes error code */
-                      slp::response::SIZE_URL_COUNT; /* 2 bytes srvtype len */
+    // Calculate the length and resize the buffer
+    uint8_t length = buff.size() + /* 14 bytes header + length of langtag */
+                     slp::response::SIZE_ERROR +    /* 2 bytes error code */
+                     slp::response::SIZE_URL_COUNT; /* 2 bytes srvtype len */
 
     buff.resize(length);
 
-    //Populate the url count
+    // Populate the url count
     uint16_t urlCount = ifaddrList.size();
     urlCount = endian::to_network(urlCount);
 
     std::copy_n((uint8_t*)&urlCount, slp::response::SIZE_URL_COUNT,
-                buff.data() +
-                slp::response::OFFSET_URL_ENTRY);
+                buff.data() + slp::response::OFFSET_URL_ENTRY);
 
-    //Find the service
+    // Find the service
     const slp::ConfigData& svc = svcIt->second;
-    //Populate the URL Entries
+    // Populate the URL Entries
     auto pos = slp::response::OFFSET_URL_ENTRY + slp::response::SIZE_URL_COUNT;
     for (const auto& addr : ifaddrList)
     {
-        std::string url = svc.name + ':' + svc.type +
-                          "//" + addr + ',' + svc.port;
+        std::string url =
+            svc.name + ':' + svc.type + "//" + addr + ',' + svc.port;
 
-
-        buff.resize(buff.size() +
-                    slp::response::SIZE_URL_ENTRY +
-                    url.length());
+        buff.resize(buff.size() + slp::response::SIZE_URL_ENTRY + url.length());
 
         uint8_t reserved = 0;
         uint16_t auth = 0;
@@ -244,7 +228,6 @@
 
         pos += slp::response::SIZE_RESERVED;
 
-
         std::copy_n((uint8_t*)&lifetime, slp::response::SIZE_LIFETIME,
                     buff.data() + pos);
 
@@ -255,8 +238,7 @@
                     buff.data() + pos);
         pos += slp::response::SIZE_URLLENGTH;
 
-        std::copy_n((uint8_t*)url.c_str(), url.length(),
-                    buff.data() + pos);
+        std::copy_n((uint8_t*)url.c_str(), url.length(), buff.data() + pos);
         pos += url.length();
 
         std::copy_n((uint8_t*)&auth, slp::response::SIZE_AUTH,
@@ -265,8 +247,7 @@
     }
     uint8_t packetLength = buff.size();
     std::copy_n((uint8_t*)&packetLength, slp::header::SIZE_VERSION,
-                buff.data() +
-                slp::header::OFFSET_LENGTH);
+                buff.data() + slp::header::OFFSET_LENGTH);
 
     return std::make_tuple((int)slp::SUCCESS, buff);
 }
@@ -282,10 +263,8 @@
         return addrList;
     }
 
-    slp::deleted_unique_ptr<ifaddrs> ifaddrPtr(ifaddr, [](ifaddrs * addr)
-    {
-        freeifaddrs(addr);
-    });
+    slp::deleted_unique_ptr<ifaddrs> ifaddrPtr(
+        ifaddr, [](ifaddrs* addr) { freeifaddrs(addr); });
 
     ifaddr = nullptr;
 
@@ -307,11 +286,10 @@
                 continue;
             }
 
-            char tmp[INET_ADDRSTRLEN] = { 0 };
+            char tmp[INET_ADDRSTRLEN] = {0};
 
             inet_ntop(AF_INET,
-                      &(((struct sockaddr_in*)(ifa->ifa_addr))->sin_addr),
-                      tmp,
+                      &(((struct sockaddr_in*)(ifa->ifa_addr))->sin_addr), tmp,
                       sizeof(tmp));
             addrList.emplace_back(tmp);
         }
@@ -320,7 +298,7 @@
     return addrList;
 }
 
-slp::handler::internal::ServiceList  readSLPServiceInfo()
+slp::handler::internal::ServiceList readSLPServiceInfo()
 {
     using namespace std::string_literals;
     slp::handler::internal::ServiceList svcLst;
@@ -332,8 +310,7 @@
     // Service File format would be "ServiceName serviceType Port"
     DIR* dir = opendir(SERVICE_DIR);
     // wrap the pointer into smart pointer.
-    slp::deleted_unique_ptr<DIR> dirPtr(dir, [](DIR * dir)
-    {
+    slp::deleted_unique_ptr<DIR> dirPtr(dir, [](DIR* dir) {
         if (!dir)
         {
             closedir(dir);
@@ -345,7 +322,7 @@
     {
         while ((dent = readdir(dirPtr.get())) != NULL)
         {
-            if (dent->d_type == DT_REG) //regular file
+            if (dent->d_type == DT_REG) // regular file
             {
                 auto absFileName = std::string(SERVICE_DIR) + dent->d_name;
                 std::ifstream readFile(absFileName);
@@ -354,24 +331,22 @@
                 svcLst.emplace(service.name, service);
             }
         }
-
     }
     return svcLst;
 }
-}//namespace internal
+} // namespace internal
 
-std::tuple<int, buffer> processRequest(
-    const Message& msg)
+std::tuple<int, buffer> processRequest(const Message& msg)
 {
     int rc = slp::SUCCESS;
     buffer resp(0);
-    std::cout << "SLP Processing Request="
-              << msg.header.functionID <<"\n";
+    std::cout << "SLP Processing Request=" << msg.header.functionID << "\n";
 
     switch (msg.header.functionID)
     {
         case (uint8_t)slp::FunctionType::SRVTYPERQST:
-            std::tie(rc, resp) = slp::handler::internal::processSrvTypeRequest(msg);
+            std::tie(rc, resp) =
+                slp::handler::internal::processSrvTypeRequest(msg);
             break;
         case (uint8_t)slp::FunctionType::SRVRQST:
             std::tie(rc, resp) = slp::handler::internal::processSrvRequest(msg);
@@ -382,17 +357,14 @@
     return std::make_tuple(rc, resp);
 }
 
-buffer processError(const Message& req,
-                    uint8_t err)
+buffer processError(const Message& req, uint8_t err)
 {
     buffer buff;
     buff = slp::handler::internal::prepareHeader(req);
 
     std::copy_n(&err, slp::response::SIZE_ERROR,
-                buff.data() +
-                slp::response::OFFSET_ERROR);
+                buff.data() + slp::response::OFFSET_ERROR);
     return buff;
-
 }
-}//namespace handler
-}//namespace slp
+} // namespace handler
+} // namespace slp
diff --git a/slp_meta.hpp b/slp_meta.hpp
index 0cebfdf..956f18d 100644
--- a/slp_meta.hpp
+++ b/slp_meta.hpp
@@ -35,7 +35,7 @@
 constexpr size_t OFFSET_LANG = 14;
 
 constexpr size_t MIN_LEN = 14;
-}//namespace header
+} // namespace header
 
 /** @brief Defines the constants for slp response.
  *  Size and the offsets.
@@ -58,7 +58,7 @@
 constexpr size_t OFFSET_SERVICE = 20;
 constexpr size_t OFFSET_URL_ENTRY = 18;
 
-}//namespace response
+} // namespace response
 
 /** @brief Defines the constants for slp request.
  *  Size and the offsets.
@@ -80,5 +80,5 @@
 constexpr size_t OFFSET_PR = 18;
 constexpr size_t OFFSET_SERVICE = 20;
 
-}//namespace request
-}//namespace slp
+} // namespace request
+} // namespace slp
diff --git a/slp_parser.cpp b/slp_parser.cpp
index 28726b0..9b4119b 100644
--- a/slp_parser.cpp
+++ b/slp_parser.cpp
@@ -1,12 +1,11 @@
+#include "endian.hpp"
 #include "slp.hpp"
+#include "slp_meta.hpp"
 
 #include <string.h>
 
-#include <string>
 #include <algorithm>
-
-#include "endian.hpp"
-#include "slp_meta.hpp"
+#include <string>
 
 namespace slp
 {
@@ -31,32 +30,25 @@
        |      Language Tag Length      |         Language Tag          \
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
 
-    Message req {0};
+    Message req{0};
     int rc = slp::SUCCESS;
 
-    std::copy_n(buff.data(),
-                slp::header::SIZE_VERSION,
-                &req.header.version);
+    std::copy_n(buff.data(), slp::header::SIZE_VERSION, &req.header.version);
 
     std::copy_n(buff.data() + slp::header::OFFSET_FUNCTION,
-                slp::header::SIZE_VERSION,
-                &req.header.functionID);
+                slp::header::SIZE_VERSION, &req.header.functionID);
 
     std::copy_n(buff.data() + slp::header::OFFSET_LENGTH,
-                slp::header::SIZE_LENGTH,
-                req.header.length.data());
+                slp::header::SIZE_LENGTH, req.header.length.data());
 
     std::copy_n(buff.data() + slp::header::OFFSET_FLAGS,
-                slp::header::SIZE_FLAGS,
-                (uint8_t*)&req.header.flags);
+                slp::header::SIZE_FLAGS, (uint8_t*)&req.header.flags);
 
     req.header.flags = endian::from_network(req.header.flags);
-    std::copy_n(buff.data() + slp::header::OFFSET_EXT,
-                slp::header::SIZE_EXT,
+    std::copy_n(buff.data() + slp::header::OFFSET_EXT, slp::header::SIZE_EXT,
                 req.header.extOffset.data());
 
-    std::copy_n(buff.data() + slp::header::OFFSET_XID,
-                slp::header::SIZE_XID,
+    std::copy_n(buff.data() + slp::header::OFFSET_XID, slp::header::SIZE_XID,
                 (uint8_t*)&req.header.xid);
 
     req.header.xid = endian::from_network(req.header.xid);
@@ -64,21 +56,17 @@
     uint16_t langtagLen;
 
     std::copy_n(buff.data() + slp::header::OFFSET_LANG_LEN,
-                slp::header::SIZE_LANG,
-                (uint8_t*)&langtagLen);
-
+                slp::header::SIZE_LANG, (uint8_t*)&langtagLen);
 
     langtagLen = endian::from_network(langtagLen);
 
-
-    req.header.langtag.insert(0, (const char*)buff.data() +
-                              slp::header::OFFSET_LANG,
-                              langtagLen);
+    req.header.langtag.insert(
+        0, (const char*)buff.data() + slp::header::OFFSET_LANG, langtagLen);
 
     /* check for the validity of the function */
-    if (req.header.functionID < static_cast<uint8_t>
-        (slp::FunctionType::SRVRQST)
-        || req.header.functionID > static_cast<uint8_t>(slp::FunctionType::SAADV))
+    if (req.header.functionID <
+            static_cast<uint8_t>(slp::FunctionType::SRVRQST) ||
+        req.header.functionID > static_cast<uint8_t>(slp::FunctionType::SAADV))
     {
         rc = static_cast<int>(slp::Error::PARSE_ERROR);
     }
@@ -86,11 +74,9 @@
     return std::make_tuple(rc, std::move(req));
 }
 
-
 int parseSrvTypeRqst(const buffer& buff, Message& req)
 {
 
-
     /*  0                   1                   2                   3
         0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -110,21 +96,18 @@
     /* Parse the PRList. */
     uint16_t prListLen;
     std::copy_n(buff.data() + slp::request::OFFSET_PR_LEN,
-                slp::request::SIZE_PRLIST,
-                (uint8_t*)&prListLen);
+                slp::request::SIZE_PRLIST, (uint8_t*)&prListLen);
 
     prListLen = endian::from_network(prListLen);
 
-    req.body.srvtyperqst.prList.insert(0, (const char*)buff.data() +
-                                       slp::request::OFFSET_PR,
-                                       prListLen);
+    req.body.srvtyperqst.prList.insert(
+        0, (const char*)buff.data() + slp::request::OFFSET_PR, prListLen);
 
     uint8_t pos = slp::request::OFFSET_PR + prListLen;
 
     /* Parse the Naming Authority. */
     uint16_t namingAuthLen;
-    std::copy_n(buff.data() + pos,
-                slp::request::SIZE_NAMING,
+    std::copy_n(buff.data() + pos, slp::request::SIZE_NAMING,
                 (uint8_t*)&namingAuthLen);
 
     pos += slp::request::SIZE_NAMING;
@@ -137,17 +120,15 @@
     }
     else
     {
-        req.body.srvtyperqst.namingAuth.insert(0, (const char*)buff.data() +
-                                               pos,
-                                               namingAuthLen);
+        req.body.srvtyperqst.namingAuth.insert(
+            0, (const char*)buff.data() + pos, namingAuthLen);
     }
 
     pos += namingAuthLen;
 
     /* Parse the <scope-list>. */
     uint16_t scopeListLen;
-    std::copy_n(buff.data() + pos,
-                slp::request::SIZE_SCOPE,
+    std::copy_n(buff.data() + pos, slp::request::SIZE_SCOPE,
                 (uint8_t*)&scopeListLen);
 
     pos += slp::request::SIZE_SCOPE;
@@ -185,8 +166,7 @@
     /* 1) Parse the PRList. */
     uint16_t prListLen;
     std::copy_n(buff.data() + slp::request::OFFSET_PR_LEN,
-                slp::request::SIZE_PRLIST,
-                (uint8_t*)&prListLen);
+                slp::request::SIZE_PRLIST, (uint8_t*)&prListLen);
 
     auto pos = slp::request::OFFSET_PR_LEN + slp::request::SIZE_PRLIST;
 
@@ -197,11 +177,9 @@
 
     pos += prListLen;
 
-
     /* 2) Parse the <service-type> string. */
     uint16_t srvTypeLen;
-    std::copy_n(buff.data() + pos,
-                slp::request::SIZE_SERVICE_TYPE,
+    std::copy_n(buff.data() + pos, slp::request::SIZE_SERVICE_TYPE,
                 (uint8_t*)&srvTypeLen);
 
     srvTypeLen = endian::from_network(srvTypeLen);
@@ -215,8 +193,7 @@
 
     /* 3) Parse the <scope-list> string. */
     uint16_t scopeListLen;
-    std::copy_n(buff.data() + pos,
-                slp::request::SIZE_SCOPE,
+    std::copy_n(buff.data() + pos, slp::request::SIZE_SCOPE,
                 (uint8_t*)&scopeListLen);
 
     scopeListLen = endian::from_network(scopeListLen);
@@ -230,8 +207,7 @@
 
     /* 4) Parse the <predicate> string. */
     uint16_t predicateLen;
-    std::copy_n(buff.data() + pos,
-                slp::request::SIZE_PREDICATE,
+    std::copy_n(buff.data() + pos, slp::request::SIZE_PREDICATE,
                 (uint8_t*)&predicateLen);
 
     predicateLen = endian::from_network(predicateLen);
@@ -244,8 +220,7 @@
 
     /* 5) Parse the <SLP SPI> string. */
     uint16_t spistrLen;
-    std::copy_n(buff.data() + pos,
-                slp::request::SIZE_SLPI,
+    std::copy_n(buff.data() + pos, slp::request::SIZE_SLPI,
                 (uint8_t*)&spistrLen);
 
     spistrLen = endian::from_network(spistrLen);
@@ -256,7 +231,7 @@
 
     return slp::SUCCESS;
 }
-}//namespace internal
+} // namespace internal
 
 std::tuple<int, Message> parseBuffer(const buffer& buff)
 {
@@ -281,5 +256,5 @@
     }
     return std::make_tuple(rc, std::move(req));
 }
-}//namespace parser
-}//namespace slp
+} // namespace parser
+} // namespace slp
diff --git a/slp_server.cpp b/slp_server.cpp
index 29c3a2f..89d751b 100644
--- a/slp_server.cpp
+++ b/slp_server.cpp
@@ -1,13 +1,13 @@
 #include "slp_server.hpp"
 
-#include <memory>
+#include "sock_channel.hpp"
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
-#include "sock_channel.hpp"
+#include <memory>
 
 /** General udp server which waits for the POLLIN event
     on the port and calls the call back once it gets the event.
@@ -16,12 +16,13 @@
  */
 int slp::udp::Server::run()
 {
-    struct sockaddr_in6 serverAddr {};
+    struct sockaddr_in6 serverAddr
+    {
+    };
 
     sd_event* event = nullptr;
 
-    slp::deleted_unique_ptr<sd_event> eventPtr(event, [](sd_event * event)
-    {
+    slp::deleted_unique_ptr<sd_event> eventPtr(event, [](sd_event* event) {
         if (!event)
         {
             event = sd_event_unref(event);
@@ -97,7 +98,7 @@
 
     if (fd >= 0)
     {
-        (void) close(fd);
+        (void)close(fd);
     }
 
     if (r < 0)
diff --git a/slp_server.hpp b/slp_server.hpp
index 0ab12c9..c890ced 100644
--- a/slp_server.hpp
+++ b/slp_server.hpp
@@ -1,14 +1,15 @@
 #pragma once
 
-#include <iostream>
-#include <string>
+#include "slp.hpp"
+#include "slp_meta.hpp"
+
 #include <sys/types.h>
 #include <systemd/sd-bus.h>
 #include <systemd/sd-daemon.h>
 #include <systemd/sd-event.h>
 
-#include "slp_meta.hpp"
-#include "slp.hpp"
+#include <iostream>
+#include <string>
 
 namespace slp
 {
@@ -23,24 +24,20 @@
 class Server
 {
 
-    public:
+  public:
+    Server() : Server(slp::PORT, nullptr){};
 
-        Server(): Server(slp::PORT, nullptr) {};
+    Server(uint16_t port, sd_event_io_handler_t cb) : port(port), callme(cb){};
 
-        Server(uint16_t port, sd_event_io_handler_t cb):
-            port(port),
-            callme(cb) {};
+    Server(const Server&) = delete;
+    Server& operator=(const Server&) = delete;
+    Server(Server&&) = default;
+    Server& operator=(Server&&) = default;
 
-        Server(const Server&) = delete;
-        Server& operator=(const Server&) = delete;
-        Server(Server&&) = default;
-        Server& operator=(Server &&) = default;
+    uint16_t port;
+    sd_event_io_handler_t callme;
 
-        uint16_t port;
-        sd_event_io_handler_t callme;
-
-        int run();
-
+    int run();
 };
-}//namespce udp
-}//namespace slp
+} // namespace udp
+} // namespace slp
diff --git a/slp_service_info.hpp b/slp_service_info.hpp
index 29fe1c4..de7ec45 100644
--- a/slp_service_info.hpp
+++ b/slp_service_info.hpp
@@ -1,7 +1,11 @@
 #pragma once
-#include <iostream>
+
+#include <array>
 #include <fstream>
+#include <iostream>
 #include <sstream>
+#include <string>
+
 namespace slp
 {
 struct ConfigData
@@ -14,20 +18,22 @@
     {
         std::string line;
         constexpr auto DELIMITER = " ";
-        size_t  delimtrPos = 0;
-        size_t  delimtrPrevPos = 0;
-        std::array<std::string, 3>tokens;
+        size_t delimtrPos = 0;
+        size_t delimtrPrevPos = 0;
+        std::array<std::string, 3> tokens;
         std::getline(str, line);
         size_t count = 0;
 
         delimtrPos = line.find(DELIMITER, delimtrPrevPos);
         while (delimtrPos != std::string::npos)
         {
-            tokens[count] = line.substr(delimtrPrevPos, (delimtrPos - delimtrPrevPos));
+            tokens[count] =
+                line.substr(delimtrPrevPos, (delimtrPos - delimtrPrevPos));
             delimtrPrevPos = delimtrPos + 1;
 
             delimtrPos = line.find(DELIMITER, delimtrPrevPos);
-            if (delimtrPos == std::string::npos && delimtrPrevPos < line.length())
+            if (delimtrPos == std::string::npos &&
+                delimtrPrevPos < line.length())
             {
                 delimtrPos = line.length();
             }
@@ -47,6 +53,5 @@
         }
         return str;
     }
-
 };
-}
+} // namespace slp
diff --git a/sock_channel.cpp b/sock_channel.cpp
index fe492db..b6332cf 100644
--- a/sock_channel.cpp
+++ b/sock_channel.cpp
@@ -14,7 +14,7 @@
 
 std::string Channel::getRemoteAddress() const
 {
-    char tmp[INET_ADDRSTRLEN] = { 0 };
+    char tmp[INET_ADDRSTRLEN] = {0};
     inet_ntop(AF_INET6, &address.inAddr.sin6_addr, tmp, sizeof(tmp));
     return std::string(tmp);
 }
@@ -41,12 +41,12 @@
 
     do
     {
-        readDataLen = recvfrom(sockfd,               // File Descriptor
-                               outputPtr ,           // Buffer
-                               bufferSize,           // Bytes requested
-                               0,                    // Flags
-                               &address.sockAddr,    // Address
-                               &address.addrSize);   // Address Length
+        readDataLen = recvfrom(sockfd,             // File Descriptor
+                               outputPtr,          // Buffer
+                               bufferSize,         // Bytes requested
+                               0,                  // Flags
+                               &address.sockAddr,  // Address
+                               &address.addrSize); // Address Length
 
         if (readDataLen == 0) // Peer has performed an orderly shutdown
         {
@@ -60,8 +60,7 @@
                       << "errno = " << rc << "\n";
             outBuffer.resize(0);
         }
-    }
-    while ((readDataLen < 0) && (-(rc) == EINTR));
+    } while ((readDataLen < 0) && (-(rc) == EINTR));
 
     // Resize the vector to the actual data read from the socket
     outBuffer.resize(readDataLen);
@@ -91,30 +90,32 @@
         {
             if (FD_ISSET(sockfd, &writeSet))
             {
-                address.addrSize = static_cast<socklen_t>(sizeof(address.inAddr));
+                address.addrSize =
+                    static_cast<socklen_t>(sizeof(address.inAddr));
                 do
                 {
-                    writeDataLen = sendto(sockfd,           // File Descriptor
-                                          outputPtr,        // Message
-                                          bufferSize,       // Length
-                                          MSG_NOSIGNAL,     // Flags
-                                          &address.sockAddr,// Destination Address
-                                          address.addrSize);// Address Length
+                    writeDataLen =
+                        sendto(sockfd,            // File Descriptor
+                               outputPtr,         // Message
+                               bufferSize,        // Length
+                               MSG_NOSIGNAL,      // Flags
+                               &address.sockAddr, // Destination Address
+                               address.addrSize); // Address Length
 
                     if (writeDataLen < 0)
                     {
                         rc = -errno;
-                        std::cerr << "Channel::Write: Write failed with errno:"
-                                  << rc << "\n";
+                        std::cerr
+                            << "Channel::Write: Write failed with errno:" << rc
+                            << "\n";
                     }
                     else if (static_cast<size_t>(writeDataLen) < bufferSize)
                     {
                         rc = -1;
                         std::cerr << "Channel::Write: Complete data not written"
-                                  " to the socket\n";
+                                     " to the socket\n";
                     }
-                }
-                while ((writeDataLen < 0) && (-(rc) == EINTR));
+                } while ((writeDataLen < 0) && (-(rc) == EINTR));
             }
             else
             {
@@ -134,17 +135,14 @@
             else
             {
                 // Error
-                rc  = -errno;
-                std::cerr << "select call (writeset) had an error : "
-                          << rc << "\n";
+                rc = -errno;
+                std::cerr << "select call (writeset) had an error : " << rc
+                          << "\n";
             }
-
         }
-    }
-    while (spuriousWakeup);
+    } while (spuriousWakeup);
 
     return rc;
 }
 
 } // namespace udpsocket
-
diff --git a/sock_channel.hpp b/sock_channel.hpp
index 0ba0df1..e759626 100644
--- a/sock_channel.hpp
+++ b/sock_channel.hpp
@@ -18,99 +18,99 @@
  */
 class Channel
 {
-    public:
-        struct SockAddr_t
+  public:
+    struct SockAddr_t
+    {
+        union
         {
-            union
-            {
-                sockaddr sockAddr;
-                sockaddr_in6 inAddr;
-            };
-            socklen_t addrSize;
+            sockaddr sockAddr;
+            sockaddr_in6 inAddr;
         };
+        socklen_t addrSize;
+    };
 
-        /**
-         * @brief Constructor
-         *
-         * Initialize the IPMI socket object with the socket descriptor
-         *
-         * @param [in] File Descriptor for the socket
-         * @param [in] Timeout parameter for the select call
-         *
-         * @return None
-         */
-        Channel(int insockfd, timeval& inTimeout)
-        {
-            sockfd = insockfd;
-            timeout = inTimeout;
-        }
+    /**
+     * @brief Constructor
+     *
+     * Initialize the IPMI socket object with the socket descriptor
+     *
+     * @param [in] File Descriptor for the socket
+     * @param [in] Timeout parameter for the select call
+     *
+     * @return None
+     */
+    Channel(int insockfd, timeval& inTimeout)
+    {
+        sockfd = insockfd;
+        timeout = inTimeout;
+    }
 
-        /**
-         * @brief Fetch the IP address of the remote peer
-         *
-         * Returns the IP address of the remote peer which is connected to this
-         * socket
-         *
-         * @return IP address of the remote peer
-         */
-        std::string getRemoteAddress() const;
+    /**
+     * @brief Fetch the IP address of the remote peer
+     *
+     * Returns the IP address of the remote peer which is connected to this
+     * socket
+     *
+     * @return IP address of the remote peer
+     */
+    std::string getRemoteAddress() const;
 
-        /**
-         * @brief Fetch the port number of the remote peer
-         *
-         * Returns the port number of the remote peer
-         *
-         * @return Port number
-         *
-         */
-        auto getPort() const
-        {
-            return address.inAddr.sin6_port;
-        }
+    /**
+     * @brief Fetch the port number of the remote peer
+     *
+     * Returns the port number of the remote peer
+     *
+     * @return Port number
+     *
+     */
+    auto getPort() const
+    {
+        return address.inAddr.sin6_port;
+    }
 
-        /**
-         * @brief Read the incoming packet
-         *
-         * Reads the data available on the socket
-         *
-         * @return A tuple with return code and vector with the buffer
-         *         In case of success, the vector is populated with the data
-         *         available on the socket and return code is 0.
-         *         In case of error, the return code is < 0 and vector is set
-         *         to size 0.
-         */
-        std::tuple<int, buffer> read();
+    /**
+     * @brief Read the incoming packet
+     *
+     * Reads the data available on the socket
+     *
+     * @return A tuple with return code and vector with the buffer
+     *         In case of success, the vector is populated with the data
+     *         available on the socket and return code is 0.
+     *         In case of error, the return code is < 0 and vector is set
+     *         to size 0.
+     */
+    std::tuple<int, buffer> read();
 
-        /**
-         *  @brief Write the outgoing packet
-         *
-         *  Writes the data in the vector to the socket
-         *
-         *  @param [in] inBuffer
-         *      The vector would be the buffer of data to write to the socket.
-         *
-         *  @return In case of success the return code is 0 and return code is
-         *          < 0 in case of failure.
-         */
-        int write(buffer& inBuffer);
+    /**
+     *  @brief Write the outgoing packet
+     *
+     *  Writes the data in the vector to the socket
+     *
+     *  @param [in] inBuffer
+     *      The vector would be the buffer of data to write to the socket.
+     *
+     *  @return In case of success the return code is 0 and return code is
+     *          < 0 in case of failure.
+     */
+    int write(buffer& inBuffer);
 
-        ~Channel() = default;
-        Channel(const Channel& right) = delete;
-        Channel& operator=(const Channel& right) = delete;
-        Channel(Channel&&) = default;
-        Channel& operator=(Channel&&) = default;
+    ~Channel() = default;
+    Channel(const Channel& right) = delete;
+    Channel& operator=(const Channel& right) = delete;
+    Channel(Channel&&) = default;
+    Channel& operator=(Channel&&) = default;
 
-    private:
-        /*
-         * The socket descriptor is the UDP server socket for the IPMI port.
-         * The same socket descriptor is used for multiple ipmi clients and the
-         * life of the descriptor is lifetime of the net-ipmid server. So we
-         * do not need to close the socket descriptor in the cleanup of the
-         * udpsocket class.
-         */
-        int sockfd;
-        SockAddr_t address;
-        timeval timeout;
+  private:
+    /*
+     * The socket descriptor is the UDP server socket for the IPMI port.
+     * The same socket descriptor is used for multiple ipmi clients and the
+     * life of the descriptor is lifetime of the net-ipmid server. So we
+     * do not need to close the socket descriptor in the cleanup of the
+     * udpsocket class.
+     */
+    int sockfd;
+    SockAddr_t address;
+    timeval timeout;
 };
 
 } // namespace udpsocket