198a23840SMatthew Barth #include "sensorhandler.h"
237af7331SPatrick Williams #include "host-ipmid/ipmid-api.h"
3d700e76aSTom #include <mapper.h>
498a23840SMatthew Barth #include <stdio.h>
598a23840SMatthew Barth #include <string.h>
698a23840SMatthew Barth #include <stdint.h>
798a23840SMatthew Barth #include <systemd/sd-bus.h>
8d700e76aSTom #include "ipmid.hpp"
998a23840SMatthew Barth 
1098a23840SMatthew Barth extern int updateSensorRecordFromSSRAESC(const void *);
11d700e76aSTom extern sd_bus *bus;
1298a23840SMatthew Barth 
1398a23840SMatthew Barth void register_netfn_sen_functions()   __attribute__((constructor));
1498a23840SMatthew Barth 
1598a23840SMatthew Barth struct sensorTypemap_t {
1698a23840SMatthew Barth     uint8_t number;
1798a23840SMatthew Barth     uint8_t typecode;
1898a23840SMatthew Barth     char dbusname[32];
1998a23840SMatthew Barth } ;
2098a23840SMatthew Barth 
2198a23840SMatthew Barth 
2298a23840SMatthew Barth sensorTypemap_t g_SensorTypeMap[] = {
2398a23840SMatthew Barth 
2498a23840SMatthew Barth     {0x01, 0x6F, "Temp"},
2598a23840SMatthew Barth     {0x0C, 0x6F, "DIMM"},
2698a23840SMatthew Barth     {0x0C, 0x6F, "MEMORY_BUFFER"},
2798a23840SMatthew Barth     {0x07, 0x6F, "PROC"},
2898a23840SMatthew Barth     {0x07, 0x6F, "CORE"},
2998a23840SMatthew Barth     {0x07, 0x6F, "CPU"},
3098a23840SMatthew Barth     {0x0F, 0x6F, "BootProgress"},
3198a23840SMatthew Barth     {0xe9, 0x09, "OccStatus"},  // E9 is an internal mapping to handle sensor type code os 0x09
3298a23840SMatthew Barth     {0xC3, 0x6F, "BootCount"},
3398a23840SMatthew Barth     {0x1F, 0x6F, "OperatingSystemStatus"},
3498a23840SMatthew Barth     {0x12, 0x6F, "SYSTEM_EVENT"},
3598a23840SMatthew Barth     {0xC7, 0x03, "SYSTEM"},
3698a23840SMatthew Barth     {0xC7, 0x03, "MAIN_PLANAR"},
3798a23840SMatthew Barth     {0xC2, 0x6F, "PowerCap"},
3898a23840SMatthew Barth     {0xFF, 0x00, ""},
3998a23840SMatthew Barth };
4098a23840SMatthew Barth 
4198a23840SMatthew Barth 
4298a23840SMatthew Barth struct sensor_data_t {
4398a23840SMatthew Barth     uint8_t sennum;
4498a23840SMatthew Barth }  __attribute__ ((packed)) ;
4598a23840SMatthew Barth 
4698a23840SMatthew Barth struct sensorreadingresp_t {
4798a23840SMatthew Barth     uint8_t value;
4898a23840SMatthew Barth     uint8_t operation;
4998a23840SMatthew Barth     uint8_t indication[2];
5098a23840SMatthew Barth }  __attribute__ ((packed)) ;
5198a23840SMatthew Barth 
52d700e76aSTom 
53d700e76aSTom // Use a lookup table to find the interface name of a specific sensor
54d700e76aSTom // This will be used until an alternative is found.  this is the first
55d700e76aSTom // step for mapping IPMI
56d700e76aSTom int find_interface_property_fru_type(dbus_interface_t *interface, const char *property_name, char *property_value) {
57d700e76aSTom 
58d700e76aSTom     char  *str1;
59d700e76aSTom     sd_bus_error error = SD_BUS_ERROR_NULL;
60d700e76aSTom     sd_bus_message *reply = NULL, *m=NULL;
61d700e76aSTom 
62d700e76aSTom 
63d700e76aSTom     int r;
64d700e76aSTom 
65d700e76aSTom     r = sd_bus_message_new_method_call(bus,&m,interface->bus,interface->path,"org.freedesktop.DBus.Properties","Get");
66d700e76aSTom     if (r < 0) {
67d700e76aSTom         fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
68d700e76aSTom         fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
69d700e76aSTom                 interface->bus, interface->path, interface->interface);
70d700e76aSTom         goto final;
71d700e76aSTom     }
72d700e76aSTom 
73d700e76aSTom     r = sd_bus_message_append(m, "ss", "org.openbmc.InventoryItem", property_name);
74d700e76aSTom     if (r < 0) {
75d700e76aSTom         fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
76d700e76aSTom         fprintf(stderr,"Bus: %s Path: %s Interface: %s \n",
77d700e76aSTom                 interface->bus, interface->path, interface->interface);
78d700e76aSTom         goto final;
79d700e76aSTom     }
80d700e76aSTom 
81d700e76aSTom     r = sd_bus_call(bus, m, 0, &error, &reply);
82d700e76aSTom     if (r < 0) {
83d700e76aSTom         fprintf(stderr, "Failed to call the method: %s", strerror(-r));
84d700e76aSTom         goto final;
85d700e76aSTom     }
86d700e76aSTom 
87d700e76aSTom     r = sd_bus_message_read(reply, "v",  "s", &str1) ;
88d700e76aSTom     if (r < 0) {
89d700e76aSTom         fprintf(stderr, "Failed to get a response: %s", strerror(-r));
90d700e76aSTom         goto final;
91d700e76aSTom     }
92d700e76aSTom 
93d700e76aSTom     strcpy(property_value, str1);
94d700e76aSTom 
95d700e76aSTom final:
96d700e76aSTom 
97d700e76aSTom     sd_bus_error_free(&error);
98d700e76aSTom     m = sd_bus_message_unref(m);
99d700e76aSTom     reply = sd_bus_message_unref(reply);
100d700e76aSTom 
101d700e76aSTom     return r;
102d700e76aSTom }
103d700e76aSTom 
104d700e76aSTom 
105d700e76aSTom // Use a lookup table to find the interface name of a specific sensor
106d700e76aSTom // This will be used until an alternative is found.  this is the first
107d700e76aSTom // step for mapping IPMI
108d700e76aSTom int find_openbmc_path(const char *type, const uint8_t num, dbus_interface_t *interface) {
109d700e76aSTom     char  *busname = NULL;
110d700e76aSTom     const char  *iface = "org.openbmc.managers.System";
111d700e76aSTom     const char  *objname = "/org/openbmc/managers/System";
112d700e76aSTom     char  *str1 = NULL, *str2, *str3;
113d700e76aSTom     sd_bus_error error = SD_BUS_ERROR_NULL;
114d700e76aSTom     sd_bus_message *reply = NULL;
115d700e76aSTom 
116d700e76aSTom 
117d700e76aSTom     int r;
118d700e76aSTom     r = mapper_get_service(bus, objname, &busname);
119d700e76aSTom     if (r < 0) {
120*819ddd42SBrad Bishop         fprintf(stderr, "Failed to get %s busname: %s\n",
121*819ddd42SBrad Bishop                 objname, strerror(-r));
122d700e76aSTom         goto final;
123d700e76aSTom     }
124d700e76aSTom 
125d700e76aSTom     r = sd_bus_call_method(bus,busname,objname,iface, "getObjectFromByteId",
126d700e76aSTom                            &error, &reply, "sy", type, num);
127d700e76aSTom     if (r < 0) {
128d700e76aSTom         fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
129d700e76aSTom         goto final;
130d700e76aSTom     }
131d700e76aSTom 
132d700e76aSTom     r = sd_bus_message_read(reply, "(ss)", &str2, &str3);
133d700e76aSTom     if (r < 0) {
134d700e76aSTom         fprintf(stderr, "Failed to get a response: %s", strerror(-r));
135d700e76aSTom         goto final;
136d700e76aSTom     }
137d700e76aSTom 
138d700e76aSTom     r = mapper_get_service(bus, str2, &str1);
139d700e76aSTom     if (r < 0) {
140*819ddd42SBrad Bishop         fprintf(stderr, "Failed to get %s busname: %s\n",
141*819ddd42SBrad Bishop                 str2, strerror(-r));
142d700e76aSTom         goto final;
143d700e76aSTom     }
144d700e76aSTom 
145d700e76aSTom     strncpy(interface->bus, str1, MAX_DBUS_PATH);
146d700e76aSTom     strncpy(interface->path, str2, MAX_DBUS_PATH);
147d700e76aSTom     strncpy(interface->interface, str3, MAX_DBUS_PATH);
148d700e76aSTom 
149d700e76aSTom     interface->sensornumber = num;
150d700e76aSTom 
151d700e76aSTom final:
152d700e76aSTom 
153d700e76aSTom     sd_bus_error_free(&error);
154d700e76aSTom     reply = sd_bus_message_unref(reply);
155d700e76aSTom     free(busname);
156d700e76aSTom     free(str1);
157d700e76aSTom 
158d700e76aSTom     return r;
159d700e76aSTom }
160d700e76aSTom 
161d700e76aSTom 
162d700e76aSTom /////////////////////////////////////////////////////////////////////
163d700e76aSTom //
164d700e76aSTom // Routines used by ipmi commands wanting to interact on the dbus
165d700e76aSTom //
166d700e76aSTom /////////////////////////////////////////////////////////////////////
167d700e76aSTom int set_sensor_dbus_state_s(uint8_t number, const char *method, const char *value) {
168d700e76aSTom 
169d700e76aSTom 
170d700e76aSTom     dbus_interface_t a;
171d700e76aSTom     int r;
172d700e76aSTom     sd_bus_error error = SD_BUS_ERROR_NULL;
173d700e76aSTom     sd_bus_message *m=NULL;
174d700e76aSTom 
175d700e76aSTom     fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of %s\n",
176d700e76aSTom         number, method, value);
177d700e76aSTom 
178d700e76aSTom     r = find_openbmc_path("SENSOR", number, &a);
179d700e76aSTom 
180d700e76aSTom     if (r < 0) {
181d700e76aSTom         fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
182d700e76aSTom         return 0;
183d700e76aSTom     }
184d700e76aSTom 
185d700e76aSTom     r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
186d700e76aSTom     if (r < 0) {
187d700e76aSTom         fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
188d700e76aSTom         goto final;
189d700e76aSTom     }
190d700e76aSTom 
191d700e76aSTom     r = sd_bus_message_append(m, "v", "s", value);
192d700e76aSTom     if (r < 0) {
193d700e76aSTom         fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
194d700e76aSTom         goto final;
195d700e76aSTom     }
196d700e76aSTom 
197d700e76aSTom 
198d700e76aSTom     r = sd_bus_call(bus, m, 0, &error, NULL);
199d700e76aSTom     if (r < 0) {
200d700e76aSTom         fprintf(stderr, "Failed to call the method: %s", strerror(-r));
201d700e76aSTom     }
202d700e76aSTom 
203d700e76aSTom final:
204d700e76aSTom     sd_bus_error_free(&error);
205d700e76aSTom     m = sd_bus_message_unref(m);
206d700e76aSTom 
207d700e76aSTom     return 0;
208d700e76aSTom }
209d700e76aSTom int set_sensor_dbus_state_y(uint8_t number, const char *method, const uint8_t value) {
210d700e76aSTom 
211d700e76aSTom 
212d700e76aSTom     dbus_interface_t a;
213d700e76aSTom     int r;
214d700e76aSTom     sd_bus_error error = SD_BUS_ERROR_NULL;
215d700e76aSTom     sd_bus_message *m=NULL;
216d700e76aSTom 
217d700e76aSTom     fprintf(ipmidbus, "Attempting to set a dbus Variant Sensor 0x%02x via %s with a value of 0x%02x\n",
218d700e76aSTom         number, method, value);
219d700e76aSTom 
220d700e76aSTom     r = find_openbmc_path("SENSOR", number, &a);
221d700e76aSTom 
222d700e76aSTom     if (r < 0) {
223d700e76aSTom         fprintf(stderr, "Failed to find Sensor 0x%02x\n", number);
224d700e76aSTom         return 0;
225d700e76aSTom     }
226d700e76aSTom 
227d700e76aSTom     r = sd_bus_message_new_method_call(bus,&m,a.bus,a.path,a.interface,method);
228d700e76aSTom     if (r < 0) {
229d700e76aSTom         fprintf(stderr, "Failed to create a method call: %s", strerror(-r));
230d700e76aSTom         goto final;
231d700e76aSTom     }
232d700e76aSTom 
233d700e76aSTom     r = sd_bus_message_append(m, "v", "i", value);
234d700e76aSTom     if (r < 0) {
235d700e76aSTom         fprintf(stderr, "Failed to create a input parameter: %s", strerror(-r));
236d700e76aSTom         goto final;
237d700e76aSTom     }
238d700e76aSTom 
239d700e76aSTom 
240d700e76aSTom     r = sd_bus_call(bus, m, 0, &error, NULL);
241d700e76aSTom     if (r < 0) {
242d700e76aSTom         fprintf(stderr, "12 Failed to call the method: %s", strerror(-r));
243d700e76aSTom     }
244d700e76aSTom 
245d700e76aSTom final:
246d700e76aSTom     sd_bus_error_free(&error);
247d700e76aSTom     m = sd_bus_message_unref(m);
248d700e76aSTom 
249d700e76aSTom     return 0;
250d700e76aSTom }
251d700e76aSTom 
252d700e76aSTom 
25398a23840SMatthew Barth uint8_t dbus_to_sensor_type(char *p) {
25498a23840SMatthew Barth 
25598a23840SMatthew Barth     sensorTypemap_t *s = g_SensorTypeMap;
25698a23840SMatthew Barth     char r=0;
25798a23840SMatthew Barth 
25898a23840SMatthew Barth     while (s->number != 0xFF) {
25998a23840SMatthew Barth         if (!strcmp(s->dbusname,p)) {
26098a23840SMatthew Barth             r = s->number;
26198a23840SMatthew Barth              break;
26298a23840SMatthew Barth         }
26398a23840SMatthew Barth         s++;
26498a23840SMatthew Barth     }
26598a23840SMatthew Barth 
26698a23840SMatthew Barth 
26798a23840SMatthew Barth     if (s->number == 0xFF)
26898a23840SMatthew Barth         printf("Failed to find Sensor Type %s\n", p);
26998a23840SMatthew Barth 
27098a23840SMatthew Barth     return r;
27198a23840SMatthew Barth }
27298a23840SMatthew Barth 
27398a23840SMatthew Barth 
27498a23840SMatthew Barth uint8_t dbus_to_sensor_type_from_dbus(dbus_interface_t *a) {
27598a23840SMatthew Barth     char fru_type_name[64];
27698a23840SMatthew Barth     int r= 0;
27798a23840SMatthew Barth 
27898a23840SMatthew Barth     r = find_interface_property_fru_type(a, "fru_type", fru_type_name);
27998a23840SMatthew Barth     if (r<0) {
28098a23840SMatthew Barth         fprintf(stderr, "Failed to get a fru type: %s", strerror(-r));
28198a23840SMatthew Barth         return -1;
28298a23840SMatthew Barth     } else {
28398a23840SMatthew Barth         return dbus_to_sensor_type(fru_type_name);
28498a23840SMatthew Barth     }
28598a23840SMatthew Barth }
28698a23840SMatthew Barth 
28798a23840SMatthew Barth 
28898a23840SMatthew Barth uint8_t find_sensor(uint8_t sensor_number) {
28998a23840SMatthew Barth 
29098a23840SMatthew Barth     dbus_interface_t a;
29198a23840SMatthew Barth     char *p;
29298a23840SMatthew Barth     char r;
29398a23840SMatthew Barth 
29498a23840SMatthew Barth     r = find_openbmc_path("SENSOR", sensor_number, &a);
29598a23840SMatthew Barth 
29698a23840SMatthew Barth     if (r < 0) { return 0; }
29798a23840SMatthew Barth 
29898a23840SMatthew Barth     // This is where sensors that do not exist in dbus but do
29998a23840SMatthew Barth     // exist in the host code stop.  This should indicate it
30098a23840SMatthew Barth     // is not a supported sensor
30198a23840SMatthew Barth     if (a.interface[0] == 0) { return 0;}
30298a23840SMatthew Barth 
30398a23840SMatthew Barth     if (strstr(a.interface, "InventoryItem")) {
30498a23840SMatthew Barth         // InventoryItems are real frus.  So need to get the
30598a23840SMatthew Barth         // fru_type property
30698a23840SMatthew Barth         r = dbus_to_sensor_type_from_dbus(&a);
30798a23840SMatthew Barth     } else {
30898a23840SMatthew Barth         // Non InventoryItems
30998a23840SMatthew Barth         p = strrchr (a.path, '/');
31098a23840SMatthew Barth         r = dbus_to_sensor_type(p+1);
31198a23840SMatthew Barth     }
31298a23840SMatthew Barth 
31398a23840SMatthew Barth     return r;
31498a23840SMatthew Barth  }
31598a23840SMatthew Barth 
31698a23840SMatthew Barth 
31798a23840SMatthew Barth 
31898a23840SMatthew Barth 
31998a23840SMatthew Barth 
32098a23840SMatthew Barth ipmi_ret_t ipmi_sen_get_sensor_type(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
32198a23840SMatthew Barth                              ipmi_request_t request, ipmi_response_t response,
32298a23840SMatthew Barth                              ipmi_data_len_t data_len, ipmi_context_t context)
32398a23840SMatthew Barth {
32498a23840SMatthew Barth     sensor_data_t *reqptr = (sensor_data_t*)request;
32598a23840SMatthew Barth     ipmi_ret_t rc = IPMI_CC_OK;
32698a23840SMatthew Barth 
32798a23840SMatthew Barth     printf("IPMI GET_SENSOR_TYPE [0x%02X]\n",reqptr->sennum);
32898a23840SMatthew Barth 
32998a23840SMatthew Barth     // TODO Not sure what the System-event-sensor is suppose to return
33098a23840SMatthew Barth     // need to ask Hostboot team
33198a23840SMatthew Barth     unsigned char buf[] = {0x00,0x6F};
33298a23840SMatthew Barth 
33398a23840SMatthew Barth     buf[0] = find_sensor(reqptr->sennum);
33498a23840SMatthew Barth 
33598a23840SMatthew Barth     // HACK UNTIL Dbus gets updated or we find a better way
33698a23840SMatthew Barth     if (buf[0] == 0) {
33798a23840SMatthew Barth         rc = IPMI_CC_SENSOR_INVALID;
33898a23840SMatthew Barth     }
33998a23840SMatthew Barth 
34098a23840SMatthew Barth 
34198a23840SMatthew Barth     *data_len = sizeof(buf);
34298a23840SMatthew Barth     memcpy(response, &buf, *data_len);
34398a23840SMatthew Barth 
34498a23840SMatthew Barth     return rc;
34598a23840SMatthew Barth }
34698a23840SMatthew Barth 
34798a23840SMatthew Barth 
34898a23840SMatthew Barth 
34998a23840SMatthew Barth ipmi_ret_t ipmi_sen_set_sensor(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
35098a23840SMatthew Barth                              ipmi_request_t request, ipmi_response_t response,
35198a23840SMatthew Barth                              ipmi_data_len_t data_len, ipmi_context_t context)
35298a23840SMatthew Barth {
35398a23840SMatthew Barth     sensor_data_t *reqptr = (sensor_data_t*)request;
35498a23840SMatthew Barth     ipmi_ret_t rc = IPMI_CC_OK;
35598a23840SMatthew Barth 
35698a23840SMatthew Barth     printf("IPMI SET_SENSOR [0x%02x]\n",reqptr->sennum);
35798a23840SMatthew Barth 
35898a23840SMatthew Barth     updateSensorRecordFromSSRAESC(reqptr);
35998a23840SMatthew Barth 
36098a23840SMatthew Barth     *data_len=0;
36198a23840SMatthew Barth 
36298a23840SMatthew Barth     return rc;
36398a23840SMatthew Barth }
36498a23840SMatthew Barth 
36598a23840SMatthew Barth 
36698a23840SMatthew Barth ipmi_ret_t ipmi_sen_get_sensor_reading(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
36798a23840SMatthew Barth                              ipmi_request_t request, ipmi_response_t response,
36898a23840SMatthew Barth                              ipmi_data_len_t data_len, ipmi_context_t context)
36998a23840SMatthew Barth {
37098a23840SMatthew Barth     sensor_data_t *reqptr = (sensor_data_t*)request;
37198a23840SMatthew Barth     ipmi_ret_t rc = IPMI_CC_SENSOR_INVALID;
37298a23840SMatthew Barth     uint8_t type;
37398a23840SMatthew Barth     sensorreadingresp_t *resp = (sensorreadingresp_t*) response;
37498a23840SMatthew Barth     int r;
37598a23840SMatthew Barth     dbus_interface_t a;
37698a23840SMatthew Barth     sd_bus *bus = ipmid_get_sd_bus_connection();
37798a23840SMatthew Barth     sd_bus_message *reply = NULL;
37898a23840SMatthew Barth     int reading = 0;
37998a23840SMatthew Barth 
38098a23840SMatthew Barth 
38198a23840SMatthew Barth     printf("IPMI GET_SENSOR_READING [0x%02x]\n",reqptr->sennum);
38298a23840SMatthew Barth 
38398a23840SMatthew Barth     r = find_openbmc_path("SENSOR", reqptr->sennum, &a);
38498a23840SMatthew Barth 
38598a23840SMatthew Barth     if (r < 0) {
38698a23840SMatthew Barth         fprintf(stderr, "Failed to find Sensor 0x%02x\n", reqptr->sennum);
38798a23840SMatthew Barth         return IPMI_CC_SENSOR_INVALID;
38898a23840SMatthew Barth     }
38998a23840SMatthew Barth 
39098a23840SMatthew Barth     type = find_sensor(reqptr->sennum);
39198a23840SMatthew Barth 
39298a23840SMatthew Barth     fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n", a.bus, a.path, a.interface);
39398a23840SMatthew Barth 
39498a23840SMatthew Barth     *data_len=0;
39598a23840SMatthew Barth 
39698a23840SMatthew Barth     switch(type) {
39798a23840SMatthew Barth         case 0xC3:
39898a23840SMatthew Barth         case 0xC2:
39998a23840SMatthew Barth             r = sd_bus_get_property(bus,a.bus, a.path, a.interface, "value", NULL, &reply, "i");
40098a23840SMatthew Barth             if (r < 0) {
40198a23840SMatthew Barth                 fprintf(stderr, "Failed to call sd_bus_get_property:%d,  %s\n", r, strerror(-r));
40298a23840SMatthew Barth                 fprintf(stderr, "Bus: %s, Path: %s, Interface: %s\n",
40398a23840SMatthew Barth                         a.bus, a.path, a.interface);
40498a23840SMatthew Barth                 break;
40598a23840SMatthew Barth             }
40698a23840SMatthew Barth 
40798a23840SMatthew Barth             r = sd_bus_message_read(reply, "i", &reading);
40898a23840SMatthew Barth             if (r < 0) {
40998a23840SMatthew Barth                 fprintf(stderr, "Failed to read sensor: %s\n", strerror(-r));
41098a23840SMatthew Barth                 break;
41198a23840SMatthew Barth             }
41298a23840SMatthew Barth 
41398a23840SMatthew Barth             printf("Contents of a 0x%02x is 0x%02x\n", type, reading);
41498a23840SMatthew Barth 
41598a23840SMatthew Barth             rc = IPMI_CC_OK;
41698a23840SMatthew Barth             *data_len=sizeof(sensorreadingresp_t);
41798a23840SMatthew Barth 
41898a23840SMatthew Barth             resp->value         = (uint8_t)reading;
41998a23840SMatthew Barth             resp->operation     = 0;
42098a23840SMatthew Barth             resp->indication[0] = 0;
42198a23840SMatthew Barth             resp->indication[1] = 0;
42298a23840SMatthew Barth             break;
42398a23840SMatthew Barth 
42498a23840SMatthew Barth         default:
42598a23840SMatthew Barth             *data_len=0;
42698a23840SMatthew Barth             rc = IPMI_CC_SENSOR_INVALID;
42798a23840SMatthew Barth             break;
42898a23840SMatthew Barth     }
42998a23840SMatthew Barth 
43098a23840SMatthew Barth 
43198a23840SMatthew Barth     reply = sd_bus_message_unref(reply);
43298a23840SMatthew Barth 
43398a23840SMatthew Barth     return rc;
43498a23840SMatthew Barth }
43598a23840SMatthew Barth 
43698a23840SMatthew Barth ipmi_ret_t ipmi_sen_wildcard(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
43798a23840SMatthew Barth                              ipmi_request_t request, ipmi_response_t response,
43898a23840SMatthew Barth                              ipmi_data_len_t data_len, ipmi_context_t context)
43998a23840SMatthew Barth {
44070aa8d96SNan Li     ipmi_ret_t rc = IPMI_CC_INVALID;
44198a23840SMatthew Barth 
44298a23840SMatthew Barth     printf("IPMI S/E Wildcard Netfn:[0x%X], Cmd:[0x%X]\n",netfn,cmd);
44398a23840SMatthew Barth     *data_len = 0;
44498a23840SMatthew Barth 
44598a23840SMatthew Barth     return rc;
44698a23840SMatthew Barth }
44798a23840SMatthew Barth 
44898a23840SMatthew Barth 
44998a23840SMatthew Barth void register_netfn_sen_functions()
45098a23840SMatthew Barth {
45198a23840SMatthew Barth     printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_WILDCARD);
45298a23840SMatthew Barth     ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_WILDCARD, NULL, ipmi_sen_wildcard);
45398a23840SMatthew Barth 
45498a23840SMatthew Barth     printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE);
45598a23840SMatthew Barth     ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_TYPE, NULL, ipmi_sen_get_sensor_type);
45698a23840SMatthew Barth 
45798a23840SMatthew Barth     printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_SET_SENSOR);
45898a23840SMatthew Barth     ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_SET_SENSOR, NULL, ipmi_sen_set_sensor);
45998a23840SMatthew Barth 
46098a23840SMatthew Barth     printf("Registering NetFn:[0x%X], Cmd:[0x%X]\n",NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING);
46198a23840SMatthew Barth     ipmi_register_callback(NETFUN_SENSOR, IPMI_CMD_GET_SENSOR_READING, NULL, ipmi_sen_get_sensor_reading);
46298a23840SMatthew Barth 
46398a23840SMatthew Barth     return;
46498a23840SMatthew Barth }
465