[kcs]compatible with other components
Many existed openbmc components use hard code
"org.openbmc.HostIpmi" to locate service.
In order to make compatible, make '--i' optional.
When specified, kcsbridge will use prefix in dbus name and objpath.
If not, default dbus name "org.openbmc.HostIpmi" will be used.
Change-Id: I87a8e4bd05f60d953df0a550dc633c50c6b8f537
Signed-off-by: Jia, Chunhui <chunhui.jia@linux.intel.com>
diff --git a/kcsbridged.c b/kcsbridged.c
index d943c3b..9c58acd 100644
--- a/kcsbridged.c
+++ b/kcsbridged.c
@@ -40,6 +40,10 @@
#define DBUS_NAME "org.openbmc.HostIpmi."
#define OBJ_NAME "/org/openbmc/HostIpmi/"
+#define DEFAULT_DBUS "org.openbmc.HostIpmi"
+#define DEFAULT_OBJ "/org/openbmc/HostIpmi/1"
+#define DBUS_INTF "org.openbmc.HostIpmi"
+
#define KCS_TIMEOUT_IN_SEC 5
#define KCS_MESSAGE_SIZE 256
@@ -383,7 +387,7 @@
"--v Be verbose\n"
"--vv Be verbose and dump entire messages\n"
"--s, --syslog Log output to syslog (pointless without --verbose)\n"
- "--i, --instanceid <ID> instance id (string type)\n"
+ "--i, --instanceid <ID> instance id (string type) optional\n"
"--d, --device <DEVICE> Use <DEVICE> file.\n\n",
name);
}
@@ -405,7 +409,7 @@
{
struct kcsbridged_context *context;
const char *name = argv[0];
- bool deviceOptFlag = false, dbusOptFlag = false;
+ bool deviceOptFlag = false;
int opt, polled, r;
static const struct option long_options[] = {
{"device", required_argument, 0, 'd'},
@@ -421,6 +425,9 @@
return -1;
}
+ snprintf(busName, NAMEBUFFERLEN, "%s", DEFAULT_DBUS);
+ snprintf(objPath, NAMEBUFFERLEN, "%s", DEFAULT_OBJ);
+
kcs_vlog = &kcs_log_console;
while ((opt = getopt_long(argc, argv, "", long_options, NULL)) != -1) {
switch (opt) {
@@ -446,7 +453,6 @@
optarg);
snprintf(objPath, NAMEBUFFERLEN, "%s%s", OBJ_NAME,
optarg);
- dbusOptFlag = true;
break;
case 's':
@@ -462,10 +468,9 @@
}
}
- if ((false == deviceOptFlag) || (false == dbusOptFlag)) {
+ if (false == deviceOptFlag) {
usage(name);
- MSG_OUT("Flag: device %d dbus %d \n", deviceOptFlag,
- dbusOptFlag);
+ MSG_OUT("Flag: device %d \n", deviceOptFlag);
exit(EXIT_FAILURE);
}
@@ -482,14 +487,14 @@
}
MSG_OUT("Registering dbus methods/signals\n");
- r = sd_bus_add_object_vtable(context->bus, NULL, objPath, busName,
+ r = sd_bus_add_object_vtable(context->bus, NULL, objPath, DBUS_INTF,
ipmid_vtable, context);
if (r < 0) {
MSG_ERR("Failed to issue method call: %s\n", strerror(-r));
goto finish;
}
- MSG_OUT("Requesting dbus name: %s objpath:%s \n", busName, objPath);
+ MSG_OUT("Requesting dbus : %s objpath:%s \n", busName, objPath);
r = sd_bus_request_name(context->bus, busName,
SD_BUS_NAME_ALLOW_REPLACEMENT
| SD_BUS_NAME_REPLACE_EXISTING);
diff --git a/kcsbridged.service b/kcsbridged.service
index cac223f..20b75ec 100644
--- a/kcsbridged.service
+++ b/kcsbridged.service
@@ -1,10 +1,10 @@
[Unit]
-Description=KCS Bridge Daemon
+Description=KCS Bridge Daemon(Sample service file)
[Service]
Type=dbus
BusName=org.openbmc.HostIpmi
-ExecStart=/bin/kcsbridged
+ExecStart=/bin/kcsbridged --d="/dev/ipmi-kcs3"
Restart=on-abort
[Install]