From 1c4d4f7e68ce1740b08b250292bab8361eca3402 Mon Sep 17 00:00:00 2001
From: Paul Kocialkowski <contact@paulk.fr>
Date: Sat, 26 Jul 2014 18:50:39 +0200
Subject: sec: RSIM access helper

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 include/sec.h     |  2 ++
 samsung-ipc/sec.c | 30 ++++++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/include/sec.h b/include/sec.h
index 236bc37..7a1d178 100644
--- a/include/sec.h
+++ b/include/sec.h
@@ -173,6 +173,8 @@ int ipc_sec_phone_lock_request_set_setup(struct ipc_sec_phone_lock_request_set_d
 int ipc_sec_change_locking_pw_setup(struct ipc_sec_change_locking_pw_data *data,
     unsigned char facility_type, const char *password_old,
     const char *password_new);
+void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *header,
+    const void *sim_io_data, size_t sim_io_size);
 int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
     unsigned char type);
 
diff --git a/samsung-ipc/sec.c b/samsung-ipc/sec.c
index 6ea645d..be5dccf 100644
--- a/samsung-ipc/sec.c
+++ b/samsung-ipc/sec.c
@@ -120,6 +120,36 @@ int ipc_sec_change_locking_pw_setup(struct ipc_sec_change_locking_pw_data *data,
     return 0;
 }
 
+void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *header,
+    const void *sim_io_data, size_t sim_io_size)
+{
+    void *data;
+    size_t size;
+    unsigned char *p;
+
+    if (header == NULL)
+        return NULL;
+
+    if (sim_io_data == NULL)
+        sim_io_size = 0;
+
+    size = sizeof(struct ipc_sec_rsim_access_request_header) + sim_io_size;
+
+    data = calloc(1, size);
+
+    p = (unsigned char *) data;
+
+    memcpy(p, header, sizeof(struct ipc_sec_rsim_access_request_header));
+    p += sizeof(struct ipc_sec_rsim_access_request_header);
+
+    if (sim_io_data != NULL && sim_io_size > 0) {
+        memcpy(p, sim_io_data, sim_io_size);
+        p += sim_io_size;
+    }
+
+    return data;
+}
+
 int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
     unsigned char type)
 {
-- 
cgit v1.1