sec: RSIM access extract helper
authorPaul Kocialkowski <contact@paulk.fr>
Mon, 4 Aug 2014 20:58:43 +0000 (22:58 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Mon, 4 Aug 2014 20:58:43 +0000 (22:58 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
include/sec.h
samsung-ipc/sec.c

index 882b586..c7c7000 100644 (file)
@@ -177,6 +177,8 @@ size_t ipc_sec_rsim_access_size_setup(struct ipc_sec_rsim_access_request_header
     const void *sim_io_data, size_t sim_io_size);
 void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *header,
     const void *sim_io_data, size_t sim_io_size);
+size_t ipc_sec_rsim_access_size_extract(const void *data, size_t size);
+void *ipc_sec_rsim_access_extract(const void *data, size_t size);
 int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
     unsigned char type);
 
index 8ec633f..9919592 100644 (file)
@@ -168,6 +168,37 @@ void *ipc_sec_rsim_access_setup(struct ipc_sec_rsim_access_request_header *heade
     return data;
 }
 
+size_t ipc_sec_rsim_access_size_extract(const void *data, size_t size)
+{
+    struct ipc_sec_rsim_access_response_header *header;
+
+    if (data == NULL || size < sizeof(struct ipc_sec_rsim_access_response_header))
+        return 0;
+
+    header = (struct ipc_sec_rsim_access_response_header *) data;
+    if (header->length == 0 || header->length > size - sizeof(struct ipc_sec_rsim_access_response_header))
+        return 0;
+
+    return (size_t) header->length;
+}
+
+void *ipc_sec_rsim_access_extract(const void *data, size_t size)
+{
+    struct ipc_sec_rsim_access_response_header *header;
+    void *rsim_data;
+
+    if (data == NULL || size < sizeof(struct ipc_sec_rsim_access_response_header))
+        return NULL;
+
+    header = (struct ipc_sec_rsim_access_response_header *) data;
+    if (header->length == 0 || header->length > size - sizeof(struct ipc_sec_rsim_access_response_header))
+        return NULL;
+
+    rsim_data = (void *) ((unsigned char *) data + sizeof(struct ipc_sec_rsim_access_response_header));
+
+    return rsim_data;
+}
+
 int ipc_sec_lock_infomation_setup(struct ipc_sec_lock_infomation_request_data *data,
     unsigned char type)
 {