1 #include "config.h" 2 3 #include "snmp_conf_manager.hpp" 4 5 #include <phosphor-logging/lg2.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 auto bus = sdbusplus::bus::new_default(); 25 26 sd_event* event = nullptr; 27 auto r = sd_event_default(&event); 28 if (r < 0) 29 { 30 lg2::error("Error creating a default sd_event handler: {RC}", "RC", r); 31 return r; 32 } 33 34 EventPtr eventPtr{event}; 35 event = nullptr; 36 37 // Attach the bus to sd_event to service user requests 38 bus.attach_event(eventPtr.get(), SD_EVENT_PRIORITY_NORMAL); 39 40 // Add sdbusplus Object Manager for the 'root' path of the snmp. 41 sdbusplus::server::manager_t objManager(bus, OBJ_NETWORK_SNMP); 42 bus.request_name(BUSNAME_NETWORK_SNMP); 43 44 auto manager = std::make_unique<phosphor::network::snmp::ConfManager>( 45 bus, OBJ_NETWORK_SNMP); 46 47 manager->restoreClients(); 48 49 return sd_event_loop(eventPtr.get()); 50 } 51