sms: Headers sort, pdu extract helper
authorPaul Kocialkowski <contact@paulk.fr>
Sat, 5 Jul 2014 18:16:07 +0000 (20:16 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Sat, 5 Jul 2014 18:16:20 +0000 (20:16 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
include/sms.h
samsung-ipc/sms.c

index 2d05571..b1b7518 100644 (file)
@@ -92,15 +92,17 @@ struct ipc_sms_incoming_msg_header {
     unsigned char length;
 } __attribute__((__packed__));
 
-struct ipc_sms_deliver_report_request_data {
-    unsigned char type; // IPC_SMS_TYPE
-    unsigned short ack; // IPC_SMS_ACK
-    unsigned char id;
-    unsigned char unknown;
+struct ipc_sms_save_msg_request_data {
+    unsigned char magic;
+    unsigned short index;
+    unsigned char status; // IPC_SMS_STATUS
+    unsigned char length;
 } __attribute__((__packed__));
 
-struct ipc_sms_deliver_report_response_data {
-    unsigned short ack; // IPC_SMS_ACK
+struct ipc_sms_save_msg_response_data {
+    unsigned char magic;
+    unsigned short error;
+    unsigned short index;
 } __attribute__((__packed__));
 
 struct ipc_sms_del_msg_request_data {
@@ -114,17 +116,19 @@ struct ipc_sms_del_msg_response_data {
     unsigned short index;
 } __attribute__((__packed__));
 
-struct ipc_sms_save_msg_request_data {
-    unsigned char magic;
-    unsigned short index;
-    unsigned char status; // IPC_SMS_STATUS
-    unsigned char length;
+struct ipc_sms_deliver_report_request_data {
+    unsigned char type; // IPC_SMS_TYPE
+    unsigned short ack; // IPC_SMS_ACK
+    unsigned char id;
+    unsigned char unknown;
 } __attribute__((__packed__));
 
-struct ipc_sms_save_msg_response_data {
-    unsigned char magic;
-    unsigned short error;
-    unsigned short index;
+struct ipc_sms_deliver_report_response_data {
+    unsigned short ack; // IPC_SMS_ACK
+} __attribute__((__packed__));
+
+struct ipc_sms_svc_center_addr_header {
+    unsigned char length;
 } __attribute__((__packed__));
 
 /*
@@ -133,6 +137,7 @@ struct ipc_sms_save_msg_response_data {
 
 void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
     const char *smsc, const char *pdu);
+char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size);
 
 #endif
 
index bb9e026..6743776 100644 (file)
@@ -22,6 +22,7 @@
 #include <string.h>
 
 #include <samsung-ipc.h>
+#include <utils.h>
 
 void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
     const char *smsc, const char *pdu)
@@ -58,4 +59,24 @@ void *ipc_sms_send_msg_setup(struct ipc_sms_send_msg_request_header *header,
     return data;
 }
 
+char *ipc_sms_incoming_msg_pdu_extract(const void *data, size_t size)
+{
+    struct ipc_sms_incoming_msg_header *header;
+    char *string;
+    void *pdu;
+
+    if (data == NULL || size < sizeof(struct ipc_sms_incoming_msg_header))
+        return NULL;
+
+    header = (struct ipc_sms_incoming_msg_header *) data;
+    if (header->length == 0 || header->length > size - sizeof(struct ipc_sms_incoming_msg_header))
+        return NULL;
+
+    pdu = (void *) ((unsigned char *) data + sizeof(struct ipc_sms_incoming_msg_header));
+
+    string = data2string(pdu, header->length);
+
+    return string;
+}
+
 // vim:ts=4:sw=4:expandtab