blob: 53a83d3d16e6be9512a0ee5442cef11ed40ce215 [file] [log] [blame]
vishwabmcba0bd5f2015-09-30 16:50:23 +05301#include "apphandler.h"
2#include "ipmid-api.h"
Chris Austen6caf28b2015-10-13 12:40:40 -05003#include "ipmid.H"
vishwabmcba0bd5f2015-09-30 16:50:23 +05304#include <stdio.h>
5#include <string.h>
Chris Austen6caf28b2015-10-13 12:40:40 -05006#include <stdint.h>
Adriana Kobylak3a552e12015-10-19 16:11:00 -05007#include <systemd/sd-bus.h>
8
9extern sd_bus *bus;
vishwabmcba0bd5f2015-09-30 16:50:23 +053010
Chris Austen6caf28b2015-10-13 12:40:40 -050011void register_netfn_app_functions() __attribute__((constructor));
vishwabmcba0bd5f2015-09-30 16:50:23 +053012
Chris Austen7303bdc2016-04-17 11:50:54 -050013#define DEVICE_FW1 2
14#define DEVICE_FW2 3
15#define DEVICE_AUX 11
16
vishwa36993272015-11-20 12:43:49 -060017//---------------------------------------------------------------------
18// Called by Host on seeing a SMS_ATN bit set. Return a hardcoded
19// value of 0x2 indicating we need Host read some data.
20//-------------------------------------------------------------------
21ipmi_ret_t ipmi_app_get_msg_flags(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
22 ipmi_request_t request, ipmi_response_t response,
23 ipmi_data_len_t data_len, ipmi_context_t context)
24{
25 // Generic return from IPMI commands.
26 ipmi_ret_t rc = IPMI_CC_OK;
Chris Austen6caf28b2015-10-13 12:40:40 -050027
vishwa36993272015-11-20 12:43:49 -060028 printf("IPMI APP GET MSG FLAGS returning with [bit:2] set\n");
29
30 // From IPMI spec V2.0 for Get Message Flags Command :
31 // bit:[1] from LSB : 1b = Event Message Buffer Full.
32 // Return as 0 if Event Message Buffer is not supported,
33 // or when the Event Message buffer is disabled.
34 // TODO. For now. assume its not disabled and send "0x2" anyway:
35
36 uint8_t set_event_msg_buffer_full = 0x2;
37 *data_len = sizeof(set_event_msg_buffer_full);
38
39 // Pack the actual response
40 memcpy(response, &set_event_msg_buffer_full, *data_len);
41
42 return rc;
43}
44
45//-------------------------------------------------------------------
46// Called by Host post response from Get_Message_Flags
47//-------------------------------------------------------------------
Adriana Kobylak3a552e12015-10-19 16:11:00 -050048ipmi_ret_t ipmi_app_read_event(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
49 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -050050 ipmi_data_len_t data_len, ipmi_context_t context)
51{
52 ipmi_ret_t rc = IPMI_CC_OK;
vishwa36993272015-11-20 12:43:49 -060053 printf("IPMI APP READ EVENT command received\n");
Chris Austen6caf28b2015-10-13 12:40:40 -050054
vishwa36993272015-11-20 12:43:49 -060055 // TODO : For now, this is catering only to the Soft Power Off via OEM SEL
56 // mechanism. If we need to make this generically used for some
57 // other conditions, then we can take advantage of context pointer.
58
59 struct oem_sel_timestamped soft_off = {0};
60 *data_len = sizeof(struct oem_sel_timestamped);
61
62 // either id[0] -or- id[1] can be filled in. We will use id[0]
63 soft_off.id[0] = SEL_OEM_ID_0;
64 soft_off.id[1] = SEL_OEM_ID_0;
65 soft_off.type = SEL_RECORD_TYPE_OEM;
66
67 // Following 3 bytes are from IANA Manufactre_Id field. See below
68 soft_off.manuf_id[0]= 0x41;
69 soft_off.manuf_id[1]= 0xA7;
70 soft_off.manuf_id[2]= 0x00;
71
72 // per IPMI spec NetFuntion for OEM
73 soft_off.netfun = 0x3A;
74
75 // Mechanism to kick start soft shutdown.
76 soft_off.cmd = CMD_POWER;
77 soft_off.data[0] = SOFT_OFF;
78
79 // All '0xFF' since unused.
80 memset(&soft_off.data[1], 0xFF, 3);
81
82 // Pack the actual response
83 memcpy(response, &soft_off, *data_len);
Chris Austen6caf28b2015-10-13 12:40:40 -050084 return rc;
Chris Austen6caf28b2015-10-13 12:40:40 -050085}
86
Adriana Kobylak3a552e12015-10-19 16:11:00 -050087ipmi_ret_t ipmi_app_set_acpi_power_state(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
88 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -050089 ipmi_data_len_t data_len, ipmi_context_t context)
90{
91 ipmi_ret_t rc = IPMI_CC_OK;
92 *data_len = 0;
93
94 printf("IPMI SET ACPI STATE Ignoring for now\n");
95 return rc;
96}
97
Chris Austen7303bdc2016-04-17 11:50:54 -050098
99typedef struct
100{
101 char major;
102 char minor;
103 uint8_t d[4];
104} rev_t;
105
106
107/* Currently only supports the vx.x-x-[-x] format Will return -1 if not in */
108/* the format this routine knows how to parse */
109/* version = v0.6-19-gf363f61-dirty */
110/* ^ ^ ^^ ^ */
111/* | | |----------|-- additional details */
112/* | |---------------- Minor */
113/* |------------------ Major */
114/* Additional details : If the option group exists it will force Auxiliary */
115/* Firmware Revision Information 4th byte to 1 indicating the build was */
116/* derived with additional edits */
117int convert_version(const char *p, rev_t *rev)
118{
119 char *s, *token;
120 char hexbyte[5];
121 int l;
122
123 if (*p != 'v')
124 return -1;
125 p++;
126
127 s = strdup(p);
128 token = strtok(s,".-");
129
130 rev->major = (int8_t) atoi(token);
131
132 token = strtok(NULL, ".-");
133 rev->minor = (int8_t) atoi(token);
134
135 // Capture the number of commits on top of the minor tag.
136 // I'm using BE format like the ipmi spec asked for
137 token = strtok(NULL,".-");
138 l = strlen(token);
139 if (l > 4)
140 l = 4;
141
142 memset(hexbyte,'0', 4);
143 memcpy(&hexbyte[4-l], token, l);
144 sscanf(&hexbyte[0], "%2hhX", &rev->d[0]);
145 sscanf(&hexbyte[2], "%2hhX", &rev->d[1]);
146
147 rev->d[2] = 0;
148
149 // commit number we skip
150 token = strtok(NULL,".-");
151
152 // Any value of the optional parameter forces it to 1
153 token = strtok(NULL,".-");
154 rev->d[3] = (token != NULL) ? 1 : 0;
155
156 free(s);
157 return 0;
158}
159
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500160ipmi_ret_t ipmi_app_get_device_id(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
161 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500162 ipmi_data_len_t data_len, ipmi_context_t context)
163{
164 ipmi_ret_t rc = IPMI_CC_OK;
Chris Austen7303bdc2016-04-17 11:50:54 -0500165 const char *busname = "org.openbmc.Inventory";
166 const char *objname = "/org/openbmc/inventory/system/chassis/motherboard/bmc";
167 const char *iface = "org.openbmc.InventoryItem";
168 char *ver = NULL;
169 int r;
170 rev_t rev = {0};
Chris Austen6caf28b2015-10-13 12:40:40 -0500171
Patrick Williams76b51f62015-10-28 12:14:56 -0500172 // TODO:
173 // This value is the IANA number assigned to "IBM Platform Firmware
174 // Division", which is also used by our service processor. We may want
175 // a different number or at least a different version?
Chris Austen7303bdc2016-04-17 11:50:54 -0500176 uint8_t dev_id[] = {0, 0, 0, 0, 2, 0xD, 0x41, 0xA7, 0x00, 0x43, 0x40, 0, 0, 0, 0};
Chris Austen6caf28b2015-10-13 12:40:40 -0500177
178 // Data length
Chris Austen7303bdc2016-04-17 11:50:54 -0500179 *data_len = sizeof(dev_id);
180
181 r = sd_bus_get_property_string(bus,busname,objname,iface,"version", NULL, &ver);
182 if ( r < 0 ) {
183 fprintf(stderr, "Failed to obtain version property: %s\n", strerror(-r));
184 } else {
185 r = convert_version(ver, &rev);
186 if( r >= 0 ) {
187 // bit7 identifies state of SDR repository, hence the mask
188 dev_id[DEVICE_FW1] |= 0x7F & rev.major;
189 dev_id[DEVICE_FW2] = rev.minor;
190 memcpy(&dev_id[DEVICE_AUX], rev.d, 4);
191 }
192 }
Chris Austen6caf28b2015-10-13 12:40:40 -0500193
194 // Pack the actual response
Chris Austen7303bdc2016-04-17 11:50:54 -0500195 memcpy(response, &dev_id, *data_len);
Chris Austen6caf28b2015-10-13 12:40:40 -0500196 return rc;
197}
198
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500199ipmi_ret_t ipmi_app_get_device_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
200 ipmi_request_t request, ipmi_response_t response,
201 ipmi_data_len_t data_len, ipmi_context_t context)
202{
203 const char *busname = "org.openbmc.control.Chassis";
204 const char *objname = "/org/openbmc/control/chassis0";
Adriana Kobylak31bccae2015-11-05 13:31:06 -0600205 const char *iface = "org.freedesktop.DBus.Properties";
206 const char *chassis_iface = "org.openbmc.control.Chassis";
vishwa1eaea4f2016-02-26 11:57:40 -0600207 sd_bus_message *reply = NULL;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500208 sd_bus_error error = SD_BUS_ERROR_NULL;
209 int r = 0;
210 char *uuid = NULL;
211
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500212 // UUID is in RFC4122 format. Ex: 61a39523-78f2-11e5-9862-e6402cfc3223
213 // Per IPMI Spec 2.0 need to convert to 16 hex bytes and reverse the byte order
214 // Ex: 0x2332fc2c40e66298e511f2782395a361
215
216 const int resp_size = 16; // Response is 16 hex bytes per IPMI Spec
217 uint8_t resp_uuid[resp_size]; // Array to hold the formatted response
218 int resp_loc = resp_size-1; // Point resp end of array to save in reverse order
219 int i = 0;
220 char *tokptr = NULL;
vishwa1eaea4f2016-02-26 11:57:40 -0600221 char *id_octet = NULL;
222
223 // Status code.
224 ipmi_ret_t rc = IPMI_CC_OK;
225 *data_len = 0;
226
227 printf("IPMI GET DEVICE GUID\n");
228
229 // Call Get properties method with the interface and property name
230 r = sd_bus_call_method(bus,busname,objname,iface,
231 "Get",&error, &reply, "ss",
232 chassis_iface, "uuid");
233 if (r < 0)
234 {
235 fprintf(stderr, "Failed to call Get Method: %s\n", strerror(-r));
236 rc = IPMI_CC_UNSPECIFIED_ERROR;
237 goto finish;
238 }
239
240 r = sd_bus_message_read(reply, "v", "s", &uuid);
241 if (r < 0 || uuid == NULL)
242 {
243 fprintf(stderr, "Failed to get a response: %s", strerror(-r));
244 rc = IPMI_CC_RESPONSE_ERROR;
245 goto finish;
246 }
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500247
248 // Traverse the UUID
vishwa1eaea4f2016-02-26 11:57:40 -0600249 id_octet = strtok_r(uuid, "-", &tokptr); // Get the UUID octects separated by dash
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500250
251 if (id_octet == NULL)
vishwa1eaea4f2016-02-26 11:57:40 -0600252 {
253 // Error
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500254 fprintf(stderr, "Unexpected UUID format: %s", uuid);
vishwa1eaea4f2016-02-26 11:57:40 -0600255 rc = IPMI_CC_RESPONSE_ERROR;
256 goto finish;
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500257 }
258
259 while (id_octet != NULL)
260 {
261 // Calculate the octet string size since it varies
262 // Divide it by 2 for the array size since 1 byte is built from 2 chars
263 int tmp_size = strlen(id_octet)/2;
264
265 for(i = 0; i < tmp_size; i++)
266 {
Joel Stanley38310cd2015-11-25 17:32:08 +1030267 char tmp_array[3] = {0}; // Holder of the 2 chars that will become a byte
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500268 strncpy(tmp_array, id_octet, 2); // 2 chars at a time
269
270 int resp_byte = strtoul(tmp_array, NULL, 16); // Convert to hex byte
271 memcpy((void*)&resp_uuid[resp_loc], &resp_byte, 1); // Copy end to first
272 resp_loc--;
273 id_octet+=2; // Finished with the 2 chars, advance
274 }
275 id_octet=strtok_r(NULL, "-", &tokptr); // Get next octet
276 }
277
278 // Data length
279 *data_len = resp_size;
280
281 // Pack the actual response
282 memcpy(response, &resp_uuid, *data_len);
283
vishwa1eaea4f2016-02-26 11:57:40 -0600284finish:
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500285 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600286 reply = sd_bus_message_unref(reply);
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500287
288 return rc;
289}
Chris Austen6caf28b2015-10-13 12:40:40 -0500290
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500291ipmi_ret_t ipmi_app_get_bt_capabilities(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
292 ipmi_request_t request, ipmi_response_t response,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530293 ipmi_data_len_t data_len, ipmi_context_t context)
294{
295 printf("Handling Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd);
296
297 // Status code.
298 ipmi_ret_t rc = IPMI_CC_OK;
299
Chris Austen6caf28b2015-10-13 12:40:40 -0500300 uint8_t str[] = {0x01, MAX_IPMI_BUFFER, MAX_IPMI_BUFFER, 0x0A, 0x01};
vishwabmcba0bd5f2015-09-30 16:50:23 +0530301
302 // Data length
303 *data_len = sizeof(str);
304
305 // Pack the actual response
306 memcpy(response, &str, *data_len);
307
308 return rc;
309}
310
Chris Austen6caf28b2015-10-13 12:40:40 -0500311
312struct set_wd_data_t {
313 uint8_t t_use;
314 uint8_t t_action;
315 uint8_t preset;
316 uint8_t flags;
317 uint8_t ls;
318 uint8_t ms;
319} __attribute__ ((packed));
320
321
322
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500323ipmi_ret_t ipmi_app_set_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
324 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500325 ipmi_data_len_t data_len, ipmi_context_t context)
326{
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500327 const char *busname = "org.openbmc.watchdog.Host";
Chris Austen454acfe2015-10-29 23:03:34 -0500328 const char *objname = "/org/openbmc/watchdog/host0";
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500329 const char *iface = "org.openbmc.Watchdog";
vishwa1eaea4f2016-02-26 11:57:40 -0600330 sd_bus_message *reply = NULL;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500331 sd_bus_error error = SD_BUS_ERROR_NULL;
332 int r = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500333
334 set_wd_data_t *reqptr = (set_wd_data_t*) request;
335 uint16_t timer = 0;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500336 uint32_t timer_ms = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500337
338 *data_len = 0;
339
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500340 // Get number of 100ms intervals
Chris Austen6caf28b2015-10-13 12:40:40 -0500341 timer = (((uint16_t)reqptr->ms) << 8) + reqptr->ls;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500342 // Get timer value in ms
343 timer_ms = timer * 100;
Chris Austen6caf28b2015-10-13 12:40:40 -0500344
345 printf("WATCHDOG SET Timer:[0x%X] 100ms intervals\n",timer);
346
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500347 // Set watchdog timer
vishwa1eaea4f2016-02-26 11:57:40 -0600348 r = sd_bus_call_method(bus, busname, objname, iface,
349 "set", &error, &reply, "i", timer_ms);
350 if(r < 0)
Adriana Kobylak0896be32015-10-22 13:27:23 -0500351 {
vishwa1eaea4f2016-02-26 11:57:40 -0600352 fprintf(stderr, "Failed to call the SET method: %s\n", strerror(-r));
353 goto finish;
Adriana Kobylak0896be32015-10-22 13:27:23 -0500354 }
355
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500356 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600357 reply = sd_bus_message_unref(reply);
Chris Austen6caf28b2015-10-13 12:40:40 -0500358
vishwa1eaea4f2016-02-26 11:57:40 -0600359 // Stop the current watchdog if any
360 r = sd_bus_call_method(bus, busname, objname, iface,
361 "stop", &error, &reply, NULL);
362 if(r < 0)
363 {
364 fprintf(stderr, "Failed to call the STOP method: %s\n", strerror(-r));
365 goto finish;
366 }
367
368 if (reqptr->t_use & 0x40)
369 {
370 sd_bus_error_free(&error);
371 reply = sd_bus_message_unref(reply);
372
373 // Start the watchdog if requested
374 r = sd_bus_call_method(bus, busname, objname, iface,
375 "start", &error, &reply, NULL);
376 if(r < 0)
377 {
378 fprintf(stderr, "Failed to call the START method: %s\n", strerror(-r));
379 }
380 }
381
382finish:
383 sd_bus_error_free(&error);
384 reply = sd_bus_message_unref(reply);
385
386 return (r < 0) ? -1 : IPMI_CC_OK;
Chris Austen6caf28b2015-10-13 12:40:40 -0500387}
388
389
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500390ipmi_ret_t ipmi_app_reset_watchdog(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
391 ipmi_request_t request, ipmi_response_t response,
Chris Austen6caf28b2015-10-13 12:40:40 -0500392 ipmi_data_len_t data_len, ipmi_context_t context)
393{
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500394 const char *busname = "org.openbmc.watchdog.Host";
Chris Austen454acfe2015-10-29 23:03:34 -0500395 const char *objname = "/org/openbmc/watchdog/host0";
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500396 const char *iface = "org.openbmc.Watchdog";
vishwa1eaea4f2016-02-26 11:57:40 -0600397 sd_bus_message *reply = NULL;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500398 sd_bus_error error = SD_BUS_ERROR_NULL;
399 int r = 0;
400
Chris Austen6caf28b2015-10-13 12:40:40 -0500401 // Status code.
402 ipmi_ret_t rc = IPMI_CC_OK;
403 *data_len = 0;
404
405 printf("WATCHDOG RESET\n");
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500406
407 // Refresh watchdog
vishwa1eaea4f2016-02-26 11:57:40 -0600408 r = sd_bus_call_method(bus, busname, objname, iface,
409 "poke", &error, &reply, NULL);
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500410 if (r < 0) {
vishwa1eaea4f2016-02-26 11:57:40 -0600411 fprintf(stderr, "Failed to add reset watchdog: %s\n", strerror(-r));
412 rc = -1;
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500413 }
414
415 sd_bus_error_free(&error);
vishwa1eaea4f2016-02-26 11:57:40 -0600416 reply = sd_bus_message_unref(reply);
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500417
Chris Austen6caf28b2015-10-13 12:40:40 -0500418 return rc;
419}
420
Chris Austenc2cd29d2016-02-05 20:02:29 -0600421// ATTENTION: This ipmi function is very hardcoded on purpose
422// OpenBMC does not fully support IPMI. This command is useful
423// to have around because it enables testing of interfaces with
424// the IPMI tool.
425#define GET_CHANNEL_INFO_CHANNEL_OFFSET 0
426// IPMI Table 6-2
427#define IPMI_CHANNEL_TYPE_IPMB 1
428// IPMI Table 6-3
429#define IPMI_CHANNEL_MEDIUM_TYPE_OTHER 6
430
431ipmi_ret_t ipmi_app_channel_info(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
432 ipmi_request_t request, ipmi_response_t response,
433 ipmi_data_len_t data_len, ipmi_context_t context)
434{
435 ipmi_ret_t rc = IPMI_CC_OK;
436 uint8_t resp[] = {
437 1,
438 IPMI_CHANNEL_MEDIUM_TYPE_OTHER,
439 IPMI_CHANNEL_TYPE_IPMB,
440 1,0x41,0xA7,0x00,0,0};
441 uint8_t *p = (uint8_t*) request;
442
443 printf("IPMI APP GET CHANNEL INFO\n");
444
445 // I"m only supporting channel 1. 0xE is the 'default channel'
tomjose13fb4412016-03-08 14:02:34 -0600446 if (*p == 0xe || *p == 1 || *p == 8) {
Chris Austenc2cd29d2016-02-05 20:02:29 -0600447
448 *data_len = sizeof(resp);
449 memcpy(response, resp, *data_len);
450
451 } else {
452 rc = IPMI_CC_PARM_OUT_OF_RANGE;
453 *data_len = 0;
454 }
455
456 return rc;
457}
458
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500459ipmi_ret_t ipmi_app_set_bmc_global_enables(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
460 ipmi_request_t request, ipmi_response_t response,
461 ipmi_data_len_t data_len, ipmi_context_t context)
462{
463 ipmi_ret_t rc = IPMI_CC_OK;
464 *data_len = 0;
Chris Austen6caf28b2015-10-13 12:40:40 -0500465
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500466 // Event and message logging enabled by default so return for now
467 printf("IPMI APP SET BMC GLOBAL ENABLES Ignoring for now\n");
468
469 return rc;
470}
Chris Austen6caf28b2015-10-13 12:40:40 -0500471
472
473
Adriana Kobylak3a552e12015-10-19 16:11:00 -0500474ipmi_ret_t ipmi_app_wildcard_handler(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
475 ipmi_request_t request, ipmi_response_t response,
vishwabmcba0bd5f2015-09-30 16:50:23 +0530476 ipmi_data_len_t data_len, ipmi_context_t context)
477{
478 printf("Handling WILDCARD Netfn:[0x%X], Cmd:[0x%X]\n",netfn, cmd);
479
480 // Status code.
481 ipmi_ret_t rc = IPMI_CC_OK;
482
483 *data_len = strlen("THIS IS WILDCARD");
484
485 // Now pack actual response
486 memcpy(response, "THIS IS WILDCARD", *data_len);
487
488 return rc;
489}
490
Chris Austen6caf28b2015-10-13 12:40:40 -0500491void register_netfn_app_functions()
vishwabmcba0bd5f2015-09-30 16:50:23 +0530492{
493 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CAP_BIT);
Chris Austen6caf28b2015-10-13 12:40:40 -0500494 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CAP_BIT, NULL, ipmi_app_get_bt_capabilities);
495
496 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_WILDCARD);
497 ipmi_register_callback(NETFUN_APP, IPMI_CMD_WILDCARD, NULL, ipmi_app_wildcard_handler);
498
499 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_RESET_WD);
500 ipmi_register_callback(NETFUN_APP, IPMI_CMD_RESET_WD, NULL, ipmi_app_reset_watchdog);
501
502 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_WD);
503 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_WD, NULL, ipmi_app_set_watchdog);
504
505 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_ID);
506 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_ID, NULL, ipmi_app_get_device_id);
507
Adriana Kobylakd100ee52015-10-20 17:02:37 -0500508 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID);
509 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_DEVICE_GUID, NULL, ipmi_app_get_device_guid);
510
Chris Austen6caf28b2015-10-13 12:40:40 -0500511 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_SET_ACPI);
512 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_ACPI, NULL, ipmi_app_set_acpi_power_state);
513
514 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_READ_EVENT);
515 ipmi_register_callback(NETFUN_APP, IPMI_CMD_READ_EVENT, NULL, ipmi_app_read_event);
Adriana Kobylakdfc8d772015-10-20 09:34:48 -0500516
517 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP,
518 IPMI_CMD_SET_BMC_GLOBAL_ENABLES);
519 ipmi_register_callback(NETFUN_APP, IPMI_CMD_SET_BMC_GLOBAL_ENABLES, NULL,
520 ipmi_app_set_bmc_global_enables);
521
vishwa36993272015-11-20 12:43:49 -0600522 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS);
523 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_MSG_FLAGS, NULL, ipmi_app_get_msg_flags);
524
Chris Austenc2cd29d2016-02-05 20:02:29 -0600525
526 printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_APP, IPMI_CMD_GET_CHAN_INFO);
527 ipmi_register_callback(NETFUN_APP, IPMI_CMD_GET_CHAN_INFO, NULL, ipmi_app_channel_info);
528
529
530
vishwabmcba0bd5f2015-09-30 16:50:23 +0530531 return;
532}
533
Chris Austen6caf28b2015-10-13 12:40:40 -0500534