aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-01-21 10:28:41 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-02-01 18:51:36 +0100
commit5a643dd89e2636cea19d9642c3a205d2d20250ec (patch)
tree97bed49241071dad583f65947d7a226efa137515
parent1bfa8812baf86268113de44c1aec2a4a4742ad35 (diff)
downloadhardware_replicant_libsamsung-ipc-5a643dd89e2636cea19d9642c3a205d2d20250ec.zip
hardware_replicant_libsamsung-ipc-5a643dd89e2636cea19d9642c3a205d2d20250ec.tar.gz
hardware_replicant_libsamsung-ipc-5a643dd89e2636cea19d9642c3a205d2d20250ec.tar.bz2
ipc_utils: add ipc_group_string
While ipc_group_string is not used by libsamsung-ipc (yet), it's still a good idea to add it as tools and applications using libsamsung-ipc can then use it to display the group of a command. It's also a better idea to have it in libsamsung-ipc than in each tool using it as libsamsung-ipc centralizes the knowledge about the samsung-ipc protocol, so if new groups appear at some point, the ipc_group_string function could be updated along the way. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--include/samsung-ipc.h1
-rw-r--r--samsung-ipc/ipc_utils.c50
2 files changed, 51 insertions, 0 deletions
diff --git a/include/samsung-ipc.h b/include/samsung-ipc.h
index fe8413a..25106c6 100644
--- a/include/samsung-ipc.h
+++ b/include/samsung-ipc.h
@@ -137,6 +137,7 @@ int ipc_seq_valid(unsigned char seq);
const char *ipc_request_type_string(unsigned char type);
const char *ipc_response_type_string(unsigned char type);
const char *ipc_command_string(unsigned short command);
+const char *ipc_group_string(unsigned char group);
int ipc_data_dump(struct ipc_client *client, const void *data, size_t size);
void ipc_client_log_send(struct ipc_client *client, struct ipc_message *message,
diff --git a/samsung-ipc/ipc_utils.c b/samsung-ipc/ipc_utils.c
index d8b69b7..9c4ccb8 100644
--- a/samsung-ipc/ipc_utils.c
+++ b/samsung-ipc/ipc_utils.c
@@ -357,6 +357,56 @@ const char *ipc_command_string(unsigned short command)
}
}
+const char *ipc_group_string(unsigned char group)
+{
+ static char group_string[5] = { 0 };
+
+ switch (group) {
+ case IPC_GROUP_PWR:
+ return "IPC_GROUP_PWR";
+ case IPC_GROUP_CALL:
+ return "IPC_GROUP_CALL";
+ case IPC_GROUP_SMS:
+ return "IPC_GROUP_SMS";
+ case IPC_GROUP_SEC:
+ return "IPC_GROUP_SEC";
+ case IPC_GROUP_PB:
+ return "IPC_GROUP_PB";
+ case IPC_GROUP_DISP:
+ return "IPC_GROUP_DISP";
+ case IPC_GROUP_NET:
+ return "IPC_GROUP_NET";
+ case IPC_GROUP_SND:
+ return "IPC_GROUP_SND";
+ case IPC_GROUP_MISC:
+ return "IPC_GROUP_MISC";
+ case IPC_GROUP_SVC:
+ return "IPC_GROUP_SVC";
+ case IPC_GROUP_SS:
+ return "IPC_GROUP_SS";
+ case IPC_GROUP_GPRS:
+ return "IPC_GROUP_GPRS";
+ case IPC_GROUP_SAT:
+ return "IPC_GROUP_SAT";
+ case IPC_GROUP_CFG:
+ return "IPC_GROUP_CFG";
+ case IPC_GROUP_IMEI:
+ return "IPC_GROUP_IMEI";
+ case IPC_GROUP_GPS:
+ return "IPC_GROUP_GPS";
+ case IPC_GROUP_SAP:
+ return "IPC_GROUP_SAP";
+ case IPC_GROUP_RFS:
+ return "IPC_GROUP_RFS";
+ case IPC_GROUP_GEN:
+ return "IPC_GROUP_GEN";
+ default:
+ snprintf((char *) &group_string, sizeof(group_string), "0x%02x",
+ (unsigned int)group_string);
+ return group_string;
+ }
+}
+
int ipc_data_dump(struct ipc_client *client, const void *data, size_t size)
{
unsigned int cols = 8;