vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 1 | #include "apphandler.h" |
Patrick Williams | 37af733 | 2016-09-02 21:21:42 -0500 | [diff] [blame] | 2 | #include "host-ipmid/ipmid-api.h" |
Patrick Williams | 53a360e | 2016-08-12 22:01:02 -0500 | [diff] [blame] | 3 | #include "ipmid.hpp" |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 4 | #include <stdio.h> |
| 5 | #include <string.h> |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 6 | #include <stdint.h> |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 7 | #include <systemd/sd-bus.h> |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 8 | #include <mapper.h> |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 9 | #include <array> |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 10 | #include <arpa/inet.h> |
| 11 | #include "transporthandler.h" |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 12 | |
| 13 | extern sd_bus *bus; |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 14 | |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 15 | constexpr auto app_obj = "/org/openbmc/NetworkManager/Interface"; |
| 16 | constexpr auto app_ifc = "org.openbmc.NetworkManager"; |
| 17 | constexpr auto app_nwinterface = "eth0"; |
| 18 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 19 | void register_netfn_app_functions() __attribute__((constructor)); |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 20 | |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 21 | // Offset in get device id command. |
| 22 | typedef struct |
| 23 | { |
| 24 | uint8_t id; |
| 25 | uint8_t revision; |
| 26 | uint8_t fw[2]; |
| 27 | uint8_t ipmi_ver; |
| 28 | uint8_t addn_dev_support; |
| 29 | uint8_t manuf_id[3]; |
| 30 | uint8_t prod_id[2]; |
| 31 | uint8_t aux[4]; |
| 32 | }__attribute__((packed)) ipmi_device_id_t; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 33 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 34 | ipmi_ret_t ipmi_app_set_acpi_power_state(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 35 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 36 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 37 | { |
| 38 | ipmi_ret_t rc = IPMI_CC_OK; |
| 39 | *data_len = 0; |
| 40 | |
| 41 | printf("IPMI SET ACPI STATE Ignoring for now\n"); |
| 42 | return rc; |
| 43 | } |
| 44 | |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 45 | |
| 46 | typedef struct |
| 47 | { |
| 48 | char major; |
| 49 | char minor; |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 50 | uint16_t d[2]; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 51 | } rev_t; |
| 52 | |
| 53 | |
| 54 | /* Currently only supports the vx.x-x-[-x] format Will return -1 if not in */ |
| 55 | /* the format this routine knows how to parse */ |
| 56 | /* version = v0.6-19-gf363f61-dirty */ |
| 57 | /* ^ ^ ^^ ^ */ |
| 58 | /* | | |----------|-- additional details */ |
| 59 | /* | |---------------- Minor */ |
| 60 | /* |------------------ Major */ |
| 61 | /* Additional details : If the option group exists it will force Auxiliary */ |
| 62 | /* Firmware Revision Information 4th byte to 1 indicating the build was */ |
| 63 | /* derived with additional edits */ |
| 64 | int convert_version(const char *p, rev_t *rev) |
| 65 | { |
| 66 | char *s, *token; |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 67 | uint16_t commits; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 68 | |
| 69 | if (*p != 'v') |
| 70 | return -1; |
| 71 | p++; |
| 72 | |
| 73 | s = strdup(p); |
| 74 | token = strtok(s,".-"); |
| 75 | |
| 76 | rev->major = (int8_t) atoi(token); |
| 77 | |
| 78 | token = strtok(NULL, ".-"); |
| 79 | rev->minor = (int8_t) atoi(token); |
| 80 | |
| 81 | // Capture the number of commits on top of the minor tag. |
| 82 | // I'm using BE format like the ipmi spec asked for |
| 83 | token = strtok(NULL,".-"); |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 84 | |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 85 | if (token) { |
| 86 | commits = (int16_t) atoi(token); |
| 87 | rev->d[0] = (commits>>8) | (commits<<8); |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 88 | |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 89 | // commit number we skip |
| 90 | token = strtok(NULL,".-"); |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 91 | |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 92 | } else { |
| 93 | rev->d[0] = 0; |
| 94 | } |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 95 | |
| 96 | // Any value of the optional parameter forces it to 1 |
Chris Austen | 176c965 | 2016-04-30 16:32:17 -0500 | [diff] [blame] | 97 | if (token) |
| 98 | token = strtok(NULL,".-"); |
| 99 | |
| 100 | rev->d[1] = (token != NULL) ? 1 : 0; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 101 | |
| 102 | free(s); |
| 103 | return 0; |
| 104 | } |
| 105 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 106 | ipmi_ret_t ipmi_app_get_device_id(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 107 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 108 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 109 | { |
| 110 | ipmi_ret_t rc = IPMI_CC_OK; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 111 | const char *objname = "/org/openbmc/inventory/system/chassis/motherboard/bmc"; |
| 112 | const char *iface = "org.openbmc.InventoryItem"; |
| 113 | char *ver = NULL; |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 114 | char *busname = NULL; |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 115 | int r; |
| 116 | rev_t rev = {0}; |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 117 | ipmi_device_id_t dev_id{}; |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 118 | |
| 119 | // Data length |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 120 | *data_len = sizeof(dev_id); |
| 121 | |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 122 | // From IPMI spec, controller that have different application commands, or different |
| 123 | // definitions of OEM fields, are expected to have different Device ID values. |
| 124 | // Set to 0 now. |
| 125 | |
| 126 | // Device Revision is set to 0 now. |
| 127 | // Bit7 identifies if device provide Device SDRs, obmc don't have SDR,we use ipmi to |
| 128 | // simulate SDR, hence the value: |
| 129 | dev_id.revision = 0x80; |
| 130 | |
| 131 | // Firmware revision is already implemented, so get it from appropriate position. |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 132 | r = mapper_get_service(bus, objname, &busname); |
| 133 | if (r < 0) { |
Brad Bishop | 819ddd4 | 2016-10-05 21:19:19 -0400 | [diff] [blame] | 134 | fprintf(stderr, "Failed to get %s bus name: %s\n", |
| 135 | objname, strerror(-r)); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 136 | goto finish; |
| 137 | } |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 138 | r = sd_bus_get_property_string(bus,busname,objname,iface,"version", NULL, &ver); |
| 139 | if ( r < 0 ) { |
| 140 | fprintf(stderr, "Failed to obtain version property: %s\n", strerror(-r)); |
| 141 | } else { |
| 142 | r = convert_version(ver, &rev); |
| 143 | if( r >= 0 ) { |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 144 | // bit7 identifies if the device is available, 0=normal operation, |
| 145 | // 1=device firmware, SDR update or self-initialization in progress. |
| 146 | // our SDR is normal working condition, so mask: |
| 147 | dev_id.fw[0] = 0x7F & rev.major; |
Adriana Kobylak | 0e91264 | 2016-06-22 16:54:39 -0500 | [diff] [blame] | 148 | |
| 149 | rev.minor = (rev.minor > 99 ? 99 : rev.minor); |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 150 | dev_id.fw[1] = rev.minor % 10 + (rev.minor / 10) * 16; |
| 151 | memcpy(&dev_id.aux, rev.d, 4); |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 152 | } |
| 153 | } |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 154 | |
Nan Li | ee0cb90 | 2016-07-11 15:38:03 +0800 | [diff] [blame] | 155 | // IPMI Spec verison 2.0 |
| 156 | dev_id.ipmi_ver = 2; |
| 157 | |
| 158 | // Additional device Support. |
| 159 | // List the 'logical device' commands and functions that the controller supports |
| 160 | // that are in addition to the mandatory IPM and Application commands. |
| 161 | // [7] Chassis Device (device functions as chassis device per ICMB spec.) |
| 162 | // [6] Bridge (device responds to Bridge NetFn commands) |
| 163 | // [5] IPMB Event Generator |
| 164 | // [4] IPMB Event Receiver |
| 165 | // [3] FRU Inventory Device |
| 166 | // [2] SEL Device |
| 167 | // [1] SDR Repository Device |
| 168 | // [0] Sensor Device |
| 169 | // We support FRU/SEL/Sensor now: |
| 170 | dev_id.addn_dev_support = 0x8D; |
| 171 | |
| 172 | // This value is the IANA number assigned to "IBM Platform Firmware |
| 173 | // Division", which is also used by our service processor. We may want |
| 174 | // a different number or at least a different version? |
| 175 | dev_id.manuf_id[0] = 0x41; |
| 176 | dev_id.manuf_id[1] = 0xA7; |
| 177 | dev_id.manuf_id[2] = 0x00; |
| 178 | |
| 179 | // Witherspoon's product ID is hardcoded to 4F42(ASCII 'OB'). |
| 180 | // TODO: openbmc/openbmc#495 |
| 181 | dev_id.prod_id[0] = 0x4F; |
| 182 | dev_id.prod_id[1] = 0x42; |
| 183 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 184 | // Pack the actual response |
Chris Austen | 7303bdc | 2016-04-17 11:50:54 -0500 | [diff] [blame] | 185 | memcpy(response, &dev_id, *data_len); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 186 | finish: |
| 187 | free(busname); |
Xo Wang | e553638 | 2017-07-20 20:14:00 -0700 | [diff] [blame] | 188 | free(ver); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 189 | return rc; |
| 190 | } |
| 191 | |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 192 | ipmi_ret_t ipmi_app_get_self_test_results(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 193 | ipmi_request_t request, ipmi_response_t response, |
| 194 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 195 | { |
| 196 | ipmi_ret_t rc = IPMI_CC_OK; |
| 197 | |
| 198 | // Byte 2: |
| 199 | // 55h - No error. |
| 200 | // 56h - Self Test funciton not implemented in this controller. |
| 201 | // 57h - Corrupted or inaccesssible data or devices. |
| 202 | // 58h - Fatal hardware error. |
| 203 | // FFh - reserved. |
| 204 | // all other: Device-specific 'internal failure'. |
| 205 | // Byte 3: |
| 206 | // For byte 2 = 55h, 56h, FFh: 00h |
| 207 | // For byte 2 = 58h, all other: Device-specific |
| 208 | // For byte 2 = 57h: self-test error bitfield. |
| 209 | // Note: returning 57h does not imply that all test were run. |
| 210 | // [7] 1b = Cannot access SEL device. |
| 211 | // [6] 1b = Cannot access SDR Repository. |
| 212 | // [5] 1b = Cannot access BMC FRU device. |
| 213 | // [4] 1b = IPMB signal lines do not respond. |
| 214 | // [3] 1b = SDR Repository empty. |
| 215 | // [2] 1b = Internal Use Area of BMC FRU corrupted. |
| 216 | // [1] 1b = controller update 'boot block' firmware corrupted. |
| 217 | // [0] 1b = controller operational firmware corrupted. |
| 218 | |
| 219 | char selftestresults[2] = {0}; |
| 220 | |
| 221 | *data_len = 2; |
| 222 | |
| 223 | selftestresults[0] = 0x56; |
| 224 | selftestresults[1] = 0; |
| 225 | |
| 226 | memcpy(response, selftestresults, *data_len); |
| 227 | |
| 228 | return rc; |
| 229 | } |
| 230 | |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 231 | ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 232 | ipmi_request_t request, ipmi_response_t response, |
| 233 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 234 | { |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 235 | const char *objname = "/org/openbmc/control/chassis0"; |
Adriana Kobylak | 31bccae | 2015-11-05 13:31:06 -0600 | [diff] [blame] | 236 | const char *iface = "org.freedesktop.DBus.Properties"; |
| 237 | const char *chassis_iface = "org.openbmc.control.Chassis"; |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 238 | sd_bus_message *reply = NULL; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 239 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 240 | int r = 0; |
| 241 | char *uuid = NULL; |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 242 | char *busname = NULL; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 243 | |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 244 | // UUID is in RFC4122 format. Ex: 61a39523-78f2-11e5-9862-e6402cfc3223 |
| 245 | // Per IPMI Spec 2.0 need to convert to 16 hex bytes and reverse the byte order |
| 246 | // Ex: 0x2332fc2c40e66298e511f2782395a361 |
| 247 | |
| 248 | const int resp_size = 16; // Response is 16 hex bytes per IPMI Spec |
| 249 | uint8_t resp_uuid[resp_size]; // Array to hold the formatted response |
| 250 | int resp_loc = resp_size-1; // Point resp end of array to save in reverse order |
| 251 | int i = 0; |
| 252 | char *tokptr = NULL; |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 253 | char *id_octet = NULL; |
| 254 | |
| 255 | // Status code. |
| 256 | ipmi_ret_t rc = IPMI_CC_OK; |
| 257 | *data_len = 0; |
| 258 | |
| 259 | printf("IPMI GET DEVICE GUID\n"); |
| 260 | |
| 261 | // Call Get properties method with the interface and property name |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 262 | r = mapper_get_service(bus, objname, &busname); |
| 263 | if (r < 0) { |
Brad Bishop | 819ddd4 | 2016-10-05 21:19:19 -0400 | [diff] [blame] | 264 | fprintf(stderr, "Failed to get %s bus name: %s\n", |
| 265 | objname, strerror(-r)); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 266 | goto finish; |
| 267 | } |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 268 | r = sd_bus_call_method(bus,busname,objname,iface, |
| 269 | "Get",&error, &reply, "ss", |
| 270 | chassis_iface, "uuid"); |
| 271 | if (r < 0) |
| 272 | { |
| 273 | fprintf(stderr, "Failed to call Get Method: %s\n", strerror(-r)); |
| 274 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 275 | goto finish; |
| 276 | } |
| 277 | |
| 278 | r = sd_bus_message_read(reply, "v", "s", &uuid); |
| 279 | if (r < 0 || uuid == NULL) |
| 280 | { |
| 281 | fprintf(stderr, "Failed to get a response: %s", strerror(-r)); |
| 282 | rc = IPMI_CC_RESPONSE_ERROR; |
| 283 | goto finish; |
| 284 | } |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 285 | |
| 286 | // Traverse the UUID |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 287 | id_octet = strtok_r(uuid, "-", &tokptr); // Get the UUID octects separated by dash |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 288 | |
| 289 | if (id_octet == NULL) |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 290 | { |
| 291 | // Error |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 292 | fprintf(stderr, "Unexpected UUID format: %s", uuid); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 293 | rc = IPMI_CC_RESPONSE_ERROR; |
| 294 | goto finish; |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | while (id_octet != NULL) |
| 298 | { |
| 299 | // Calculate the octet string size since it varies |
| 300 | // Divide it by 2 for the array size since 1 byte is built from 2 chars |
| 301 | int tmp_size = strlen(id_octet)/2; |
| 302 | |
| 303 | for(i = 0; i < tmp_size; i++) |
| 304 | { |
Joel Stanley | 38310cd | 2015-11-25 17:32:08 +1030 | [diff] [blame] | 305 | char tmp_array[3] = {0}; // Holder of the 2 chars that will become a byte |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 306 | strncpy(tmp_array, id_octet, 2); // 2 chars at a time |
| 307 | |
| 308 | int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte |
| 309 | memcpy((void*)&resp_uuid[resp_loc], &resp_byte, 1); // Copy end to first |
| 310 | resp_loc--; |
| 311 | id_octet+=2; // Finished with the 2 chars, advance |
| 312 | } |
| 313 | id_octet=strtok_r(NULL, "-", &tokptr); // Get next octet |
| 314 | } |
| 315 | |
| 316 | // Data length |
| 317 | *data_len = resp_size; |
| 318 | |
| 319 | // Pack the actual response |
| 320 | memcpy(response, &resp_uuid, *data_len); |
| 321 | |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 322 | finish: |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 323 | sd_bus_error_free(&error); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 324 | reply = sd_bus_message_unref(reply); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 325 | free(busname); |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 326 | |
| 327 | return rc; |
| 328 | } |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 329 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 330 | ipmi_ret_t ipmi_app_get_bt_capabilities(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 331 | ipmi_request_t request, ipmi_response_t response, |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 332 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 333 | { |
| 334 | printf("Handling Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd); |
| 335 | |
| 336 | // Status code. |
| 337 | ipmi_ret_t rc = IPMI_CC_OK; |
| 338 | |
Adriana Kobylak | 88ad815 | 2016-12-13 10:09:08 -0600 | [diff] [blame] | 339 | // Per IPMI 2.0 spec, the input and output buffer size must be the max |
| 340 | // buffer size minus one byte to allocate space for the length byte. |
| 341 | uint8_t str[] = {0x01, MAX_IPMI_BUFFER-1, MAX_IPMI_BUFFER-1, 0x0A, 0x01}; |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 342 | |
| 343 | // Data length |
| 344 | *data_len = sizeof(str); |
| 345 | |
| 346 | // Pack the actual response |
| 347 | memcpy(response, &str, *data_len); |
| 348 | |
| 349 | return rc; |
| 350 | } |
| 351 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 352 | |
| 353 | struct set_wd_data_t { |
| 354 | uint8_t t_use; |
| 355 | uint8_t t_action; |
| 356 | uint8_t preset; |
| 357 | uint8_t flags; |
| 358 | uint8_t ls; |
| 359 | uint8_t ms; |
| 360 | } __attribute__ ((packed)); |
| 361 | |
| 362 | |
| 363 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 364 | ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 365 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 366 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 367 | { |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 368 | const char *objname = "/xyz/openbmc_project/watchdog/host0"; |
| 369 | const char *iface = "xyz.openbmc_project.State.Watchdog"; |
| 370 | const char *property_iface = "org.freedesktop.DBus.Properties"; |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 371 | sd_bus_message *reply = NULL; |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 372 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 373 | int r = 0; |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 374 | |
| 375 | set_wd_data_t *reqptr = (set_wd_data_t*) request; |
| 376 | uint16_t timer = 0; |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 377 | |
| 378 | // Making this uint64_t to match with provider |
| 379 | uint64_t timer_ms = 0; |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 380 | char *busname = NULL; |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 381 | *data_len = 0; |
| 382 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 383 | // Get number of 100ms intervals |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 384 | timer = (((uint16_t)reqptr->ms) << 8) + reqptr->ls; |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 385 | // Get timer value in ms |
| 386 | timer_ms = timer * 100; |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 387 | |
| 388 | printf("WATCHDOG SET Timer:[0x%X] 100ms intervals\n",timer); |
| 389 | |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 390 | // Get bus name |
| 391 | r = mapper_get_service(bus, objname, &busname); |
| 392 | if (r < 0) { |
Brad Bishop | 819ddd4 | 2016-10-05 21:19:19 -0400 | [diff] [blame] | 393 | fprintf(stderr, "Failed to get %s bus name: %s\n", |
| 394 | objname, strerror(-r)); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 395 | goto finish; |
| 396 | } |
Adriana Kobylak | 0896be3 | 2015-10-22 13:27:23 -0500 | [diff] [blame] | 397 | |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 398 | // Disable watchdog if running |
| 399 | r = sd_bus_call_method(bus, busname, objname, property_iface, |
| 400 | "Set", &error, &reply, "ssv", |
| 401 | iface, "Enabled", "b", false); |
| 402 | if(r < 0) { |
| 403 | fprintf(stderr, "Failed to disable Watchdog: %s\n", |
| 404 | strerror(-r)); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 405 | goto finish; |
| 406 | } |
| 407 | |
| 408 | if (reqptr->t_use & 0x40) |
| 409 | { |
| 410 | sd_bus_error_free(&error); |
| 411 | reply = sd_bus_message_unref(reply); |
| 412 | |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 413 | // Now Enable Watchdog |
| 414 | r = sd_bus_call_method(bus, busname, objname, property_iface, |
| 415 | "Set", &error, &reply, "ssv", |
| 416 | iface, "Enabled", "b", true); |
| 417 | if(r < 0) { |
| 418 | fprintf(stderr, "Failed to Enable Watchdog: %s\n", |
| 419 | strerror(-r)); |
| 420 | goto finish; |
| 421 | } |
| 422 | |
| 423 | // Set watchdog timer |
| 424 | r = sd_bus_call_method(bus, busname, objname, property_iface, |
| 425 | "Set", &error, &reply, "ssv", |
| 426 | iface, "TimeRemaining", "t", timer_ms); |
| 427 | if(r < 0) { |
| 428 | fprintf(stderr, "Failed to set new expiration time: %s\n", |
| 429 | strerror(-r)); |
| 430 | goto finish; |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 431 | } |
| 432 | } |
| 433 | |
| 434 | finish: |
| 435 | sd_bus_error_free(&error); |
| 436 | reply = sd_bus_message_unref(reply); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 437 | free(busname); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 438 | |
| 439 | return (r < 0) ? -1 : IPMI_CC_OK; |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 443 | ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 444 | ipmi_request_t request, ipmi_response_t response, |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 445 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 446 | { |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 447 | const char *objname = "/xyz/openbmc_project/watchdog/host0"; |
| 448 | const char *iface = "xyz.openbmc_project.State.Watchdog"; |
| 449 | const char *property_iface = "org.freedesktop.DBus.Properties"; |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 450 | sd_bus_message *reply = NULL; |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 451 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 452 | int r = 0; |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 453 | char *busname = NULL; |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 454 | |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 455 | // Current time interval that is set in watchdog. |
| 456 | uint64_t interval = 0; |
| 457 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 458 | // Status code. |
| 459 | ipmi_ret_t rc = IPMI_CC_OK; |
| 460 | *data_len = 0; |
| 461 | |
| 462 | printf("WATCHDOG RESET\n"); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 463 | // Get bus name |
| 464 | r = mapper_get_service(bus, objname, &busname); |
| 465 | if (r < 0) { |
Brad Bishop | 819ddd4 | 2016-10-05 21:19:19 -0400 | [diff] [blame] | 466 | fprintf(stderr, "Failed to get %s bus name: %s\n", |
| 467 | objname, strerror(-r)); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 468 | goto finish; |
| 469 | } |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 470 | |
| 471 | // Get the current interval and set it back. |
| 472 | r = sd_bus_call_method(bus, busname, objname, property_iface, |
| 473 | "Get", &error, &reply, "ss", |
| 474 | iface, "Interval"); |
| 475 | |
| 476 | if(r < 0) { |
| 477 | fprintf(stderr, "Failed to get current Interval msg: %s\n", |
| 478 | strerror(-r)); |
| 479 | goto finish; |
| 480 | } |
| 481 | |
| 482 | // Now extract the value |
| 483 | r = sd_bus_message_read(reply, "v", "t", &interval); |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 484 | if (r < 0) { |
Vishwanatha Subbanna | 8fc0988 | 2017-06-12 19:57:37 +0530 | [diff] [blame] | 485 | fprintf(stderr, "Failed to read current interval: %s\n", |
| 486 | strerror(-r)); |
| 487 | goto finish; |
| 488 | } |
| 489 | |
| 490 | sd_bus_error_free(&error); |
| 491 | reply = sd_bus_message_unref(reply); |
| 492 | |
| 493 | // Set watchdog timer |
| 494 | r = sd_bus_call_method(bus, busname, objname, property_iface, |
| 495 | "Set", &error, &reply, "ssv", |
| 496 | iface, "TimeRemaining", "t", interval); |
| 497 | if(r < 0) { |
| 498 | fprintf(stderr, "Failed to refresh the timer: %s\n", |
| 499 | strerror(-r)); |
| 500 | goto finish; |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 501 | } |
| 502 | |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 503 | finish: |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 504 | sd_bus_error_free(&error); |
vishwa | 1eaea4f | 2016-02-26 11:57:40 -0600 | [diff] [blame] | 505 | reply = sd_bus_message_unref(reply); |
Sergey Solomin | eb9b814 | 2016-08-23 09:07:28 -0500 | [diff] [blame] | 506 | free(busname); |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 507 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 508 | return rc; |
| 509 | } |
| 510 | |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 511 | extern struct channel_config_t channel_config; |
| 512 | |
| 513 | ipmi_ret_t ipmi_set_channel_access(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 514 | ipmi_request_t request, ipmi_response_t response, |
| 515 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 516 | { |
| 517 | ipmi_ret_t rc = IPMI_CC_OK; |
| 518 | |
| 519 | sd_bus *bus = ipmid_get_sd_bus_connection(); |
| 520 | sd_bus_message *reply = nullptr; |
| 521 | sd_bus_error error = SD_BUS_ERROR_NULL; |
| 522 | int r = 0; |
| 523 | char *app = nullptr; |
| 524 | int family = 0; |
| 525 | unsigned char prefixlen = 0; |
| 526 | char* ipaddr = nullptr; |
| 527 | uint32_t mask = 0xFFFFFFFF; |
| 528 | char* gateway = nullptr; |
| 529 | char tmp_netmask[INET_ADDRSTRLEN]; |
| 530 | |
| 531 | // Todo: parse the request data if needed. |
| 532 | |
| 533 | // Using Set Channel cmd to apply changes of Set Lan Cmd. |
| 534 | |
| 535 | r = mapper_get_service(bus, app_obj, &app); |
| 536 | if (r < 0) { |
| 537 | fprintf(stderr, "Failed to get %s bus name: %s\n", |
| 538 | app_obj, strerror(-r)); |
| 539 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 540 | goto finish; |
| 541 | } |
| 542 | |
| 543 | r = sd_bus_call_method(bus, app, app_obj, app_ifc, "GetAddress4", &error, |
| 544 | &reply, "s", app_nwinterface); |
| 545 | if (r < 0) { |
| 546 | fprintf(stderr, "Failed to call Get Method: %s\n", strerror(-r)); |
| 547 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 548 | goto finish; |
| 549 | } |
| 550 | |
| 551 | r = sd_bus_message_read(reply, "iyss", |
| 552 | &family, &prefixlen, &ipaddr, &gateway); |
| 553 | if (r < 0) { |
| 554 | fprintf(stderr, "Failed to get a response: %s\n", strerror(-r)); |
| 555 | rc = IPMI_CC_RESPONSE_ERROR; |
| 556 | goto finish; |
| 557 | } |
| 558 | |
| 559 | printf("N/W data from Cache: %s:%s:%s\n", |
| 560 | channel_config.new_ipaddr.c_str(), |
| 561 | channel_config.new_netmask.c_str(), |
| 562 | channel_config.new_gateway.c_str()); |
| 563 | |
| 564 | if(channel_config.new_ipaddr.empty()) { |
| 565 | channel_config.new_ipaddr.assign(ipaddr); |
| 566 | } |
| 567 | |
| 568 | if(channel_config.new_netmask.empty()) { |
| 569 | mask = htonl(mask<<(32-prefixlen)); |
| 570 | uint8_t* p = (uint8_t*)&mask; |
| 571 | |
| 572 | snprintf(tmp_netmask, INET_ADDRSTRLEN, "%d.%d.%d.%d", |
| 573 | *p, *(p+1), *(p+2), *(p+3)); |
| 574 | channel_config.new_netmask.assign(tmp_netmask); |
| 575 | } |
| 576 | |
| 577 | if(channel_config.new_gateway.empty()) { |
| 578 | channel_config.new_gateway.assign(gateway); |
| 579 | } |
| 580 | |
| 581 | printf("N/W data from HW %s:%d:%s:%s\n", |
| 582 | family==AF_INET?"IPv4":"IPv6", prefixlen, ipaddr,gateway); |
| 583 | printf("N/W data from Cache: %s:%s:%s\n", |
| 584 | channel_config.new_ipaddr.c_str(), |
| 585 | channel_config.new_netmask.c_str(), |
| 586 | channel_config.new_gateway.c_str()); |
| 587 | |
| 588 | r = sd_bus_call_method(bus, // On the System Bus |
| 589 | app, // Service to contact |
| 590 | app_obj, // Object path |
| 591 | app_ifc, // Interface name |
| 592 | "SetAddress4", // Method to be called |
| 593 | &error, // object to return error |
| 594 | &reply, // Response message on success |
| 595 | "ssss", // input message (Interface, |
| 596 | // IP Address, Netmask, Gateway) |
| 597 | app_nwinterface, // eth0 |
| 598 | channel_config.new_ipaddr.c_str(), |
| 599 | channel_config.new_netmask.c_str(), |
| 600 | channel_config.new_gateway.c_str()); |
| 601 | if(r < 0) { |
| 602 | fprintf(stderr, "Failed to set network data %s:%s:%s %s\n", |
| 603 | channel_config.new_ipaddr.c_str(), |
| 604 | channel_config.new_netmask.c_str(), |
| 605 | channel_config.new_gateway.c_str(), |
| 606 | error.message); |
| 607 | rc = IPMI_CC_UNSPECIFIED_ERROR; |
| 608 | } |
| 609 | |
| 610 | channel_config.new_ipaddr.clear(); |
| 611 | channel_config.new_netmask.clear(); |
| 612 | channel_config.new_gateway.clear(); |
| 613 | |
| 614 | finish: |
| 615 | sd_bus_error_free(&error); |
| 616 | reply = sd_bus_message_unref(reply); |
| 617 | free(app); |
| 618 | |
| 619 | return rc; |
| 620 | } |
| 621 | |
Chris Austen | c2cd29d | 2016-02-05 20:02:29 -0600 | [diff] [blame] | 622 | // ATTENTION: This ipmi function is very hardcoded on purpose |
| 623 | // OpenBMC does not fully support IPMI. This command is useful |
| 624 | // to have around because it enables testing of interfaces with |
| 625 | // the IPMI tool. |
| 626 | #define GET_CHANNEL_INFO_CHANNEL_OFFSET 0 |
| 627 | // IPMI Table 6-2 |
| 628 | #define IPMI_CHANNEL_TYPE_IPMB 1 |
| 629 | // IPMI Table 6-3 |
| 630 | #define IPMI_CHANNEL_MEDIUM_TYPE_OTHER 6 |
| 631 | |
| 632 | ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 633 | ipmi_request_t request, ipmi_response_t response, |
| 634 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 635 | { |
| 636 | ipmi_ret_t rc = IPMI_CC_OK; |
| 637 | uint8_t resp[] = { |
| 638 | 1, |
| 639 | IPMI_CHANNEL_MEDIUM_TYPE_OTHER, |
| 640 | IPMI_CHANNEL_TYPE_IPMB, |
| 641 | 1,0x41,0xA7,0x00,0,0}; |
| 642 | uint8_t *p = (uint8_t*) request; |
| 643 | |
| 644 | printf("IPMI APP GET CHANNEL INFO\n"); |
| 645 | |
tomjose | 7ec0add | 2016-06-27 07:59:28 -0500 | [diff] [blame] | 646 | // The supported channels numbers are 1 and 8. |
| 647 | // Channel Number E is used as way to identify the current channel |
| 648 | // that the command is being is received from. |
tomjose | 13fb441 | 2016-03-08 14:02:34 -0600 | [diff] [blame] | 649 | if (*p == 0xe || *p == 1 || *p == 8) { |
Chris Austen | c2cd29d | 2016-02-05 20:02:29 -0600 | [diff] [blame] | 650 | |
| 651 | *data_len = sizeof(resp); |
| 652 | memcpy(response, resp, *data_len); |
| 653 | |
| 654 | } else { |
| 655 | rc = IPMI_CC_PARM_OUT_OF_RANGE; |
| 656 | *data_len = 0; |
| 657 | } |
| 658 | |
| 659 | return rc; |
| 660 | } |
| 661 | |
Adriana Kobylak | 3a552e1 | 2015-10-19 16:11:00 -0500 | [diff] [blame] | 662 | ipmi_ret_t ipmi_app_wildcard_handler(ipmi_netfn_t netfn, ipmi_cmd_t cmd, |
| 663 | ipmi_request_t request, ipmi_response_t response, |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 664 | ipmi_data_len_t data_len, ipmi_context_t context) |
| 665 | { |
| 666 | printf("Handling WILDCARD Netfn:[0x%X], Cmd:[0x%X]\n",netfn, cmd); |
| 667 | |
| 668 | // Status code. |
Nan Li | 70aa8d9 | 2016-08-29 00:11:10 +0800 | [diff] [blame] | 669 | ipmi_ret_t rc = IPMI_CC_INVALID; |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 670 | |
| 671 | *data_len = strlen("THIS IS WILDCARD"); |
| 672 | |
| 673 | // Now pack actual response |
| 674 | memcpy(response, "THIS IS WILDCARD", *data_len); |
| 675 | |
| 676 | return rc; |
| 677 | } |
| 678 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 679 | void register_netfn_app_functions() |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 680 | { |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 681 | // <Get BT Interface Capabilities> |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 682 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CAP_BIT); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 683 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CAP_BIT, NULL, ipmi_app_get_bt_capabilities, |
| 684 | PRIVILEGE_USER); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 685 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 686 | // <Wildcard Command> |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 687 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_WILDCARD); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 688 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_WILDCARD, NULL, ipmi_app_wildcard_handler, |
| 689 | PRIVILEGE_USER); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 690 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 691 | // <Reset Watchdog Timer> |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 692 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_RESET_WD); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 693 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL, ipmi_app_reset_watchdog, |
| 694 | PRIVILEGE_OPERATOR); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 695 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 696 | // <Set Watchdog Timer> |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 697 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_WD); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 698 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL, ipmi_app_set_watchdog, |
| 699 | PRIVILEGE_OPERATOR); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 700 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 701 | // <Get Device ID> |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 702 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_ID); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 703 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_ID, NULL, ipmi_app_get_device_id, |
| 704 | PRIVILEGE_USER); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 705 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 706 | // <Get Self Test Results> |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 707 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_SELF_TEST_RESULTS); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 708 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_SELF_TEST_RESULTS, NULL, |
| 709 | ipmi_app_get_self_test_results, PRIVILEGE_USER); |
Nan Li | 41fa24a | 2016-11-10 20:12:37 +0800 | [diff] [blame] | 710 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 711 | // <Get Device GUID> |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 712 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 713 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID, NULL, ipmi_app_get_device_guid, |
| 714 | PRIVILEGE_USER); |
Adriana Kobylak | d100ee5 | 2015-10-20 17:02:37 -0500 | [diff] [blame] | 715 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 716 | // <Set ACPI Power State> |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 717 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_ACPI); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 718 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_ACPI, NULL, ipmi_app_set_acpi_power_state, |
| 719 | PRIVILEGE_ADMIN); |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 720 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 721 | // <Set Channel Access> |
Nan Li | 3d0df91 | 2016-10-18 19:51:41 +0800 | [diff] [blame] | 722 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, |
| 723 | IPMI_CMD_SET_CHAN_ACCESS); |
| 724 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_CHAN_ACCESS, NULL, |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 725 | ipmi_set_channel_access, PRIVILEGE_ADMIN); |
Chris Austen | c2cd29d | 2016-02-05 20:02:29 -0600 | [diff] [blame] | 726 | |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 727 | // <Get Channel Info Command> |
Chris Austen | c2cd29d | 2016-02-05 20:02:29 -0600 | [diff] [blame] | 728 | printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CHAN_INFO); |
Tom | 0573237 | 2016-09-06 17:21:23 +0530 | [diff] [blame] | 729 | ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL, ipmi_app_channel_info, |
| 730 | PRIVILEGE_USER); |
Chris Austen | c2cd29d | 2016-02-05 20:02:29 -0600 | [diff] [blame] | 731 | |
vishwabmc | ba0bd5f | 2015-09-30 16:50:23 +0530 | [diff] [blame] | 732 | return; |
| 733 | } |
| 734 | |
Chris Austen | 6caf28b | 2015-10-13 12:40:40 -0500 | [diff] [blame] | 735 | |