1 #include "config.h" 2 3 #include "snmp_conf_manager.hpp" 4 5 #include <phosphor-logging/log.hpp> 6 #include <sdbusplus/bus.hpp> 7 #include <sdbusplus/server/manager.hpp> 8 9 #include <memory> 10 11 /* Need a custom deleter for freeing up sd_event */ 12 struct EventDeleter 13 { 14 void operator()(sd_event* event) const 15 { 16 sd_event_unref(event); 17 } 18 }; 19 20 using EventPtr = std::unique_ptr<sd_event, EventDeleter>; 21 22 int main(int /*argc*/, char** /*argv[]*/) 23 { 24 using namespace phosphor::logging; 25 26 auto bus = sdbusplus::bus::new_default(); 27 28 sd_event* event = nullptr; 29 auto r = sd_event_default(&event); 30 if (r < 0) 31 { 32 log<level::ERR>("Error creating a default sd_event handler"); 33 return r; 34 } 35 36 EventPtr eventPtr{event}; 37 event = nullptr; 38 39 // Attach the bus to sd_event to service user requests 40 bus.attach_event(eventPtr.get(), SD_EVENT_PRIORITY_NORMAL); 41 42 // Add sdbusplus Object Manager for the 'root' path of the snmp. 43 sdbusplus::server::manager::manager objManager(bus, OBJ_NETWORK_SNMP); 44 bus.request_name(BUSNAME_NETWORK_SNMP); 45 46 auto manager = std::make_unique<phosphor::network::snmp::ConfManager>( 47 bus, OBJ_NETWORK_SNMP); 48 49 manager->restoreClients(); 50 51 return sd_event_loop(eventPtr.get()); 52 } 53