aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2014-07-27 00:29:44 +0200
committerPaul Kocialkowski <contact@paulk.fr>2014-07-27 00:29:44 +0200
commitdbcd5f77206148c7d446feda48031dde06c480a8 (patch)
tree4808f0460bc801953055cc4972ba76d6356104aa
parent2cdecfab4e695e1f48e7c302f21c46035160cae2 (diff)
downloadexternal_libsamsung-ipc-dbcd5f77206148c7d446feda48031dde06c480a8.zip
external_libsamsung-ipc-dbcd5f77206148c7d446feda48031dde06c480a8.tar.gz
external_libsamsung-ipc-dbcd5f77206148c7d446feda48031dde06c480a8.tar.bz2
svc: Helpers
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--Android.mk1
-rw-r--r--include/svc.h14
-rw-r--r--samsung-ipc/Makefile.am1
-rw-r--r--samsung-ipc/call.c2
-rw-r--r--samsung-ipc/svc.c82
5 files changed, 97 insertions, 3 deletions
diff --git a/Android.mk b/Android.mk
index 2f62e5b..8d21739 100644
--- a/Android.mk
+++ b/Android.mk
@@ -69,6 +69,7 @@ LOCAL_SRC_FILES := \
samsung-ipc/sec.c \
samsung-ipc/net.c \
samsung-ipc/misc.c \
+ samsung-ipc/svc.c \
samsung-ipc/gprs.c \
samsung-ipc/rfs.c \
samsung-ipc/gen.c
diff --git a/include/svc.h b/include/svc.h
index e998789..6c12a25 100644
--- a/include/svc.h
+++ b/include/svc.h
@@ -89,7 +89,7 @@
struct ipc_svc_enter_data {
unsigned char mode; // IPC_SVC_MODE
unsigned char type; // IPC_SVC_TYPE
- unsigned char unknown;
+ unsigned char magic;
} __attribute__((__packed__));
struct ipc_svc_end_data {
@@ -109,7 +109,7 @@ struct ipc_svc_display_screen_header {
unsigned char count;
} __attribute__((__packed__));
-struct ipc_svc_display_screen_data {
+struct ipc_svc_display_screen_entry {
unsigned short index;
char line[32];
} __attribute__((__packed__));
@@ -118,6 +118,16 @@ struct ipc_svc_change_svc_mode_data {
unsigned char mode; // IPC_SVC_MODE
} __attribute__((__packed__));
+/*
+ * Helpers
+ */
+
+int ipc_svc_enter_setup(struct ipc_svc_enter_data *data,
+ unsigned char mode, unsigned char type);
+unsigned char ipc_svc_display_screen_count_extract(const void *data, size_t size);
+struct ipc_svc_display_screen_entry *ipc_svc_display_screen_extract(const void *data,
+ size_t size, unsigned int index);
+
#endif
// vim:ts=4:sw=4:expandtab
diff --git a/samsung-ipc/Makefile.am b/samsung-ipc/Makefile.am
index a82eecf..b40fc67 100644
--- a/samsung-ipc/Makefile.am
+++ b/samsung-ipc/Makefile.am
@@ -58,6 +58,7 @@ libsamsung_ipc_la_SOURCES = \
sec.c \
net.c \
misc.c \
+ svc.c \
gprs.c \
rfs.c \
gen.c \
diff --git a/samsung-ipc/call.c b/samsung-ipc/call.c
index 58b0f52..37bdc20 100644
--- a/samsung-ipc/call.c
+++ b/samsung-ipc/call.c
@@ -71,7 +71,7 @@ struct ipc_call_list_entry *ipc_call_list_entry_extract(const void *data,
return NULL;
count = ipc_call_list_count_extract(data, size);
- if (count == 0)
+ if (count == 0 || index >= count)
return NULL;
offset = sizeof(struct ipc_call_list_header);
diff --git a/samsung-ipc/svc.c b/samsung-ipc/svc.c
new file mode 100644
index 0000000..9c8920b
--- /dev/null
+++ b/samsung-ipc/svc.c
@@ -0,0 +1,82 @@
+/*
+ * This file is part of libsamsung-ipc.
+ *
+ * Copyright (C) 2014 Paul Kocialkowski <contact@paulk.fr>
+ *
+ * libsamsung-ipc is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * libsamsung-ipc is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdlib.h>
+
+#include <samsung-ipc.h>
+
+int ipc_svc_enter_setup(struct ipc_svc_enter_data *data,
+ unsigned char mode, unsigned char type)
+{
+ if (data == NULL)
+ return -1;
+
+ memset(data, 0, sizeof(struct ipc_svc_enter_data));
+ data->mode = mode;
+ data->type = type;
+
+ if (mode == IPC_SVC_MODE_MONITOR)
+ data->magic = 0x00;
+ else
+ data->magic = 0x10;
+
+ return 0;
+}
+
+unsigned char ipc_svc_display_screen_count_extract(const void *data, size_t size)
+{
+ struct ipc_svc_display_screen_header *header;
+
+ if (data == NULL || size < sizeof(struct ipc_svc_display_screen_header))
+ return 0;
+
+ header = (struct ipc_svc_display_screen_header *) data;
+
+ return header->count;
+}
+
+struct ipc_svc_display_screen_entry *ipc_svc_display_screen_extract(const void *data,
+ size_t size, unsigned int index)
+{
+ struct ipc_svc_display_screen_entry *entry = NULL;
+ unsigned char count;
+ unsigned char i;
+ unsigned int offset;
+
+ if (data == NULL)
+ return NULL;
+
+ count = ipc_svc_display_screen_count_extract(data, size);
+ if (count == 0 || index >= count)
+ return NULL;
+
+ offset = sizeof(struct ipc_svc_display_screen_header);
+
+ for (i = 0; i < (index + 1); i++) {
+ entry = (struct ipc_svc_display_screen_entry *) ((unsigned char *) data + offset);
+ offset += sizeof(struct ipc_svc_display_screen_entry);
+ }
+
+ if (offset > size)
+ return NULL;
+
+ return entry;
+}
+
+// vim:ts=4:sw=4:expandtab