From 36c0cb62c51206105e16aaa7131b42fcb860bd32 Mon Sep 17 00:00:00 2001 From: Nan Li Date: Thu, 31 Mar 2016 11:16:08 +0800 Subject: Handle multiple attempts at ipmi reservation ids 1. Keep Reservation ID follow IPMI Spec. 2. Make Reservation ID increase sequentially. 3. Make Reservation ID available in shared librarys. Signed-off-by: Nan Li --- ipmid.C | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'ipmid.C') diff --git a/ipmid.C b/ipmid.C index 728ba0b..c4a6763 100644 --- a/ipmid.C +++ b/ipmid.C @@ -26,8 +26,6 @@ void print_usage(void) { fprintf(stderr, " mask : 0xFF - Print all trace\n"); } - - const char * DBUS_INTF = "org.openbmc.HostIpmi"; const char * FILTER = "type='signal',interface='org.openbmc.HostIpmi',member='ReceivedMessage'"; @@ -39,6 +37,13 @@ typedef std::pair ipmi_fn_context_t; // Global data structure that contains the IPMI command handler's registrations. std::map g_ipmid_router_map; +// IPMI Spec, shared Reservation ID. +unsigned short g_sel_reserve = 0xFFFF; + +unsigned short get_sel_reserve_id(void) +{ + return g_sel_reserve; +} #ifndef HEXDUMP_COLS #define HEXDUMP_COLS 16 @@ -341,8 +346,8 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path) handler_fqdn += "/"; num_handlers = scandir(ipmi_lib_path, &handler_list, handler_select, alphasort); - if (num_handlers < 0) - return; + if (num_handlers < 0) + return; while(num_handlers--) { @@ -351,6 +356,7 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path) printf("Registering handler:[%s]\n",handler_fqdn.c_str()); lib_handler = dlopen(handler_fqdn.c_str(), RTLD_NOW); + if(lib_handler == NULL) { fprintf(stderr,"ERROR opening [%s]: %s\n", @@ -359,6 +365,7 @@ void ipmi_register_callback_handlers(const char* ipmi_lib_path) // Wipe the memory allocated for this particular entry. free(handler_list[num_handlers]); } + // Done with all registration. free(handler_list); } -- cgit v1.2.1