1 #include "handler.hpp"
2 
3 #include <blobs-ipmid/blobs.hpp>
4 
5 #include <memory>
6 
7 // Extern "C" is used due to the usage of dlopen() for loading IPMI handlers
8 // and IPMI blob handlers. This happens in two steps:
9 //
10 // 1) ipmid loads all libraries in /usr/lib/ipmid-providers from its
11 //    loadLibraries() function using dlopen().
12 // 2) The blobs library, libblobcmds.so, loads all libraries in
13 //    /usr/lib/blobs-ipmid from its loadLibraries() function. It uses dlsym()
14 //    to locate the createHandler function by its un-mangled name
15 //    "createHandler". Using extern "C" prevents its name from being mangled
16 //    into, for example, "_Z13createHandlerv".
17 
18 extern "C" std::unique_ptr<blobs::GenericBlobInterface> createHandler()
19 {
20     return std::make_unique<blobs::MetricBlobHandler>();
21 }
22