[Replicant] [libsamsung-ipc] [PATCH 5/5] ipc_utils: add ipc_group_string
Denis 'GNUtoo' Carikli
GNUtoo at cyberdimension.org
Mon Feb 1 18:00:50 UTC 2021
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 at cyberdimension.org>
---
include/samsung-ipc.h | 1 +
samsung-ipc/ipc_utils.c | 50 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
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;
--
2.30.0
More information about the Replicant
mailing list