aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-07-04 00:06:44 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-07-04 00:06:44 +0200
commite4acdd0a32e3d6f317d860e25488abde209b0e9c (patch)
tree1cc2b6d129fd966250e95a2be0747180d4948609
parent960d41a9e018978d1622801def431990983774a4 (diff)
downloadexternal_libsamsung-ipc-e4acdd0a32e3d6f317d860e25488abde209b0e9c.zip
external_libsamsung-ipc-e4acdd0a32e3d6f317d860e25488abde209b0e9c.tar.gz
external_libsamsung-ipc-e4acdd0a32e3d6f317d860e25488abde209b0e9c.tar.bz2
misc: IPC_MISC_ME_VERSION request data and new helpers
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--include/misc.h16
-rw-r--r--samsung-ipc/misc.c29
2 files changed, 42 insertions, 3 deletions
diff --git a/include/misc.h b/include/misc.h
index ad1afad..7769f37 100644
--- a/include/misc.h
+++ b/include/misc.h
@@ -47,7 +47,11 @@
* Structures
*/
-struct ipc_misc_me_version_data {
+struct ipc_misc_me_version_request_data {
+ unsigned char magic;
+} __attribute__((__packed__));
+
+struct ipc_misc_me_version_response_data {
unsigned char unknown;
char software_version[32];
char hardware_version[32];
@@ -59,8 +63,12 @@ struct ipc_misc_me_imsi_header {
unsigned char length;
} __attribute__((__packed__));
-struct ipc_misc_me_sn_data {
- unsigned char type; // IPC_MISC_ME_SN_SERIAL_NUM
+struct ipc_misc_me_sn_request_data {
+ unsigned char type; // IPC_MISC_ME_SN_SERIAL
+} __attribute__((__packed__));
+
+struct ipc_misc_me_sn_response_data {
+ unsigned char type; // IPC_MISC_ME_SN_SERIAL
unsigned char length;
char data[32];
} __attribute__((__packed__));
@@ -77,7 +85,9 @@ struct ipc_misc_time_info_data {
* Helpers
*/
+int ipc_misc_me_version_setup(struct ipc_misc_me_version_request_data *data);
char *ipc_misc_me_imsi_imsi_extract(const void *data, size_t size);
+char *ipc_misc_me_sn_extract(const struct ipc_misc_me_sn_response_data *data);
#endif
diff --git a/samsung-ipc/misc.c b/samsung-ipc/misc.c
index b766b3c..f10b9d3 100644
--- a/samsung-ipc/misc.c
+++ b/samsung-ipc/misc.c
@@ -23,6 +23,17 @@
#include <samsung-ipc.h>
+int ipc_misc_me_version_setup(struct ipc_misc_me_version_request_data *data)
+{
+ if (data == NULL)
+ return -1;
+
+ memset(data, 0, sizeof(struct ipc_misc_me_version_request_data));
+ data->magic = 0xff;
+
+ return 0;
+}
+
char *ipc_misc_me_imsi_imsi_extract(const void *data, size_t size)
{
struct ipc_misc_me_imsi_header *header;
@@ -45,4 +56,22 @@ char *ipc_misc_me_imsi_imsi_extract(const void *data, size_t size)
return imsi;
}
+char *ipc_misc_me_sn_extract(const struct ipc_misc_me_sn_response_data *data)
+{
+ char *string;
+ size_t length;
+
+ if (data == NULL || data->length > sizeof(data->data))
+ return NULL;
+
+ length = data->length + sizeof(char);
+
+ string = (char *) calloc(1, length);
+
+ strncpy(string, (char *) &data->data, data->length);
+ string[data->length] = '\0';
+
+ return string;
+}
+
// vim:ts=4:sw=4:expandtab