summaryrefslogtreecommitdiffstats
path: root/tinySMS
diff options
context:
space:
mode:
Diffstat (limited to 'tinySMS')
-rwxr-xr-xtinySMS/include/tinysms.h6
-rwxr-xr-xtinySMS/include/tinysms/rpdu/tsms_rpdu.h54
-rwxr-xr-xtinySMS/include/tinysms/tpdu/tsms_tpdu_command.h92
-rwxr-xr-xtinySMS/include/tinysms/tpdu/tsms_tpdu_deliver.h81
-rwxr-xr-xtinySMS/include/tinysms/tpdu/tsms_tpdu_report.h75
-rwxr-xr-xtinySMS/include/tinysms/tpdu/tsms_tpdu_status_report.h190
-rwxr-xr-xtinySMS/include/tinysms/tpdu/tsms_tpdu_submit.h89
-rwxr-xr-xtinySMS/include/tinysms/tsms.h6
-rwxr-xr-xtinySMS/include/tinysms/tsms_address.h100
-rwxr-xr-xtinySMS/include/tinysms/tsms_common.h116
-rwxr-xr-xtinySMS/include/tinysms/tsms_etsi_gsm_03_38.h257
-rwxr-xr-xtinySMS/include/tinysms/tsms_packing.h6
-rwxr-xr-xtinySMS/include/tinysms_config.h12
-rwxr-xr-xtinySMS/src/rpdu/tsms_rpdu.c782
-rwxr-xr-xtinySMS/src/tpdu/tsms_tpdu_command.c369
-rwxr-xr-xtinySMS/src/tpdu/tsms_tpdu_deliver.c357
-rwxr-xr-xtinySMS/src/tpdu/tsms_tpdu_report.c397
-rwxr-xr-xtinySMS/src/tpdu/tsms_tpdu_status_report.c471
-rwxr-xr-xtinySMS/src/tpdu/tsms_tpdu_submit.c450
-rwxr-xr-xtinySMS/src/tsms.c22
-rwxr-xr-xtinySMS/src/tsms_address.c331
-rwxr-xr-xtinySMS/src/tsms_common.c498
-rwxr-xr-xtinySMS/src/tsms_packing.c464
-rwxr-xr-xtinySMS/test/stdafx.c6
-rwxr-xr-xtinySMS/test/stdafx.h6
-rwxr-xr-xtinySMS/test/targetver.h4
-rwxr-xr-xtinySMS/test/test.c72
-rwxr-xr-xtinySMS/test/test_packing.h185
-rwxr-xr-xtinySMS/test/test_rpdu.h407
-rwxr-xr-xtinySMS/test/test_tpdu.h366
30 files changed, 3128 insertions, 3143 deletions
diff --git a/tinySMS/include/tinysms.h b/tinySMS/include/tinysms.h
index d3f69ee..98ecb8e 100755
--- a/tinySMS/include/tinysms.h
+++ b/tinySMS/include/tinysms.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
diff --git a/tinySMS/include/tinysms/rpdu/tsms_rpdu.h b/tinySMS/include/tinysms/rpdu/tsms_rpdu.h
index 4c2b704..c73ca84 100755
--- a/tinySMS/include/tinysms/rpdu/tsms_rpdu.h
+++ b/tinySMS/include/tinysms/rpdu/tsms_rpdu.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -37,16 +37,15 @@
TSMS_BEGIN_DECLS
/** @a RP-DATA as per 3GPP TS 24.011 section 7.3.1. */
-typedef struct tsms_rpdu_data_s
-{
- TSMS_DECLARE_RPDU_MESSAGE;
-
- // section 8.2.5.1
- tsms_address_t *oa;
- //section 8.2.5.2
- tsms_address_t *da;
- // section 8.2.5.3
- tsk_buffer_t* udata;
+typedef struct tsms_rpdu_data_s {
+ TSMS_DECLARE_RPDU_MESSAGE;
+
+ // section 8.2.5.1
+ tsms_address_t *oa;
+ //section 8.2.5.2
+ tsms_address_t *da;
+ // section 8.2.5.3
+ tsk_buffer_t* udata;
}
tsms_rpdu_data_t;
@@ -101,9 +100,8 @@ TINYSMS_API tsms_rpdu_data_t* tsms_rpdu_data_create(uint8_t mr, const tsms_addre
TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_data_def_t;
/** RP-SMMA as per 3GPP TS 24.011 section 7.3.2. */
-typedef struct tsms_rpdu_smma_s
-{
- TSMS_DECLARE_RPDU_MESSAGE;
+typedef struct tsms_rpdu_smma_s {
+ TSMS_DECLARE_RPDU_MESSAGE;
}
tsms_rpdu_smma_t;
@@ -128,12 +126,11 @@ TINYSMS_API tsms_rpdu_smma_t* tsms_rpdu_smma_create(uint8_t mr);
TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_smma_def_t;
/** RP-ACK as per 3GPP TS 24.011 section 7.3.3. */
-typedef struct tsms_rpdu_ack_s
-{
- TSMS_DECLARE_RPDU_MESSAGE;
+typedef struct tsms_rpdu_ack_s {
+ TSMS_DECLARE_RPDU_MESSAGE;
- // section 8.2.5.3
- tsk_buffer_t* udata;
+ // section 8.2.5.3
+ tsk_buffer_t* udata;
}
tsms_rpdu_ack_t;
@@ -184,14 +181,13 @@ TINYSMS_API tsms_rpdu_ack_t* tsms_rpdu_ack_create(uint8_t mr, const tsms_tpdu_me
TINYSMS_GEXTERN const tsk_object_def_t *tsms_rpdu_ack_def_t;
/** RP-ERROR as per 3GPP TS 24.011 section 7.3.4. */
-typedef struct tsms_rpdu_error_s
-{
- TSMS_DECLARE_RPDU_MESSAGE;
-
- // section 8.2.5.4
- uint8_t cause [3]; //2-3o
- // section 8.2.5.3
- tsk_buffer_t* udata;
+typedef struct tsms_rpdu_error_s {
+ TSMS_DECLARE_RPDU_MESSAGE;
+
+ // section 8.2.5.4
+ uint8_t cause [3]; //2-3o
+ // section 8.2.5.3
+ tsk_buffer_t* udata;
}
tsms_rpdu_error_t;
diff --git a/tinySMS/include/tinysms/tpdu/tsms_tpdu_command.h b/tinySMS/include/tinysms/tpdu/tsms_tpdu_command.h
index 655dc00..fe79bb2 100755
--- a/tinySMS/include/tinysms/tpdu/tsms_tpdu_command.h
+++ b/tinySMS/include/tinysms/tpdu/tsms_tpdu_command.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -36,58 +36,56 @@
TSMS_BEGIN_DECLS
-/** TP-Command-Type (TP-CT) as per 3GPP TS 23.040 section 9.2.3.19.
+/** TP-Command-Type (TP-CT) as per 3GPP TS 23.040 section 9.2.3.19.
* An 8-bit field.
*/
-typedef enum tsms_tpdu_cmd_e
-{
- tsms_tpdu_cmd_rel = 0x00, /**< Enquiry relating to previously submitted short message. */
- tsms_tpdu_cmd_cancel = 0x01, /**< Cancel Status Report Request relating to previously submitted short message. */
- tsms_tpdu_cmd_delete = 0x02, /**< Delete previously submitted Short Message. */
- tsms_tpdu_cmd_enable_status = 0x03, /**< Enable Status Report Request relating to previously submitted short message. */
- /* 00000100..00011111 ==> Reserved */
- /* 11100000..11111111 ==> Values specific for each SC */
+typedef enum tsms_tpdu_cmd_e {
+ tsms_tpdu_cmd_rel = 0x00, /**< Enquiry relating to previously submitted short message. */
+ tsms_tpdu_cmd_cancel = 0x01, /**< Cancel Status Report Request relating to previously submitted short message. */
+ tsms_tpdu_cmd_delete = 0x02, /**< Delete previously submitted Short Message. */
+ tsms_tpdu_cmd_enable_status = 0x03, /**< Enable Status Report Request relating to previously submitted short message. */
+ /* 00000100..00011111 ==> Reserved */
+ /* 11100000..11111111 ==> Values specific for each SC */
}
tsms_tpdu_cmd_t;
/** SMS TPDU SMS-COMMAND message as per 3GPP TS 23.040 section 9.2.2.4.
*/
-typedef struct tsms_tpdu_command_s
-{
- TSMS_DECLARE_TPDU_MESSAGE;
-
- tsms_address_t* smsc;
-
- /** TP-User-Data-Header-Indication (O - 1b)
- * Parameter indicating that the TP-CD field contains a Header. */
- unsigned udhi:1;
- /** TP Status Report Request (O - 1b)
- * Parameter indicating if the SMS Command is requesting a status report. */
- unsigned srr:1;
- /** TP Message Reference (M - I)
- * Parameter identifying the SMS COMMAND. */
- uint8_t mr;
- /** TP Protocol Identifier (M - o)
- * Parameter identifying the above layer protocol, if any. */
- //(base)uint8_t pid;
- /** TP Command Type (M - o)
- * Parameter specifying which operation is to be performed on a SM.
- * See section 9.2.3.19 */
- tsms_tpdu_cmd_t ct;
- /** TP Message Number (M - o)
- * Parameter indicating which SM in the SC to operate on.
- * See section 9.2.3.18 */
- uint8_t mn;
- /** TP Destination Address (M - 2-12o)
- * Parameter indicating the Destination Address to which the TP Command refers. */
- tsms_address_t* da;
- /** TP Command Data Length (M - o)
- * Parameter indicating the length of the TP-CD field in octets. */
- //(base)uint8_t cdl;
- /** TP Command Data (O - o)
- * Parameter containing user data. */
- //(base)uint8_t cd;
+typedef struct tsms_tpdu_command_s {
+ TSMS_DECLARE_TPDU_MESSAGE;
+
+ tsms_address_t* smsc;
+
+ /** TP-User-Data-Header-Indication (O - 1b)
+ * Parameter indicating that the TP-CD field contains a Header. */
+ unsigned udhi:1;
+ /** TP Status Report Request (O - 1b)
+ * Parameter indicating if the SMS Command is requesting a status report. */
+ unsigned srr:1;
+ /** TP Message Reference (M - I)
+ * Parameter identifying the SMS COMMAND. */
+ uint8_t mr;
+ /** TP Protocol Identifier (M - o)
+ * Parameter identifying the above layer protocol, if any. */
+ //(base)uint8_t pid;
+ /** TP Command Type (M - o)
+ * Parameter specifying which operation is to be performed on a SM.
+ * See section 9.2.3.19 */
+ tsms_tpdu_cmd_t ct;
+ /** TP Message Number (M - o)
+ * Parameter indicating which SM in the SC to operate on.
+ * See section 9.2.3.18 */
+ uint8_t mn;
+ /** TP Destination Address (M - 2-12o)
+ * Parameter indicating the Destination Address to which the TP Command refers. */
+ tsms_address_t* da;
+ /** TP Command Data Length (M - o)
+ * Parameter indicating the length of the TP-CD field in octets. */
+ //(base)uint8_t cdl;
+ /** TP Command Data (O - o)
+ * Parameter containing user data. */
+ //(base)uint8_t cd;
}
tsms_tpdu_command_t;
diff --git a/tinySMS/include/tinysms/tpdu/tsms_tpdu_deliver.h b/tinySMS/include/tinysms/tpdu/tsms_tpdu_deliver.h
index 6413bda..09d1dd6 100755
--- a/tinySMS/include/tinysms/tpdu/tsms_tpdu_deliver.h
+++ b/tinySMS/include/tinysms/tpdu/tsms_tpdu_deliver.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -39,46 +39,45 @@ TSMS_BEGIN_DECLS
/** SMS TPDU SMS-DELIVER message as per 3GPP TS 23.040 section 9.2.2.1.
*/
-typedef struct tsms_tpdu_deliver_s
-{
- TSMS_DECLARE_TPDU_MESSAGE;
+typedef struct tsms_tpdu_deliver_s {
+ TSMS_DECLARE_TPDU_MESSAGE;
- tsms_address_t* smsc;
+ tsms_address_t* smsc;
- /** TP More Messages to Send (M - 1b)
- * Parameter indicating whether or not there are more messages to send. */
- unsigned mms:1;
- /** TP-Loop-Prevention (O - 1b)
- * Parameter indicating that SMS applications should inhibit forwarding or automatic message generation that could cause infinite looping. */
- unsigned lp:2;
- /** TP Reply Path (M - 1b)
- * Parameter indicating the request for Reply Path.
- Section 9.2.3.28 */
- unsigned rp:1;
- /** TP User Data Header Indicator (O - 1b)
- * Parameter indicating that the TP UD field contains a Header. */
- unsigned udhi:1;
- /** TP Status Report Indicator (O - 1b)
- * Parameter indicating if the SME has requested a status report. */
- unsigned sri:1;
- /** TP Originating Address (M - 2-12o)
- * Address of the originating SME. */
- tsms_address_t* oa;
- /** TP Protocol Identifier (M - o)
- * Parameter identifying the above layer protocol, if any. */
- //(base)uint8_t pid;
- /** TP Data Coding Scheme (M - o)
- * Parameter identifying the coding scheme within the TP-User-Data. */
- //(base)uint8_t dcs;
- /** TP Service Centre Time Stamp (M - 7o)
- * Parameter identifying time when the SC received the message. */
- uint8_t scts[7];
- /** TP User Data Length (M - I)
- * Parameter indicating the length of the TP User Data field to follow. */
- //(base)uint8_t udl;
- /** TP User Data (O - v)
- * User data. */
- //(base)tsk_buffer_t* ud;
+ /** TP More Messages to Send (M - 1b)
+ * Parameter indicating whether or not there are more messages to send. */
+ unsigned mms:1;
+ /** TP-Loop-Prevention (O - 1b)
+ * Parameter indicating that SMS applications should inhibit forwarding or automatic message generation that could cause infinite looping. */
+ unsigned lp:2;
+ /** TP Reply Path (M - 1b)
+ * Parameter indicating the request for Reply Path.
+ Section 9.2.3.28 */
+ unsigned rp:1;
+ /** TP User Data Header Indicator (O - 1b)
+ * Parameter indicating that the TP UD field contains a Header. */
+ unsigned udhi:1;
+ /** TP Status Report Indicator (O - 1b)
+ * Parameter indicating if the SME has requested a status report. */
+ unsigned sri:1;
+ /** TP Originating Address (M - 2-12o)
+ * Address of the originating SME. */
+ tsms_address_t* oa;
+ /** TP Protocol Identifier (M - o)
+ * Parameter identifying the above layer protocol, if any. */
+ //(base)uint8_t pid;
+ /** TP Data Coding Scheme (M - o)
+ * Parameter identifying the coding scheme within the TP-User-Data. */
+ //(base)uint8_t dcs;
+ /** TP Service Centre Time Stamp (M - 7o)
+ * Parameter identifying time when the SC received the message. */
+ uint8_t scts[7];
+ /** TP User Data Length (M - I)
+ * Parameter indicating the length of the TP User Data field to follow. */
+ //(base)uint8_t udl;
+ /** TP User Data (O - v)
+ * User data. */
+ //(base)tsk_buffer_t* ud;
}
tsms_tpdu_deliver_t;
diff --git a/tinySMS/include/tinysms/tpdu/tsms_tpdu_report.h b/tinySMS/include/tinysms/tpdu/tsms_tpdu_report.h
index 0eb1874..d42279c 100755
--- a/tinySMS/include/tinysms/tpdu/tsms_tpdu_report.h
+++ b/tinySMS/include/tinysms/tpdu/tsms_tpdu_report.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -40,41 +40,40 @@ TSMS_BEGIN_DECLS
/** SMS TPDU SMS-DELIVER-REPORT or SMS-SUBMIT-REPORT
* message as per 3GPP TS 23.040 section 9.2.2.1a or 9.2.2.2a.
*/
-typedef struct tsms_tpdu_report_s
-{
- TSMS_DECLARE_TPDU_MESSAGE;
-
- tsms_address_t* smsc;
-
- /** Indicates whether the Report is for RP-ERROR or not (RP-ACK).*/
- tsk_bool_t error;
-
- /** TP-User-Data-Header-Indication (O - 1b)
- * Parameter indicating that the TP-UD field contains a Header. */
- unsigned udhi:1;
- /** TP Failure Cause (M - I)
- * Parameter indicating the reason for SMS DELIVER/SUBMIT failure.
- See clause 9.2.3.22 */
- uint8_t fcs;
- /** TP Parameter Indicator (M - o)
- * Parameter indicating the presence of any of the optional parameters which follow. */
- uint8_t pi;
- /** TP Service Centre Time Stamp (M - 7o)
- * Parameter identifying the time when the SC received the SMS DELIVER/SUBMIT.
- * See clause 9.2.3.11. */
- uint8_t scts[7];
- /** TP Protocol Identifier (O - o)
- * See clause 9.2.3.9. */
- //(base)uint8_t pid;
- /** TP Data Coding Scheme (O - o)
- * See clause 9.2.3.10. */
- //(base)uint8_t dcs;
- /** TP User Data Length (O- o)
- * See clause 9.2.3.16. */
- //(base)uint8_t udl;
- /** TP User Data (O - v)
- * User data. */
- //(base)tsk_buffer_t* ud;
+typedef struct tsms_tpdu_report_s {
+ TSMS_DECLARE_TPDU_MESSAGE;
+
+ tsms_address_t* smsc;
+
+ /** Indicates whether the Report is for RP-ERROR or not (RP-ACK).*/
+ tsk_bool_t error;
+
+ /** TP-User-Data-Header-Indication (O - 1b)
+ * Parameter indicating that the TP-UD field contains a Header. */
+ unsigned udhi:1;
+ /** TP Failure Cause (M - I)
+ * Parameter indicating the reason for SMS DELIVER/SUBMIT failure.
+ See clause 9.2.3.22 */
+ uint8_t fcs;
+ /** TP Parameter Indicator (M - o)
+ * Parameter indicating the presence of any of the optional parameters which follow. */
+ uint8_t pi;
+ /** TP Service Centre Time Stamp (M - 7o)
+ * Parameter identifying the time when the SC received the SMS DELIVER/SUBMIT.
+ * See clause 9.2.3.11. */
+ uint8_t scts[7];
+ /** TP Protocol Identifier (O - o)
+ * See clause 9.2.3.9. */
+ //(base)uint8_t pid;
+ /** TP Data Coding Scheme (O - o)
+ * See clause 9.2.3.10. */
+ //(base)uint8_t dcs;
+ /** TP User Data Length (O- o)
+ * See clause 9.2.3.16. */
+ //(base)uint8_t udl;
+ /** TP User Data (O - v)
+ * User data. */
+ //(base)tsk_buffer_t* ud;
}
tsms_tpdu_report_t;
diff --git a/tinySMS/include/tinysms/tpdu/tsms_tpdu_status_report.h b/tinySMS/include/tinysms/tpdu/tsms_tpdu_status_report.h
index 001127d..8eae0a7 100755
--- a/tinySMS/include/tinysms/tpdu/tsms_tpdu_status_report.h
+++ b/tinySMS/include/tinysms/tpdu/tsms_tpdu_status_report.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -40,105 +40,103 @@ TSMS_BEGIN_DECLS
/** 3GPP TS 23.040 v910 section 9.2.3.15 (TP-ST).
* Used in SMS-STATUS-REPORT message.
*/
-typedef enum tsms_tpdu_status_type_e
-{
- /*== Short message transaction completed ==*/
- tsms_tpdu_status_received = 0x00, /**< Short message received by the SME. */
- tsms_tpdu_status_forwarded = 0x01, /**< Short message forwarded by the SC to the SME but the SC is unable to confirm delivery. */
- tsms_tpdu_status_replaced = 0x02, /**< Short message replaced by the SC. */
- /* 0000011..0001111 Reserved */
- /* 0010000..0011111 Values specific to each SC */
-
- /*== Temporary error, SC still trying to transfer SM ==*/
- tsms_tpdu_status_congestion = 0x20, /**< Congestion. */
- tsms_tpdu_status_busy = 0x21, /**< ME busy. */
- tsms_tpdu_status_no_response = 0x22, /**< No response from SME. */
- tsms_tpdu_status_serv_rejected = 0x23, /**< Service rejected. */
- tsms_tpdu_status_no_qos = 0x24, /**< Quality of service not available. */
- tsms_tpdu_status_error_in_sme= 0x25, /**< Error in SME. */
- /* 0100110..0101111 Reserved */
- /* 0110000..0111111 Values specific to each SC */
-
- /*== Permanent error, SC is not making any more transfer attempts ==*/
- tsms_tpdu_status_remote_error = 0x40, /**< Remote procedure error. */
- tsms_tpdu_status_incompatible_dest = 0x41, /**< Incompatible destination. */
- tsms_tpdu_status_conn_rejected = 0x42, /**< Connection rejected by SME. */
- tsms_tpdu_status_not_obtainable = 0x43, /**< Not obtainable. */
- tsms_tpdu_status_no_qos_2 = 0x44, /**< Quality of service not available. */
- tsms_tpdu_status_no_inter_avail = 0x45, /**< No interworking available. */
- tsms_tpdu_status_vp_expired = 0x46, /**< SM Validity Period Expired. */
- tsms_tpdu_status_deleted_by_orig = 0x47, /**< SM Deleted by originating SME. */
- tsms_tpdu_status_deleted_by_admin = 0x48, /**< SM Deleted by SC Administration. */
- tsms_tpdu_status_sm_not_exist = 0x49, /**< SM does not exist (The SM may have previously existed in the SC but the SC no longer has knowledge of it or the SM may never have previously existed in the SC). */
- /* 1001010..1001111 Reserved */
- /* 1010000..1011111 Values specific to each SC */
-
- /*== Temporary error, SC is not making any more transfer attempts ==*/
- tsms_tpdu_status_congestion_3 = 0x50, /**< Congestion. */
- tsms_tpdu_status_busy_3 = 0x51, /**< SME busy. */
- tsms_tpdu_status_no_response_3 = 0x52, /**< No response from SME. */
- tsms_tpdu_status_serv_rejected_3 = 0x53, /**< Service rejected. */
- tsms_tpdu_status_temp_no_qos_3 = 0x54, /**< Quality of service not available. */
- tsms_tpdu_status_error_in_sme_3 = 0x55, /**< Error in SME. */
- /* 1100110..1101001 Reserved */
- /* 1101010..1101111 Reserved */
- /* 1110000..1111111 Values specific to each SC */
+typedef enum tsms_tpdu_status_type_e {
+ /*== Short message transaction completed ==*/
+ tsms_tpdu_status_received = 0x00, /**< Short message received by the SME. */
+ tsms_tpdu_status_forwarded = 0x01, /**< Short message forwarded by the SC to the SME but the SC is unable to confirm delivery. */
+ tsms_tpdu_status_replaced = 0x02, /**< Short message replaced by the SC. */
+ /* 0000011..0001111 Reserved */
+ /* 0010000..0011111 Values specific to each SC */
+
+ /*== Temporary error, SC still trying to transfer SM ==*/
+ tsms_tpdu_status_congestion = 0x20, /**< Congestion. */
+ tsms_tpdu_status_busy = 0x21, /**< ME busy. */
+ tsms_tpdu_status_no_response = 0x22, /**< No response from SME. */
+ tsms_tpdu_status_serv_rejected = 0x23, /**< Service rejected. */
+ tsms_tpdu_status_no_qos = 0x24, /**< Quality of service not available. */
+ tsms_tpdu_status_error_in_sme= 0x25, /**< Error in SME. */
+ /* 0100110..0101111 Reserved */
+ /* 0110000..0111111 Values specific to each SC */
+
+ /*== Permanent error, SC is not making any more transfer attempts ==*/
+ tsms_tpdu_status_remote_error = 0x40, /**< Remote procedure error. */
+ tsms_tpdu_status_incompatible_dest = 0x41, /**< Incompatible destination. */
+ tsms_tpdu_status_conn_rejected = 0x42, /**< Connection rejected by SME. */
+ tsms_tpdu_status_not_obtainable = 0x43, /**< Not obtainable. */
+ tsms_tpdu_status_no_qos_2 = 0x44, /**< Quality of service not available. */
+ tsms_tpdu_status_no_inter_avail = 0x45, /**< No interworking available. */
+ tsms_tpdu_status_vp_expired = 0x46, /**< SM Validity Period Expired. */
+ tsms_tpdu_status_deleted_by_orig = 0x47, /**< SM Deleted by originating SME. */
+ tsms_tpdu_status_deleted_by_admin = 0x48, /**< SM Deleted by SC Administration. */
+ tsms_tpdu_status_sm_not_exist = 0x49, /**< SM does not exist (The SM may have previously existed in the SC but the SC no longer has knowledge of it or the SM may never have previously existed in the SC). */
+ /* 1001010..1001111 Reserved */
+ /* 1010000..1011111 Values specific to each SC */
+
+ /*== Temporary error, SC is not making any more transfer attempts ==*/
+ tsms_tpdu_status_congestion_3 = 0x50, /**< Congestion. */
+ tsms_tpdu_status_busy_3 = 0x51, /**< SME busy. */
+ tsms_tpdu_status_no_response_3 = 0x52, /**< No response from SME. */
+ tsms_tpdu_status_serv_rejected_3 = 0x53, /**< Service rejected. */
+ tsms_tpdu_status_temp_no_qos_3 = 0x54, /**< Quality of service not available. */
+ tsms_tpdu_status_error_in_sme_3 = 0x55, /**< Error in SME. */
+ /* 1100110..1101001 Reserved */
+ /* 1101010..1101111 Reserved */
+ /* 1110000..1111111 Values specific to each SC */
}
tsms_tpdu_status_type_t;
/** SMS TPDU SMS-STATUS-REPORT message as per 3GPP TS 23.040 section 9.2.2.3.
*/
-typedef struct tsms_tpdu_status_report_s
-{
- TSMS_DECLARE_TPDU_MESSAGE;
-
- tsms_address_t* smsc;
-
- /** TP User Data Header Indicator (O - 1b)
- * Parameter indicating that the TP UD field contains a Header. */
- unsigned udhi:1;
- /** TP More Messages to Send (M - 1b)
- * Parameter indicating whether or not there are more messages to send. */
- unsigned mms:1;
- /** TP-Loop-Prevention (O - 1b)
- * Parameter indicating that SMS applications should inhibit forwarding or automatic message generation that could cause infinite looping.
- Section 9.2.3.28 */
- unsigned lp:1;
- /** TP Status Report Qualifier (M - 1b)
- * Parameter indicating whether the previously submitted TPDU was an SMS-SUBMIT or an SMS COMMAND. */
- unsigned srq:1;
- /** TP Message Reference (M - I)
- * Parameter identifying the previously submitted SMS SUBMIT or SMS COMMAND.
- * See section 9.2.3.26. */
- unsigned mr;
- /** TP Recipient Address (M - 2-12o)
- * Address of the recipient of the previously submitted mobile originated short message. */
- tsms_address_t* ra;
- /** TP Service Centre Time Stamp (M - 7o)
- * Parameter identifying time when the SC received the previously sent SMS SUBMIT. */
- uint8_t scts[7];
- /** TP Discharge Time (M 7o)
- * Parameter identifying the time associated with a particular TP ST outcome. */
- uint8_t dt[7];
- /** TP Status (M - o)
- * Parameter identifying the status of the previously sent mobile originated short message. */
- tsms_tpdu_status_type_t st;
- /** TP-Parameter-Indicator (O - o)
- * Parameter indicating the presence of any of the optional parameters which follow. */
- uint8_t pi;
- /** TP Protocol Identifier (O - o)
- * See clause 9.2.3.9. TP-PID of original SMS-SUBMIT. */
- //(base)uint8_t pid;
- /** TP Data Coding Scheme (O - o)
- * See clause 9.2.3.10. */
- //(base)uint8_t dcs;
- /** TP User Data Length (O- o)
- * See clause 9.2.3.16. */
- //(base)uint8_t udl;
- /** TP User Data (O - v)
- * User data. See clause 9.2.3.24. */
- //(base)uint8_t* ud;
+typedef struct tsms_tpdu_status_report_s {
+ TSMS_DECLARE_TPDU_MESSAGE;
+
+ tsms_address_t* smsc;
+
+ /** TP User Data Header Indicator (O - 1b)
+ * Parameter indicating that the TP UD field contains a Header. */
+ unsigned udhi:1;
+ /** TP More Messages to Send (M - 1b)
+ * Parameter indicating whether or not there are more messages to send. */
+ unsigned mms:1;
+ /** TP-Loop-Prevention (O - 1b)
+ * Parameter indicating that SMS applications should inhibit forwarding or automatic message generation that could cause infinite looping.
+ Section 9.2.3.28 */
+ unsigned lp:1;
+ /** TP Status Report Qualifier (M - 1b)
+ * Parameter indicating whether the previously submitted TPDU was an SMS-SUBMIT or an SMS COMMAND. */
+ unsigned srq:1;
+ /** TP Message Reference (M - I)
+ * Parameter identifying the previously submitted SMS SUBMIT or SMS COMMAND.
+ * See section 9.2.3.26. */
+ unsigned mr;
+ /** TP Recipient Address (M - 2-12o)
+ * Address of the recipient of the previously submitted mobile originated short message. */
+ tsms_address_t* ra;
+ /** TP Service Centre Time Stamp (M - 7o)
+ * Parameter identifying time when the SC received the previously sent SMS SUBMIT. */
+ uint8_t scts[7];
+ /** TP Discharge Time (M 7o)
+ * Parameter identifying the time associated with a particular TP ST outcome. */
+ uint8_t dt[7];
+ /** TP Status (M - o)
+ * Parameter identifying the status of the previously sent mobile originated short message. */
+ tsms_tpdu_status_type_t st;
+ /** TP-Parameter-Indicator (O - o)
+ * Parameter indicating the presence of any of the optional parameters which follow. */
+ uint8_t pi;
+ /** TP Protocol Identifier (O - o)
+ * See clause 9.2.3.9. TP-PID of original SMS-SUBMIT. */
+ //(base)uint8_t pid;
+ /** TP Data Coding Scheme (O - o)
+ * See clause 9.2.3.10. */
+ //(base)uint8_t dcs;
+ /** TP User Data Length (O- o)
+ * See clause 9.2.3.16. */
+ //(base)uint8_t udl;
+ /** TP User Data (O - v)
+ * User data. See clause 9.2.3.24. */
+ //(base)uint8_t* ud;
}
tsms_tpdu_status_report_t;
diff --git a/tinySMS/include/tinysms/tpdu/tsms_tpdu_submit.h b/tinySMS/include/tinysms/tpdu/tsms_tpdu_submit.h
index 4191a8f..c965bdf 100755
--- a/tinySMS/include/tinysms/tpdu/tsms_tpdu_submit.h
+++ b/tinySMS/include/tinysms/tpdu/tsms_tpdu_submit.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -39,50 +39,49 @@ TSMS_BEGIN_DECLS
/** SMS @a SMS-SUBMIT message as per 3GPP TS 23.040 section 9.2.2.2
*/
-typedef struct tsms_tpdu_submit_s
-{
- TSMS_DECLARE_TPDU_MESSAGE;
+typedef struct tsms_tpdu_submit_s {
+ TSMS_DECLARE_TPDU_MESSAGE;
- tsms_address_t* smsc;
+ tsms_address_t* smsc;
- /** TP Reject Duplicates (M - 1b)
- * Parameter indicating whether or not the SC shall accept an SMS SUBMIT for an
- * SM still held in the SC which has the same TP MR and the same TP DA as a
- * previously submitted SM from the same OA. */
- unsigned rd:1;
- /** TP Validity Period Format (M - 2b)
- * Parameter indicating whether or not the TP VP field is present. */
- tsms_tpdu_vpf_t vpf;
- /** TP Reply Path (M - 1b)
- * Parameter indicating the request for Reply Path. */
- unsigned rp:1;
- /** TP User Data Header Indicator (O - 1b)
- * Parameter indicating that the TP UD field contains a Header. */
- unsigned udhi:1;
- /** TP Status Report Request (O - 1b)
- * Parameter indicating if the MS is requesting a status report. */
- unsigned srr:1;
- /** TP Message Reference (M - I)
- * Parameter identifying the SMS SUBMIT. */
- uint8_t mr;
- /** TP Destination Address (M - 2-12o)
- * Address of the destination SME. */
- tsms_address_t* da;
- /** TP Protocol Identifier (M - o)
- * Parameter identifying the above layer protocol, if any. */
- //(base)uint8_t pid;
- /** TP Data Coding Scheme (M - o)
- * Parameter identifying the coding scheme within the TP User Data. */
- //(base)uint8_t dcs;
- /** TP Validity Period (O - o/7o)
- * Parameter identifying the time from where the message is no longer valid. */
- uint8_t vp[7];
- /** TP User Data Length (M - I)
- * Parameter indicating the length of the TP User Data field to follow. */
- //(base)uint8_t udl;
- /** TP User Data (O - v)
- * User data. */
- //(base)tsk_buffer_t* ud;
+ /** TP Reject Duplicates (M - 1b)
+ * Parameter indicating whether or not the SC shall accept an SMS SUBMIT for an
+ * SM still held in the SC which has the same TP MR and the same TP DA as a
+ * previously submitted SM from the same OA. */
+ unsigned rd:1;
+ /** TP Validity Period Format (M - 2b)
+ * Parameter indicating whether or not the TP VP field is present. */
+ tsms_tpdu_vpf_t vpf;
+ /** TP Reply Path (M - 1b)
+ * Parameter indicating the request for Reply Path. */
+ unsigned rp:1;
+ /** TP User Data Header Indicator (O - 1b)
+ * Parameter indicating that the TP UD field contains a Header. */
+ unsigned udhi:1;
+ /** TP Status Report Request (O - 1b)
+ * Parameter indicating if the MS is requesting a status report. */
+ unsigned srr:1;
+ /** TP Message Reference (M - I)
+ * Parameter identifying the SMS SUBMIT. */
+ uint8_t mr;
+ /** TP Destination Address (M - 2-12o)
+ * Address of the destination SME. */
+ tsms_address_t* da;
+ /** TP Protocol Identifier (M - o)
+ * Parameter identifying the above layer protocol, if any. */
+ //(base)uint8_t pid;
+ /** TP Data Coding Scheme (M - o)
+ * Parameter identifying the coding scheme within the TP User Data. */
+ //(base)uint8_t dcs;
+ /** TP Validity Period (O - o/7o)
+ * Parameter identifying the time from where the message is no longer valid. */
+ uint8_t vp[7];
+ /** TP User Data Length (M - I)
+ * Parameter indicating the length of the TP User Data field to follow. */
+ //(base)uint8_t udl;
+ /** TP User Data (O - v)
+ * User data. */
+ //(base)tsk_buffer_t* ud;
}
tsms_tpdu_submit_t;
diff --git a/tinySMS/include/tinysms/tsms.h b/tinySMS/include/tinysms/tsms.h
index fb11185..2ef5c7c 100755
--- a/tinySMS/include/tinysms/tsms.h
+++ b/tinySMS/include/tinysms/tsms.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
diff --git a/tinySMS/include/tinysms/tsms_address.h b/tinySMS/include/tinysms/tsms_address.h
index f71589f..0a74483 100755
--- a/tinySMS/include/tinysms/tsms_address.h
+++ b/tinySMS/include/tinysms/tsms_address.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -40,74 +40,70 @@ typedef uint8_t tsms_address_string_t[13]; /* 12 + (+) */
/** Address type
*/
-typedef enum tsms_address_type_e
-{
- tsms_addr_oa,
- tsms_addr_da,
- tsms_addr_smsc,
+typedef enum tsms_address_type_e {
+ tsms_addr_oa,
+ tsms_addr_da,
+ tsms_addr_smsc,
}
tsms_address_type_t;
/** Type-of-number
* 3GPP TS 23.040 v910 section 9.1.2.5.
*/
-typedef enum tsms_address_ton_e
-{
- /** "Unknown" is used when the user or network has no a priori information about the numbering plan. In
- this case, the Address-Value field is organized according to the network dialling plan, e.g. prefix or
- escape digits might be present.*/
- tsms_addr_ton_unknown = 0x00, // 0b000
- /** International number
- The international format shall be accepted also when the message is destined to a recipient in the
- same country as the MSC. */
- tsms_addr_ton_international = 0x01, // 0b001
- /** National number
- Prefix or escape digits shall not be included */
- tsms_addr_ton_national = 0x02, // 0b010
- /** "Network specific number" is used to indicate administration/service number specific to the serving
- network, e.g. used to access an operator. */
- tsms_addr_ton_network_specific = 0x03, // 0b011
- /** "Subscriber number" is used when a specific short number representation is stored in one or more
- SCs as part of a higher layer application. (Note that "Subscriber number" shall only be used in
- connection with the proper PID referring to this application). */
- tsms_addr_ton_subscriber = 0x04, // 0b100
- /** Alphanumeric, (coded according to GSM TS 03.38 7-bit default alphabet) */
- tsms_addr_ton_alphanumeric = 0x05, // 0b101
- /** Abbreviated number */
- tsms_addr_ton_abbreviated = 0x06, // 0b110
- /** Reserved for extension */
- tsms_addr_ton_reserved = 0x07, // 0b111
+typedef enum tsms_address_ton_e {
+ /** "Unknown" is used when the user or network has no a priori information about the numbering plan. In
+ this case, the Address-Value field is organized according to the network dialling plan, e.g. prefix or
+ escape digits might be present.*/
+ tsms_addr_ton_unknown = 0x00, // 0b000
+ /** International number
+ The international format shall be accepted also when the message is destined to a recipient in the
+ same country as the MSC. */
+ tsms_addr_ton_international = 0x01, // 0b001
+ /** National number
+ Prefix or escape digits shall not be included */
+ tsms_addr_ton_national = 0x02, // 0b010
+ /** "Network specific number" is used to indicate administration/service number specific to the serving
+ network, e.g. used to access an operator. */
+ tsms_addr_ton_network_specific = 0x03, // 0b011
+ /** "Subscriber number" is used when a specific short number representation is stored in one or more
+ SCs as part of a higher layer application. (Note that "Subscriber number" shall only be used in
+ connection with the proper PID referring to this application). */
+ tsms_addr_ton_subscriber = 0x04, // 0b100
+ /** Alphanumeric, (coded according to GSM TS 03.38 7-bit default alphabet) */
+ tsms_addr_ton_alphanumeric = 0x05, // 0b101
+ /** Abbreviated number */
+ tsms_addr_ton_abbreviated = 0x06, // 0b110
+ /** Reserved for extension */
+ tsms_addr_ton_reserved = 0x07, // 0b111
}
tsms_address_ton_t;
/** Numbering-Plan-Identification
* 3GPP TS 23.040 v910 section 9.1.2.5.
*/
-typedef enum tsms_address_npi_e
-{
- /* 0000 */ tsms_addr_npi_unknown = 0x00, /**< Unknown */
- /* 0001 */ tsms_addr_npi_isdn = 0x01, /**< ISDN/telephone numbering plan (E.164/E.163) */
- /* 0011 */ tsms_addr_npi_x121 = 0x03, /**< Data numbering plan (X.121) */
- /* 0100 */ tsms_addr_npi_telex = 0x04, /**< Telex numbering plan */
- /* 1000 */ tsms_addr_npi_national = 0x08, /**< National numbering plan */
- /* 1001 */ tsms_addr_npi_private = 0x09, /**< Private numbering plan */
- /* 1010 */ tsms_addr_npi_ermes = 0x0A, /**< ERMES numbering plan (ETSI DE/PS 3 01-3) */
- /* 1111 */ tsms_addr_npi_reserved = 0x0F, /**< Reserved for extension */
+typedef enum tsms_address_npi_e {
+ /* 0000 */ tsms_addr_npi_unknown = 0x00, /**< Unknown */
+ /* 0001 */ tsms_addr_npi_isdn = 0x01, /**< ISDN/telephone numbering plan (E.164/E.163) */
+ /* 0011 */ tsms_addr_npi_x121 = 0x03, /**< Data numbering plan (X.121) */
+ /* 0100 */ tsms_addr_npi_telex = 0x04, /**< Telex numbering plan */
+ /* 1000 */ tsms_addr_npi_national = 0x08, /**< National numbering plan */
+ /* 1001 */ tsms_addr_npi_private = 0x09, /**< Private numbering plan */
+ /* 1010 */ tsms_addr_npi_ermes = 0x0A, /**< ERMES numbering plan (ETSI DE/PS 3 01-3) */
+ /* 1111 */ tsms_addr_npi_reserved = 0x0F, /**< Reserved for extension */
}
tsms_address_npi_t;
/** Address
*/
-typedef struct tsms_address_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tsms_address_s {
+ TSK_DECLARE_OBJECT;
- // Address Type
- tsms_address_ton_t ton; /**< Type-of-number */
- tsms_address_npi_t npi; /**< Numbering-Plan-Identification */
+ // Address Type
+ tsms_address_ton_t ton; /**< Type-of-number */
+ tsms_address_npi_t npi; /**< Numbering-Plan-Identification */
- tsms_address_type_t type;
- char* digits; /* BCD digits */
+ tsms_address_type_t type;
+ char* digits; /* BCD digits */
}
tsms_address_t;
diff --git a/tinySMS/include/tinysms/tsms_common.h b/tinySMS/include/tinysms/tsms_common.h
index 38bef53..e80bac9 100755
--- a/tinySMS/include/tinysms/tsms_common.h
+++ b/tinySMS/include/tinysms/tsms_common.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -38,14 +38,13 @@
TSMS_BEGIN_DECLS
-/** SMS alphabet values as per 3GPP TS 23.038 v911 section 4.
+/** SMS alphabet values as per 3GPP TS 23.038 v911 section 4.
* Part of TP-DCS (SMS Data Coding Scheme).
*/
-typedef enum tsms_alphabet_e
-{
- /*11*/ tsms_alpha_reserved = 0x03,
- /*00*/ tsms_alpha_7bit = 0x00,
- /*01*/ tsms_alpha_8bit = 0x01,
+typedef enum tsms_alphabet_e {
+ /*11*/ tsms_alpha_reserved = 0x03,
+ /*00*/ tsms_alpha_7bit = 0x00,
+ /*01*/ tsms_alpha_8bit = 0x01,
/*10*/ tsms_alpha_ucs2 = 0x02
}
tsms_alphabet_t;
@@ -54,19 +53,18 @@ tsms_alphabet_t;
#define TSMS_ALPHA_FROM_DCS(dcs) (((dcs) & 0x0C) >> 2) /* Bit3 and Bit2 */
-/* ======================== TPDU ========================
+/* ======================== TPDU ========================
=========================================================*/
/** 3GPP TS 23.040 - 9.2.3.1 TP Message Type Indicator (TP MTI) */
-typedef enum tsms_tpdu_mti_e
-{
- /*0 0*/ tsms_tpdu_mti_deliver_mt = 0x00, /**< SMS-DELIVER (in the direction SC to MS)*/
- /*0 0*/ tsms_tpdu_mti_deliver_report_mo = 0x00, /**< SMS-DELIVER-REPORT (in the direction MS to SC)*/
- /*1 0*/ tsms_tpdu_mti_status_report_mt = 0x02, /**< SMS-STATUS-REPORT (in the direction SC to MS)*/
- /*1 0*/ tsms_tpdu_mti_command_mo = 0x02, /**< SMS-COMMAND (in the direction MS to SC)*/
- /*0 1*/ tsms_tpdu_mti_submit_mo = 0x01, /**< SMS-SUBMIT (in the direction MS to SC)*/
- /*0 1*/ tsms_tpdu_mti_submit_report_mt = 0x01, /**< SMS-SUBMIT-REPORT (in the direction SC to MS)*/
- /*1 1*/ tsms_tpdu_mti_reserved = 0x03 /**< Reserved*/
+typedef enum tsms_tpdu_mti_e {
+ /*0 0*/ tsms_tpdu_mti_deliver_mt = 0x00, /**< SMS-DELIVER (in the direction SC to MS)*/
+ /*0 0*/ tsms_tpdu_mti_deliver_report_mo = 0x00, /**< SMS-DELIVER-REPORT (in the direction MS to SC)*/
+ /*1 0*/ tsms_tpdu_mti_status_report_mt = 0x02, /**< SMS-STATUS-REPORT (in the direction SC to MS)*/
+ /*1 0*/ tsms_tpdu_mti_command_mo = 0x02, /**< SMS-COMMAND (in the direction MS to SC)*/
+ /*0 1*/ tsms_tpdu_mti_submit_mo = 0x01, /**< SMS-SUBMIT (in the direction MS to SC)*/
+ /*0 1*/ tsms_tpdu_mti_submit_report_mt = 0x01, /**< SMS-SUBMIT-REPORT (in the direction SC to MS)*/
+ /*1 1*/ tsms_tpdu_mti_reserved = 0x03 /**< Reserved*/
}
tsms_tpdu_mti_t;
@@ -74,38 +72,36 @@ tsms_tpdu_mti_t;
#define TSMS_TPDU_MTI_IS_MO(mti) (((mti) == tsms_tpdu_mti_deliver_report_mo) || ((mti) == tsms_tpdu_mti_command_mo) || ((mti) == tsms_tpdu_mti_submit_mo))
/** 3GPP TS 23.040 - 9.2.3.1 TP Message Type Indicator (TP MTI) */
-typedef enum tsms_tpdu_vpf_e
-{
- // Bit4 and Bit3
- /*0 0*/ tsms_tpdu_vpf_not_present = 0x00, /**< TP VP field not present */
- /*1 0*/ tsms_tpdu_vpf_relative = 0x02, /**< TP VP field present - relative format*/
- /*0 1*/ tsms_tpdu_vpf_enhanced = 0x01, /**< TP-VP field present - enhanced format */
- /*1 1*/ tsms_tpdu_vpf_absolute = 0x03, /**< TP VP field present - absolute format */
+typedef enum tsms_tpdu_vpf_e {
+ // Bit4 and Bit3
+ /*0 0*/ tsms_tpdu_vpf_not_present = 0x00, /**< TP VP field not present */
+ /*1 0*/ tsms_tpdu_vpf_relative = 0x02, /**< TP VP field present - relative format*/
+ /*0 1*/ tsms_tpdu_vpf_enhanced = 0x01, /**< TP-VP field present - enhanced format */
+ /*1 1*/ tsms_tpdu_vpf_absolute = 0x03, /**< TP VP field present - absolute format */
}
tsms_tpdu_vpf_t;
/** SM-TL base type as per 3GPP TS 23.040 section 9.2.
*/
-typedef struct tsms_tpdu_message_s
-{
- TSK_DECLARE_OBJECT;
-
- tsk_bool_t MobOrig;
-
- /** TP Message Type Indicator (TP MTI) as per TS 23.040 section 9.2.3.1. 2-bit field. */
- tsms_tpdu_mti_t mti;
- /** TP Protocol Identifier (M - o)
- * Parameter identifying the above layer protocol, if any. */
- uint8_t pid;
- /** TP Data Coding Scheme (M - o)
- * Parameter identifying the coding scheme within the TP-User-Data. */
- uint8_t dcs;
- /** TP User Data Length (M - I)
- * Parameter indicating the length of the TP User Data field to follow. */
- uint8_t udl;
- /** TP User Data (O - v)
- * User data. */
- tsk_buffer_t* ud;
+typedef struct tsms_tpdu_message_s {
+ TSK_DECLARE_OBJECT;
+
+ tsk_bool_t MobOrig;
+
+ /** TP Message Type Indicator (TP MTI) as per TS 23.040 section 9.2.3.1. 2-bit field. */
+ tsms_tpdu_mti_t mti;
+ /** TP Protocol Identifier (M - o)
+ * Parameter identifying the above layer protocol, if any. */
+ uint8_t pid;
+ /** TP Data Coding Scheme (M - o)
+ * Parameter identifying the coding scheme within the TP-User-Data. */
+ uint8_t dcs;
+ /** TP User Data Length (M - I)
+ * Parameter indicating the length of the TP User Data field to follow. */
+ uint8_t udl;
+ /** TP User Data (O - v)
+ * User data. */
+ tsk_buffer_t* ud;
}
tsms_tpdu_message_t;
@@ -167,20 +163,19 @@ int tsms_tpdu_message_deinit(tsms_tpdu_message_t* self);
*/
#define TSMS_TPDU_APPEND_SMSC 0
-/* ======================== RPDU ========================
+/* ======================== RPDU ========================
=========================================================*/
/** RP-MTI types as per 3GPP TS 24.011 section 8.2.2
* 3bit field located in the first octet of all RP-Messages. */
-typedef enum tsms_rpdu_type_e
-{
- /*000*/ tsms_rpdu_type_data_mo = 0x00, /**< RP-DATA message ms->n */
- /*001*/ tsms_rpdu_type_data_mt = 0x01, /**< RP-DATA message n->ms */
- /*010*/ tsms_rpdu_type_ack_mo = 0x02, /**< RP-ACK message ms->n */
- /*011*/ tsms_rpdu_type_ack_mt = 0x03, /**< RP-ACK message n->ms */
- /*100*/ tsms_rpdu_type_error_mo = 0x04, /**< RP-ERROR message ms->n */
- /*101*/ tsms_rpdu_type_error_mt = 0x05, /**< RP-ERROR message n->ms */
- /*110*/ tsms_rpdu_type_smma_mo = 0x06, /**< RP-SMMA message ms->n */
+typedef enum tsms_rpdu_type_e {
+ /*000*/ tsms_rpdu_type_data_mo = 0x00, /**< RP-DATA message ms->n */
+ /*001*/ tsms_rpdu_type_data_mt = 0x01, /**< RP-DATA message n->ms */
+ /*010*/ tsms_rpdu_type_ack_mo = 0x02, /**< RP-ACK message ms->n */
+ /*011*/ tsms_rpdu_type_ack_mt = 0x03, /**< RP-ACK message n->ms */
+ /*100*/ tsms_rpdu_type_error_mo = 0x04, /**< RP-ERROR message ms->n */
+ /*101*/ tsms_rpdu_type_error_mt = 0x05, /**< RP-ERROR message n->ms */
+ /*110*/ tsms_rpdu_type_smma_mo = 0x06, /**< RP-SMMA message ms->n */
}
tsms_rpdu_type_t;
@@ -189,12 +184,11 @@ tsms_rpdu_type_t;
|| ((type) == tsms_rpdu_type_error_mo) \
|| ((type) == tsms_rpdu_type_smma_mo))
-typedef struct tsms_rpdu_message_s
-{
- TSK_DECLARE_OBJECT;
+typedef struct tsms_rpdu_message_s {
+ TSK_DECLARE_OBJECT;
- tsms_rpdu_type_t mti;
- uint8_t mr; /**< Message Reference. */
+ tsms_rpdu_type_t mti;
+ uint8_t mr; /**< Message Reference. */
}
tsms_rpdu_message_t;
#define TSMS_DECLARE_RPDU_MESSAGE tsms_rpdu_message_t rpdu
diff --git a/tinySMS/include/tinysms/tsms_etsi_gsm_03_38.h b/tinySMS/include/tinysms/tsms_etsi_gsm_03_38.h
index 40aedda..cac8171 100755
--- a/tinySMS/include/tinysms/tsms_etsi_gsm_03_38.h
+++ b/tinySMS/include/tinysms/tsms_etsi_gsm_03_38.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -35,132 +35,131 @@
TSMS_BEGIN_DECLS
#define TSMS_ETSI_GSM_03_38_COUNT 123
-static uint16_t TSMS_ETSI_GSM_03_38[TSMS_ETSI_GSM_03_38_COUNT][2] =
-{
- 0x00, 0x0040 ,//# COMMERCIAL AT
- 0x01, 0x00A3 ,//# POUND SIGN
- 0x02, 0x0024 ,//# DOLLAR SIGN
- 0x03, 0x00A5 ,//# YEN SIGN
- 0x04, 0x00E8 ,//# LATIN SMALL LETTER E WITH GRAVE
- 0x05, 0x00E9 ,//# LATIN SMALL LETTER E WITH ACUTE
- 0x06, 0x00F9 ,//# LATIN SMALL LETTER U WITH GRAVE
- 0x07, 0x00EC ,//# LATIN SMALL LETTER I WITH GRAVE
- 0x08, 0x00F2 ,//# LATIN SMALL LETTER O WITH GRAVE
- 0x09, 0x00E7 ,//# LATIN SMALL LETTER C WITH CEDILLA
- 0x0B, 0x00D8 ,//# LATIN CAPITAL LETTER O WITH STROKE
- 0x0C, 0x00F8 ,//# LATIN SMALL LETTER O WITH STROKE
- 0x0E, 0x00C5 ,//# LATIN CAPITAL LETTER A WITH RING ABOVE
- 0x0F, 0x00E5 ,//# LATIN SMALL LETTER A WITH RING ABOVE
- 0x11, 0x005F ,//# LOW LINE
- 0x1B14, 0x005E ,//# CIRCUMFLEX ACCENT
- 0x1B28, 0x007B ,//# LEFT CURLY BRACKET
- 0x1B29, 0x007D ,//# RIGHT CURLY BRACKET
- 0x1B2F, 0x005C ,//# REVERSE SOLIDUS
- 0x1B3C, 0x005B ,//# LEFT SQUARE BRACKET
- 0x1B3D, 0x007E ,//# TILDE
- 0x1B3E, 0x005D ,//# RIGHT SQUARE BRACKET
- 0x1B40, 0x007C ,//# VERTICAL LINE
- 0x1C, 0x00C6 ,//# LATIN CAPITAL LETTER AE
- 0x1D, 0x00E6 ,//# LATIN SMALL LETTER AE
- 0x1E, 0x00DF ,//# LATIN SMALL LETTER SHARP S (German)
- 0x1F, 0x00C9 ,//# LATIN CAPITAL LETTER E WITH ACUTE
- 0x20, 0x0020 ,//# SPACE
- 0x21, 0x0021 ,//# EXCLAMATION MARK
- 0x22, 0x0022 ,//# QUOTATION MARK
- 0x23, 0x0023 ,//# NUMBER SIGN
- 0x24, 0x00A4 ,//# CURRENCY SIGN
- 0x25, 0x0025 ,//# PERCENT SIGN
- 0x26, 0x0026 ,//# AMPERSAND
- 0x27, 0x0027 ,//# APOSTROPHE
- 0x28, 0x0028 ,//# LEFT PARENTHESIS
- 0x29, 0x0029 ,//# RIGHT PARENTHESIS
- 0x2A, 0x002A ,//# ASTERISK
- 0x2B, 0x002B ,//# PLUS SIGN
- 0x2C, 0x002C ,//# COMMA
- 0x2D, 0x002D ,//# HYPHEN-MINUS
- 0x2E, 0x002E ,//# FULL STOP
- 0x2F, 0x002F ,//# SOLIDUS
- 0x30, 0x0030 ,//# DIGIT ZERO
- 0x31, 0x0031 ,//# DIGIT ONE
- 0x32, 0x0032 ,//# DIGIT TWO
- 0x33, 0x0033 ,//# DIGIT THREE
- 0x34, 0x0034 ,//# DIGIT FOUR
- 0x35, 0x0035 ,//# DIGIT FIVE
- 0x36, 0x0036 ,//# DIGIT SIX
- 0x37, 0x0037 ,//# DIGIT SEVEN
- 0x38, 0x0038 ,//# DIGIT EIGHT
- 0x39, 0x0039 ,//# DIGIT NINE
- 0x3A, 0x003A ,//# COLON
- 0x3B, 0x003B ,//# SEMICOLON
- 0x3C, 0x003C ,//# LESS-THAN SIGN
- 0x3D, 0x003D ,//# EQUALS SIGN
- 0x3E, 0x003E ,//# GREATER-THAN SIGN
- 0x3F, 0x003F ,//# QUESTION MARK
- 0x40, 0x00A1 ,//# INVERTED EXCLAMATION MARK
- 0x41, 0x0041 ,//# LATIN CAPITAL LETTER A
- 0x42, 0x0042 ,//# LATIN CAPITAL LETTER B
- //,//#0x42 0x0392 ,//# GREEK CAPITAL LETTER BETA
- 0x43, 0x0043 ,//# LATIN CAPITAL LETTER C
- 0x44, 0x0044 ,//# LATIN CAPITAL LETTER D
- 0x45, 0x0045 ,//# LATIN CAPITAL LETTER E
- 0x46, 0x0046 ,//# LATIN CAPITAL LETTER F
- 0x47, 0x0047 ,//# LATIN CAPITAL LETTER G
- 0x48, 0x0048 ,//# LATIN CAPITAL LETTER H
- 0x49, 0x0049 ,//# LATIN CAPITAL LETTER I
- 0x4A, 0x004A ,//# LATIN CAPITAL LETTER J
- 0x4B, 0x004B ,//# LATIN CAPITAL LETTER K
- 0x4C, 0x004C ,//# LATIN CAPITAL LETTER L
- 0x4D, 0x004D ,//# LATIN CAPITAL LETTER M
- 0x4E, 0x004E ,//# LATIN CAPITAL LETTER N
- 0x4F, 0x004F ,//# LATIN CAPITAL LETTER O
- 0x50, 0x0050 ,//# LATIN CAPITAL LETTER P
- 0x51, 0x0051 ,//# LATIN CAPITAL LETTER Q
- 0x52, 0x0052 ,//# LATIN CAPITAL LETTER R
- 0x53, 0x0053 ,//# LATIN CAPITAL LETTER S
- 0x54, 0x0054 ,//# LATIN CAPITAL LETTER T
- 0x55, 0x0055 ,//# LATIN CAPITAL LETTER U
- 0x56, 0x0056 ,//# LATIN CAPITAL LETTER V
- 0x57, 0x0057 ,//# LATIN CAPITAL LETTER W
- 0x58, 0x0058 ,//# LATIN CAPITAL LETTER X
- 0x59, 0x0059 ,//# LATIN CAPITAL LETTER Y
- 0x5A, 0x005A ,//# LATIN CAPITAL LETTER Z
- 0x5B, 0x00C4 ,//# LATIN CAPITAL LETTER A WITH DIAERESIS
- 0x5C, 0x00D6 ,//# LATIN CAPITAL LETTER O WITH DIAERESIS
- 0x5D, 0x00D1 ,//# LATIN CAPITAL LETTER N WITH TILDE
- 0x5E, 0x00DC ,//# LATIN CAPITAL LETTER U WITH DIAERESIS
- 0x5F, 0x00A7 ,//# SECTION SIGN
- 0x60, 0x00BF ,//# INVERTED QUESTION MARK
- 0x61, 0x0061 ,//# LATIN SMALL LETTER A
- 0x62, 0x0062 ,//# LATIN SMALL LETTER B
- 0x63, 0x0063 ,//# LATIN SMALL LETTER C
- 0x64, 0x0064 ,//# LATIN SMALL LETTER D
- 0x65, 0x0065 ,//# LATIN SMALL LETTER E
- 0x66, 0x0066 ,//# LATIN SMALL LETTER F
- 0x67, 0x0067 ,//# LATIN SMALL LETTER G
- 0x68, 0x0068 ,//# LATIN SMALL LETTER H
- 0x69, 0x0069 ,//# LATIN SMALL LETTER I
- 0x6A, 0x006A ,//# LATIN SMALL LETTER J
- 0x6B, 0x006B ,//# LATIN SMALL LETTER K
- 0x6C, 0x006C ,//# LATIN SMALL LETTER L
- 0x6D, 0x006D ,//# LATIN SMALL LETTER M
- 0x6E, 0x006E ,//# LATIN SMALL LETTER N
- 0x6F, 0x006F ,//# LATIN SMALL LETTER O
- 0x70, 0x0070 ,//# LATIN SMALL LETTER P
- 0x71, 0x0071 ,//# LATIN SMALL LETTER Q
- 0x72, 0x0072 ,//# LATIN SMALL LETTER R
- 0x73, 0x0073 ,//# LATIN SMALL LETTER S
- 0x74, 0x0074 ,//# LATIN SMALL LETTER T
- 0x75, 0x0075 ,//# LATIN SMALL LETTER U
- 0x76, 0x0076 ,//# LATIN SMALL LETTER V
- 0x77, 0x0077 ,//# LATIN SMALL LETTER W
- 0x78, 0x0078 ,//# LATIN SMALL LETTER X
- 0x79, 0x0079 ,//# LATIN SMALL LETTER Y
- 0x7A, 0x007A ,//# LATIN SMALL LETTER Z
- 0x7B, 0x00E4 ,//# LATIN SMALL LETTER A WITH DIAERESIS
- 0x7C, 0x00F6 ,//# LATIN SMALL LETTER O WITH DIAERESIS
- 0x7D, 0x00F1 ,//# LATIN SMALL LETTER N WITH TILDE
- 0x7E, 0x00FC ,//# LATIN SMALL LETTER U WITH DIAERESIS
- 0x7F, 0x00E0 ,//# LATIN SMALL LETTER A WITH GRAVE
+static uint16_t TSMS_ETSI_GSM_03_38[TSMS_ETSI_GSM_03_38_COUNT][2] = {
+ 0x00, 0x0040 ,//# COMMERCIAL AT
+ 0x01, 0x00A3 ,//# POUND SIGN
+ 0x02, 0x0024 ,//# DOLLAR SIGN
+ 0x03, 0x00A5 ,//# YEN SIGN
+ 0x04, 0x00E8 ,//# LATIN SMALL LETTER E WITH GRAVE
+ 0x05, 0x00E9 ,//# LATIN SMALL LETTER E WITH ACUTE
+ 0x06, 0x00F9 ,//# LATIN SMALL LETTER U WITH GRAVE
+ 0x07, 0x00EC ,//# LATIN SMALL LETTER I WITH GRAVE
+ 0x08, 0x00F2 ,//# LATIN SMALL LETTER O WITH GRAVE
+ 0x09, 0x00E7 ,//# LATIN SMALL LETTER C WITH CEDILLA
+ 0x0B, 0x00D8 ,//# LATIN CAPITAL LETTER O WITH STROKE
+ 0x0C, 0x00F8 ,//# LATIN SMALL LETTER O WITH STROKE
+ 0x0E, 0x00C5 ,//# LATIN CAPITAL LETTER A WITH RING ABOVE
+ 0x0F, 0x00E5 ,//# LATIN SMALL LETTER A WITH RING ABOVE
+ 0x11, 0x005F ,//# LOW LINE
+ 0x1B14, 0x005E ,//# CIRCUMFLEX ACCENT
+ 0x1B28, 0x007B ,//# LEFT CURLY BRACKET
+ 0x1B29, 0x007D ,//# RIGHT CURLY BRACKET
+ 0x1B2F, 0x005C ,//# REVERSE SOLIDUS
+ 0x1B3C, 0x005B ,//# LEFT SQUARE BRACKET
+ 0x1B3D, 0x007E ,//# TILDE
+ 0x1B3E, 0x005D ,//# RIGHT SQUARE BRACKET
+ 0x1B40, 0x007C ,//# VERTICAL LINE
+ 0x1C, 0x00C6 ,//# LATIN CAPITAL LETTER AE
+ 0x1D, 0x00E6 ,//# LATIN SMALL LETTER AE
+ 0x1E, 0x00DF ,//# LATIN SMALL LETTER SHARP S (German)
+ 0x1F, 0x00C9 ,//# LATIN CAPITAL LETTER E WITH ACUTE
+ 0x20, 0x0020 ,//# SPACE
+ 0x21, 0x0021 ,//# EXCLAMATION MARK
+ 0x22, 0x0022 ,//# QUOTATION MARK
+ 0x23, 0x0023 ,//# NUMBER SIGN
+ 0x24, 0x00A4 ,//# CURRENCY SIGN
+ 0x25, 0x0025 ,//# PERCENT SIGN
+ 0x26, 0x0026 ,//# AMPERSAND
+ 0x27, 0x0027 ,//# APOSTROPHE
+ 0x28, 0x0028 ,//# LEFT PARENTHESIS
+ 0x29, 0x0029 ,//# RIGHT PARENTHESIS
+ 0x2A, 0x002A ,//# ASTERISK
+ 0x2B, 0x002B ,//# PLUS SIGN
+ 0x2C, 0x002C ,//# COMMA
+ 0x2D, 0x002D ,//# HYPHEN-MINUS
+ 0x2E, 0x002E ,//# FULL STOP
+ 0x2F, 0x002F ,//# SOLIDUS
+ 0x30, 0x0030 ,//# DIGIT ZERO
+ 0x31, 0x0031 ,//# DIGIT ONE
+ 0x32, 0x0032 ,//# DIGIT TWO
+ 0x33, 0x0033 ,//# DIGIT THREE
+ 0x34, 0x0034 ,//# DIGIT FOUR
+ 0x35, 0x0035 ,//# DIGIT FIVE
+ 0x36, 0x0036 ,//# DIGIT SIX
+ 0x37, 0x0037 ,//# DIGIT SEVEN
+ 0x38, 0x0038 ,//# DIGIT EIGHT
+ 0x39, 0x0039 ,//# DIGIT NINE
+ 0x3A, 0x003A ,//# COLON
+ 0x3B, 0x003B ,//# SEMICOLON
+ 0x3C, 0x003C ,//# LESS-THAN SIGN
+ 0x3D, 0x003D ,//# EQUALS SIGN
+ 0x3E, 0x003E ,//# GREATER-THAN SIGN
+ 0x3F, 0x003F ,//# QUESTION MARK
+ 0x40, 0x00A1 ,//# INVERTED EXCLAMATION MARK
+ 0x41, 0x0041 ,//# LATIN CAPITAL LETTER A
+ 0x42, 0x0042 ,//# LATIN CAPITAL LETTER B
+ //,//#0x42 0x0392 ,//# GREEK CAPITAL LETTER BETA
+ 0x43, 0x0043 ,//# LATIN CAPITAL LETTER C
+ 0x44, 0x0044 ,//# LATIN CAPITAL LETTER D
+ 0x45, 0x0045 ,//# LATIN CAPITAL LETTER E
+ 0x46, 0x0046 ,//# LATIN CAPITAL LETTER F
+ 0x47, 0x0047 ,//# LATIN CAPITAL LETTER G
+ 0x48, 0x0048 ,//# LATIN CAPITAL LETTER H
+ 0x49, 0x0049 ,//# LATIN CAPITAL LETTER I
+ 0x4A, 0x004A ,//# LATIN CAPITAL LETTER J
+ 0x4B, 0x004B ,//# LATIN CAPITAL LETTER K
+ 0x4C, 0x004C ,//# LATIN CAPITAL LETTER L
+ 0x4D, 0x004D ,//# LATIN CAPITAL LETTER M
+ 0x4E, 0x004E ,//# LATIN CAPITAL LETTER N
+ 0x4F, 0x004F ,//# LATIN CAPITAL LETTER O
+ 0x50, 0x0050 ,//# LATIN CAPITAL LETTER P
+ 0x51, 0x0051 ,//# LATIN CAPITAL LETTER Q
+ 0x52, 0x0052 ,//# LATIN CAPITAL LETTER R
+ 0x53, 0x0053 ,//# LATIN CAPITAL LETTER S
+ 0x54, 0x0054 ,//# LATIN CAPITAL LETTER T
+ 0x55, 0x0055 ,//# LATIN CAPITAL LETTER U
+ 0x56, 0x0056 ,//# LATIN CAPITAL LETTER V
+ 0x57, 0x0057 ,//# LATIN CAPITAL LETTER W
+ 0x58, 0x0058 ,//# LATIN CAPITAL LETTER X
+ 0x59, 0x0059 ,//# LATIN CAPITAL LETTER Y
+ 0x5A, 0x005A ,//# LATIN CAPITAL LETTER Z
+ 0x5B, 0x00C4 ,//# LATIN CAPITAL LETTER A WITH DIAERESIS
+ 0x5C, 0x00D6 ,//# LATIN CAPITAL LETTER O WITH DIAERESIS
+ 0x5D, 0x00D1 ,//# LATIN CAPITAL LETTER N WITH TILDE
+ 0x5E, 0x00DC ,//# LATIN CAPITAL LETTER U WITH DIAERESIS
+ 0x5F, 0x00A7 ,//# SECTION SIGN
+ 0x60, 0x00BF ,//# INVERTED QUESTION MARK
+ 0x61, 0x0061 ,//# LATIN SMALL LETTER A
+ 0x62, 0x0062 ,//# LATIN SMALL LETTER B
+ 0x63, 0x0063 ,//# LATIN SMALL LETTER C
+ 0x64, 0x0064 ,//# LATIN SMALL LETTER D
+ 0x65, 0x0065 ,//# LATIN SMALL LETTER E
+ 0x66, 0x0066 ,//# LATIN SMALL LETTER F
+ 0x67, 0x0067 ,//# LATIN SMALL LETTER G
+ 0x68, 0x0068 ,//# LATIN SMALL LETTER H
+ 0x69, 0x0069 ,//# LATIN SMALL LETTER I
+ 0x6A, 0x006A ,//# LATIN SMALL LETTER J
+ 0x6B, 0x006B ,//# LATIN SMALL LETTER K
+ 0x6C, 0x006C ,//# LATIN SMALL LETTER L
+ 0x6D, 0x006D ,//# LATIN SMALL LETTER M
+ 0x6E, 0x006E ,//# LATIN SMALL LETTER N
+ 0x6F, 0x006F ,//# LATIN SMALL LETTER O
+ 0x70, 0x0070 ,//# LATIN SMALL LETTER P
+ 0x71, 0x0071 ,//# LATIN SMALL LETTER Q
+ 0x72, 0x0072 ,//# LATIN SMALL LETTER R
+ 0x73, 0x0073 ,//# LATIN SMALL LETTER S
+ 0x74, 0x0074 ,//# LATIN SMALL LETTER T
+ 0x75, 0x0075 ,//# LATIN SMALL LETTER U
+ 0x76, 0x0076 ,//# LATIN SMALL LETTER V
+ 0x77, 0x0077 ,//# LATIN SMALL LETTER W
+ 0x78, 0x0078 ,//# LATIN SMALL LETTER X
+ 0x79, 0x0079 ,//# LATIN SMALL LETTER Y
+ 0x7A, 0x007A ,//# LATIN SMALL LETTER Z
+ 0x7B, 0x00E4 ,//# LATIN SMALL LETTER A WITH DIAERESIS
+ 0x7C, 0x00F6 ,//# LATIN SMALL LETTER O WITH DIAERESIS
+ 0x7D, 0x00F1 ,//# LATIN SMALL LETTER N WITH TILDE
+ 0x7E, 0x00FC ,//# LATIN SMALL LETTER U WITH DIAERESIS
+ 0x7F, 0x00E0 ,//# LATIN SMALL LETTER A WITH GRAVE
};
TSMS_END_DECLS
diff --git a/tinySMS/include/tinysms/tsms_packing.h b/tinySMS/include/tinysms/tsms_packing.h
index e1452cb..f3dc2b1 100755
--- a/tinySMS/include/tinysms/tsms_packing.h
+++ b/tinySMS/include/tinysms/tsms_packing.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
diff --git a/tinySMS/include/tinysms_config.h b/tinySMS/include/tinysms_config.h
index e0cd694..7d68583 100755
--- a/tinySMS/include/tinysms_config.h
+++ b/tinySMS/include/tinysms_config.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -46,13 +46,13 @@
# define TINYSMS_GEXTERN extern
#endif
-/* Guards against C++ name mangling
+/* Guards against C++ name mangling
*/
#ifdef __cplusplus
# define TSMS_BEGIN_DECLS extern "C" {
# define TSMS_END_DECLS }
#else
-# define TSMS_BEGIN_DECLS
+# define TSMS_BEGIN_DECLS
# define TSMS_END_DECLS
#endif
@@ -74,7 +74,7 @@
#endif
#if HAVE_CONFIG_H
- #include <config.h>
+#include <config.h>
#endif
#endif // TINYSMS_CONFIG_H
diff --git a/tinySMS/src/rpdu/tsms_rpdu.c b/tinySMS/src/rpdu/tsms_rpdu.c
index 72640b9..4f3d8d0 100755
--- a/tinySMS/src/rpdu/tsms_rpdu.c
+++ b/tinySMS/src/rpdu/tsms_rpdu.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -42,93 +42,93 @@
/** internal function used to deserialize a RP-DATA message from binary content. */
tsms_rpdu_message_t* _tsms_rpdu_rpdata_deserialize(const void* data, tsk_size_t size)
{
- /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
- tsms_rpdu_data_t* self = tsms_rpdu_data_create(0x00, tsk_null, tsk_null, tsk_false);
- tsk_bool_t failed = tsk_false;
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
- tsk_size_t smsc_len;
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.5.1 Originator address element */
- if(TSMS_RPDU_MESSAGE(self)->mti == tsms_rpdu_type_data_mt){
- /* 7.3.1.1 RP DATA (Network to Mobile Station) */
- if((self->oa = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_smsc, &smsc_len))){
- pdata += smsc_len;
- }
- /* 7.3.1.2 RP DATA (Mobile Station to Network) */
- pdata++; /* 1o */
- }
- else if(TSMS_RPDU_MESSAGE(self)->mti == tsms_rpdu_type_data_mo){
- /* 7.3.1.1 RP DATA (Network to Mobile Station) */
- pdata++; /* 1o */
- /* 7.3.1.2 RP DATA (Mobile Station to Network) */
- if((self->da = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_smsc, &smsc_len))){
- pdata += smsc_len;
- }
- }
- else{
- failed = tsk_true;
- TSK_DEBUG_ERROR("%d Not a valid RP-DATA messsage", TSMS_RPDU_MESSAGE(self)->mti);
- goto bail;
- }
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if((pend-pdata) > 1){
- tsk_size_t length = *pdata++; // length-indicator
- if((length != (pend-pdata))){
- TSK_DEBUG_WARN("Invalid length-indicator.");
- }
- else{
- self->udata = tsk_buffer_create(pdata, length);
- }
- }
- else{
- TSK_DEBUG_WARN("RP-User data element is mandatory for RP-DATA messages.");
- }
-
+ /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
+ tsms_rpdu_data_t* self = tsms_rpdu_data_create(0x00, tsk_null, tsk_null, tsk_false);
+ tsk_bool_t failed = tsk_false;
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+ tsk_size_t smsc_len;
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.5.1 Originator address element */
+ if(TSMS_RPDU_MESSAGE(self)->mti == tsms_rpdu_type_data_mt) {
+ /* 7.3.1.1 RP DATA (Network to Mobile Station) */
+ if((self->oa = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_smsc, &smsc_len))) {
+ pdata += smsc_len;
+ }
+ /* 7.3.1.2 RP DATA (Mobile Station to Network) */
+ pdata++; /* 1o */
+ }
+ else if(TSMS_RPDU_MESSAGE(self)->mti == tsms_rpdu_type_data_mo) {
+ /* 7.3.1.1 RP DATA (Network to Mobile Station) */
+ pdata++; /* 1o */
+ /* 7.3.1.2 RP DATA (Mobile Station to Network) */
+ if((self->da = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_smsc, &smsc_len))) {
+ pdata += smsc_len;
+ }
+ }
+ else {
+ failed = tsk_true;
+ TSK_DEBUG_ERROR("%d Not a valid RP-DATA messsage", TSMS_RPDU_MESSAGE(self)->mti);
+ goto bail;
+ }
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if((pend-pdata) > 1) {
+ tsk_size_t length = *pdata++; // length-indicator
+ if((length != (pend-pdata))) {
+ TSK_DEBUG_WARN("Invalid length-indicator.");
+ }
+ else {
+ self->udata = tsk_buffer_create(pdata, length);
+ }
+ }
+ else {
+ TSK_DEBUG_WARN("RP-User data element is mandatory for RP-DATA messages.");
+ }
+
bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_RPDU_MESSAGE(self);
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_RPDU_MESSAGE(self);
}
/** internal function used to serialize a RP-DATA message as binary content.*/
int _tsms_rpdu_rpdata_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t* output)
{
- /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
- const tsms_rpdu_data_t* self = (const tsms_rpdu_data_t*)_self;
+ /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
+ const tsms_rpdu_data_t* self = (const tsms_rpdu_data_t*)_self;
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- tsk_buffer_append(output, &_self->mti, 1);
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ tsk_buffer_append(output, &_self->mti, 1);
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- tsk_buffer_append(output, &_self->mr, 1);
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ tsk_buffer_append(output, &_self->mr, 1);
- /* 3GPP TS 24.011 ==> 8.2.5.1 Originator address element */
- tsms_address_serialize(self->oa, output);
+ /* 3GPP TS 24.011 ==> 8.2.5.1 Originator address element */
+ tsms_address_serialize(self->oa, output);
- /* 3GPP TS 24.011 ==> 8.2.5.2 Destination address element */
- tsms_address_serialize(self->da, output);
+ /* 3GPP TS 24.011 ==> 8.2.5.2 Destination address element */
+ tsms_address_serialize(self->da, output);
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if(self->udata){
- tsk_buffer_append(output, &self->udata->size, 1); // length-indicator
- tsk_buffer_append(output, self->udata->data, self->udata->size);
- }
- else{
- static uint8_t _1byte = 0x00;
- tsk_buffer_append(output, &_1byte, 1); // length-indicator
- }
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if(self->udata) {
+ tsk_buffer_append(output, &self->udata->size, 1); // length-indicator
+ tsk_buffer_append(output, self->udata->data, self->udata->size);
+ }
+ else {
+ static uint8_t _1byte = 0x00;
+ tsk_buffer_append(output, &_1byte, 1); // length-indicator
+ }
- return 0;
+ return 0;
}
/**@ingroup tsms_rpdu_group
@@ -146,45 +146,45 @@ int _tsms_rpdu_rpdata_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t*
*/
tsms_rpdu_data_t* tsms_rpdu_data_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_tpdu_message_t* tpdu, tsk_bool_t MobOrig)
{
- tsms_rpdu_data_t* ret = tsk_null;
-
- if(!(ret = tsk_object_new(tsms_rpdu_data_def_t))){
- goto bail;
- }
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(ret)->mti = MobOrig? tsms_rpdu_type_data_mo : tsms_rpdu_type_data_mt;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(ret)->mr = mr;
-
- /* 3GPP TS 24.341 section B5 (Moblie Originated RP-DATA message)
- The payload includes an RP-DATA message (see 3GPP TS 24.011 [8]). It includes:
- - Address of the originating UE: this field includes the length indicator only;
- - Address of the destination SC, which is configured in the UE; and
- - RP-User-Data (see 3GPP TS 23.040 [3]), which includes SMS-SUBMIT as type indicator.
- */
-
-
- /* 3GPP TS 24.011 ==> 8.2.5.1 Originator address element */
- if(smsc){
- if(TSMS_RPDU_MESSAGE(ret)->mti == tsms_rpdu_type_data_mt){
- /* 7.3.1.1 RP DATA (Network to Mobile Station) */
- ret->oa = tsms_address_smsc_create(smsc);
- }
- else{
- /* 7.3.1.2 RP DATA (Mobile Station to Network) */
- ret->da = tsms_address_smsc_create(smsc);
- }
- }
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if(tpdu && (ret->udata = tsk_buffer_create_null())){
- tsms_tpdu_message_serialize(tpdu, ret->udata, MobOrig);
- }
+ tsms_rpdu_data_t* ret = tsk_null;
+
+ if(!(ret = tsk_object_new(tsms_rpdu_data_def_t))) {
+ goto bail;
+ }
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(ret)->mti = MobOrig? tsms_rpdu_type_data_mo : tsms_rpdu_type_data_mt;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(ret)->mr = mr;
+
+ /* 3GPP TS 24.341 section B5 (Moblie Originated RP-DATA message)
+ The payload includes an RP-DATA message (see 3GPP TS 24.011 [8]). It includes:
+ - Address of the originating UE: this field includes the length indicator only;
+ - Address of the destination SC, which is configured in the UE; and
+ - RP-User-Data (see 3GPP TS 23.040 [3]), which includes SMS-SUBMIT as type indicator.
+ */
+
+
+ /* 3GPP TS 24.011 ==> 8.2.5.1 Originator address element */
+ if(smsc) {
+ if(TSMS_RPDU_MESSAGE(ret)->mti == tsms_rpdu_type_data_mt) {
+ /* 7.3.1.1 RP DATA (Network to Mobile Station) */
+ ret->oa = tsms_address_smsc_create(smsc);
+ }
+ else {
+ /* 7.3.1.2 RP DATA (Mobile Station to Network) */
+ ret->da = tsms_address_smsc_create(smsc);
+ }
+ }
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if(tpdu && (ret->udata = tsk_buffer_create_null())) {
+ tsms_tpdu_message_serialize(tpdu, ret->udata, MobOrig);
+ }
bail:
- return ret;
+ return ret;
}
//
@@ -192,37 +192,36 @@ bail:
//
static tsk_object_t* tsms_rpdu_data_ctor(tsk_object_t * self, va_list * app)
{
- tsms_rpdu_data_t *rpdata = self;
- if(rpdata){
- TSMS_RPDU_MESSAGE(rpdata)->mti = tsms_rpdu_type_data_mo;
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ tsms_rpdu_data_t *rpdata = self;
+ if(rpdata) {
+ TSMS_RPDU_MESSAGE(rpdata)->mti = tsms_rpdu_type_data_mo;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_rpdu_data_dtor(tsk_object_t * self)
-{
- tsms_rpdu_data_t *rpdata = self;
- if(rpdata){
- TSK_OBJECT_SAFE_FREE(rpdata->oa);
- TSK_OBJECT_SAFE_FREE(rpdata->da);
- TSK_OBJECT_SAFE_FREE(rpdata->udata);
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
-
- return self;
+{
+ tsms_rpdu_data_t *rpdata = self;
+ if(rpdata) {
+ TSK_OBJECT_SAFE_FREE(rpdata->oa);
+ TSK_OBJECT_SAFE_FREE(rpdata->da);
+ TSK_OBJECT_SAFE_FREE(rpdata->udata);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+
+ return self;
}
-static const tsk_object_def_t tsms_rpdu_data_def_s =
-{
- sizeof(tsms_rpdu_data_t),
- tsms_rpdu_data_ctor,
- tsms_rpdu_data_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_rpdu_data_def_s = {
+ sizeof(tsms_rpdu_data_t),
+ tsms_rpdu_data_ctor,
+ tsms_rpdu_data_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_rpdu_data_def_t = &tsms_rpdu_data_def_s;
@@ -231,32 +230,32 @@ const tsk_object_def_t *tsms_rpdu_data_def_t = &tsms_rpdu_data_def_s;
/** internal function used to deserialize a RP-SMMA message from binary content. */
tsms_rpdu_message_t* _tsms_rpdu_rpsmma_deserialize(const void* data, tsk_size_t size)
{
- /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
- tsms_rpdu_smma_t* self = tsms_rpdu_smma_create(0);
- const uint8_t* pdata = data;
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
-
- return TSMS_RPDU_MESSAGE(self);
+ /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
+ tsms_rpdu_smma_t* self = tsms_rpdu_smma_create(0);
+ const uint8_t* pdata = data;
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
+
+ return TSMS_RPDU_MESSAGE(self);
}
/** internal function used to serialize a RP-SMMA message as binary content. */
int _tsms_rpdu_rpsmma_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t* output)
{
- /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
- //const tsms_rpdu_smma_t* self = (const tsms_rpdu_smma_t*)_self;
+ /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
+ //const tsms_rpdu_smma_t* self = (const tsms_rpdu_smma_t*)_self;
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- tsk_buffer_append(output, &_self->mti, 1);
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ tsk_buffer_append(output, &_self->mti, 1);
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- tsk_buffer_append(output, &_self->mr, 1);
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ tsk_buffer_append(output, &_self->mr, 1);
- return 0;
+ return 0;
}
/**@ingroup tsms_rpdu_group
@@ -270,12 +269,12 @@ int _tsms_rpdu_rpsmma_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t*
*/
tsms_rpdu_smma_t* tsms_rpdu_smma_create(uint8_t mr)
{
- tsms_rpdu_smma_t* ret = tsk_null;
+ tsms_rpdu_smma_t* ret = tsk_null;
- if((ret = tsk_object_new(tsms_rpdu_smma_def_t))){
- TSMS_RPDU_MESSAGE(ret)->mr = mr;
- }
- return ret;
+ if((ret = tsk_object_new(tsms_rpdu_smma_def_t))) {
+ TSMS_RPDU_MESSAGE(ret)->mr = mr;
+ }
+ return ret;
}
//
@@ -283,34 +282,33 @@ tsms_rpdu_smma_t* tsms_rpdu_smma_create(uint8_t mr)
//
static tsk_object_t* tsms_rpdu_smma_ctor(tsk_object_t * self, va_list * app)
{
- tsms_rpdu_smma_t *smma = self;
- if(smma){
- TSMS_RPDU_MESSAGE(smma)->mti = tsms_rpdu_type_smma_mo;
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ tsms_rpdu_smma_t *smma = self;
+ if(smma) {
+ TSMS_RPDU_MESSAGE(smma)->mti = tsms_rpdu_type_smma_mo;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_rpdu_smma_dtor(tsk_object_t * self)
-{
- tsms_rpdu_smma_t *smma = self;
- if(smma){
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
-
- return self;
+{
+ tsms_rpdu_smma_t *smma = self;
+ if(smma) {
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+
+ return self;
}
-static const tsk_object_def_t tsms_rpdu_smma_def_s =
-{
- sizeof(tsms_rpdu_smma_t),
- tsms_rpdu_smma_ctor,
- tsms_rpdu_smma_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_rpdu_smma_def_s = {
+ sizeof(tsms_rpdu_smma_t),
+ tsms_rpdu_smma_ctor,
+ tsms_rpdu_smma_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_rpdu_smma_def_t = &tsms_rpdu_smma_def_s;
@@ -320,58 +318,58 @@ const tsk_object_def_t *tsms_rpdu_smma_def_t = &tsms_rpdu_smma_def_s;
/** internal function used to deserialize an RP-ACK message from binary content. */
tsms_rpdu_message_t* _tsms_rpdu_rpack_deserialize(const void* data, tsk_size_t size)
{
- /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
- tsms_rpdu_ack_t* self = tsms_rpdu_ack_create(0, tsk_null, tsk_false);
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if((pend-pdata) > 1){
- tsk_size_t length;
- /*uint8_t iei =*/ (void)(*pdata++); // IEI MUST be equal to 0x41
- length = *pdata++; // length-indicator
- if((length != (pend-pdata))){
- TSK_DEBUG_WARN("Invalid length-indicator.");
- }
- else{
- self->udata = tsk_buffer_create(pdata, length);
- }
- }
-
- return TSMS_RPDU_MESSAGE(self);
+ /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
+ tsms_rpdu_ack_t* self = tsms_rpdu_ack_create(0, tsk_null, tsk_false);
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if((pend-pdata) > 1) {
+ tsk_size_t length;
+ /*uint8_t iei =*/ (void)(*pdata++); // IEI MUST be equal to 0x41
+ length = *pdata++; // length-indicator
+ if((length != (pend-pdata))) {
+ TSK_DEBUG_WARN("Invalid length-indicator.");
+ }
+ else {
+ self->udata = tsk_buffer_create(pdata, length);
+ }
+ }
+
+ return TSMS_RPDU_MESSAGE(self);
}
/** internal function used to serialize a RP-ACK message as binary content. */
int _tsms_rpdu_rpack_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t* output)
{
- /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
- const tsms_rpdu_ack_t* self = (const tsms_rpdu_ack_t*)_self;
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- tsk_buffer_append(output, &_self->mti, 1);
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- tsk_buffer_append(output, &_self->mr, 1);
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if(self->udata){
- static uint8_t iei = 0x41;
- tsk_buffer_append(output, &iei, 1); // IEI
- tsk_buffer_append(output, &self->udata->size, 1); // length-indicator
- tsk_buffer_append(output, self->udata->data, self->udata->size);
- }
- else{
- static uint8_t _1byte = 0x00;
- tsk_buffer_append(output, &_1byte, 1); // length-indicator
- }
-
- return 0;
+ /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
+ const tsms_rpdu_ack_t* self = (const tsms_rpdu_ack_t*)_self;
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ tsk_buffer_append(output, &_self->mti, 1);
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ tsk_buffer_append(output, &_self->mr, 1);
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if(self->udata) {
+ static uint8_t iei = 0x41;
+ tsk_buffer_append(output, &iei, 1); // IEI
+ tsk_buffer_append(output, &self->udata->size, 1); // length-indicator
+ tsk_buffer_append(output, self->udata->data, self->udata->size);
+ }
+ else {
+ static uint8_t _1byte = 0x00;
+ tsk_buffer_append(output, &_1byte, 1); // length-indicator
+ }
+
+ return 0;
}
/**@ingroup tsms_rpdu_group
@@ -387,29 +385,29 @@ int _tsms_rpdu_rpack_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t* o
*/
tsms_rpdu_ack_t* tsms_rpdu_ack_create(uint8_t mr, const tsms_tpdu_message_t* tpdu, tsk_bool_t MobOrig)
{
- tsms_rpdu_ack_t* ret = tsk_null;
-
- if(!tpdu){
- TSK_DEBUG_WARN("TPDU for RP-ACK message is Null.");
- }
-
- if(!(ret = tsk_object_new(tsms_rpdu_ack_def_t))){
- goto bail;
- }
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(ret)->mti = MobOrig? tsms_rpdu_type_ack_mo : tsms_rpdu_type_ack_mt;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(ret)->mr = mr;
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if(tpdu && (ret->udata = tsk_buffer_create_null())){
- tsms_tpdu_message_serialize(tpdu, ret->udata, MobOrig);
- }
+ tsms_rpdu_ack_t* ret = tsk_null;
+
+ if(!tpdu) {
+ TSK_DEBUG_WARN("TPDU for RP-ACK message is Null.");
+ }
+
+ if(!(ret = tsk_object_new(tsms_rpdu_ack_def_t))) {
+ goto bail;
+ }
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(ret)->mti = MobOrig? tsms_rpdu_type_ack_mo : tsms_rpdu_type_ack_mt;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(ret)->mr = mr;
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if(tpdu && (ret->udata = tsk_buffer_create_null())) {
+ tsms_tpdu_message_serialize(tpdu, ret->udata, MobOrig);
+ }
bail:
- return ret;
+ return ret;
}
//
@@ -417,35 +415,34 @@ bail:
//
static tsk_object_t* tsms_rpdu_ack_ctor(tsk_object_t * self, va_list * app)
{
- tsms_rpdu_ack_t *ack = self;
- if(ack){
- TSMS_RPDU_MESSAGE(ack)->mti = tsms_rpdu_type_ack_mo;
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ tsms_rpdu_ack_t *ack = self;
+ if(ack) {
+ TSMS_RPDU_MESSAGE(ack)->mti = tsms_rpdu_type_ack_mo;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_rpdu_ack_dtor(tsk_object_t * self)
-{
- tsms_rpdu_ack_t *ack = self;
- if(ack){
- TSK_OBJECT_SAFE_FREE(ack->udata);
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
-
- return self;
+{
+ tsms_rpdu_ack_t *ack = self;
+ if(ack) {
+ TSK_OBJECT_SAFE_FREE(ack->udata);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+
+ return self;
}
-static const tsk_object_def_t tsms_rpdu_ack_def_s =
-{
- sizeof(tsms_rpdu_ack_t),
- tsms_rpdu_ack_ctor,
- tsms_rpdu_ack_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_rpdu_ack_def_s = {
+ sizeof(tsms_rpdu_ack_t),
+ tsms_rpdu_ack_ctor,
+ tsms_rpdu_ack_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_rpdu_ack_def_t = &tsms_rpdu_ack_def_s;
@@ -454,79 +451,79 @@ const tsk_object_def_t *tsms_rpdu_ack_def_t = &tsms_rpdu_ack_def_s;
/** internal function used to deserialize a RP-ERROR message from binary content. */
tsms_rpdu_message_t* _tsms_rpdu_rperror_deserialize(const void* data, tsk_size_t size)
{
- /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
- tsms_rpdu_error_t* self = tsms_rpdu_error_create(0, tsk_null, 0, tsk_false);
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
- tsk_bool_t failed = tsk_false;
- uint8_t cause_count;
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
-
- /* 3GPP TS 24.011 ==> 8.2.5.4 RP Cause
- * Only 1 cause (LV)*/
- if((cause_count = *pdata++)){
- self->cause[0] = cause_count;
- self->cause[1] = *pdata++;
- if((pdata += (cause_count-1)) >= pend){
- TSMS_ERROR_TOO_SHORT("RP-ERROR");
- }
- }
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if((pend-pdata) > 2){
- tsk_size_t length;
- /*uint8_t iei =*/ (void)(*pdata++); // IEI MUST be equal to 0x41
- length = *pdata++; // length-indicator
- if((length != (pend-pdata))){
- TSK_DEBUG_WARN("Invalid length-indicator.");
- }
- else{
- self->udata = tsk_buffer_create(pdata, length);
- }
- }
-
+ /* don't need to test data and size --> already done by tsms_rpdu_message_deserialize() */
+ tsms_rpdu_error_t* self = tsms_rpdu_error_create(0, tsk_null, 0, tsk_false);
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+ tsk_bool_t failed = tsk_false;
+ uint8_t cause_count;
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(self)->mti = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(self)->mr = *pdata++;
+
+ /* 3GPP TS 24.011 ==> 8.2.5.4 RP Cause
+ * Only 1 cause (LV)*/
+ if((cause_count = *pdata++)) {
+ self->cause[0] = cause_count;
+ self->cause[1] = *pdata++;
+ if((pdata += (cause_count-1)) >= pend) {
+ TSMS_ERROR_TOO_SHORT("RP-ERROR");
+ }
+ }
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if((pend-pdata) > 2) {
+ tsk_size_t length;
+ /*uint8_t iei =*/ (void)(*pdata++); // IEI MUST be equal to 0x41
+ length = *pdata++; // length-indicator
+ if((length != (pend-pdata))) {
+ TSK_DEBUG_WARN("Invalid length-indicator.");
+ }
+ else {
+ self->udata = tsk_buffer_create(pdata, length);
+ }
+ }
+
bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_RPDU_MESSAGE(self);
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_RPDU_MESSAGE(self);
}
/** internal function used to serialize a RP-ERROR message as binary content. */
int _tsms_rpdu_rperror_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t* output)
{
- /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
- const tsms_rpdu_error_t* self = (const tsms_rpdu_error_t*)_self;
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- tsk_buffer_append(output, &_self->mti, 1);
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- tsk_buffer_append(output, &_self->mr, 1);
-
- /* 3GPP TS 24.011 ==> 8.2.5.4 RP Cause
- * Only 1 cause (LV)*/
- tsk_buffer_append(output, self->cause, 2);
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if(self->udata){
- static uint8_t iei = 0x41;
- tsk_buffer_append(output, &iei, 1); // IEI
- tsk_buffer_append(output, &self->udata->size, 1); // length-indicator
- tsk_buffer_append(output, self->udata->data, self->udata->size);
- }
- else{
- static uint8_t _1byte = 0x00;
- tsk_buffer_append(output, &_1byte, 1); // length-indicator
- }
-
- return 0;
+ /* don't need to test output and self --> already done by tsms_rpdu_message_serialize() */
+ const tsms_rpdu_error_t* self = (const tsms_rpdu_error_t*)_self;
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ tsk_buffer_append(output, &_self->mti, 1);
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ tsk_buffer_append(output, &_self->mr, 1);
+
+ /* 3GPP TS 24.011 ==> 8.2.5.4 RP Cause
+ * Only 1 cause (LV)*/
+ tsk_buffer_append(output, self->cause, 2);
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if(self->udata) {
+ static uint8_t iei = 0x41;
+ tsk_buffer_append(output, &iei, 1); // IEI
+ tsk_buffer_append(output, &self->udata->size, 1); // length-indicator
+ tsk_buffer_append(output, self->udata->data, self->udata->size);
+ }
+ else {
+ static uint8_t _1byte = 0x00;
+ tsk_buffer_append(output, &_1byte, 1); // length-indicator
+ }
+
+ return 0;
}
/**@ingroup tsms_rpdu_group
@@ -543,33 +540,33 @@ int _tsms_rpdu_rperror_serialize(const tsms_rpdu_message_t* _self, tsk_buffer_t*
*/
tsms_rpdu_error_t* tsms_rpdu_error_create(uint8_t mr, const tsms_tpdu_message_t* tpdu, uint8_t cause, tsk_bool_t MobOrig)
{
- tsms_rpdu_error_t* ret = tsk_null;
-
- /*if(!tpdu){
- TSK_DEBUG_WARN("TPDU for RP-ERROR message is Null.");
- }*/
-
- if(!(ret = tsk_object_new(tsms_rpdu_error_def_t))){
- goto bail;
- }
-
- /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
- TSMS_RPDU_MESSAGE(ret)->mti = MobOrig? tsms_rpdu_type_error_mo : tsms_rpdu_type_error_mt;
-
- /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
- TSMS_RPDU_MESSAGE(ret)->mr = mr;
-
- /* 3GPP TS 24.011 ==> 8.2.5.4 RP Cause */
- ret->cause[0] = 1 /*len*/;
- ret->cause[1] = cause;
-
- /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
- if(tpdu && (ret->udata = tsk_buffer_create_null())){
- tsms_tpdu_message_serialize(tpdu, ret->udata, MobOrig);
- }
+ tsms_rpdu_error_t* ret = tsk_null;
+
+ /*if(!tpdu){
+ TSK_DEBUG_WARN("TPDU for RP-ERROR message is Null.");
+ }*/
+
+ if(!(ret = tsk_object_new(tsms_rpdu_error_def_t))) {
+ goto bail;
+ }
+
+ /* 3GPP TS 24.011 ==> 8.2.2 Message type indicator (MTI) */
+ TSMS_RPDU_MESSAGE(ret)->mti = MobOrig? tsms_rpdu_type_error_mo : tsms_rpdu_type_error_mt;
+
+ /* 3GPP TS 24.011 ==> 8.2.3 Message reference */
+ TSMS_RPDU_MESSAGE(ret)->mr = mr;
+
+ /* 3GPP TS 24.011 ==> 8.2.5.4 RP Cause */
+ ret->cause[0] = 1 /*len*/;
+ ret->cause[1] = cause;
+
+ /* 3GPP TS 24.011 ==> 8.2.5.3 RP-User data element */
+ if(tpdu && (ret->udata = tsk_buffer_create_null())) {
+ tsms_tpdu_message_serialize(tpdu, ret->udata, MobOrig);
+ }
bail:
- return ret;
+ return ret;
}
//
@@ -577,35 +574,34 @@ bail:
//
static tsk_object_t* tsms_rpdu_error_ctor(tsk_object_t * self, va_list * app)
{
- tsms_rpdu_error_t *error = self;
- if(error){
- TSMS_RPDU_MESSAGE(error)->mti = tsms_rpdu_type_error_mo;
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ tsms_rpdu_error_t *error = self;
+ if(error) {
+ TSMS_RPDU_MESSAGE(error)->mti = tsms_rpdu_type_error_mo;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_rpdu_error_dtor(tsk_object_t * self)
-{
- tsms_rpdu_error_t *error = self;
- if(error){
- TSK_OBJECT_SAFE_FREE(error->udata);
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
-
- return self;
+{
+ tsms_rpdu_error_t *error = self;
+ if(error) {
+ TSK_OBJECT_SAFE_FREE(error->udata);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+
+ return self;
}
-static const tsk_object_def_t tsms_rpdu_error_def_s =
-{
- sizeof(tsms_rpdu_error_t),
- tsms_rpdu_error_ctor,
- tsms_rpdu_error_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_rpdu_error_def_s = {
+ sizeof(tsms_rpdu_error_t),
+ tsms_rpdu_error_ctor,
+ tsms_rpdu_error_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_rpdu_error_def_t = &tsms_rpdu_error_def_s;
diff --git a/tinySMS/src/tpdu/tsms_tpdu_command.c b/tinySMS/src/tpdu/tsms_tpdu_command.c
index 4733edc..7d84f12 100755
--- a/tinySMS/src/tpdu/tsms_tpdu_command.c
+++ b/tinySMS/src/tpdu/tsms_tpdu_command.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -39,153 +39,153 @@
/** internal function used to deserialse a SMS-COMMAND message from binary content. */
tsms_tpdu_message_t* _tsms_tpdu_command_deserialize(const void* data, tsk_size_t size)
{
- /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
- tsms_tpdu_command_t* self = tsms_tpdu_command_create(0, tsk_null, tsk_null, 0, tsms_tpdu_cmd_rel);
- tsk_bool_t failed = tsk_false;
- tsk_size_t any_len;
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
-
- /* SMSC address */
+ /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
+ tsms_tpdu_command_t* self = tsms_tpdu_command_create(0, tsk_null, tsk_null, 0, tsms_tpdu_cmd_rel);
+ tsk_bool_t failed = tsk_false;
+ tsk_size_t any_len;
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-COMMAND == Failed to parse SMSC address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
+ if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-COMMAND == Failed to parse SMSC address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
#endif
- /* SMS-COMMAND first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Request(1b)
-
- +----+----+----+----+----+----+----+----+
- | |UDHI|SRR | | | | MTI |
- +----+----+----+----+----+----+----+----+
- */
- TSMS_TPDU_MESSAGE(self)->mti = (*pdata & 0x03);
- self->srr = (*pdata & 0x20)>>5,
- self->udhi = (*pdata & 0x40)>>6;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR)
- * 1o */
- self->mr = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->pid = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.19 TP-Command-Type (TP-CT)
- * 1o */
- self->ct = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.18 TP-Message-Number (TP-MN)
- * 1o */
- self->mn = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
- if(!(self->da = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_da, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse DA address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.20 TP Command Data Length (TP CDL)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->udl = *pdata;
- pdata++;
-
- /* 3GPP TS 23.040 ==> 9.2.3.21 TP Command Data (TP CD) */
- if((pend-pdata) > 0){
- TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
- }
-
- bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_TPDU_MESSAGE(self);
+ /* SMS-COMMAND first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Request(1b)
+
+ +----+----+----+----+----+----+----+----+
+ | |UDHI|SRR | | | | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ TSMS_TPDU_MESSAGE(self)->mti = (*pdata & 0x03);
+ self->srr = (*pdata & 0x20)>>5,
+ self->udhi = (*pdata & 0x40)>>6;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR)
+ * 1o */
+ self->mr = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->pid = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.19 TP-Command-Type (TP-CT)
+ * 1o */
+ self->ct = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.18 TP-Message-Number (TP-MN)
+ * 1o */
+ self->mn = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
+ if(!(self->da = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_da, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse DA address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.20 TP Command Data Length (TP CDL)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->udl = *pdata;
+ pdata++;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.21 TP Command Data (TP CD) */
+ if((pend-pdata) > 0) {
+ TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
+ }
+
+bail:
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_TPDU_MESSAGE(self);
}
/** internal function used to serialize a SMS-COMMAND message as binary content. */
int _tsms_tpdu_command_serialize(const tsms_tpdu_command_t* self, tsk_buffer_t* output)
{
- uint8_t _1byte;
+ uint8_t _1byte;
- if(!self){
- return -1;
- }
+ if(!self) {
+ return -1;
+ }
- /* SMSC address */
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- tsms_address_serialize(self->smsc, output);
+ tsms_address_serialize(self->smsc, output);
#endif
- /* SMS-COMMAND first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Request(1b)
-
- +----+----+----+----+----+----+----+----+
- | |UDHI|SRR | | | | MTI |
- +----+----+----+----+----+----+----+----+
- */
- _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
- _1byte |=
- /*1b*/
- /*2b*/
- ((uint8_t)self->srr) << 5 /*1b*/
- | ((uint8_t)self->udhi) << 6; /*1b*/
- tsk_buffer_append(output, &_1byte, 1);
-
- /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR) */
- tsk_buffer_append(output, &self->mr, 1); /*0-255 ==> 1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.19 TP-Command-Type (TP-CT) */
- tsk_buffer_append(output, &self->ct, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.18 TP-Message-Number (TP-MN) */
- tsk_buffer_append(output, &self->mn, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
- tsms_address_serialize(self->da, output);
-
- /* 3GPP TS 23.040 ==> 9.2.3.20 TP Command Data Length (TP CDL) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.21 TP Command Data (TP CD) */
- tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
-
- return 0;
+ /* SMS-COMMAND first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Request(1b)
+
+ +----+----+----+----+----+----+----+----+
+ | |UDHI|SRR | | | | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
+ _1byte |=
+ /*1b*/
+ /*2b*/
+ ((uint8_t)self->srr) << 5 /*1b*/
+ | ((uint8_t)self->udhi) << 6; /*1b*/
+ tsk_buffer_append(output, &_1byte, 1);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR) */
+ tsk_buffer_append(output, &self->mr, 1); /*0-255 ==> 1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.19 TP-Command-Type (TP-CT) */
+ tsk_buffer_append(output, &self->ct, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.18 TP-Message-Number (TP-MN) */
+ tsk_buffer_append(output, &self->mn, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
+ tsms_address_serialize(self->da, output);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.20 TP Command Data Length (TP CDL) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.21 TP Command Data (TP CD) */
+ tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
+
+ return 0;
}
/**@ingroup tsms_tpdu_group
@@ -195,15 +195,15 @@ int _tsms_tpdu_command_serialize(const tsms_tpdu_command_t* self, tsk_buffer_t*
* @param mr TP-Message-Reference (TP-MR) as per 3GPP TS 23.040 section 9.2.3.6.
* @param smsc The address of the SMSC. e.g. "+331253688".
* @param dest The address of the destination. e.g. "+331253688".
-* @param msg_num The message number. For more information, please refer to 3GPP TS 23.040 section 9.2.3.18 (TP-MN).
+* @param msg_num The message number. For more information, please refer to 3GPP TS 23.040 section 9.2.3.18 (TP-MN).
* @param cmd The command type as per 3GPP TS 23.040 v910 section 9.2.3.19 (TP-CT).
* @retval SMS-COMMAND message.
*
* See For more information, see @ref tsms_tpdu_group_COMMAND "SMS-COMMAND".
*/
tsms_tpdu_command_t* tsms_tpdu_command_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_address_string_t dest, uint8_t msg_num, tsms_tpdu_cmd_t cmd)
-{
- return tsk_object_new(tsms_tpdu_command_def_t, mr, smsc, dest, msg_num, cmd);
+{
+ return tsk_object_new(tsms_tpdu_command_def_t, mr, smsc, dest, msg_num, cmd);
}
@@ -213,63 +213,62 @@ tsms_tpdu_command_t* tsms_tpdu_command_create(uint8_t mr, const tsms_address_str
//
static tsk_object_t* tsms_tpdu_command_ctor(tsk_object_t * self, va_list * app)
{
- tsms_tpdu_command_t *command = self;
- if(command){
- const char* smsc, *dest;
- uint8_t mr, msg_num;
- tsms_tpdu_cmd_t cmd;
-
+ tsms_tpdu_command_t *command = self;
+ if(command) {
+ const char* smsc, *dest;
+ uint8_t mr, msg_num;
+ tsms_tpdu_cmd_t cmd;
+
#if defined(__GNUC__)
- mr = (uint8_t)va_arg(*app, unsigned);
+ mr = (uint8_t)va_arg(*app, unsigned);
#else
- mr = va_arg(*app, uint8_t);
+ mr = va_arg(*app, uint8_t);
#endif
- smsc = va_arg(*app, const char*);
- dest = va_arg(*app, const char*);
+ smsc = va_arg(*app, const char*);
+ dest = va_arg(*app, const char*);
#if defined(__GNUC__)
- msg_num = (uint8_t)va_arg(*app, unsigned);
+ msg_num = (uint8_t)va_arg(*app, unsigned);
#else
- msg_num = va_arg(*app, uint8_t);
+ msg_num = va_arg(*app, uint8_t);
#endif
- cmd = va_arg(*app, tsms_tpdu_cmd_t);
-
- /* init base*/
- tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(command), tsms_tpdu_mti_command_mo);
- /* init self */
- command->mr = mr;
- if(smsc){
- command->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
- }
- if(dest){
- command->da = tsms_address_da_create((const uint8_t*)dest);
- }
- command->mn = msg_num;
- command->ct = cmd;
- }
- return self;
+ cmd = va_arg(*app, tsms_tpdu_cmd_t);
+
+ /* init base*/
+ tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(command), tsms_tpdu_mti_command_mo);
+ /* init self */
+ command->mr = mr;
+ if(smsc) {
+ command->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
+ }
+ if(dest) {
+ command->da = tsms_address_da_create((const uint8_t*)dest);
+ }
+ command->mn = msg_num;
+ command->ct = cmd;
+ }
+ return self;
}
static tsk_object_t* tsms_tpdu_command_dtor(tsk_object_t * self)
-{
- tsms_tpdu_command_t *command = self;
- if(command){
- /*deinit base*/
- tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(command));
- /*deinit self*/
- TSK_OBJECT_SAFE_FREE(command->smsc);
- TSK_OBJECT_SAFE_FREE(command->da);
- }
-
- return self;
+{
+ tsms_tpdu_command_t *command = self;
+ if(command) {
+ /*deinit base*/
+ tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(command));
+ /*deinit self*/
+ TSK_OBJECT_SAFE_FREE(command->smsc);
+ TSK_OBJECT_SAFE_FREE(command->da);
+ }
+
+ return self;
}
-static const tsk_object_def_t tsms_tpdu_command_def_s =
-{
- sizeof(tsms_tpdu_command_t),
- tsms_tpdu_command_ctor,
- tsms_tpdu_command_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_tpdu_command_def_s = {
+ sizeof(tsms_tpdu_command_t),
+ tsms_tpdu_command_ctor,
+ tsms_tpdu_command_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_tpdu_command_def_t = &tsms_tpdu_command_def_s;
diff --git a/tinySMS/src/tpdu/tsms_tpdu_deliver.c b/tinySMS/src/tpdu/tsms_tpdu_deliver.c
index afc4086..327cb04 100755
--- a/tinySMS/src/tpdu/tsms_tpdu_deliver.c
+++ b/tinySMS/src/tpdu/tsms_tpdu_deliver.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -43,153 +43,153 @@
/** internal function used to deserialize a buffer containing a SMS-DELIVER message. */
tsms_tpdu_message_t* _tsms_tpdu_deliver_deserialize(const void* data, tsk_size_t size)
{
- /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
- tsms_tpdu_deliver_t* self = tsms_tpdu_deliver_create(tsk_null, tsk_null);
- tsk_bool_t failed = tsk_false;
- tsk_size_t any_len;
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
-
- /* SMSC address */
+ /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
+ tsms_tpdu_deliver_t* self = tsms_tpdu_deliver_create(tsk_null, tsk_null);
+ tsk_bool_t failed = tsk_false;
+ tsk_size_t any_len;
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse SMSC address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
+ if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse SMSC address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
#endif
- /* SMS-DELIVER first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-More-Messages-to-Send(1b)
- - TP-Loop-Prevention(1b)
- - TP-Reply-Path(1b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Indication(1b)
- +----+----+----+----+----+----+----+----+
- | RP|UDHI|SRI | |LP |MMS | MTI |
- +----+----+----+----+----+----+----+----+
- */
- TSMS_TPDU_MESSAGE(self)->mti = (*pdata & 0x03);
- self->mms = (*pdata & 0x04)>>2,
- self->lp = (*pdata & 0x08)>>3,
- self->sri = (*pdata & 0x20)>>5,
- self->udhi = (*pdata & 0x40)>>6,
- self->rp = (*pdata & 0x80)>>7;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> TP-Originating-Address (TP-OA)*/
- if(!(self->oa = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_oa, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse OA address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->pid = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)
- * 7o */
- if((pend - pdata)<=7){
- TSMS_ERROR_TOO_SHORT();
- }
- memcpy(self->scts, pdata, 7);
- pdata += 7;
-
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->udl = *pdata;
- pdata++;
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- if((pend-pdata) > 0){
- TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
- }
-
- bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_TPDU_MESSAGE(self);
+ /* SMS-DELIVER first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-More-Messages-to-Send(1b)
+ - TP-Loop-Prevention(1b)
+ - TP-Reply-Path(1b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Indication(1b)
+ +----+----+----+----+----+----+----+----+
+ | RP|UDHI|SRI | |LP |MMS | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ TSMS_TPDU_MESSAGE(self)->mti = (*pdata & 0x03);
+ self->mms = (*pdata & 0x04)>>2,
+ self->lp = (*pdata & 0x08)>>3,
+ self->sri = (*pdata & 0x20)>>5,
+ self->udhi = (*pdata & 0x40)>>6,
+ self->rp = (*pdata & 0x80)>>7;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> TP-Originating-Address (TP-OA)*/
+ if(!(self->oa = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_oa, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse OA address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->pid = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)
+ * 7o */
+ if((pend - pdata)<=7) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ memcpy(self->scts, pdata, 7);
+ pdata += 7;
+
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->udl = *pdata;
+ pdata++;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ if((pend-pdata) > 0) {
+ TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
+ }
+
+bail:
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_TPDU_MESSAGE(self);
}
/** internal function used to serialize a SMS-DELIVER message. */
int _tsms_tpdu_deliver_serialize(const tsms_tpdu_deliver_t* self, tsk_buffer_t* output)
{
- uint8_t _1byte;
+ uint8_t _1byte;
- if(!self){
- return -1;
- }
+ if(!self) {
+ return -1;
+ }
-/* SMSC address */
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- tsms_address_serialize(self->smsc, output);
+ tsms_address_serialize(self->smsc, output);
#endif
- /* SMS-DELIVER first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-More-Messages-to-Send(1b)
- - TP-Loop-Prevention(1b)
- - TP-Reply-Path(1b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Indication(1b)
- +----+----+----+----+----+----+----+----+
- | RP|UDHI|SRI | |LP |MMS | MTI |
- +----+----+----+----+----+----+----+----+
- */
- _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
- _1byte |= ((uint8_t)self->mms) << 2 /*1b*/
- | ((uint8_t)self->lp) << 3 /*1b*/
- /*1b (unused)*/
- | ((uint8_t)self->sri) << 5 /*1b*/
- | ((uint8_t)self->udhi) << 6 /*1b*/
- | ((uint8_t)self->rp) << 7; /*1b*/
- tsk_buffer_append(output, &_1byte, 1);
-
- /* 3GPP TS 23.040 ==> TP-Originating-Address (TP-OA)*/
- tsms_address_serialize(self->oa, output);
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)*/
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)*/
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)*/
- tsk_buffer_append(output, self->scts, sizeof(self->scts)); /*7o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
-
- return 0;
+ /* SMS-DELIVER first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-More-Messages-to-Send(1b)
+ - TP-Loop-Prevention(1b)
+ - TP-Reply-Path(1b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Indication(1b)
+ +----+----+----+----+----+----+----+----+
+ | RP|UDHI|SRI | |LP |MMS | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
+ _1byte |= ((uint8_t)self->mms) << 2 /*1b*/
+ | ((uint8_t)self->lp) << 3 /*1b*/
+ /*1b (unused)*/
+ | ((uint8_t)self->sri) << 5 /*1b*/
+ | ((uint8_t)self->udhi) << 6 /*1b*/
+ | ((uint8_t)self->rp) << 7; /*1b*/
+ tsk_buffer_append(output, &_1byte, 1);
+
+ /* 3GPP TS 23.040 ==> TP-Originating-Address (TP-OA)*/
+ tsms_address_serialize(self->oa, output);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)*/
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)*/
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)*/
+ tsk_buffer_append(output, self->scts, sizeof(self->scts)); /*7o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
+
+ return 0;
}
/**@ingroup tsms_tpdu_group
@@ -204,14 +204,14 @@ int _tsms_tpdu_deliver_serialize(const tsms_tpdu_deliver_t* self, tsk_buffer_t*
*/
tsms_tpdu_deliver_t* tsms_tpdu_deliver_create(const tsms_address_string_t smsc, const tsms_address_string_t orig)
{
- tsms_tpdu_deliver_t* ret = tsk_null;
-
- if(!(ret = tsk_object_new(tsms_tpdu_deliver_def_t, smsc, orig))){
- goto bail;
- }
-
+ tsms_tpdu_deliver_t* ret = tsk_null;
+
+ if(!(ret = tsk_object_new(tsms_tpdu_deliver_def_t, smsc, orig))) {
+ goto bail;
+ }
+
bail:
- return ret;
+ return ret;
}
//=================================================================================================
@@ -219,45 +219,44 @@ bail:
//
static tsk_object_t* tsms_tpdu_deliver_ctor(tsk_object_t * self, va_list * app)
{
- tsms_tpdu_deliver_t *deliver = self;
- if(deliver){
- const char* smsc, *orig;
-
- smsc = va_arg(*app, const char*);
- orig = va_arg(*app, const char*);
-
- /* init base*/
- tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(deliver), tsms_tpdu_mti_deliver_mt);
- /* init self */
- deliver->mms = TSMS_TPDU_DEFAULT_MMS;
- if(smsc){
- deliver->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
- }
- if(orig){
- deliver->oa = tsms_address_oa_create((const uint8_t*)orig);
- }
- }
- return self;
+ tsms_tpdu_deliver_t *deliver = self;
+ if(deliver) {
+ const char* smsc, *orig;
+
+ smsc = va_arg(*app, const char*);
+ orig = va_arg(*app, const char*);
+
+ /* init base*/
+ tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(deliver), tsms_tpdu_mti_deliver_mt);
+ /* init self */
+ deliver->mms = TSMS_TPDU_DEFAULT_MMS;
+ if(smsc) {
+ deliver->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
+ }
+ if(orig) {
+ deliver->oa = tsms_address_oa_create((const uint8_t*)orig);
+ }
+ }
+ return self;
}
static tsk_object_t* tsms_tpdu_deliver_dtor(tsk_object_t * self)
-{
- tsms_tpdu_deliver_t *deliver = self;
- if(deliver){
- /*deinit base*/
- tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(deliver));
- /*deinit self*/
- TSK_OBJECT_SAFE_FREE(deliver->oa);
- TSK_OBJECT_SAFE_FREE(deliver->smsc);
- }
- return self;
+{
+ tsms_tpdu_deliver_t *deliver = self;
+ if(deliver) {
+ /*deinit base*/
+ tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(deliver));
+ /*deinit self*/
+ TSK_OBJECT_SAFE_FREE(deliver->oa);
+ TSK_OBJECT_SAFE_FREE(deliver->smsc);
+ }
+ return self;
}
-static const tsk_object_def_t tsms_tpdu_deliver_def_s =
-{
- sizeof(tsms_tpdu_deliver_t),
- tsms_tpdu_deliver_ctor,
- tsms_tpdu_deliver_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_tpdu_deliver_def_s = {
+ sizeof(tsms_tpdu_deliver_t),
+ tsms_tpdu_deliver_ctor,
+ tsms_tpdu_deliver_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_tpdu_deliver_def_t = &tsms_tpdu_deliver_def_s;
diff --git a/tinySMS/src/tpdu/tsms_tpdu_report.c b/tinySMS/src/tpdu/tsms_tpdu_report.c
index 73f6132..1a2ce9d 100755
--- a/tinySMS/src/tpdu/tsms_tpdu_report.c
+++ b/tinySMS/src/tpdu/tsms_tpdu_report.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -42,187 +42,187 @@
tsms_tpdu_message_t* _tsms_tpdu_report_deserialize_2(const void* data, tsk_size_t size, tsk_bool_t error)
{
- /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
- tsms_tpdu_report_t* self = tsms_tpdu_report_create(tsk_null, tsk_false, error);
- tsk_bool_t failed = tsk_false;
+ /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
+ tsms_tpdu_report_t* self = tsms_tpdu_report_create(tsk_null, tsk_false, error);
+ tsk_bool_t failed = tsk_false;
// tsk_size_t any_len;
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
- /* SMSC address */
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC && 0
- if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse SMSC address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
+ if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-DELIVER == Failed to parse SMSC address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
#endif
- /* SMS-DELIVER-REPORT/MS-SUBMIT-REPORT (both ACK and ERROR) first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-User-Data-Header-Indication(1b)
-
- +----+----+----+----+----+----+----+----+
- | |UDHI| | | | | MTI |
- +----+----+----+----+----+----+----+----+
- */
- TSMS_TPDU_MESSAGE(self)->mti = *pdata & 0x03;
- self->udhi = (*pdata & 0x40)>>6;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- if(self->error){ /* FIXME ==> should comes from RP layer */
- /* 3GPP TS 23.040 ==> 9.2.3.22 TP-Failure-Cause(TP-FCS) */
- //tsk_buffer_append(output, &self->fcs, 1); /*0x00-0xFF ==> 1o*/
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.27 TP-Parameter-Indicator (TP-PI)
- * 1o
- bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
- Extension bit Reserved Reserved Reserved Reserved TP UDL TP DCS TP PID
- */
- self->pi = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- if(TSMS_TPDU_MESSAGE(self)->mti == tsms_tpdu_mti_submit_report_mt){
- /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)
- * 7o */
- if((pend - pdata)<7){
- TSMS_ERROR_TOO_SHORT();
- }
- memcpy(self->scts, pdata, 7);
- pdata += 7;
- }
-
- if(self->pi & 0x01){ /* bit 0 */
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->pid = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
-
- if(self->pi & 0x02){ /* bit 1 */
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
-
- if(self->pi & 0x04){ /* bit 2 */
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->udl = *pdata;
- pdata++;
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- if((pend-pdata) > 0){
- TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
- }
- }
+ /* SMS-DELIVER-REPORT/MS-SUBMIT-REPORT (both ACK and ERROR) first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-User-Data-Header-Indication(1b)
+
+ +----+----+----+----+----+----+----+----+
+ | |UDHI| | | | | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ TSMS_TPDU_MESSAGE(self)->mti = *pdata & 0x03;
+ self->udhi = (*pdata & 0x40)>>6;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ if(self->error) { /* FIXME ==> should comes from RP layer */
+ /* 3GPP TS 23.040 ==> 9.2.3.22 TP-Failure-Cause(TP-FCS) */
+ //tsk_buffer_append(output, &self->fcs, 1); /*0x00-0xFF ==> 1o*/
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.27 TP-Parameter-Indicator (TP-PI)
+ * 1o
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
+ Extension bit Reserved Reserved Reserved Reserved TP UDL TP DCS TP PID
+ */
+ self->pi = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ if(TSMS_TPDU_MESSAGE(self)->mti == tsms_tpdu_mti_submit_report_mt) {
+ /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)
+ * 7o */
+ if((pend - pdata)<7) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ memcpy(self->scts, pdata, 7);
+ pdata += 7;
+ }
+
+ if(self->pi & 0x01) { /* bit 0 */
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->pid = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
+
+ if(self->pi & 0x02) { /* bit 1 */
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
+
+ if(self->pi & 0x04) { /* bit 2 */
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->udl = *pdata;
+ pdata++;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ if((pend-pdata) > 0) {
+ TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
+ }
+ }
bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_TPDU_MESSAGE(self);
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_TPDU_MESSAGE(self);
}
tsms_tpdu_message_t* _tsms_tpdu_report_deserialize(const void* data, tsk_size_t size)
{
- return _tsms_tpdu_report_deserialize_2(data, size, tsk_false);
+ return _tsms_tpdu_report_deserialize_2(data, size, tsk_false);
}
int _tsms_tpdu_report_serialize(const tsms_tpdu_report_t* self, tsk_buffer_t* output)
{
- uint8_t _1byte;
+ uint8_t _1byte;
- if(!self){
- return -1;
- }
+ if(!self) {
+ return -1;
+ }
- /* SMSC address */
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- tsms_address_serialize(self->smsc, output);
+ tsms_address_serialize(self->smsc, output);
#endif
- /* SMS-DELIVER-REPORT/MS-SUBMIT-REPORT (both ACK and ERROR) first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-User-Data-Header-Indication(1b)
-
- +----+----+----+----+----+----+----+----+
- | |UDHI| | | | | MTI |
- +----+----+----+----+----+----+----+----+
- */
- _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
- _1byte |= ((uint8_t)self->udhi) << 6; /*1b*/
- tsk_buffer_append(output, &_1byte, 1);
-
- if(self->error){
- /* 3GPP TS 23.040 ==> 9.2.3.22 TP-Failure-Cause(TP-FCS) */
- tsk_buffer_append(output, &self->fcs, 1); /*0x00-0xFF ==> 1o*/
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.27 TP-Parameter-Indicator (TP-PI)
- bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
- Extension bit Reserved Reserved Reserved Reserved TP UDL TP DCS TP PID
- As we are the serializer, we know which field should be added or not ==> append our own TP-PI field
- */
- _1byte = self->pi | 0x07 /* Bits 2,1 and 0 to '1' */;
- tsk_buffer_append(output, &_1byte, 1); /* 1o*/
-
- if(TSMS_TPDU_MESSAGE(self)->mti == tsms_tpdu_mti_submit_report_mt){
- /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS) */
- tsk_buffer_append(output, self->scts, sizeof(self->scts)); /*7o*/
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
-
- return 0;
+ /* SMS-DELIVER-REPORT/MS-SUBMIT-REPORT (both ACK and ERROR) first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-User-Data-Header-Indication(1b)
+
+ +----+----+----+----+----+----+----+----+
+ | |UDHI| | | | | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
+ _1byte |= ((uint8_t)self->udhi) << 6; /*1b*/
+ tsk_buffer_append(output, &_1byte, 1);
+
+ if(self->error) {
+ /* 3GPP TS 23.040 ==> 9.2.3.22 TP-Failure-Cause(TP-FCS) */
+ tsk_buffer_append(output, &self->fcs, 1); /*0x00-0xFF ==> 1o*/
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.27 TP-Parameter-Indicator (TP-PI)
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
+ Extension bit Reserved Reserved Reserved Reserved TP UDL TP DCS TP PID
+ As we are the serializer, we know which field should be added or not ==> append our own TP-PI field
+ */
+ _1byte = self->pi | 0x07 /* Bits 2,1 and 0 to '1' */;
+ tsk_buffer_append(output, &_1byte, 1); /* 1o*/
+
+ if(TSMS_TPDU_MESSAGE(self)->mti == tsms_tpdu_mti_submit_report_mt) {
+ /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS) */
+ tsk_buffer_append(output, self->scts, sizeof(self->scts)); /*7o*/
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
+
+ return 0;
}
tsms_tpdu_report_t* tsms_tpdu_report_create(const tsms_address_string_t smsc, tsk_bool_t submit, tsk_bool_t error)
{
- tsms_tpdu_report_t* ret = tsk_null;
-
- if(!(ret = tsk_object_new(tsms_tpdu_report_def_t, smsc, submit, error))){
- goto bail;
- }
-
+ tsms_tpdu_report_t* ret = tsk_null;
+
+ if(!(ret = tsk_object_new(tsms_tpdu_report_def_t, smsc, submit, error))) {
+ goto bail;
+ }
+
bail:
- return ret;
+ return ret;
}
int tsms_tpdu_report_set_fcs(tsms_tpdu_report_t* self, uint8_t code)
{
- if(self){
- tsms_tpdu_report_t* report = self;
- report->fcs = code;
- return 0;
- }
- return -1;
+ if(self) {
+ tsms_tpdu_report_t* report = self;
+ report->fcs = code;
+ return 0;
+ }
+ return -1;
}
//=================================================================================================
@@ -230,55 +230,54 @@ int tsms_tpdu_report_set_fcs(tsms_tpdu_report_t* self, uint8_t code)
//
static tsk_object_t* tsms_tpdu_report_ctor(tsk_object_t * self, va_list * app)
{
- tsms_tpdu_report_t *report = self;
- if(report){
- const char* smsc;
- tsk_bool_t error, submit;
-
- smsc = va_arg(*app, const char*);
- submit = va_arg(*app, tsk_bool_t);
- error = va_arg(*app, tsk_bool_t);
-
- /* init base*/
- tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(report), submit?tsms_tpdu_mti_submit_report_mt
- :tsms_tpdu_mti_deliver_report_mo);
- /* init self */
- if(smsc){
- report->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
- }
- report->error = error;
-
- /*init self*/
- if(report->error){
- report->fcs = TSMS_TPDU_DEFAULT_FCS;
- }
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ tsms_tpdu_report_t *report = self;
+ if(report) {
+ const char* smsc;
+ tsk_bool_t error, submit;
+
+ smsc = va_arg(*app, const char*);
+ submit = va_arg(*app, tsk_bool_t);
+ error = va_arg(*app, tsk_bool_t);
+
+ /* init base*/
+ tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(report), submit?tsms_tpdu_mti_submit_report_mt
+ :tsms_tpdu_mti_deliver_report_mo);
+ /* init self */
+ if(smsc) {
+ report->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
+ }
+ report->error = error;
+
+ /*init self*/
+ if(report->error) {
+ report->fcs = TSMS_TPDU_DEFAULT_FCS;
+ }
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_tpdu_report_dtor(tsk_object_t * self)
-{
- tsms_tpdu_report_t *report = self;
- if(report){
- /*deinit base*/
- tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(report));
- /*deinit self*/
- TSK_OBJECT_SAFE_FREE(report->smsc);
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+{
+ tsms_tpdu_report_t *report = self;
+ if(report) {
+ /*deinit base*/
+ tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(report));
+ /*deinit self*/
+ TSK_OBJECT_SAFE_FREE(report->smsc);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
-static const tsk_object_def_t tsms_tpdu_report_def_s =
-{
- sizeof(tsms_tpdu_report_t),
- tsms_tpdu_report_ctor,
- tsms_tpdu_report_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_tpdu_report_def_s = {
+ sizeof(tsms_tpdu_report_t),
+ tsms_tpdu_report_ctor,
+ tsms_tpdu_report_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_tpdu_report_def_t = &tsms_tpdu_report_def_s;
diff --git a/tinySMS/src/tpdu/tsms_tpdu_status_report.c b/tinySMS/src/tpdu/tsms_tpdu_status_report.c
index 5c08b1b..b7691b0 100755
--- a/tinySMS/src/tpdu/tsms_tpdu_status_report.c
+++ b/tinySMS/src/tpdu/tsms_tpdu_status_report.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -43,194 +43,194 @@
/** internal function used to deserialize a SMS-STATUS-REPORT message from a binary buffer. */
tsms_tpdu_message_t* _tsms_tpdu_status_report_deserialize(const void* data, tsk_size_t size)
{
- /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
- tsms_tpdu_status_report_t* self = tsms_tpdu_status_report_create(0, tsk_null, tsk_null, tsms_tpdu_status_received, tsk_false);
- tsk_bool_t failed = tsk_false;
- tsk_size_t any_len;
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
-
- /* SMSC address */
+ /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
+ tsms_tpdu_status_report_t* self = tsms_tpdu_status_report_create(0, tsk_null, tsk_null, tsms_tpdu_status_received, tsk_false);
+ tsk_bool_t failed = tsk_false;
+ tsk_size_t any_len;
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-STATUS-REPORT == Failed to parse SMSC address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
+ if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-STATUS-REPORT == Failed to parse SMSC address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
#endif
- /* SMS-STATUS-REPORT first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-More-Messages-to-Send(1b)
- - TP-Loop-Prevention(1b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Qualifier(1b)
- +----+----+----+----+----+----+----+----+
- | |UDHI| SRQ| |LP |MMS | MTI |
- +----+----+----+----+----+----+----+----+
- */
- TSMS_TPDU_MESSAGE(self)->mti = *pdata & 0x03;
- self->mms = (*pdata & 0x04)>>2,
- self->lp = (*pdata & 0x08)>>3,
- self->srq = (*pdata & 0x20)>>5,
- self->udhi = (*pdata & 0x40)>>6;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR)
- * 1o */
- self->mr = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> xxxx TP-Recipient-Address (TP-RA) */
- if(!(self->ra = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_da, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-STATUS-REPORT == Failed to parse RA address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
-
- /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)
- * 7o */
- if((pend - pdata)<=7){
- TSMS_ERROR_TOO_SHORT();
- }
- memcpy(self->scts, pdata, 7);
- pdata += 7;
-
- /* 3GPP TS 23.040 ==> xxxx TP Discharge Time(TP-DT)
- * 7o */
- if((pend - pdata)<=7){
- TSMS_ERROR_TOO_SHORT();
- }
- memcpy(self->dt, pdata, 7);
- pdata += 7;
-
- /* 3GPP TS 23.040 ==> 9.2.3.15 TP Status(TP-ST)
- * 1o */
- self->st = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> xxxx TP-Parameter-Indicator (TP-PI)
- * 1o */
- self->pi = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->pid = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->udl = *pdata;
- pdata++;
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- if((pend-pdata) > 0){
- TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
- }
-
- bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_TPDU_MESSAGE(self);
+ /* SMS-STATUS-REPORT first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-More-Messages-to-Send(1b)
+ - TP-Loop-Prevention(1b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Qualifier(1b)
+ +----+----+----+----+----+----+----+----+
+ | |UDHI| SRQ| |LP |MMS | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ TSMS_TPDU_MESSAGE(self)->mti = *pdata & 0x03;
+ self->mms = (*pdata & 0x04)>>2,
+ self->lp = (*pdata & 0x08)>>3,
+ self->srq = (*pdata & 0x20)>>5,
+ self->udhi = (*pdata & 0x40)>>6;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR)
+ * 1o */
+ self->mr = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> xxxx TP-Recipient-Address (TP-RA) */
+ if(!(self->ra = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_da, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-STATUS-REPORT == Failed to parse RA address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
+
+ /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS)
+ * 7o */
+ if((pend - pdata)<=7) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ memcpy(self->scts, pdata, 7);
+ pdata += 7;
+
+ /* 3GPP TS 23.040 ==> xxxx TP Discharge Time(TP-DT)
+ * 7o */
+ if((pend - pdata)<=7) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ memcpy(self->dt, pdata, 7);
+ pdata += 7;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.15 TP Status(TP-ST)
+ * 1o */
+ self->st = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> xxxx TP-Parameter-Indicator (TP-PI)
+ * 1o */
+ self->pi = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->pid = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->udl = *pdata;
+ pdata++;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ if((pend-pdata) > 0) {
+ TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
+ }
+
+bail:
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_TPDU_MESSAGE(self);
}
/* internal function used to serialize a SMS-STATUS-REPORT to binary content. */
int _tsms_tpdu_status_report_serialize(const tsms_tpdu_status_report_t* self, tsk_buffer_t* output)
{
- uint8_t _1byte;
+ uint8_t _1byte;
- if(!self){
- return -1;
- }
+ if(!self) {
+ return -1;
+ }
- /* SMSC address */
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- tsms_address_serialize(self->smsc, output);
+ tsms_address_serialize(self->smsc, output);
#endif
- /* SMS-STATUS-REPORT first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-More-Messages-to-Send(1b)
- - TP-Loop-Prevention(1b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Qualifier(1b)
- +----+----+----+----+----+----+----+----+
- | |UDHI| SRQ| |LP |MMS | MTI |
- +----+----+----+----+----+----+----+----+
- */
- _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
- _1byte |= ((uint8_t)self->mms) << 2 /*1b*/
- | ((uint8_t)self->lp) << 3 /*1b*/
- /*1b (unused)*/
- | ((uint8_t)self->srq) << 5 /*1b*/
- | ((uint8_t)self->udhi) << 6; /*1b*/
- tsk_buffer_append(output, &_1byte, 1);
-
- /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR) */
- tsk_buffer_append(output, &self->mr, 1); /*0-255 ==> 1o*/
-
- /* 3GPP TS 23.040 ==> xxxx TP-Recipient-Address (TP-RA) */
- tsms_address_serialize(self->ra, output);
-
- /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS) */
- tsk_buffer_append(output, self->scts, sizeof(self->scts)); /*7o*/
-
- /* 3GPP TS 23.040 ==> xxxx TP Discharge Time(TP-DT) */
- tsk_buffer_append(output, self->dt, sizeof(self->dt)); /*7o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.15 TP Status(TP-ST) */
- tsk_buffer_append(output, &self->st, 1); /*0-255 ==> 1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.27 TP-Parameter-Indicator (TP-PI)
- bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
- Extension bit Reserved Reserved Reserved Reserved TP UDL TP DCS TP PID
- As we are the serializer, we know which field should be added or not ==> append our own TP-PI field
- */
- _1byte = self->pi | 0x07 /* Bits 2,1 and 0 to '1' */;
- tsk_buffer_append(output, &_1byte, 1); /* 1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
-
- return 0;
+ /* SMS-STATUS-REPORT first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-More-Messages-to-Send(1b)
+ - TP-Loop-Prevention(1b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Qualifier(1b)
+ +----+----+----+----+----+----+----+----+
+ | |UDHI| SRQ| |LP |MMS | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
+ _1byte |= ((uint8_t)self->mms) << 2 /*1b*/
+ | ((uint8_t)self->lp) << 3 /*1b*/
+ /*1b (unused)*/
+ | ((uint8_t)self->srq) << 5 /*1b*/
+ | ((uint8_t)self->udhi) << 6; /*1b*/
+ tsk_buffer_append(output, &_1byte, 1);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR) */
+ tsk_buffer_append(output, &self->mr, 1); /*0-255 ==> 1o*/
+
+ /* 3GPP TS 23.040 ==> xxxx TP-Recipient-Address (TP-RA) */
+ tsms_address_serialize(self->ra, output);
+
+ /* 3GPP TS 23.040 ==> TP-Service-Centre-Time-Stamp (TP-SCTS) */
+ tsk_buffer_append(output, self->scts, sizeof(self->scts)); /*7o*/
+
+ /* 3GPP TS 23.040 ==> xxxx TP Discharge Time(TP-DT) */
+ tsk_buffer_append(output, self->dt, sizeof(self->dt)); /*7o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.15 TP Status(TP-ST) */
+ tsk_buffer_append(output, &self->st, 1); /*0-255 ==> 1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.27 TP-Parameter-Indicator (TP-PI)
+ bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
+ Extension bit Reserved Reserved Reserved Reserved TP UDL TP DCS TP PID
+ As we are the serializer, we know which field should be added or not ==> append our own TP-PI field
+ */
+ _1byte = self->pi | 0x07 /* Bits 2,1 and 0 to '1' */;
+ tsk_buffer_append(output, &_1byte, 1); /* 1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
+
+ return 0;
}
/**@ingroup tsms_tpdu_group
@@ -249,14 +249,14 @@ int _tsms_tpdu_status_report_serialize(const tsms_tpdu_status_report_t* self, ts
*/
tsms_tpdu_status_report_t* tsms_tpdu_status_report_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_address_string_t recipient, tsms_tpdu_status_type_t status, tsk_bool_t submit)
{
- tsms_tpdu_status_report_t* ret = tsk_null;
-
- if(!(ret = tsk_object_new(tsms_tpdu_status_report_def_t, mr, smsc, recipient, status))){
- goto bail;
- }
-
+ tsms_tpdu_status_report_t* ret = tsk_null;
+
+ if(!(ret = tsk_object_new(tsms_tpdu_status_report_def_t, mr, smsc, recipient, status))) {
+ goto bail;
+ }
+
bail:
- return ret;
+ return ret;
}
//=================================================================================================
@@ -264,64 +264,63 @@ bail:
//
static tsk_object_t* tsms_tpdu_status_report_ctor(tsk_object_t * self, va_list * app)
{
- tsms_tpdu_status_report_t *status_report = self;
- if(status_report){
- const char* smsc, *recipient;
- uint8_t mr;
- tsms_tpdu_status_type_t status;
- tsk_bool_t submit;
-
+ tsms_tpdu_status_report_t *status_report = self;
+ if(status_report) {
+ const char* smsc, *recipient;
+ uint8_t mr;
+ tsms_tpdu_status_type_t status;
+ tsk_bool_t submit;
+
#if defined(__GNUC__)
- mr = (uint8_t)va_arg(*app, unsigned);
+ mr = (uint8_t)va_arg(*app, unsigned);
#else
- mr = va_arg(*app, uint8_t);
+ mr = va_arg(*app, uint8_t);
#endif
- smsc = va_arg(*app, const char*);
- recipient = va_arg(*app, const char*);
- status = va_arg(*app, tsms_tpdu_status_type_t);
- submit = va_arg(*app, tsk_bool_t);
-
- /* init base*/
- tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(status_report), tsms_tpdu_mti_status_report_mt);
- /* init self */
- status_report->mr = mr;
- if(smsc){
- status_report->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
- }
- if(recipient){
- status_report->ra = tsms_address_da_create((const uint8_t*)recipient);
- }
- status_report->st = status;
- status_report->mms = TSMS_TPDU_DEFAULT_MMS;
- status_report->srq = submit?0:1/*SMS-COMAND*/;
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ smsc = va_arg(*app, const char*);
+ recipient = va_arg(*app, const char*);
+ status = va_arg(*app, tsms_tpdu_status_type_t);
+ submit = va_arg(*app, tsk_bool_t);
+
+ /* init base*/
+ tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(status_report), tsms_tpdu_mti_status_report_mt);
+ /* init self */
+ status_report->mr = mr;
+ if(smsc) {
+ status_report->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
+ }
+ if(recipient) {
+ status_report->ra = tsms_address_da_create((const uint8_t*)recipient);
+ }
+ status_report->st = status;
+ status_report->mms = TSMS_TPDU_DEFAULT_MMS;
+ status_report->srq = submit?0:1/*SMS-COMAND*/;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_tpdu_status_report_dtor(tsk_object_t * self)
-{
- tsms_tpdu_status_report_t *status_report = self;
- if(status_report){
- /*deinit base*/
- tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(status_report));
- /*deinit self*/
- TSK_OBJECT_SAFE_FREE(status_report->smsc);
- TSK_OBJECT_SAFE_FREE(status_report->ra);
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+{
+ tsms_tpdu_status_report_t *status_report = self;
+ if(status_report) {
+ /*deinit base*/
+ tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(status_report));
+ /*deinit self*/
+ TSK_OBJECT_SAFE_FREE(status_report->smsc);
+ TSK_OBJECT_SAFE_FREE(status_report->ra);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
-static const tsk_object_def_t tsms_tpdu_status_report_def_s =
-{
- sizeof(tsms_tpdu_status_report_t),
- tsms_tpdu_status_report_ctor,
- tsms_tpdu_status_report_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_tpdu_status_report_def_s = {
+ sizeof(tsms_tpdu_status_report_t),
+ tsms_tpdu_status_report_ctor,
+ tsms_tpdu_status_report_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_tpdu_status_report_def_t = &tsms_tpdu_status_report_def_s;
diff --git a/tinySMS/src/tpdu/tsms_tpdu_submit.c b/tinySMS/src/tpdu/tsms_tpdu_submit.c
index 22095c0..b5e36be 100755
--- a/tinySMS/src/tpdu/tsms_tpdu_submit.c
+++ b/tinySMS/src/tpdu/tsms_tpdu_submit.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -44,117 +44,120 @@
*/
tsms_tpdu_message_t* _tsms_tpdu_submit_deserialize(const void* data, tsk_size_t size)
{
- /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
- tsms_tpdu_submit_t* self = tsms_tpdu_submit_create(0, tsk_null, tsk_null);
- tsk_bool_t failed = tsk_false;
- tsk_size_t any_len;
- const uint8_t* pdata = data;
- const uint8_t* pend = pdata + size;
-
- /* SMSC address */
+ /* You don't need to test data and test, this is an internal function called by tsms_tpdu_message_deserialize() */
+ tsms_tpdu_submit_t* self = tsms_tpdu_submit_create(0, tsk_null, tsk_null);
+ tsk_bool_t failed = tsk_false;
+ tsk_size_t any_len;
+ const uint8_t* pdata = data;
+ const uint8_t* pend = pdata + size;
+
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-SUBMIT == Failed to parse SMSC address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
+ if(!(self->smsc = tsms_address_deserialize(data, size, tsms_addr_smsc, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-SUBMIT == Failed to parse SMSC address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
#endif
- /* SMS-SUBMIT first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-Reject-Duplicates(1b)
- - TP-Validity-Period-Format(1b)
- - TP-Reply-Path(1b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Request(1b)
-
- +----+----+----+----+----+----+----+----+
- |RP |UDHI|SRR |VPF | RD | MTI |
- +----+----+----+----+----+----+----+----+
- */
- TSMS_TPDU_MESSAGE(self)->mti = *pdata & 0x03;
- self->rd = (*pdata & 0x04)>>2,
- self->vpf = (*pdata & 0x18)>>3,
- self->srr = (*pdata & 0x20)>>5,
- self->udhi = (*pdata & 0x40)>>6,
- self->rp = (*pdata & 0x80)>>7;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR)
- * 1o */
- self->mr = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
- if(!(self->da = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_da, &any_len)) || !any_len){
- TSK_DEBUG_ERROR("SMS-SUBMIT == Failed to parse DA address");
- failed = tsk_true;
- goto bail;
- }
- else{
- if((pdata += any_len) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->pid = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
- if((++pdata) >= pend){
- TSMS_ERROR_TOO_SHORT();
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.12 TP-Validity-Period
- * 1o for Relative format (9.2.3.12.1)
- * 7o for Absolute format (9.2.3.12.2)
- * 7o for Enhanced format (9.2.3.12.3)*/
- switch(self->vpf){
- case tsms_tpdu_vpf_relative:
- any_len = 1; break;
- case tsms_tpdu_vpf_enhanced:
- case tsms_tpdu_vpf_absolute:
- any_len = 7; break;
- default:
- case tsms_tpdu_vpf_not_present:
- any_len = 0; break;
- }
- if((tsk_size_t)(pend-pdata) <= any_len){
- TSMS_ERROR_TOO_SHORT();
- }
- memcpy(self->vp, pdata, any_len);
- pdata += any_len;
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
- * 1o */
- TSMS_TPDU_MESSAGE(self)->udl = *pdata;
- pdata++;
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- if((pend-pdata) > 0){
- TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
- }
+ /* SMS-SUBMIT first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-Reject-Duplicates(1b)
+ - TP-Validity-Period-Format(1b)
+ - TP-Reply-Path(1b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Request(1b)
+
+ +----+----+----+----+----+----+----+----+
+ |RP |UDHI|SRR |VPF | RD | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ TSMS_TPDU_MESSAGE(self)->mti = *pdata & 0x03;
+ self->rd = (*pdata & 0x04)>>2,
+ self->vpf = (*pdata & 0x18)>>3,
+ self->srr = (*pdata & 0x20)>>5,
+ self->udhi = (*pdata & 0x40)>>6,
+ self->rp = (*pdata & 0x80)>>7;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR)
+ * 1o */
+ self->mr = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
+ if(!(self->da = tsms_address_deserialize(pdata, (pend-pdata), tsms_addr_da, &any_len)) || !any_len) {
+ TSK_DEBUG_ERROR("SMS-SUBMIT == Failed to parse DA address");
+ failed = tsk_true;
+ goto bail;
+ }
+ else {
+ if((pdata += any_len) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->pid = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->dcs = *pdata;
+ if((++pdata) >= pend) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.12 TP-Validity-Period
+ * 1o for Relative format (9.2.3.12.1)
+ * 7o for Absolute format (9.2.3.12.2)
+ * 7o for Enhanced format (9.2.3.12.3)*/
+ switch(self->vpf) {
+ case tsms_tpdu_vpf_relative:
+ any_len = 1;
+ break;
+ case tsms_tpdu_vpf_enhanced:
+ case tsms_tpdu_vpf_absolute:
+ any_len = 7;
+ break;
+ default:
+ case tsms_tpdu_vpf_not_present:
+ any_len = 0;
+ break;
+ }
+ if((tsk_size_t)(pend-pdata) <= any_len) {
+ TSMS_ERROR_TOO_SHORT();
+ }
+ memcpy(self->vp, pdata, any_len);
+ pdata += any_len;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
+ * 1o */
+ TSMS_TPDU_MESSAGE(self)->udl = *pdata;
+ pdata++;
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ if((pend-pdata) > 0) {
+ TSMS_TPDU_MESSAGE(self)->ud = tsk_buffer_create(pdata, (pend-pdata));
+ }
bail:
- if(failed){
- TSK_OBJECT_SAFE_FREE(self);
- }
- return TSMS_TPDU_MESSAGE(self);
+ if(failed) {
+ TSK_OBJECT_SAFE_FREE(self);
+ }
+ return TSMS_TPDU_MESSAGE(self);
}
@@ -162,72 +165,72 @@ bail:
*/
int _tsms_tpdu_submit_serialize(const tsms_tpdu_submit_t* self, tsk_buffer_t* output)
{
- uint8_t _1byte;
+ uint8_t _1byte;
- if(!self){
- return -1;
- }
+ if(!self) {
+ return -1;
+ }
- /* SMSC address */
+ /* SMSC address */
#if TSMS_TPDU_APPEND_SMSC
- tsms_address_serialize(self->smsc, output);
+ tsms_address_serialize(self->smsc, output);
#endif
- /* SMS-SUBMIT first Octect:
- - TP-Message-Type-Indicator(2b)
- - TP-Reject-Duplicates(1b)
- - TP-Validity-Period-Format(1b)
- - TP-Reply-Path(1b)
- - TP-User-Data-Header-Indicator(1b)
- - TP-Status-Report-Request(1b)
-
- +----+----+----+----+----+----+----+----+
- |RP |UDHI|SRR |VPF | RD | MTI |
- +----+----+----+----+----+----+----+----+
- */
- _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
- _1byte |= ((uint8_t)self->rd) << 2 /*1b*/
- | ((uint8_t)self->vpf) << 3 /*2b*/
- | ((uint8_t)self->srr) << 5 /*1b*/
- | ((uint8_t)self->udhi) << 6; /*1b*/
- tsk_buffer_append(output, &_1byte, 1);
-
- /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR) */
- tsk_buffer_append(output, &self->mr, 1); /*0-255 ==> 1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
- tsms_address_serialize(self->da, output);
-
- /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.12 TP-Validity-Period
- * 1o for Relative format (9.2.3.12.1)
- * 7o for Absolute format (9.2.3.12.2)
- * 7o for Enhanced format (9.2.3.12.3)*/
- switch(self->vpf){
- case tsms_tpdu_vpf_relative:
- tsk_buffer_append(output, &self->vp, 1);
- break;
- case tsms_tpdu_vpf_enhanced:
- case tsms_tpdu_vpf_absolute:
- tsk_buffer_append(output, &self->vp, 7);
- break;
- default:
- case tsms_tpdu_vpf_not_present:
- break;
- }
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
- tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
-
- return 0;
+ /* SMS-SUBMIT first Octect:
+ - TP-Message-Type-Indicator(2b)
+ - TP-Reject-Duplicates(1b)
+ - TP-Validity-Period-Format(1b)
+ - TP-Reply-Path(1b)
+ - TP-User-Data-Header-Indicator(1b)
+ - TP-Status-Report-Request(1b)
+
+ +----+----+----+----+----+----+----+----+
+ |RP |UDHI|SRR |VPF | RD | MTI |
+ +----+----+----+----+----+----+----+----+
+ */
+ _1byte = (TSMS_TPDU_MESSAGE(self)->mti & 0xF3); /*2b*/
+ _1byte |= ((uint8_t)self->rd) << 2 /*1b*/
+ | ((uint8_t)self->vpf) << 3 /*2b*/
+ | ((uint8_t)self->srr) << 5 /*1b*/
+ | ((uint8_t)self->udhi) << 6; /*1b*/
+ tsk_buffer_append(output, &_1byte, 1);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.6 TP-Message-Reference (TP-MR) */
+ tsk_buffer_append(output, &self->mr, 1); /*0-255 ==> 1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.8 TP-Destination-Address (TP-DA) */
+ tsms_address_serialize(self->da, output);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.9 TP-Protocol-Identifier (TP-PID) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->pid, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.10 TP-Data-Coding-Scheme (TP-DCS) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->dcs, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.12 TP-Validity-Period
+ * 1o for Relative format (9.2.3.12.1)
+ * 7o for Absolute format (9.2.3.12.2)
+ * 7o for Enhanced format (9.2.3.12.3)*/
+ switch(self->vpf) {
+ case tsms_tpdu_vpf_relative:
+ tsk_buffer_append(output, &self->vp, 1);
+ break;
+ case tsms_tpdu_vpf_enhanced:
+ case tsms_tpdu_vpf_absolute:
+ tsk_buffer_append(output, &self->vp, 7);
+ break;
+ default:
+ case tsms_tpdu_vpf_not_present:
+ break;
+ }
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL) */
+ tsk_buffer_append(output, &TSMS_TPDU_MESSAGE(self)->udl, 1); /*1o*/
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ tsk_buffer_append(output, TSK_BUFFER_DATA(TSMS_TPDU_MESSAGE(self)->ud), TSK_BUFFER_SIZE(TSMS_TPDU_MESSAGE(self)->ud));
+
+ return 0;
}
/**@ingroup tsms_tpdu_group
@@ -243,14 +246,14 @@ int _tsms_tpdu_submit_serialize(const tsms_tpdu_submit_t* self, tsk_buffer_t* ou
*/
tsms_tpdu_submit_t* tsms_tpdu_submit_create(uint8_t mr, const tsms_address_string_t smsc, const tsms_address_string_t dest)
{
- tsms_tpdu_submit_t* ret = tsk_null;
-
- if(!(ret = tsk_object_new(tsms_tpdu_submit_def_t, mr, smsc, dest))){
- goto bail;
- }
-
+ tsms_tpdu_submit_t* ret = tsk_null;
+
+ if(!(ret = tsk_object_new(tsms_tpdu_submit_def_t, mr, smsc, dest))) {
+ goto bail;
+ }
+
bail:
- return ret;
+ return ret;
}
//=================================================================================================
@@ -258,60 +261,59 @@ bail:
//
static tsk_object_t* tsms_tpdu_submit_ctor(tsk_object_t * self, va_list * app)
{
- tsms_tpdu_submit_t *submit = self;
- if(submit){
- const char* smsc, *dest;
- uint8_t mr;
-
+ tsms_tpdu_submit_t *submit = self;
+ if(submit) {
+ const char* smsc, *dest;
+ uint8_t mr;
+
#if defined(__GNUC__)
- mr = (uint8_t)va_arg(*app, unsigned);
+ mr = (uint8_t)va_arg(*app, unsigned);
#else
- mr = va_arg(*app, uint8_t);
+ mr = va_arg(*app, uint8_t);
#endif
- smsc = va_arg(*app, const char*);
- dest = va_arg(*app, const char*);
-
- /* init base*/
- tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(submit), tsms_tpdu_mti_submit_mo);
- /* init self */
- submit->mr = mr;
- if(smsc){
- submit->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
- }
- if(dest){
- submit->da = tsms_address_da_create((const uint8_t*)dest);
- }
-
- submit->vp[0] = TSMS_TPDU_DEFAULT_VP;
- submit->vpf = TSMS_TPDU_DEFAULT_VPF;
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+ smsc = va_arg(*app, const char*);
+ dest = va_arg(*app, const char*);
+
+ /* init base*/
+ tsms_tpdu_message_init(TSMS_TPDU_MESSAGE(submit), tsms_tpdu_mti_submit_mo);
+ /* init self */
+ submit->mr = mr;
+ if(smsc) {
+ submit->smsc = tsms_address_smsc_create((const uint8_t*)smsc);
+ }
+ if(dest) {
+ submit->da = tsms_address_da_create((const uint8_t*)dest);
+ }
+
+ submit->vp[0] = TSMS_TPDU_DEFAULT_VP;
+ submit->vpf = TSMS_TPDU_DEFAULT_VPF;
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
static tsk_object_t* tsms_tpdu_submit_dtor(tsk_object_t * self)
-{
- tsms_tpdu_submit_t *submit = self;
- if(submit){
- /*deinit base*/
- tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(submit));
- /*deinit self*/
- TSK_OBJECT_SAFE_FREE(submit->smsc);
- TSK_OBJECT_SAFE_FREE(submit->da);
- }
- else{
- TSK_DEBUG_ERROR("Null");
- }
- return self;
+{
+ tsms_tpdu_submit_t *submit = self;
+ if(submit) {
+ /*deinit base*/
+ tsms_tpdu_message_deinit(TSMS_TPDU_MESSAGE(submit));
+ /*deinit self*/
+ TSK_OBJECT_SAFE_FREE(submit->smsc);
+ TSK_OBJECT_SAFE_FREE(submit->da);
+ }
+ else {
+ TSK_DEBUG_ERROR("Null");
+ }
+ return self;
}
-static const tsk_object_def_t tsms_tpdu_submit_def_s =
-{
- sizeof(tsms_tpdu_submit_t),
- tsms_tpdu_submit_ctor,
- tsms_tpdu_submit_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_tpdu_submit_def_s = {
+ sizeof(tsms_tpdu_submit_t),
+ tsms_tpdu_submit_ctor,
+ tsms_tpdu_submit_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_tpdu_submit_def_t = &tsms_tpdu_submit_def_s;
diff --git a/tinySMS/src/tsms.c b/tinySMS/src/tsms.c
index 3ad8abf..aa63e17 100755
--- a/tinySMS/src/tsms.c
+++ b/tinySMS/src/tsms.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -50,7 +50,7 @@
*
*
* @image html SMS_Architecture.png "Protocol layer overview for the Short Message Service"
-*
+*
* <h2>18.1 Modes</h2>
* In real world, there are two ways to receive or send SMS messages over mobile networks: Binary (PDU) and Text mode.
*
@@ -77,7 +77,7 @@
/**@defgroup tsms_tpdu_group Service provided by the SM-TL (Transport)
* The Short Message Transfer Layer (SM TL) provides a service to the Short Message Application Layer (SM AL).
*
-* This service enables the SM AL to transfer short messages to its peer entity, receive short messages from its
+* This service enables the SM AL to transfer short messages to its peer entity, receive short messages from its
* peer entity and receive reports about earlier requests for short messages to be transferred.
*
* ======
@@ -177,7 +177,7 @@ TSK_OBJECT_SAFE_FREE(buffer);
* <i>SMS-STATUS-REPORT</i> messages are used to convey status reports from the SC (Service Center) to the MS (Mobile Station).<br>
* For more information, please refer to 3GPP TS 23.040 section 9.2.2.3.<br>
* The code below shows how to receive a <i>SMS-STATUS-REPORT</i> message, sent from the SC to the MS (MT).<br>
-*
+*
* @code
#include "tsk.h"
#include "tinysms.h"
@@ -216,7 +216,7 @@ uint8_t mr = 0xF5;
uint8_t message_number = 0xF8;
command = tsms_tpdu_command_create(mr, smsc, destination, message_number, tsms_tpdu_cmd_delete);
-
+
if((hex = tsms_tpdu_command_tohexastring(command))){
TSK_DEBUG_INFO("SMS-COMMAND=%s", hex);
TSK_FREE(hex);
@@ -319,7 +319,7 @@ TSK_OBJECT_SAFE_FREE(buffer);
*
* A SC receiving binary <i>RP-DATA</i> message (or any other <i>RP-*</i>) from the network should use tsms_rpdu_message_deserialize() function to deserialize the content.<br>
* The code below shows how to receive a <i>RP-DATA</i> message with a <i>RP-User-Data</i> (see 3GPP TS 23.011 section 8.2.5.3) information element which includes <i>SMS-DELIVER</i> as type indicator (this use case comes from 3GPP TS 24.341 chapter B.6). <br>
-*
+*
* @code
#include "tsk.h"
#include "tinysms.h"
@@ -383,7 +383,7 @@ TSK_OBJECT_SAFE_FREE(rp_smma);
* This message is sent between the MSC and the mobile station in both directions and used to relay the acknowledgement of a <i>RP-DATA</i> or <i>RP-SMMA</i> message reception.<br>
* For more information, please refer to 3GPP TS 24.011 section 7.3.2.3.<br>
* The code below shows how to send a <i>RP-ACK</i> message with a <i>RP-User-Data</i> (see 3GPP TS 23.011 section 8.2.5.3) information element which includes <i>SMS-DELIVER-REPORT</i> as type indicator (this use case comes from 3GPP TS 24.341 chapter B.6 section 8). <br>
-*
+*
* @code
#include "tsk.h"
#include "tinysms.h"
@@ -419,7 +419,7 @@ TSK_OBJECT_SAFE_FREE(rp_ack);
* This message is sent between the MSC and the mobile station in both directions and used to relay an error cause from an erroneous short message or notification transfer attempt.<br>
* For more information, please refer to 3GPP TS 24.011 section7.3.2.4.<br>
* The code below shows how to send a <i>RP-ERROR</i> message with a <i>RP-User-Data</i> (see 3GPP TS 23.011 section 8.2.5.3) information element which includes <i>SMS-DELIVER-REPORT</i> as type indicator. In this example, the error message is sent because the “call is barred”. For more information about the cause values that may be contained in an <i>RP-ERROR</i> message, please refer to 3GPP TS 24.011 section 8.2.5.4.<br>
-*
+*
* @code
#include "tsk.h"
#include "tinysms.h"
@@ -436,7 +436,7 @@ uint8_t mr = 0xF5;
// create SMS-DELIVER-REPORT message
sms_report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
// create RP-ERROR message
-rp_error = tsms_rpdu_error_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report),
+rp_error = tsms_rpdu_error_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report),
0x0A//call barred
);
// serialize
diff --git a/tinySMS/src/tsms_address.c b/tinySMS/src/tsms_address.c
index 26da4c6..56f9fde 100755
--- a/tinySMS/src/tsms_address.c
+++ b/tinySMS/src/tsms_address.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -39,163 +39,163 @@
*/
char* tsms_address_swap(const char* in, tsk_size_t in_len)
{
- tsk_size_t i;
- char* ret = tsk_null;
- if(tsk_strnullORempty(in)){
- goto bail;
- }
- ret = tsk_calloc(in_len + 2/*\0 and trainling F*/, sizeof(uint8_t));
-
- if(in_len>=2){
- for(i=0; i<in_len; i+=2){
- ret[i] = in[i+1];
- ret[i+1] = in[i];
- }
- }
-
- if(in_len & 0x01){ /* odd number? */
- ret[i-2] = 'F';
- ret[i-1] = in[i-2];
- }
+ tsk_size_t i;
+ char* ret = tsk_null;
+ if(tsk_strnullORempty(in)) {
+ goto bail;
+ }
+ ret = tsk_calloc(in_len + 2/*\0 and trainling F*/, sizeof(uint8_t));
+
+ if(in_len>=2) {
+ for(i=0; i<in_len; i+=2) {
+ ret[i] = in[i+1];
+ ret[i+1] = in[i];
+ }
+ }
+
+ if(in_len & 0x01) { /* odd number? */
+ ret[i-2] = 'F';
+ ret[i-1] = in[i-2];
+ }
bail:
- return ret;
+ return ret;
}
tsms_address_t* tsms_address_create(const tsms_address_string_t digits, tsms_address_type_t type)
{
- return tsk_object_new(tsms_address_def_t, digits, type);
+ return tsk_object_new(tsms_address_def_t, digits, type);
}
tsms_address_t* tsms_address_oa_create(const tsms_address_string_t digits)
{
- return tsms_address_create(digits, tsms_addr_oa);
+ return tsms_address_create(digits, tsms_addr_oa);
}
tsms_address_t* tsms_address_da_create(const tsms_address_string_t digits)
{
- return tsms_address_create(digits, tsms_addr_da);
+ return tsms_address_create(digits, tsms_addr_da);
}
tsms_address_t* tsms_address_smsc_create(const tsms_address_string_t digits)
{
- return tsms_address_create(digits, tsms_addr_smsc);
+ return tsms_address_create(digits, tsms_addr_smsc);
}
/** Serialize the address as per 3GPP TS 23.040 v910 section 9.1.2.5. */
int tsms_address_serialize(const tsms_address_t* address, tsk_buffer_t* output)
{
- char* number = tsk_null;
- tsk_size_t i, num_len/*real len*/;
- uint8_t type_of_address;
- if(!output){
- return -1;
- }
-
- /* For more information see 3GPP TS 23.040 v910 section 9.1.2.5
-
- 1 - Address-Length
- 2 - Type-of-Address
- +----+----+----+----+----+----+----+----+
- | 1 | TON | NPI |
- +----+----+----+----+----+----+----+----+
- 3 - Phone number in semi octets
- */
- number = tsms_address_swap(address ? address->digits : tsk_null, address ? strlen(address->digits) : 0);
-
- if(number){
- tsk_size_t len = (address->type == tsms_addr_smsc) ?
- ((strlen(number)/2) + 1) /* Number of octets plus 1. */
- : strlen(address->digits); /* Number of BCD digits */
- /* 1 - Address-Length */
- tsk_buffer_append(output, &len, 1);
- }
- else{
- /* 1 - Address-Length */
- static uint8_t _1bytes = 0x00;
- tsk_buffer_append(output, &_1bytes, 1);
- goto bail; /* neither 2 nor 3 will be executed */
- }
-
- /* 2 - Type-of-Address */
- type_of_address = (address->npi | (((address->ton << 4) | 0x80)));
- tsk_buffer_append(output, &type_of_address, 1);
- /* 3 - Phone number in semi octets (BCD digits) */
- if(((num_len = strlen(number)))){
- unsigned _1bytes; /* do not use neither int8_t nor uint8_t */
- /* as number comes from swap ==> num_len not odd */
- for(i=0; i<num_len; i+=2){
- if(sscanf(&number[i], "%2x", &_1bytes)){ /*do not use tsk_atox(str), because str should end with '\0'.*/
- tsk_buffer_append(output, &_1bytes, 1);
- }
- }
- }
-
+ char* number = tsk_null;
+ tsk_size_t i, num_len/*real len*/;
+ uint8_t type_of_address;
+ if(!output) {
+ return -1;
+ }
+
+ /* For more information see 3GPP TS 23.040 v910 section 9.1.2.5
+
+ 1 - Address-Length
+ 2 - Type-of-Address
+ +----+----+----+----+----+----+----+----+
+ | 1 | TON | NPI |
+ +----+----+----+----+----+----+----+----+
+ 3 - Phone number in semi octets
+ */
+ number = tsms_address_swap(address ? address->digits : tsk_null, address ? strlen(address->digits) : 0);
+
+ if(number) {
+ tsk_size_t len = (address->type == tsms_addr_smsc) ?
+ ((strlen(number)/2) + 1) /* Number of octets plus 1. */
+ : strlen(address->digits); /* Number of BCD digits */
+ /* 1 - Address-Length */
+ tsk_buffer_append(output, &len, 1);
+ }
+ else {
+ /* 1 - Address-Length */
+ static uint8_t _1bytes = 0x00;
+ tsk_buffer_append(output, &_1bytes, 1);
+ goto bail; /* neither 2 nor 3 will be executed */
+ }
+
+ /* 2 - Type-of-Address */
+ type_of_address = (address->npi | (((address->ton << 4) | 0x80)));
+ tsk_buffer_append(output, &type_of_address, 1);
+ /* 3 - Phone number in semi octets (BCD digits) */
+ if(((num_len = strlen(number)))) {
+ unsigned _1bytes; /* do not use neither int8_t nor uint8_t */
+ /* as number comes from swap ==> num_len not odd */
+ for(i=0; i<num_len; i+=2) {
+ if(sscanf(&number[i], "%2x", &_1bytes)) { /*do not use tsk_atox(str), because str should end with '\0'.*/
+ tsk_buffer_append(output, &_1bytes, 1);
+ }
+ }
+ }
+
bail:
- TSK_FREE(number);
- return 0;
+ TSK_FREE(number);
+ return 0;
}
tsms_address_t* tsms_address_deserialize(const void* data, tsk_size_t size, tsms_address_type_t xtype, tsk_size_t *length)
{
- tsms_address_t* address = tsk_null;
- uint8_t addr_len, _1byte, i;
- const uint8_t* pdata = data;
- *length = 0;
-
- if(!pdata || size<=2){
- TSK_DEBUG_ERROR("Invalid Parameter.");
- goto bail;
- }
-
- /* 1 - Address-Length */
- addr_len = *pdata;
- pdata++;
-
- /*== len=0 ==*/
- if(!addr_len){
- address = tsms_address_create(tsk_null, xtype);
- *length = 1;
- goto bail;
- }
- /*== check validity for non-zero-length address ==*/
- addr_len = (xtype == tsms_addr_smsc) ?
- (addr_len - 1) /* Number of octets plus 1. */
- : ((addr_len/2) + (addr_len%2)); /* Number of BCD digits */
- if((tsk_size_t)(1 /*Address-Length*/ + 1 /*Type-of-Address*/ + addr_len /* digits */) >= size){
- TSK_DEBUG_ERROR("Too short to contain an address.");
- goto bail;
- }
- else{
- address = tsms_address_create(tsk_null, xtype);
- *length = 1 /*Address-Length*/ + 1 /*Type-of-Address*/ + addr_len /* digits */;
- }
-
- /* 2 - Type-of-Address
- +----+----+----+----+----+----+----+----+
- | 1 | TON | NPI |
- +----+----+----+----+----+----+----+----+
- */
- address->ton = ((*pdata &0x70) >> 4);
- address->npi = (*pdata &0x0F);
- pdata++;
-
- /* 3 - Phone number in semi octets (BCD digits) */
- //address->digits = tsk_calloc((addr_len/2) + 1, sizeof(uint8_t));
- for(i=0; i<addr_len; i++, pdata++){
- _1byte = ((*pdata << 4) | (*pdata >> 4));
- if((_1byte & 0x0F) == 0x0F){ /* ends with 'F'? */
- _1byte = ((_1byte & 0xF0) >> 4);
- tsk_strcat_2(&address->digits, "%.1x", _1byte);
- }
- else{
- tsk_strcat_2(&address->digits, "%.2x", _1byte);
- }
- }
-
+ tsms_address_t* address = tsk_null;
+ uint8_t addr_len, _1byte, i;
+ const uint8_t* pdata = data;
+ *length = 0;
+
+ if(!pdata || size<=2) {
+ TSK_DEBUG_ERROR("Invalid Parameter.");
+ goto bail;
+ }
+
+ /* 1 - Address-Length */
+ addr_len = *pdata;
+ pdata++;
+
+ /*== len=0 ==*/
+ if(!addr_len) {
+ address = tsms_address_create(tsk_null, xtype);
+ *length = 1;
+ goto bail;
+ }
+ /*== check validity for non-zero-length address ==*/
+ addr_len = (xtype == tsms_addr_smsc) ?
+ (addr_len - 1) /* Number of octets plus 1. */
+ : ((addr_len/2) + (addr_len%2)); /* Number of BCD digits */
+ if((tsk_size_t)(1 /*Address-Length*/ + 1 /*Type-of-Address*/ + addr_len /* digits */) >= size) {
+ TSK_DEBUG_ERROR("Too short to contain an address.");
+ goto bail;
+ }
+ else {
+ address = tsms_address_create(tsk_null, xtype);
+ *length = 1 /*Address-Length*/ + 1 /*Type-of-Address*/ + addr_len /* digits */;
+ }
+
+ /* 2 - Type-of-Address
+ +----+----+----+----+----+----+----+----+
+ | 1 | TON | NPI |
+ +----+----+----+----+----+----+----+----+
+ */
+ address->ton = ((*pdata &0x70) >> 4);
+ address->npi = (*pdata &0x0F);
+ pdata++;
+
+ /* 3 - Phone number in semi octets (BCD digits) */
+ //address->digits = tsk_calloc((addr_len/2) + 1, sizeof(uint8_t));
+ for(i=0; i<addr_len; i++, pdata++) {
+ _1byte = ((*pdata << 4) | (*pdata >> 4));
+ if((_1byte & 0x0F) == 0x0F) { /* ends with 'F'? */
+ _1byte = ((_1byte & 0xF0) >> 4);
+ tsk_strcat_2(&address->digits, "%.1x", _1byte);
+ }
+ else {
+ tsk_strcat_2(&address->digits, "%.2x", _1byte);
+ }
+ }
+
bail:
- return address;
+ return address;
}
//=================================================================================================
@@ -203,47 +203,46 @@ bail:
//
static tsk_object_t* tsms_address_ctor(tsk_object_t * self, va_list * app)
{
- tsms_address_t *address = self;
- if(address){
- const char* digits = va_arg(*app, const char*);
- address->type = va_arg(*app, tsms_address_type_t);
-
- if(!tsk_strnullORempty(digits)){
- if(*digits == '+'){
- address->npi = tsms_addr_npi_isdn;
- address->ton = tsms_addr_ton_international;
- address->digits = tsk_strdup((digits+1));
- }
- else{
- address->npi = tsms_addr_npi_national;
- address->ton = tsms_addr_ton_national;
- address->digits = tsk_strdup((digits));
- }
- }
- else{
- address->npi = tsms_addr_npi_unknown;
- address->ton = tsms_addr_ton_unknown;
- }
-
- }
- return self;
+ tsms_address_t *address = self;
+ if(address) {
+ const char* digits = va_arg(*app, const char*);
+ address->type = va_arg(*app, tsms_address_type_t);
+
+ if(!tsk_strnullORempty(digits)) {
+ if(*digits == '+') {
+ address->npi = tsms_addr_npi_isdn;
+ address->ton = tsms_addr_ton_international;
+ address->digits = tsk_strdup((digits+1));
+ }
+ else {
+ address->npi = tsms_addr_npi_national;
+ address->ton = tsms_addr_ton_national;
+ address->digits = tsk_strdup((digits));
+ }
+ }
+ else {
+ address->npi = tsms_addr_npi_unknown;
+ address->ton = tsms_addr_ton_unknown;
+ }
+
+ }
+ return self;
}
static tsk_object_t* tsms_address_dtor(tsk_object_t * self)
-{
- tsms_address_t *address = self;
- if(address){
- TSK_FREE(address->digits);
- }
+{
+ tsms_address_t *address = self;
+ if(address) {
+ TSK_FREE(address->digits);
+ }
- return self;
+ return self;
}
-static const tsk_object_def_t tsms_address_def_s =
-{
- sizeof(tsms_address_t),
- tsms_address_ctor,
- tsms_address_dtor,
- tsk_null,
+static const tsk_object_def_t tsms_address_def_s = {
+ sizeof(tsms_address_t),
+ tsms_address_ctor,
+ tsms_address_dtor,
+ tsk_null,
};
const tsk_object_def_t *tsms_address_def_t = &tsms_address_def_s;
diff --git a/tinySMS/src/tsms_common.c b/tinySMS/src/tsms_common.c
index 92cda4c..f1e926a 100755
--- a/tinySMS/src/tsms_common.c
+++ b/tinySMS/src/tsms_common.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -37,7 +37,7 @@
#include <string.h> /* strlen() */
-/* ======================== TPDU ========================
+/* ======================== TPDU ========================
=========================================================*/
extern tsms_tpdu_message_t* _tsms_tpdu_submit_deserialize(const void* data, tsk_size_t size);
@@ -54,14 +54,14 @@ extern int _tsms_tpdu_status_report_serialize(const tsms_tpdu_message_t* self, t
int tsms_tpdu_message_init(tsms_tpdu_message_t* self, tsms_tpdu_mti_t mti)
{
- if(self){
- self->MobOrig = tsk_true;
- self->mti = mti;
- self->pid = TSMS_TPDU_DEFAULT_PID;
- self->dcs = TSMS_TPDU_DEFAULT_DCS;
- return 0;
- }
- return -1;
+ if(self) {
+ self->MobOrig = tsk_true;
+ self->mti = mti;
+ self->pid = TSMS_TPDU_DEFAULT_PID;
+ self->dcs = TSMS_TPDU_DEFAULT_DCS;
+ return 0;
+ }
+ return -1;
}
/**@ingroup tsms_tpdu_group
@@ -75,36 +75,44 @@ int tsms_tpdu_message_init(tsms_tpdu_message_t* self, tsms_tpdu_mti_t mti)
*/
int tsms_tpdu_message_serialize(const tsms_tpdu_message_t* self, tsk_buffer_t* output, tsk_bool_t MobOrig)
{
- if(!self){
- return -1;
- }
-
- /* 3GPP TS 23.040 - 9.2.3.1 TP Message Type Indicator (TP MTI)
- bit1 bit0 Message type
- 0 0 SMS-DELIVER (in the direction SC to MS)
- 0 0 SMS-DELIVER-REPORT (in the direction MS to SC)
- 1 0 SMS-STATUS-REPORT (in the direction SC to MS)
- 1 0 SMS-COMMAND (in the direction MS to SC)
- 0 1 SMS-SUBMIT (in the direction MS to SC)
- 0 1 SMS-SUBMIT-REPORT (in the direction SC to MS)
- 1 1 Reserved
- */
- if(MobOrig){ /* MO */
- switch(self->mti){
- case tsms_tpdu_mti_deliver_report_mo: return _tsms_tpdu_report_serialize(self, output); /* SMS-DELIVER-REPORT */
- case tsms_tpdu_mti_command_mo: return _tsms_tpdu_command_serialize(self, output); /* SMS-COMMAND */
- case tsms_tpdu_mti_submit_mo: return _tsms_tpdu_submit_serialize(self, output); /* SMS-SUBMIT */
- default: return -2;
- }
- }
- else{ /* MT */
- switch(self->mti){
- case tsms_tpdu_mti_deliver_mt: return _tsms_tpdu_deliver_serialize(self, output); /* SMS-DELIVER */
- case tsms_tpdu_mti_status_report_mt: return _tsms_tpdu_status_report_serialize(self, output); /* SMS-STATUS-REPORT */
- case tsms_tpdu_mti_submit_report_mt: return _tsms_tpdu_report_serialize(self, output); /* SMS-SUBMIT-REPORT */
- default: return -2;
- }
- }
+ if(!self) {
+ return -1;
+ }
+
+ /* 3GPP TS 23.040 - 9.2.3.1 TP Message Type Indicator (TP MTI)
+ bit1 bit0 Message type
+ 0 0 SMS-DELIVER (in the direction SC to MS)
+ 0 0 SMS-DELIVER-REPORT (in the direction MS to SC)
+ 1 0 SMS-STATUS-REPORT (in the direction SC to MS)
+ 1 0 SMS-COMMAND (in the direction MS to SC)
+ 0 1 SMS-SUBMIT (in the direction MS to SC)
+ 0 1 SMS-SUBMIT-REPORT (in the direction SC to MS)
+ 1 1 Reserved
+ */
+ if(MobOrig) { /* MO */
+ switch(self->mti) {
+ case tsms_tpdu_mti_deliver_report_mo:
+ return _tsms_tpdu_report_serialize(self, output); /* SMS-DELIVER-REPORT */
+ case tsms_tpdu_mti_command_mo:
+ return _tsms_tpdu_command_serialize(self, output); /* SMS-COMMAND */
+ case tsms_tpdu_mti_submit_mo:
+ return _tsms_tpdu_submit_serialize(self, output); /* SMS-SUBMIT */
+ default:
+ return -2;
+ }
+ }
+ else { /* MT */
+ switch(self->mti) {
+ case tsms_tpdu_mti_deliver_mt:
+ return _tsms_tpdu_deliver_serialize(self, output); /* SMS-DELIVER */
+ case tsms_tpdu_mti_status_report_mt:
+ return _tsms_tpdu_status_report_serialize(self, output); /* SMS-STATUS-REPORT */
+ case tsms_tpdu_mti_submit_report_mt:
+ return _tsms_tpdu_report_serialize(self, output); /* SMS-SUBMIT-REPORT */
+ default:
+ return -2;
+ }
+ }
}
/**@ingroup tsms_tpdu_group
@@ -116,56 +124,70 @@ int tsms_tpdu_message_serialize(const tsms_tpdu_message_t* self, tsk_buffer_t* o
*/
tsms_tpdu_message_t* tsms_tpdu_message_deserialize(const void* data, tsk_size_t size, tsk_bool_t MobOrig)
{
- tsms_tpdu_mti_t mti;
- uint8_t smsc_len = 0;
- tsms_tpdu_message_t* ret = tsk_null;
-
- if(!data || size<=1){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_null;
- }
+ tsms_tpdu_mti_t mti;
+ uint8_t smsc_len = 0;
+ tsms_tpdu_message_t* ret = tsk_null;
+
+ if(!data || size<=1) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_null;
+ }
#if TSMS_TPDU_APPEND_SMSC
- smsc_len = *((uint8_t*)data) + 1/* len itself*/;
- if(smsc_len>=size){
- TSK_DEBUG_ERROR("Too short.");
- return tsk_null;
- }
+ smsc_len = *((uint8_t*)data) + 1/* len itself*/;
+ if(smsc_len>=size) {
+ TSK_DEBUG_ERROR("Too short.");
+ return tsk_null;
+ }
#endif
-
- mti = (*(((uint8_t*)data)+smsc_len) & 0x03);
-
- /* 3GPP TS 23.040 - 9.2.3.1 TP Message Type Indicator (TP MTI)
- bit1 bit0 Message type
- 0 0 SMS-DELIVER (in the direction SC to MS)
- 0 0 SMS-DELIVER-REPORT (in the direction MS to SC)
- 1 0 SMS-STATUS-REPORT (in the direction SC to MS)
- 1 0 SMS-COMMAND (in the direction MS to SC)
- 0 1 SMS-SUBMIT (in the direction MS to SC)
- 0 1 SMS-SUBMIT-REPORT (in the direction SC to MS)
- 1 1 Reserved
- */
- if(MobOrig){ /* MO */
- switch(mti){
- case tsms_tpdu_mti_deliver_report_mo: ret = _tsms_tpdu_report_deserialize(data, size); break; /* SMS-DELIVER-REPORT */
- case tsms_tpdu_mti_command_mo: ret = _tsms_tpdu_command_deserialize(data, size); break; /* SMS-COMMAND */
- case tsms_tpdu_mti_submit_mo: ret = _tsms_tpdu_submit_deserialize(data, size); break; /* SMS-SUBMIT */
- default: return tsk_null;
- }
- }
- else{ /* MT */
- switch(mti){
- case tsms_tpdu_mti_deliver_mt: ret = _tsms_tpdu_deliver_deserialize(data, size); break;/* SMS-DELIVER */
- case tsms_tpdu_mti_status_report_mt: ret = _tsms_tpdu_status_report_deserialize(data, size); break;/* SMS-STATUS-REPORT */
- case tsms_tpdu_mti_submit_report_mt: ret = _tsms_tpdu_report_deserialize(data, size); break;/* SMS-SUBMIT-REPORT */
- default: return tsk_null;
- }
- }
-
- if(ret){
- ret->MobOrig = MobOrig;
- }
- return ret;
+
+ mti = (*(((uint8_t*)data)+smsc_len) & 0x03);
+
+ /* 3GPP TS 23.040 - 9.2.3.1 TP Message Type Indicator (TP MTI)
+ bit1 bit0 Message type
+ 0 0 SMS-DELIVER (in the direction SC to MS)
+ 0 0 SMS-DELIVER-REPORT (in the direction MS to SC)
+ 1 0 SMS-STATUS-REPORT (in the direction SC to MS)
+ 1 0 SMS-COMMAND (in the direction MS to SC)
+ 0 1 SMS-SUBMIT (in the direction MS to SC)
+ 0 1 SMS-SUBMIT-REPORT (in the direction SC to MS)
+ 1 1 Reserved
+ */
+ if(MobOrig) { /* MO */
+ switch(mti) {
+ case tsms_tpdu_mti_deliver_report_mo:
+ ret = _tsms_tpdu_report_deserialize(data, size);
+ break; /* SMS-DELIVER-REPORT */
+ case tsms_tpdu_mti_command_mo:
+ ret = _tsms_tpdu_command_deserialize(data, size);
+ break; /* SMS-COMMAND */
+ case tsms_tpdu_mti_submit_mo:
+ ret = _tsms_tpdu_submit_deserialize(data, size);
+ break; /* SMS-SUBMIT */
+ default:
+ return tsk_null;
+ }
+ }
+ else { /* MT */
+ switch(mti) {
+ case tsms_tpdu_mti_deliver_mt:
+ ret = _tsms_tpdu_deliver_deserialize(data, size);
+ break;/* SMS-DELIVER */
+ case tsms_tpdu_mti_status_report_mt:
+ ret = _tsms_tpdu_status_report_deserialize(data, size);
+ break;/* SMS-STATUS-REPORT */
+ case tsms_tpdu_mti_submit_report_mt:
+ ret = _tsms_tpdu_report_deserialize(data, size);
+ break;/* SMS-SUBMIT-REPORT */
+ default:
+ return tsk_null;
+ }
+ }
+
+ if(ret) {
+ ret->MobOrig = MobOrig;
+ }
+ return ret;
}
/**@ingroup tsms_tpdu_group
@@ -173,21 +195,21 @@ tsms_tpdu_message_t* tsms_tpdu_message_deserialize(const void* data, tsk_size_t
*/
char* tsms_tpdu_message_tostring(const tsms_tpdu_message_t* self, tsk_bool_t MobOrig)
{
- char* ret = tsk_null;
- tsk_buffer_t* output = tsk_null;
- if(!self){
- goto bail;
- }
-
- if((output = tsk_buffer_create_null())){
- if(!tsms_tpdu_message_serialize(self, output, MobOrig)){
- ret = tsk_strndup(output->data, output->size);
- }
- TSK_OBJECT_SAFE_FREE(output);
- }
+ char* ret = tsk_null;
+ tsk_buffer_t* output = tsk_null;
+ if(!self) {
+ goto bail;
+ }
+
+ if((output = tsk_buffer_create_null())) {
+ if(!tsms_tpdu_message_serialize(self, output, MobOrig)) {
+ ret = tsk_strndup(output->data, output->size);
+ }
+ TSK_OBJECT_SAFE_FREE(output);
+ }
bail:
- return ret;
+ return ret;
}
/**@ingroup tsms_tpdu_group
@@ -200,24 +222,24 @@ bail:
*/
char* tsms_tpdu_message_tohexastring(const tsms_tpdu_message_t* self, tsk_bool_t MobOrig)
{
- char* ret = tsk_null;
- tsk_buffer_t* output = tsk_null;
- if(!self){
- goto bail;
- }
-
- if((output = tsk_buffer_create_null())){
- if(!tsms_tpdu_message_serialize(self, output, MobOrig)){
- tsk_size_t i;
- for(i=0;i<output->size;i++){
- tsk_strcat_2(&ret, "%.2X", *(TSK_BUFFER_TO_U8(output)+i));
- }
- }
- TSK_OBJECT_SAFE_FREE(output);
- }
+ char* ret = tsk_null;
+ tsk_buffer_t* output = tsk_null;
+ if(!self) {
+ goto bail;
+ }
+
+ if((output = tsk_buffer_create_null())) {
+ if(!tsms_tpdu_message_serialize(self, output, MobOrig)) {
+ tsk_size_t i;
+ for(i=0; i<output->size; i++) {
+ tsk_strcat_2(&ret, "%.2X", *(TSK_BUFFER_TO_U8(output)+i));
+ }
+ }
+ TSK_OBJECT_SAFE_FREE(output);
+ }
bail:
- return ret;
+ return ret;
}
/**@ingroup tsms_tpdu_group
@@ -227,25 +249,24 @@ bail:
*/
char* tsms_tpdu_message_get_payload(const tsms_tpdu_message_t* self)
{
- if(!self || !self->ud || !self->ud->data || !self->ud->size){
- TSK_DEBUG_WARN("No content.");
- return tsk_null;
- }
-
- switch(TSMS_ALPHA_FROM_DCS(self->dcs)){
- case tsms_alpha_7bit:
- return tsms_pack_from_7bit(self->ud->data, self->ud->size);
- case tsms_alpha_8bit:
- return tsms_pack_from_8bit(self->ud->data, self->ud->size);
- case tsms_alpha_ucs2:
- return tsms_pack_from_ucs2(self->ud->data, self->ud->size);
- case tsms_alpha_reserved:
- default:
- {
- TSK_DEBUG_ERROR("%d alpha not suported", TSMS_ALPHA_FROM_DCS(self->dcs));
- return tsk_null;
- }
- }
+ if(!self || !self->ud || !self->ud->data || !self->ud->size) {
+ TSK_DEBUG_WARN("No content.");
+ return tsk_null;
+ }
+
+ switch(TSMS_ALPHA_FROM_DCS(self->dcs)) {
+ case tsms_alpha_7bit:
+ return tsms_pack_from_7bit(self->ud->data, self->ud->size);
+ case tsms_alpha_8bit:
+ return tsms_pack_from_8bit(self->ud->data, self->ud->size);
+ case tsms_alpha_ucs2:
+ return tsms_pack_from_ucs2(self->ud->data, self->ud->size);
+ case tsms_alpha_reserved:
+ default: {
+ TSK_DEBUG_ERROR("%d alpha not suported", TSMS_ALPHA_FROM_DCS(self->dcs));
+ return tsk_null;
+ }
+ }
}
/**@ingroup tsms_tpdu_group
@@ -258,57 +279,56 @@ char* tsms_tpdu_message_get_payload(const tsms_tpdu_message_t* self)
*/
int tsms_tpdu_message_set_userdata(tsms_tpdu_message_t* self, const tsk_buffer_t* udata, tsms_alphabet_t alpha)
{
- if(!self || !udata){
- return -1;
- }
- /* SMS alphabet values as per 3GPP TS 23.038 v911 section 4.
- * Part of TP-DCS (SMS Data Coding Scheme).
- */
- self->dcs = ((self->dcs & 0xF3) | (alpha << 2)); /* Bit3 and Bit2 */
-
- TSK_OBJECT_SAFE_FREE(self->ud);
-
- /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
- * (alpha = SMS_ALPHA_7bit) ==> number of septets.
- * ((alpha == SMS_ALPHA_8bit) || (alpha == SMS_ALPHA_UCS2)) ==> number of octes.
- */
-
- /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
- switch(alpha){
- case tsms_alpha_7bit: {
- self->udl = (udata->size) + (udata->size/7);
- self->ud = tsk_buffer_create(udata->data, udata->size);
- }
- break;
- case tsms_alpha_8bit:
- case tsms_alpha_ucs2: {
- self->udl = udata->size;
- self->ud = tsk_buffer_create(udata->data, udata->size);
- }
- break;
-
- default:
- {
- TSK_DEBUG_ERROR("Invalid Alphabet.");
- return -2;
- }
- }
- return 0;
+ if(!self || !udata) {
+ return -1;
+ }
+ /* SMS alphabet values as per 3GPP TS 23.038 v911 section 4.
+ * Part of TP-DCS (SMS Data Coding Scheme).
+ */
+ self->dcs = ((self->dcs & 0xF3) | (alpha << 2)); /* Bit3 and Bit2 */
+
+ TSK_OBJECT_SAFE_FREE(self->ud);
+
+ /* 3GPP TS 23.040 ==> 9.2.3.16 TP-User-Data-Length (TP-UDL)
+ * (alpha = SMS_ALPHA_7bit) ==> number of septets.
+ * ((alpha == SMS_ALPHA_8bit) || (alpha == SMS_ALPHA_UCS2)) ==> number of octes.
+ */
+
+ /* 3GPP TS 23.040 ==> 9.2.3.24 TP-User Data (TP-UD) */
+ switch(alpha) {
+ case tsms_alpha_7bit: {
+ self->udl = (udata->size) + (udata->size/7);
+ self->ud = tsk_buffer_create(udata->data, udata->size);
+ }
+ break;
+ case tsms_alpha_8bit:
+ case tsms_alpha_ucs2: {
+ self->udl = udata->size;
+ self->ud = tsk_buffer_create(udata->data, udata->size);
+ }
+ break;
+
+ default: {
+ TSK_DEBUG_ERROR("Invalid Alphabet.");
+ return -2;
+ }
+ }
+ return 0;
}
/** internal function used to deinit a TP-Message.*/
int tsms_tpdu_message_deinit(tsms_tpdu_message_t* self)
{
- if(self){
- TSK_OBJECT_SAFE_FREE(self->ud);
- return 0;
- }
- return -1;
+ if(self) {
+ TSK_OBJECT_SAFE_FREE(self->ud);
+ return 0;
+ }
+ return -1;
}
-/* ======================== RPDU ========================
+/* ======================== RPDU ========================
=========================================================*/
extern int _tsms_rpdu_rpdata_serialize(const tsms_rpdu_message_t* self, tsk_buffer_t* output);
@@ -333,26 +353,26 @@ extern tsms_rpdu_message_t* _tsms_rpdu_rperror_deserialize(const void* data, tsk
*/
int tsms_rpdu_message_serialize(const tsms_rpdu_message_t* self, tsk_buffer_t* output)
{
- if(!self || !output){
- TSK_DEBUG_ERROR("Invalid Parameter");
- return -1;
- }
-
- switch(self->mti){
- case tsms_rpdu_type_data_mo:
- case tsms_rpdu_type_data_mt:
- return _tsms_rpdu_rpdata_serialize(self, output);
- case tsms_rpdu_type_ack_mo:
- case tsms_rpdu_type_ack_mt:
- return _tsms_rpdu_rpack_serialize(self, output);
- case tsms_rpdu_type_error_mo:
- case tsms_rpdu_type_error_mt:
- return _tsms_rpdu_rperror_serialize(self, output);
- case tsms_rpdu_type_smma_mo:
- return _tsms_rpdu_rpsmma_serialize(self, output);
- }
-
- return -2;
+ if(!self || !output) {
+ TSK_DEBUG_ERROR("Invalid Parameter");
+ return -1;
+ }
+
+ switch(self->mti) {
+ case tsms_rpdu_type_data_mo:
+ case tsms_rpdu_type_data_mt:
+ return _tsms_rpdu_rpdata_serialize(self, output);
+ case tsms_rpdu_type_ack_mo:
+ case tsms_rpdu_type_ack_mt:
+ return _tsms_rpdu_rpack_serialize(self, output);
+ case tsms_rpdu_type_error_mo:
+ case tsms_rpdu_type_error_mt:
+ return _tsms_rpdu_rperror_serialize(self, output);
+ case tsms_rpdu_type_smma_mo:
+ return _tsms_rpdu_rpsmma_serialize(self, output);
+ }
+
+ return -2;
}
/**@ingroup tsms_rpdu_group
@@ -363,30 +383,30 @@ int tsms_rpdu_message_serialize(const tsms_rpdu_message_t* self, tsk_buffer_t* o
*/
tsms_rpdu_message_t* tsms_rpdu_message_deserialize(const void* data, tsk_size_t size)
{
- tsms_rpdu_type_t mti;
-
- if(!data || size<2 /* MTI and MR*/){
- TSK_DEBUG_ERROR("Invalid parameter.");
- return tsk_null;
- }
-
- mti = (*((uint8_t*)data) & 0x07);
-
- switch(mti){
- case tsms_rpdu_type_data_mo:
- case tsms_rpdu_type_data_mt:
- return _tsms_rpdu_rpdata_deserialize(data, size);
- case tsms_rpdu_type_ack_mo:
- case tsms_rpdu_type_ack_mt:
- return _tsms_rpdu_rpack_deserialize(data, size);
- case tsms_rpdu_type_error_mo:
- case tsms_rpdu_type_error_mt:
- return _tsms_rpdu_rperror_deserialize(data, size);
- case tsms_rpdu_type_smma_mo:
- return _tsms_rpdu_rpsmma_deserialize(data, size);
- }
-
- return tsk_null;
+ tsms_rpdu_type_t mti;
+
+ if(!data || size<2 /* MTI and MR*/) {
+ TSK_DEBUG_ERROR("Invalid parameter.");
+ return tsk_null;
+ }
+
+ mti = (*((uint8_t*)data) & 0x07);
+
+ switch(mti) {
+ case tsms_rpdu_type_data_mo:
+ case tsms_rpdu_type_data_mt:
+ return _tsms_rpdu_rpdata_deserialize(data, size);
+ case tsms_rpdu_type_ack_mo:
+ case tsms_rpdu_type_ack_mt:
+ return _tsms_rpdu_rpack_deserialize(data, size);
+ case tsms_rpdu_type_error_mo:
+ case tsms_rpdu_type_error_mt:
+ return _tsms_rpdu_rperror_deserialize(data, size);
+ case tsms_rpdu_type_smma_mo:
+ return _tsms_rpdu_rpsmma_deserialize(data, size);
+ }
+
+ return tsk_null;
}
/**@ingroup tsms_rpdu_group
@@ -396,22 +416,22 @@ tsms_rpdu_message_t* tsms_rpdu_message_deserialize(const void* data, tsk_size_t
*/
char* tsms_rpdu_message_tohexastring(const tsms_rpdu_message_t* self)
{
- char* ret = tsk_null;
- tsk_buffer_t* output = tsk_null;
- if(!self){
- goto bail;
- }
-
- if((output = tsk_buffer_create_null())){
- if(!tsms_rpdu_message_serialize(self, output)){
- tsk_size_t i;
- for(i=0;i<output->size;i++){
- tsk_strcat_2(&ret, "%.2X", *(TSK_BUFFER_TO_U8(output)+i));
- }
- }
- TSK_OBJECT_SAFE_FREE(output);
- }
+ char* ret = tsk_null;
+ tsk_buffer_t* output = tsk_null;
+ if(!self) {
+ goto bail;
+ }
+
+ if((output = tsk_buffer_create_null())) {
+ if(!tsms_rpdu_message_serialize(self, output)) {
+ tsk_size_t i;
+ for(i=0; i<output->size; i++) {
+ tsk_strcat_2(&ret, "%.2X", *(TSK_BUFFER_TO_U8(output)+i));
+ }
+ }
+ TSK_OBJECT_SAFE_FREE(output);
+ }
bail:
- return ret;
+ return ret;
}
diff --git a/tinySMS/src/tsms_packing.c b/tinySMS/src/tsms_packing.c
index 9f9f916..8a833bf 100755
--- a/tinySMS/src/tsms_packing.c
+++ b/tinySMS/src/tsms_packing.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -48,95 +48,95 @@
*/
tsk_buffer_t* tsms_pack_to_7bit(const char* ascii)
{
- /* 3GPP TS 23.038 - 6.1.2.1.1 Packing of 7-bit characters
- If a character number $ is noted in the following way:
- b7 b6 b5 b4 b3 b2 b1
- $a $b $c $d $e $f $g
- The packing of the 7-bitscharacters in octets is done by completing the octets with zeros on the left.
- For examples, packing: $
- - one character in one octet:
- - bits number:
- 7 6 5 4 3 2 1 0
- 0 1a 1b 1c 1d 1e 1f 1g
-
- - two characters in two octets:
- - bits number:
- 7 6 5 4 3 2 1 0
- 2g 1a 1b 1c 1d 1e 1f 1g
- 0 0 2a 2b 2c 2d 2e 2f
-
- - three characters in three octets:
- - bits number:
- 7 6 5 4 3 2 1 0
- 2g 1a 1b 1c 1d 1e 1f 1g
- 3f 3g 2a 2b 2c 2d 2e 2f
- 0 0 0 3a 3b 3c 3d 3e
-
- - seven characters in seven octets:
- - bits number:
- 7 6 5 4 3 2 1 0
- 2g 1a 1b 1c 1d 1e 1f 1g
- 3f 3g 2a 2b 2c 2d 2e 2f
- 4e 4f 4g 3a 3b 3c 3d 3e
- 5d 5e 5f 5g 4a 4b 4c 4d
- 6c 6d 6e 6f 6g 5a 5b 5c
- 7b 7c 7d 7e 7f 7g 6a 6b
- 0 0 0 0 0 0 0 7a
-
- - eight characters in seven octets:
- - bits number:
- 7 6 5 4 3 2 1 0
- 2g 1a 1b 1c 1d 1e 1f 1g
- 3f 3g 2a 2b 2c 2d 2e 2f
- 4e 4f 4g 3a 3b 3c 3d 3e
- 5d 5e 5f 5g 4a 4b 4c 4d
- 6c 6d 6e 6f 6g 5a 5b 5c
- 7b 7c 7d 7e 7f 7g 6a 6b
- 8a 8b 8c 8d 8e 8f 8g 7a
-
- The bit number zero is always transmitted first.
- Therefore, in 140 octets, it is possible to pack (140x8)/7=160 characters.
- */
- tsk_buffer_t* ret = tsk_null;
- uint8_t* _ret = tsk_null;
- register tsk_size_t len, bcount = 1/*1-7*/, index = 0, retindex = 0, retlen = 0;
- const uint8_t* pascii = (const uint8_t*)ascii;
-
- if(!ascii || !(len = strlen(ascii))){
- TSK_DEBUG_WARN("Null or Empty ascci string.");
- goto bail;
- }
-
- retlen = len - (len/7) + 1;
- if(!(_ret = tsk_calloc(retlen, sizeof(uint8_t)))){
- goto bail;
- }
-
- while(index < len){
- if(index == 0){
- _ret[retindex] |= (pascii[index] & (0xFF >> bcount)) |
- (pascii[index+1] << (8 - bcount));
- }
- else{
- _ret[retindex] = ((pascii[index] >> (bcount - 1))& (0xFF >> bcount))
- | (pascii[index+1] <<(8-bcount));
- }
-
- /* how many bytes to use to complete on the left? */
- if(++bcount == 8){
- bcount = 1, ++index;
- }
- /* next */
- retindex++;
- index++;
- }
-
- /* creat ret */
- ret = tsk_buffer_create(_ret, (retlen-1));
+ /* 3GPP TS 23.038 - 6.1.2.1.1 Packing of 7-bit characters
+ If a character number $ is noted in the following way:
+ b7 b6 b5 b4 b3 b2 b1
+ $a $b $c $d $e $f $g
+ The packing of the 7-bitscharacters in octets is done by completing the octets with zeros on the left.
+ For examples, packing: $
+ - one character in one octet:
+ - bits number:
+ 7 6 5 4 3 2 1 0
+ 0 1a 1b 1c 1d 1e 1f 1g
+
+ - two characters in two octets:
+ - bits number:
+ 7 6 5 4 3 2 1 0
+ 2g 1a 1b 1c 1d 1e 1f 1g
+ 0 0 2a 2b 2c 2d 2e 2f
+
+ - three characters in three octets:
+ - bits number:
+ 7 6 5 4 3 2 1 0
+ 2g 1a 1b 1c 1d 1e 1f 1g
+ 3f 3g 2a 2b 2c 2d 2e 2f
+ 0 0 0 3a 3b 3c 3d 3e
+
+ - seven characters in seven octets:
+ - bits number:
+ 7 6 5 4 3 2 1 0
+ 2g 1a 1b 1c 1d 1e 1f 1g
+ 3f 3g 2a 2b 2c 2d 2e 2f
+ 4e 4f 4g 3a 3b 3c 3d 3e
+ 5d 5e 5f 5g 4a 4b 4c 4d
+ 6c 6d 6e 6f 6g 5a 5b 5c
+ 7b 7c 7d 7e 7f 7g 6a 6b
+ 0 0 0 0 0 0 0 7a
+
+ - eight characters in seven octets:
+ - bits number:
+ 7 6 5 4 3 2 1 0
+ 2g 1a 1b 1c 1d 1e 1f 1g
+ 3f 3g 2a 2b 2c 2d 2e 2f
+ 4e 4f 4g 3a 3b 3c 3d 3e
+ 5d 5e 5f 5g 4a 4b 4c 4d
+ 6c 6d 6e 6f 6g 5a 5b 5c
+ 7b 7c 7d 7e 7f 7g 6a 6b
+ 8a 8b 8c 8d 8e 8f 8g 7a
+
+ The bit number zero is always transmitted first.
+ Therefore, in 140 octets, it is possible to pack (140x8)/7=160 characters.
+ */
+ tsk_buffer_t* ret = tsk_null;
+ uint8_t* _ret = tsk_null;
+ register tsk_size_t len, bcount = 1/*1-7*/, index = 0, retindex = 0, retlen = 0;
+ const uint8_t* pascii = (const uint8_t*)ascii;
+
+ if(!ascii || !(len = strlen(ascii))) {
+ TSK_DEBUG_WARN("Null or Empty ascci string.");
+ goto bail;
+ }
+
+ retlen = len - (len/7) + 1;
+ if(!(_ret = tsk_calloc(retlen, sizeof(uint8_t)))) {
+ goto bail;
+ }
+
+ while(index < len) {
+ if(index == 0) {
+ _ret[retindex] |= (pascii[index] & (0xFF >> bcount)) |
+ (pascii[index+1] << (8 - bcount));
+ }
+ else {
+ _ret[retindex] = ((pascii[index] >> (bcount - 1))& (0xFF >> bcount))
+ | (pascii[index+1] <<(8-bcount));
+ }
+
+ /* how many bytes to use to complete on the left? */
+ if(++bcount == 8) {
+ bcount = 1, ++index;
+ }
+ /* next */
+ retindex++;
+ index++;
+ }
+
+ /* creat ret */
+ ret = tsk_buffer_create(_ret, (retlen-1));
bail:
- TSK_FREE(_ret);
-
- return ret;
+ TSK_FREE(_ret);
+
+ return ret;
}
/**@ingroup tsms_packing_group
@@ -147,36 +147,36 @@ bail:
*/
tsk_buffer_t* tsms_pack_to_ucs2(const char* ascii)
{
- register tsk_size_t i, j;
- tsk_size_t len, retlen = 0;
- uint8_t* str = tsk_null;
- tsk_buffer_t* ret = tsk_null;
-
- if(!ascii || !(len=strlen(ascii))){
- TSK_DEBUG_WARN("Null or Empty gsm7bit buffer.");
- goto bail;
- }
-
- if(!(str = tsk_calloc(len, sizeof(uint8_t)*2))){
- goto bail;
- }
-
- /* very bas way to do conversion ==> to be fixed */
- for(i=0; i<len; i++){
- for(j=0; j<TSMS_ETSI_GSM_03_38_COUNT; j++){
- if((uint8_t)ascii[i] == (uint8_t)(TSMS_ETSI_GSM_03_38[j][1] & 0xFF)){
- retlen++; /* 00 */
- *(str + retlen++) = (TSMS_ETSI_GSM_03_38[j][0] & 0xFF);
- }
- }
- }
-
- /* create buffer */
- ret = tsk_buffer_create(str, retlen);
+ register tsk_size_t i, j;
+ tsk_size_t len, retlen = 0;
+ uint8_t* str = tsk_null;
+ tsk_buffer_t* ret = tsk_null;
+
+ if(!ascii || !(len=strlen(ascii))) {
+ TSK_DEBUG_WARN("Null or Empty gsm7bit buffer.");
+ goto bail;
+ }
+
+ if(!(str = tsk_calloc(len, sizeof(uint8_t)*2))) {
+ goto bail;
+ }
+
+ /* very bas way to do conversion ==> to be fixed */
+ for(i=0; i<len; i++) {
+ for(j=0; j<TSMS_ETSI_GSM_03_38_COUNT; j++) {
+ if((uint8_t)ascii[i] == (uint8_t)(TSMS_ETSI_GSM_03_38[j][1] & 0xFF)) {
+ retlen++; /* 00 */
+ *(str + retlen++) = (TSMS_ETSI_GSM_03_38[j][0] & 0xFF);
+ }
+ }
+ }
+
+ /* create buffer */
+ ret = tsk_buffer_create(str, retlen);
bail:
- TSK_FREE(str);
- return ret;
+ TSK_FREE(str);
+ return ret;
}
/**@ingroup tsms_packing_group
@@ -187,36 +187,36 @@ bail:
*/
tsk_buffer_t* tsms_pack_to_8bit(const char* ascii)
{
- register tsk_size_t i, j;
- tsk_size_t len, retlen = 0;
- uint8_t* str = tsk_null;
- tsk_buffer_t* ret = tsk_null;
-
- if(!ascii || !(len=strlen(ascii))){
- TSK_DEBUG_WARN("Null or Empty gsm7bit buffer.");
- goto bail;
- }
-
- if(!(str = tsk_calloc(len, sizeof(uint8_t)))){
- goto bail;
- }
-
- /* very bas way to do conversion ==> to be fixed */
- for(i = 0; i<len; i++){
- for(j = 0; j<TSMS_ETSI_GSM_03_38_COUNT; j++){
- if((uint8_t)ascii[i] == (uint8_t)(TSMS_ETSI_GSM_03_38[j][1] & 0xFF)){
- *(str + retlen++) = (TSMS_ETSI_GSM_03_38[j][0] & 0xFF);
- continue;
- }
- }
- }
-
- /* create buffer */
- ret = tsk_buffer_create(str, retlen);
+ register tsk_size_t i, j;
+ tsk_size_t len, retlen = 0;
+ uint8_t* str = tsk_null;
+ tsk_buffer_t* ret = tsk_null;
+
+ if(!ascii || !(len=strlen(ascii))) {
+ TSK_DEBUG_WARN("Null or Empty gsm7bit buffer.");
+ goto bail;
+ }
+
+ if(!(str = tsk_calloc(len, sizeof(uint8_t)))) {
+ goto bail;
+ }
+
+ /* very bas way to do conversion ==> to be fixed */
+ for(i = 0; i<len; i++) {
+ for(j = 0; j<TSMS_ETSI_GSM_03_38_COUNT; j++) {
+ if((uint8_t)ascii[i] == (uint8_t)(TSMS_ETSI_GSM_03_38[j][1] & 0xFF)) {
+ *(str + retlen++) = (TSMS_ETSI_GSM_03_38[j][0] & 0xFF);
+ continue;
+ }
+ }
+ }
+
+ /* create buffer */
+ ret = tsk_buffer_create(str, retlen);
bail:
- TSK_FREE(str);
- return ret;
+ TSK_FREE(str);
+ return ret;
}
/**@ingroup tsms_packing_group
@@ -228,45 +228,45 @@ bail:
*/
char* tsms_pack_from_7bit(const void* gsm7bit, tsk_size_t size)
{
- char* ret = tsk_null;
- register tsk_size_t bcount = 1/*1-7*/, index = 0, retindex = 0, retsize = 0;
- const uint8_t* pgsm7bit = gsm7bit;
-
- if(!gsm7bit || !size){
- TSK_DEBUG_WARN("Null or Empty gsm7bit buffer.");
- goto bail;
- }
-
- // dup the gsm7bit buffer
- retsize = size + (size/7) + 1; // variable used for debug
- if(!(ret = tsk_calloc(retsize, sizeof(uint8_t)))){
- goto bail;
- }
-
- while(index < size){
- ret[retindex] = (pgsm7bit[index] & (0xFF >>bcount));
- if(index){
- ret[retindex] = (ret[retindex] << (bcount - 1))
- | (pgsm7bit[index-1] >> (8 - bcount + 1));
- }
-
- /* how many bytes to use to complete on the right? */
- if(bcount++ == 8){
- bcount = 1, --index;
- }
- /* next */
- index++;
- retindex++;
- }
-
- /* special one */
- if(!(size%7)){
- ret[retindex] = pgsm7bit[size-1]>>1;
- }
-
+ char* ret = tsk_null;
+ register tsk_size_t bcount = 1/*1-7*/, index = 0, retindex = 0, retsize = 0;
+ const uint8_t* pgsm7bit = gsm7bit;
+
+ if(!gsm7bit || !size) {
+ TSK_DEBUG_WARN("Null or Empty gsm7bit buffer.");
+ goto bail;
+ }
+
+ // dup the gsm7bit buffer
+ retsize = size + (size/7) + 1; // variable used for debug
+ if(!(ret = tsk_calloc(retsize, sizeof(uint8_t)))) {
+ goto bail;
+ }
+
+ while(index < size) {
+ ret[retindex] = (pgsm7bit[index] & (0xFF >>bcount));
+ if(index) {
+ ret[retindex] = (ret[retindex] << (bcount - 1))
+ | (pgsm7bit[index-1] >> (8 - bcount + 1));
+ }
+
+ /* how many bytes to use to complete on the right? */
+ if(bcount++ == 8) {
+ bcount = 1, --index;
+ }
+ /* next */
+ index++;
+ retindex++;
+ }
+
+ /* special one */
+ if(!(size%7)) {
+ ret[retindex] = pgsm7bit[size-1]>>1;
+ }
+
bail:
-
- return ret;
+
+ return ret;
}
/**@ingroup tsms_packing_group
@@ -278,31 +278,31 @@ bail:
*/
char* tsms_pack_from_ucs2(const void* ucs2, tsk_size_t size)
{
- register tsk_size_t i, j;
- char* ret = tsk_null;
-
- const uint16_t* pucs2 = ucs2;
-
- if(!ucs2 || !size){
- TSK_DEBUG_WARN("Null or Empty gsm8bit buffer.");
- goto bail;
- }
-
- if(!(ret = tsk_calloc(size+1, sizeof(uint8_t)))){
- goto bail;
- }
-
- for(i=0; i<size; i++){
- for(j=0; j<TSMS_ETSI_GSM_03_38_COUNT; j++){
- if(*(pucs2 + i) == (TSMS_ETSI_GSM_03_38[j][0])){
- *(ret+i) = (TSMS_ETSI_GSM_03_38[j][1] & 0xFF);
- continue;
- }
- }
- }
+ register tsk_size_t i, j;
+ char* ret = tsk_null;
+
+ const uint16_t* pucs2 = ucs2;
+
+ if(!ucs2 || !size) {
+ TSK_DEBUG_WARN("Null or Empty gsm8bit buffer.");
+ goto bail;
+ }
+
+ if(!(ret = tsk_calloc(size+1, sizeof(uint8_t)))) {
+ goto bail;
+ }
+
+ for(i=0; i<size; i++) {
+ for(j=0; j<TSMS_ETSI_GSM_03_38_COUNT; j++) {
+ if(*(pucs2 + i) == (TSMS_ETSI_GSM_03_38[j][0])) {
+ *(ret+i) = (TSMS_ETSI_GSM_03_38[j][1] & 0xFF);
+ continue;
+ }
+ }
+ }
bail:
- return ret;
+ return ret;
}
/**@ingroup tsms_packing_group
@@ -314,30 +314,30 @@ bail:
*/
char* tsms_pack_from_8bit(const void* gsm8bit, tsk_size_t size)
{
- register tsk_size_t i, j;
- char* ret = tsk_null;
-
- const uint8_t* pgsm8bit = gsm8bit;
-
- if(!gsm8bit || !size){
- TSK_DEBUG_WARN("Null or Empty gsm8bit buffer.");
- goto bail;
- }
-
- if(!(ret = tsk_calloc(size+1, sizeof(uint8_t)))){
- goto bail;
- }
-
- /* Very bad way to do convertion ==> to be changed */
- for(i=0; i<size; i++){
- for(j=0; j<TSMS_ETSI_GSM_03_38_COUNT; j++){
- if(*(pgsm8bit + i) == (TSMS_ETSI_GSM_03_38[j][0] & 0xFF)){
- *(ret+i) = (TSMS_ETSI_GSM_03_38[j][1] & 0xFF);
- continue;
- }
- }
- }
+ register tsk_size_t i, j;
+ char* ret = tsk_null;
+
+ const uint8_t* pgsm8bit = gsm8bit;
+
+ if(!gsm8bit || !size) {
+ TSK_DEBUG_WARN("Null or Empty gsm8bit buffer.");
+ goto bail;
+ }
+
+ if(!(ret = tsk_calloc(size+1, sizeof(uint8_t)))) {
+ goto bail;
+ }
+
+ /* Very bad way to do convertion ==> to be changed */
+ for(i=0; i<size; i++) {
+ for(j=0; j<TSMS_ETSI_GSM_03_38_COUNT; j++) {
+ if(*(pgsm8bit + i) == (TSMS_ETSI_GSM_03_38[j][0] & 0xFF)) {
+ *(ret+i) = (TSMS_ETSI_GSM_03_38[j][1] & 0xFF);
+ continue;
+ }
+ }
+ }
bail:
- return ret;
+ return ret;
}
diff --git a/tinySMS/test/stdafx.c b/tinySMS/test/stdafx.c
index a98e092..938920a 100755
--- a/tinySMS/test/stdafx.c
+++ b/tinySMS/test/stdafx.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
diff --git a/tinySMS/test/stdafx.h b/tinySMS/test/stdafx.h
index d87dff0..7015ac9 100755
--- a/tinySMS/test/stdafx.h
+++ b/tinySMS/test/stdafx.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
diff --git a/tinySMS/test/targetver.h b/tinySMS/test/targetver.h
index a4c6bd1..920ad46 100755
--- a/tinySMS/test/targetver.h
+++ b/tinySMS/test/targetver.h
@@ -1,8 +1,8 @@
#ifndef SMS_TEST_TARGETVER_H
#define SMS_TEST_TARGETVER_H
// The following macros define the minimum required platform. The minimum required platform
-// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
-// your application. The macros work by enabling all features available on platform versions up to and
+// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
+// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
diff --git a/tinySMS/test/test.c b/tinySMS/test/test.c
index 538cd16..a1f7717 100755
--- a/tinySMS/test/test.c
+++ b/tinySMS/test/test.c
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -27,38 +27,38 @@
char* tohex(uint8_t* ptr, size_t size)
{
- char* ret = tsk_null;
- size_t i;
- for(i=0;i<size;i++){
- tsk_strcat_2(&ret, "%.2X", *ptr++);
- }
- return ret;
+ char* ret = tsk_null;
+ size_t i;
+ for(i=0; i<size; i++) {
+ tsk_strcat_2(&ret, "%.2X", *ptr++);
+ }
+ return ret;
}
void printhex(const char* what, uint8_t* ptr, size_t size)
{
- size_t i;
- printf("%s", what);
- for(i=0;i<size;i++){
- printf("%.2X", *ptr++);
- }
- printf("\n");
+ size_t i;
+ printf("%s", what);
+ for(i=0; i<size; i++) {
+ printf("%.2X", *ptr++);
+ }
+ printf("\n");
}
tsk_bool_t bin_equals(const uint8_t* b1, const uint8_t* b2, size_t size)
{
- size_t i;
-
- // we assume that sizeof(b1)==sizeof(b2)
- if(!b1 || !b2 || !size){
- return tsk_false;
- }
- for(i=0; i<size;i++){
- if(b1[i] != b2[i]){
- return tsk_false;
- }
- }
- return tsk_true;
+ size_t i;
+
+ // we assume that sizeof(b1)==sizeof(b2)
+ if(!b1 || !b2 || !size) {
+ return tsk_false;
+ }
+ for(i=0; i<size; i++) {
+ if(b1[i] != b2[i]) {
+ return tsk_false;
+ }
+ }
+ return tsk_true;
}
@@ -82,23 +82,23 @@ int main()
#endif
{
#if RUN_TEST_LOOP
- for(;;)
+ for(;;)
#endif
- {
- /* Print copyright information */
- printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");
-
+ {
+ /* Print copyright information */
+ printf("Doubango Project\nCopyright (C) 2009 - 2010 Mamadou Diop \n\n");
+
#if RUN_TEST_ALL || RUN_TEST_PACKING
- test_packing();
+ test_packing();
#endif
#if RUN_TEST_ALL || RUN_TEST_TPDU
- test_tpdu();
+ test_tpdu();
#endif
#if RUN_TEST_ALL || RUN_TEST_RPDU
- test_rpdu();
+ test_rpdu();
#endif
- }
+ }
} \ No newline at end of file
diff --git a/tinySMS/test/test_packing.h b/tinySMS/test/test_packing.h
index d37ef33..f83da14 100755
--- a/tinySMS/test/test_packing.h
+++ b/tinySMS/test/test_packing.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -22,119 +22,118 @@
#ifndef _TEST_SMSPACKING_H
#define _TEST_SMSPACKING_H
-typedef struct test_message_7bit_s{
- const char* ascii;
- const char* _7bit;
+typedef struct test_message_7bit_s {
+ const char* ascii;
+ const char* _7bit;
}
test_message_7bit_t;
-test_message_7bit_t test_messages_7bit[] =
-{
- "a","\x61",
- "ab","\x61\x31",
- "abc","\x61\xF1\x18",
- "abcdefg","\x61\xF1\x98\x5C\x36\x9F\x01",
- "abcdefgh","\x61\xF1\x98\x5C\x36\x9F\xD1",
- "abcdefghi","\x61\xF1\x98\x5C\x36\x9F\xD1\x69",
- "abcdefgh12345678","\x61\xF1\x98\x5C\x36\x9F\xD1\x31\xD9\x8C\x56\xB3\xDD\x70",
- "abcdefgh123456789","\x61\xF1\x98\x5C\x36\x9F\xD1\x31\xD9\x8C\x56\xB3\xDD\x70\x39",
- "This is a test sms message","\x54\x74\x7A\x0E\x4A\xCF\x41\x61\x10\xBD\x3C\xA7\x83\xE6\xED\x39\xA8\x5D\x9E\xCF\xC3\xE7\x32",
- "salut","\xF3\x30\xBB\x4E\x07",
- "hellohello","\xE8\x32\x9B\xFD\x46\x97\xD9\xEC\x37",
+test_message_7bit_t test_messages_7bit[] = {
+ "a","\x61",
+ "ab","\x61\x31",
+ "abc","\x61\xF1\x18",
+ "abcdefg","\x61\xF1\x98\x5C\x36\x9F\x01",
+ "abcdefgh","\x61\xF1\x98\x5C\x36\x9F\xD1",
+ "abcdefghi","\x61\xF1\x98\x5C\x36\x9F\xD1\x69",
+ "abcdefgh12345678","\x61\xF1\x98\x5C\x36\x9F\xD1\x31\xD9\x8C\x56\xB3\xDD\x70",
+ "abcdefgh123456789","\x61\xF1\x98\x5C\x36\x9F\xD1\x31\xD9\x8C\x56\xB3\xDD\x70\x39",
+ "This is a test sms message","\x54\x74\x7A\x0E\x4A\xCF\x41\x61\x10\xBD\x3C\xA7\x83\xE6\xED\x39\xA8\x5D\x9E\xCF\xC3\xE7\x32",
+ "salut","\xF3\x30\xBB\x4E\x07",
+ "hellohello","\xE8\x32\x9B\xFD\x46\x97\xD9\xEC\x37",
};
void test_7bit()
{
- tsk_size_t i;
- tsk_buffer_t* buffer;
- char* temp;
+ tsk_size_t i;
+ tsk_buffer_t* buffer;
+ char* temp;
- /* To 7bit */
- for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++){
- if((buffer = tsms_pack_to_7bit(test_messages_7bit[i].ascii))){
- /*if((temp = tohex(buffer->data, buffer->size))){
- if(!tsk_striequals(temp, test_messages_7bit[i]._7bit)){
- TSK_DEBUG_ERROR("tsms_pack_to_7bit(\"%s\") Failed.\n", test_messages_7bit[i].ascii);
- }
- TSK_FREE(temp);
- }*/
- if(!bin_equals(buffer->data, test_messages_7bit[i]._7bit, buffer->size)){
- TSK_DEBUG_ERROR("tsms_pack_to_7bit(\"%s\") Failed.\n", test_messages_7bit[i].ascii);
- }
- TSK_OBJECT_SAFE_FREE(buffer);
- }
- }
+ /* To 7bit */
+ for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++) {
+ if((buffer = tsms_pack_to_7bit(test_messages_7bit[i].ascii))) {
+ /*if((temp = tohex(buffer->data, buffer->size))){
+ if(!tsk_striequals(temp, test_messages_7bit[i]._7bit)){
+ TSK_DEBUG_ERROR("tsms_pack_to_7bit(\"%s\") Failed.\n", test_messages_7bit[i].ascii);
+ }
+ TSK_FREE(temp);
+ }*/
+ if(!bin_equals(buffer->data, test_messages_7bit[i]._7bit, buffer->size)) {
+ TSK_DEBUG_ERROR("tsms_pack_to_7bit(\"%s\") Failed.\n", test_messages_7bit[i].ascii);
+ }
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+ }
- /* From 7bit */
- for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++){
- if((temp = tsms_pack_from_7bit(test_messages_7bit[i]._7bit, (tsk_size_t)tsk_strlen(test_messages_7bit[i]._7bit)))){
- if(!tsk_striequals(temp, test_messages_7bit[i].ascii)){
- TSK_DEBUG_ERROR("tsms_pack_from_7bit(\"%s\") Failed.\n", test_messages_7bit[i].ascii);
- }
- TSK_FREE(temp);
- }
- }
+ /* From 7bit */
+ for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++) {
+ if((temp = tsms_pack_from_7bit(test_messages_7bit[i]._7bit, (tsk_size_t)tsk_strlen(test_messages_7bit[i]._7bit)))) {
+ if(!tsk_striequals(temp, test_messages_7bit[i].ascii)) {
+ TSK_DEBUG_ERROR("tsms_pack_from_7bit(\"%s\") Failed.\n", test_messages_7bit[i].ascii);
+ }
+ TSK_FREE(temp);
+ }
+ }
}
void test_8bit()
{
- tsk_size_t i;
- tsk_buffer_t* buffer;
- char* temp;
-
- /* To 8bit */
- for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++){
- if((buffer = tsms_pack_to_8bit(test_messages_7bit[i].ascii))){
- if(!tsk_strequals(buffer->data, test_messages_7bit[i].ascii)){
- TSK_DEBUG_INFO("tsms_pack_to_8bit(%s) Failed", test_messages_7bit[i].ascii);
- }
- TSK_OBJECT_SAFE_FREE(buffer);
- }
- }
+ tsk_size_t i;
+ tsk_buffer_t* buffer;
+ char* temp;
+
+ /* To 8bit */
+ for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++) {
+ if((buffer = tsms_pack_to_8bit(test_messages_7bit[i].ascii))) {
+ if(!tsk_strequals(buffer->data, test_messages_7bit[i].ascii)) {
+ TSK_DEBUG_INFO("tsms_pack_to_8bit(%s) Failed", test_messages_7bit[i].ascii);
+ }
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+ }
- /* From 8bit */
- for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++){
- if((temp = tsms_pack_from_8bit(test_messages_7bit[i].ascii, (tsk_size_t)tsk_strlen(test_messages_7bit[i].ascii)))){
- if(!tsk_strequals(temp, test_messages_7bit[i].ascii)){
- TSK_DEBUG_INFO("tsms_pack_from_8bit(%s) Failed", test_messages_7bit[i].ascii);
- }
- TSK_FREE(temp);
- }
- }
+ /* From 8bit */
+ for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++) {
+ if((temp = tsms_pack_from_8bit(test_messages_7bit[i].ascii, (tsk_size_t)tsk_strlen(test_messages_7bit[i].ascii)))) {
+ if(!tsk_strequals(temp, test_messages_7bit[i].ascii)) {
+ TSK_DEBUG_INFO("tsms_pack_from_8bit(%s) Failed", test_messages_7bit[i].ascii);
+ }
+ TSK_FREE(temp);
+ }
+ }
}
void test_ucs2()
{
- tsk_size_t i;
- tsk_buffer_t* buffer;
- char* temp;
-
- /* To ucs2 */
- for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++){
- if((buffer = tsms_pack_to_ucs2(test_messages_7bit[i].ascii))){
- if(!tsk_strequals(buffer->data, test_messages_7bit[i].ascii)){
- TSK_DEBUG_INFO("tsms_pack_to_ucs2(%s) Failed", test_messages_7bit[i].ascii);
- }
- TSK_OBJECT_SAFE_FREE(buffer);
- }
- }
+ tsk_size_t i;
+ tsk_buffer_t* buffer;
+ char* temp;
+
+ /* To ucs2 */
+ for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++) {
+ if((buffer = tsms_pack_to_ucs2(test_messages_7bit[i].ascii))) {
+ if(!tsk_strequals(buffer->data, test_messages_7bit[i].ascii)) {
+ TSK_DEBUG_INFO("tsms_pack_to_ucs2(%s) Failed", test_messages_7bit[i].ascii);
+ }
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+ }
- /* From ucs2 */
- for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++){
- if((temp = tsms_pack_from_ucs2(test_messages_7bit[i].ascii, (tsk_size_t)tsk_strlen(test_messages_7bit[i].ascii)))){
- if(!tsk_strequals(temp, test_messages_7bit[i].ascii)){
- TSK_DEBUG_INFO("tsms_pack_from_ucs2(%s) Failed", test_messages_7bit[i].ascii);
- }
- TSK_FREE(temp);
- }
- }
+ /* From ucs2 */
+ for(i=0; i<sizeof(test_messages_7bit)/sizeof(test_message_7bit_t); i++) {
+ if((temp = tsms_pack_from_ucs2(test_messages_7bit[i].ascii, (tsk_size_t)tsk_strlen(test_messages_7bit[i].ascii)))) {
+ if(!tsk_strequals(temp, test_messages_7bit[i].ascii)) {
+ TSK_DEBUG_INFO("tsms_pack_from_ucs2(%s) Failed", test_messages_7bit[i].ascii);
+ }
+ TSK_FREE(temp);
+ }
+ }
}
void test_packing()
{
- test_ucs2();
- test_8bit();
- test_7bit();
+ test_ucs2();
+ test_8bit();
+ test_7bit();
}
#endif /* _TEST_SMSPACKING_H */
diff --git a/tinySMS/test/test_rpdu.h b/tinySMS/test/test_rpdu.h
index 11044e7..066ab0a 100755
--- a/tinySMS/test/test_rpdu.h
+++ b/tinySMS/test/test_rpdu.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -24,249 +24,244 @@
void test_i_rpdata(const void* data, tsk_size_t size, tsk_bool_t MobOrig)
{
- tsms_rpdu_message_t* rp_message = tsk_null;
- tsms_tpdu_message_t* tpdu = tsk_null;
+ tsms_rpdu_message_t* rp_message = tsk_null;
+ tsms_tpdu_message_t* tpdu = tsk_null;
- if(!(rp_message = tsms_rpdu_message_deserialize(data, size))){
- TSK_DEBUG_ERROR("Failed to deserialize the RP-MESSAGE");
- goto bail;
- }
-
- switch(rp_message->mti){
- case tsms_rpdu_type_data_mo:
- case tsms_rpdu_type_data_mt:
- {
- char* ascii = tsk_null;
- tsms_rpdu_data_t* rp_data = TSMS_RPDU_DATA(rp_message);
- if((tpdu = tsms_tpdu_message_deserialize(rp_data->udata->data, rp_data->udata->size, MobOrig))){
- if(tpdu->mti == tsms_tpdu_mti_deliver_mt || tpdu->mti == tsms_tpdu_mti_submit_mo){ /* SMS-SUBMIT or SMS-DELIVER? */
- if((ascii = tsms_tpdu_message_get_payload(tpdu))){
- TSK_DEBUG_INFO("ASCII message=%s", ascii);
- TSK_FREE(ascii);
- }
- }
- }
- break;
- }
- case tsms_rpdu_type_ack_mo:
- case tsms_rpdu_type_ack_mt:
- {
- tsms_rpdu_ack_t* rp_ack = TSMS_RPDU_ACK(rp_message);
- // ...do whatever you want
- if(rp_ack->udata && (tpdu = tsms_tpdu_message_deserialize(rp_ack->udata->data, rp_ack->udata->size, MobOrig))){
- // ...do whatever you want
- }
- TSK_DEBUG_INFO("RP-ACK");
- break;
- }
- case tsms_rpdu_type_error_mo:
- case tsms_rpdu_type_error_mt:
- {
- tsms_rpdu_error_t* rp_error = TSMS_RPDU_ERROR(rp_message);
- // ...do whatever you want
- if(rp_error->udata && (tpdu = tsms_tpdu_message_deserialize(rp_error->udata->data, rp_error->udata->size, MobOrig))){
- // ...do whatever you want
- }
- TSK_DEBUG_INFO("RP-ERROR");
- break;
- }
- case tsms_rpdu_type_smma_mo:
- {
- tsms_rpdu_smma_t* rp_smma = TSMS_RPDU_SMMA(rp_message);
- // ...do whatever you want
- TSK_DEBUG_INFO("RP-SMMA");
- break;
- }
- default:
- {
- TSK_DEBUG_INFO("Unknown RP-Message type (%u).", rp_message->mti);
- break;
- }
- }
+ if(!(rp_message = tsms_rpdu_message_deserialize(data, size))) {
+ TSK_DEBUG_ERROR("Failed to deserialize the RP-MESSAGE");
+ goto bail;
+ }
+
+ switch(rp_message->mti) {
+ case tsms_rpdu_type_data_mo:
+ case tsms_rpdu_type_data_mt: {
+ char* ascii = tsk_null;
+ tsms_rpdu_data_t* rp_data = TSMS_RPDU_DATA(rp_message);
+ if((tpdu = tsms_tpdu_message_deserialize(rp_data->udata->data, rp_data->udata->size, MobOrig))) {
+ if(tpdu->mti == tsms_tpdu_mti_deliver_mt || tpdu->mti == tsms_tpdu_mti_submit_mo) { /* SMS-SUBMIT or SMS-DELIVER? */
+ if((ascii = tsms_tpdu_message_get_payload(tpdu))) {
+ TSK_DEBUG_INFO("ASCII message=%s", ascii);
+ TSK_FREE(ascii);
+ }
+ }
+ }
+ break;
+ }
+ case tsms_rpdu_type_ack_mo:
+ case tsms_rpdu_type_ack_mt: {
+ tsms_rpdu_ack_t* rp_ack = TSMS_RPDU_ACK(rp_message);
+ // ...do whatever you want
+ if(rp_ack->udata && (tpdu = tsms_tpdu_message_deserialize(rp_ack->udata->data, rp_ack->udata->size, MobOrig))) {
+ // ...do whatever you want
+ }
+ TSK_DEBUG_INFO("RP-ACK");
+ break;
+ }
+ case tsms_rpdu_type_error_mo:
+ case tsms_rpdu_type_error_mt: {
+ tsms_rpdu_error_t* rp_error = TSMS_RPDU_ERROR(rp_message);
+ // ...do whatever you want
+ if(rp_error->udata && (tpdu = tsms_tpdu_message_deserialize(rp_error->udata->data, rp_error->udata->size, MobOrig))) {
+ // ...do whatever you want
+ }
+ TSK_DEBUG_INFO("RP-ERROR");
+ break;
+ }
+ case tsms_rpdu_type_smma_mo: {
+ tsms_rpdu_smma_t* rp_smma = TSMS_RPDU_SMMA(rp_message);
+ // ...do whatever you want
+ TSK_DEBUG_INFO("RP-SMMA");
+ break;
+ }
+ default: {
+ TSK_DEBUG_INFO("Unknown RP-Message type (%u).", rp_message->mti);
+ break;
+ }
+ }
bail:
- TSK_OBJECT_SAFE_FREE(rp_message);
- TSK_OBJECT_SAFE_FREE(tpdu);
+ TSK_OBJECT_SAFE_FREE(rp_message);
+ TSK_OBJECT_SAFE_FREE(tpdu);
}
void test_o_rpdata_submit()
{
- //== Sending RP-DATA(SMS-SUBMIT) ==
- int ret;
- tsk_buffer_t* buffer = tsk_null;
- tsms_tpdu_submit_t* sms_submit = tsk_null;
- tsms_rpdu_data_t* rp_data = tsk_null;
- const char* smsc = "+331000009";
- const char* destination = "+333361234567";
- const char* short_message = "hello world";
- uint8_t mr = 0xF5;
- uint8_t message_number = 0xF8;
- char* hex;
-
- // create SMS-SUBMIT message
- sms_submit = tsms_tpdu_submit_create(mr, smsc, destination);
- // Set content for SMS-SUBMIT
- if((buffer = tsms_pack_to_7bit(short_message))){
- ret = tsms_tpdu_submit_set_userdata(sms_submit, buffer, tsms_alpha_7bit);
- TSK_OBJECT_SAFE_FREE(buffer);
- }
- // create RP-DATA message and print its content (for test only)
- rp_data = tsms_rpdu_data_create_mo(mr, smsc, TSMS_TPDU_MESSAGE(sms_submit));
- if((hex = tsms_rpdu_message_tohexastring(TSMS_RPDU_MESSAGE(rp_data)))){
- TSK_DEBUG_INFO("RP-DATA=%s", hex);
- TSK_FREE(hex);
- }
+ //== Sending RP-DATA(SMS-SUBMIT) ==
+ int ret;
+ tsk_buffer_t* buffer = tsk_null;
+ tsms_tpdu_submit_t* sms_submit = tsk_null;
+ tsms_rpdu_data_t* rp_data = tsk_null;
+ const char* smsc = "+331000009";
+ const char* destination = "+333361234567";
+ const char* short_message = "hello world";
+ uint8_t mr = 0xF5;
+ uint8_t message_number = 0xF8;
+ char* hex;
+
+ // create SMS-SUBMIT message
+ sms_submit = tsms_tpdu_submit_create(mr, smsc, destination);
+ // Set content for SMS-SUBMIT
+ if((buffer = tsms_pack_to_7bit(short_message))) {
+ ret = tsms_tpdu_submit_set_userdata(sms_submit, buffer, tsms_alpha_7bit);
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+ // create RP-DATA message and print its content (for test only)
+ rp_data = tsms_rpdu_data_create_mo(mr, smsc, TSMS_TPDU_MESSAGE(sms_submit));
+ if((hex = tsms_rpdu_message_tohexastring(TSMS_RPDU_MESSAGE(rp_data)))) {
+ TSK_DEBUG_INFO("RP-DATA=%s", hex);
+ TSK_FREE(hex);
+ }
- // serialize
- buffer = tsk_buffer_create_null();
- ret = tsms_rpdu_data_serialize(rp_data, buffer);
- // send(socket, buffer->data, buffer->size);
- // print result (hex) to the console
- printhex("==RP-DATA(SMS-SUBMIT):", buffer->data, buffer->size);
-
- // receiving
- test_i_rpdata(buffer->data, buffer->size, tsk_true);
+ // serialize
+ buffer = tsk_buffer_create_null();
+ ret = tsms_rpdu_data_serialize(rp_data, buffer);
+ // send(socket, buffer->data, buffer->size);
+ // print result (hex) to the console
+ printhex("==RP-DATA(SMS-SUBMIT):", buffer->data, buffer->size);
- TSK_OBJECT_SAFE_FREE(buffer);
- TSK_OBJECT_SAFE_FREE(sms_submit);
- TSK_OBJECT_SAFE_FREE(rp_data);
+ // receiving
+ test_i_rpdata(buffer->data, buffer->size, tsk_true);
+
+ TSK_OBJECT_SAFE_FREE(buffer);
+ TSK_OBJECT_SAFE_FREE(sms_submit);
+ TSK_OBJECT_SAFE_FREE(rp_data);
}
void test_o_rpdata_deliver()
{
- //== Sending RP-DATA(SMS-DELIVER) ==
- int ret;
- tsk_buffer_t* buffer = tsk_null;
- tsms_tpdu_deliver_t* sms_deliver = tsk_null;
- tsms_rpdu_data_t* rp_data = tsk_null;
- const char* smsc = "+331000000";
- const char* originator = "+3361234567";
- const char* content = "hello world!";
-
- // create SMS-DELIVER message
- sms_deliver = tsms_tpdu_deliver_create(smsc, originator);
- // Set content for SMS-DELIVER
- if((buffer = tsms_pack_to_7bit(content))){
- ret = tsms_tpdu_deliver_set_userdata(sms_deliver, buffer, tsms_alpha_7bit);
- TSK_OBJECT_SAFE_FREE(buffer);
- }
- // create RP-DATA message
- rp_data = tsms_rpdu_data_create_mt(0x01, smsc, TSMS_TPDU_MESSAGE(sms_deliver));
- // serialize
- buffer = tsk_buffer_create_null();
- ret = tsms_rpdu_data_serialize(rp_data, buffer);
- // send(socket, buffer->data, buffer->size);
- // print result (hex) to the console
- printhex("==RP-DATA(SMS-DELIVER):", buffer->data, buffer->size);
-
- // receiving
- test_i_rpdata(buffer->data, buffer->size, tsk_false);
+ //== Sending RP-DATA(SMS-DELIVER) ==
+ int ret;
+ tsk_buffer_t* buffer = tsk_null;
+ tsms_tpdu_deliver_t* sms_deliver = tsk_null;
+ tsms_rpdu_data_t* rp_data = tsk_null;
+ const char* smsc = "+331000000";
+ const char* originator = "+3361234567";
+ const char* content = "hello world!";
+
+ // create SMS-DELIVER message
+ sms_deliver = tsms_tpdu_deliver_create(smsc, originator);
+ // Set content for SMS-DELIVER
+ if((buffer = tsms_pack_to_7bit(content))) {
+ ret = tsms_tpdu_deliver_set_userdata(sms_deliver, buffer, tsms_alpha_7bit);
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+ // create RP-DATA message
+ rp_data = tsms_rpdu_data_create_mt(0x01, smsc, TSMS_TPDU_MESSAGE(sms_deliver));
+ // serialize
+ buffer = tsk_buffer_create_null();
+ ret = tsms_rpdu_data_serialize(rp_data, buffer);
+ // send(socket, buffer->data, buffer->size);
+ // print result (hex) to the console
+ printhex("==RP-DATA(SMS-DELIVER):", buffer->data, buffer->size);
+
+ // receiving
+ test_i_rpdata(buffer->data, buffer->size, tsk_false);
- TSK_OBJECT_SAFE_FREE(buffer);
- TSK_OBJECT_SAFE_FREE(sms_deliver);
- TSK_OBJECT_SAFE_FREE(rp_data);
+ TSK_OBJECT_SAFE_FREE(buffer);
+ TSK_OBJECT_SAFE_FREE(sms_deliver);
+ TSK_OBJECT_SAFE_FREE(rp_data);
}
void test_o_rpdata_smma()
{
- //== Sending RP-SMMA ==
- int ret;
- tsk_buffer_t* buffer = tsk_null;
- tsms_rpdu_smma_t* rp_smma = tsk_null;
- uint8_t mr = 0xF5;
-
- // create RP-SMMA message
- rp_smma = tsms_rpdu_smma_create(mr);
- // serialize
- buffer = tsk_buffer_create_null();
- ret = tsms_rpdu_data_serialize(rp_smma, buffer);
- // send(socket, buffer->data, buffer->size);
- // print result (hex) to the console
- printhex("==RP-SMMA:", buffer->data, buffer->size);
-
- // receiving
- test_i_rpdata(buffer->data, buffer->size, tsk_true);
+ //== Sending RP-SMMA ==
+ int ret;
+ tsk_buffer_t* buffer = tsk_null;
+ tsms_rpdu_smma_t* rp_smma = tsk_null;
+ uint8_t mr = 0xF5;
+
+ // create RP-SMMA message
+ rp_smma = tsms_rpdu_smma_create(mr);
+ // serialize
+ buffer = tsk_buffer_create_null();
+ ret = tsms_rpdu_data_serialize(rp_smma, buffer);
+ // send(socket, buffer->data, buffer->size);
+ // print result (hex) to the console
+ printhex("==RP-SMMA:", buffer->data, buffer->size);
+
+ // receiving
+ test_i_rpdata(buffer->data, buffer->size, tsk_true);
- TSK_OBJECT_SAFE_FREE(buffer);
- TSK_OBJECT_SAFE_FREE(rp_smma);
+ TSK_OBJECT_SAFE_FREE(buffer);
+ TSK_OBJECT_SAFE_FREE(rp_smma);
}
void test_o_rpdata_ack()
{
- //== Sending RP-ACK(SMS-DELIVER-REPORT) ==
- int ret;
- tsk_buffer_t* buffer = tsk_null;
- tsms_tpdu_report_t* sms_report = tsk_null;
- tsms_rpdu_ack_t* rp_ack= tsk_null;
- const char* smsc = "+331000000";
- tsk_bool_t isSUBMIT = tsk_false; /* isDELIVER */
- tsk_bool_t isERROR = tsk_false;
- uint8_t mr = 0xF5;
+ //== Sending RP-ACK(SMS-DELIVER-REPORT) ==
+ int ret;
+ tsk_buffer_t* buffer = tsk_null;
+ tsms_tpdu_report_t* sms_report = tsk_null;
+ tsms_rpdu_ack_t* rp_ack= tsk_null;
+ const char* smsc = "+331000000";
+ tsk_bool_t isSUBMIT = tsk_false; /* isDELIVER */
+ tsk_bool_t isERROR = tsk_false;
+ uint8_t mr = 0xF5;
- // create SMS-DELIVER-REPORT message
- sms_report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
- // create RP-ACK message (From MS to SC)
- rp_ack = tsms_rpdu_ack_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report));
- // serialize
- buffer = tsk_buffer_create_null();
- if(!(ret = tsms_rpdu_data_serialize(rp_ack, buffer))){
- // send(socket, buffer->data, buffer->size);
- // print result (hex) to the console
- printhex("==RP-ACK(SMS-DELIVER-REPORT):", buffer->data, buffer->size);
- }
+ // create SMS-DELIVER-REPORT message
+ sms_report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
+ // create RP-ACK message (From MS to SC)
+ rp_ack = tsms_rpdu_ack_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report));
+ // serialize
+ buffer = tsk_buffer_create_null();
+ if(!(ret = tsms_rpdu_data_serialize(rp_ack, buffer))) {
+ // send(socket, buffer->data, buffer->size);
+ // print result (hex) to the console
+ printhex("==RP-ACK(SMS-DELIVER-REPORT):", buffer->data, buffer->size);
+ }
- // receiving
- test_i_rpdata(buffer->data, buffer->size, tsk_true);
+ // receiving
+ test_i_rpdata(buffer->data, buffer->size, tsk_true);
- TSK_OBJECT_SAFE_FREE(buffer);
- TSK_OBJECT_SAFE_FREE(sms_report);
- TSK_OBJECT_SAFE_FREE(rp_ack);
+ TSK_OBJECT_SAFE_FREE(buffer);
+ TSK_OBJECT_SAFE_FREE(sms_report);
+ TSK_OBJECT_SAFE_FREE(rp_ack);
}
void test_o_rpdata_error()
{
- //== Sending RP-ERROR(SMS-DELIVER-REPORT) ==
- int ret;
- tsk_buffer_t* buffer = tsk_null;
- tsms_tpdu_report_t* sms_report = tsk_null;
- tsms_rpdu_error_t* rp_error= tsk_null;
- tsk_bool_t isSUBMIT = tsk_false; /* isDELIVER */
- tsk_bool_t isERROR = tsk_true;
- const char* smsc = "+331000000";
- uint8_t mr = 0xF5;
+ //== Sending RP-ERROR(SMS-DELIVER-REPORT) ==
+ int ret;
+ tsk_buffer_t* buffer = tsk_null;
+ tsms_tpdu_report_t* sms_report = tsk_null;
+ tsms_rpdu_error_t* rp_error= tsk_null;
+ tsk_bool_t isSUBMIT = tsk_false; /* isDELIVER */
+ tsk_bool_t isERROR = tsk_true;
+ const char* smsc = "+331000000";
+ uint8_t mr = 0xF5;
- // create SMS-DELIVER-REPORT message
- sms_report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
- // create RP-ERROR message
- rp_error = tsms_rpdu_error_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report), 0x0A/*call barred*/);
- // serialize
- buffer = tsk_buffer_create_null();
- if(!(ret = tsms_rpdu_data_serialize(rp_error, buffer))){
- // send(socket, buffer->data, buffer->size);
- // print result (hex) to the console
- printhex("==RP-ERROR(SMS-DELIVER-REPORT):", buffer->data, buffer->size);
- }
+ // create SMS-DELIVER-REPORT message
+ sms_report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
+ // create RP-ERROR message
+ rp_error = tsms_rpdu_error_create_mo(mr, TSMS_TPDU_MESSAGE(sms_report), 0x0A/*call barred*/);
+ // serialize
+ buffer = tsk_buffer_create_null();
+ if(!(ret = tsms_rpdu_data_serialize(rp_error, buffer))) {
+ // send(socket, buffer->data, buffer->size);
+ // print result (hex) to the console
+ printhex("==RP-ERROR(SMS-DELIVER-REPORT):", buffer->data, buffer->size);
+ }
- // receiving
- test_i_rpdata(buffer->data, buffer->size, tsk_true);
+ // receiving
+ test_i_rpdata(buffer->data, buffer->size, tsk_true);
- TSK_OBJECT_SAFE_FREE(buffer);
- TSK_OBJECT_SAFE_FREE(sms_report);
- TSK_OBJECT_SAFE_FREE(rp_error);
+ TSK_OBJECT_SAFE_FREE(buffer);
+ TSK_OBJECT_SAFE_FREE(sms_report);
+ TSK_OBJECT_SAFE_FREE(rp_error);
}
void test_rpdu()
{
- test_o_rpdata_submit();
- //test_o_rpdata_deliver();
- //test_o_rpdata_smma();
- //test_o_rpdata_ack();
- //test_o_rpdata_error();
+ test_o_rpdata_submit();
+ //test_o_rpdata_deliver();
+ //test_o_rpdata_smma();
+ //test_o_rpdata_ack();
+ //test_o_rpdata_error();
- //const char* data = "\x03\x01\x41\x09\x01\x00\x01\x80\x01\x32\x42\x00\x69";
- //test_i_rpdata(data, 13, tsk_false);
+ //const char* data = "\x03\x01\x41\x09\x01\x00\x01\x80\x01\x32\x42\x00\x69";
+ //test_i_rpdata(data, 13, tsk_false);
}
#endif /* _TEST_SMSRPDU_H */
diff --git a/tinySMS/test/test_tpdu.h b/tinySMS/test/test_tpdu.h
index 27433f8..fe3b617 100755
--- a/tinySMS/test/test_tpdu.h
+++ b/tinySMS/test/test_tpdu.h
@@ -2,19 +2,19 @@
* Copyright (C) 2009 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango.org>
-*
+*
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO 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 3 of the License, or
* (at your option) any later version.
-*
+*
* DOUBANGO 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 DOUBANGO.
*
@@ -28,188 +28,188 @@ static uint8_t __pdu_last_mr = 0;
void test_submit()
{
- int ret;
- tsms_tpdu_submit_t* submit = tsk_null;
- tsk_buffer_t* buffer = tsk_null;
- char* hex;
- const char* smsc = "+331000009";
- const char* destination = "+333361234567";
- const char* short_message = "hello world";
- uint8_t mr = 0xF5;
-
- submit = tsms_tpdu_submit_create(mr, smsc, destination);
-
- /* encode the user data to GSM 7-bit alphabet */
- if((buffer = tsms_pack_to_7bit(short_message))){
- ret = tsms_tpdu_submit_set_userdata(submit, buffer, tsms_alpha_7bit);
- if((hex = tsms_tpdu_submit_tohexastring(submit))){
- TSK_DEBUG_INFO("SMS-SUBMIT=%s", hex);
- TSK_FREE(hex);
- }
- TSK_OBJECT_SAFE_FREE(buffer);
- }
-
- /* receiving */
- buffer = tsk_buffer_create_null();
- ret = tsms_tpdu_submit_serialize(submit, buffer);
- // send(socket, buffer->data, buffer->size);
-
- TSK_OBJECT_SAFE_FREE(submit);
- submit = (tsms_tpdu_submit_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);
- if((hex = tsms_tpdu_submit_tohexastring(submit))){
- TSK_DEBUG_INFO("SMS-SUBMIT=%s", hex);
- TSK_FREE(hex);
- }
-
- TSK_OBJECT_SAFE_FREE(submit);
- TSK_OBJECT_SAFE_FREE(buffer);
-
- printf("==========\n");
+ int ret;
+ tsms_tpdu_submit_t* submit = tsk_null;
+ tsk_buffer_t* buffer = tsk_null;
+ char* hex;
+ const char* smsc = "+331000009";
+ const char* destination = "+333361234567";
+ const char* short_message = "hello world";
+ uint8_t mr = 0xF5;
+
+ submit = tsms_tpdu_submit_create(mr, smsc, destination);
+
+ /* encode the user data to GSM 7-bit alphabet */
+ if((buffer = tsms_pack_to_7bit(short_message))) {
+ ret = tsms_tpdu_submit_set_userdata(submit, buffer, tsms_alpha_7bit);
+ if((hex = tsms_tpdu_submit_tohexastring(submit))) {
+ TSK_DEBUG_INFO("SMS-SUBMIT=%s", hex);
+ TSK_FREE(hex);
+ }
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+
+ /* receiving */
+ buffer = tsk_buffer_create_null();
+ ret = tsms_tpdu_submit_serialize(submit, buffer);
+ // send(socket, buffer->data, buffer->size);
+
+ TSK_OBJECT_SAFE_FREE(submit);
+ submit = (tsms_tpdu_submit_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);
+ if((hex = tsms_tpdu_submit_tohexastring(submit))) {
+ TSK_DEBUG_INFO("SMS-SUBMIT=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ TSK_OBJECT_SAFE_FREE(submit);
+ TSK_OBJECT_SAFE_FREE(buffer);
+
+ printf("==========\n");
}
void test_deliver()
{
- int ret;
- tsms_tpdu_deliver_t* deliver = tsk_null;
- tsk_buffer_t* buffer = tsk_null;
- char* hex;
-
- deliver = tsms_tpdu_deliver_create("+27381000015", "+46708251358");
-
- /* sending */
- if((buffer = tsms_pack_to_7bit(USER_DATA))){
- ret = tsms_tpdu_deliver_set_userdata(deliver, buffer, tsms_alpha_7bit);
- if((hex = tsms_tpdu_deliver_tohexastring(deliver))){
- TSK_DEBUG_INFO("SMS-DELIVER=%s", hex);
- TSK_FREE(hex);
- }
- TSK_OBJECT_SAFE_FREE(buffer);
- }
-
- /* receiving */
- buffer = tsk_buffer_create_null();
- tsms_tpdu_deliver_serialize(deliver, buffer);
-
- TSK_OBJECT_SAFE_FREE(deliver);
-
- //{
- // tsms_tpdu_message_t* sms_any = tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
- // if(sms_any && sms_any->mti == tsms_tpdu_mti_deliver_mt){
- // //tsms_tpdu_deliver_t* sms_deliver = TSMS_TPDU_DELIVER(sms_any); ==> Yes we can !
- // char* ascii;
- // if((ascii = tsms_tpdu_message_get_payload(sms_any))){
- // TSK_DEBUG_INFO("Message=%s", ascii);
- // TSK_FREE(ascii);
- // }
- // }
- // TSK_OBJECT_SAFE_FREE(sms_any);
- //}
-
- deliver = (tsms_tpdu_deliver_t*)tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
- if((hex = tsms_tpdu_deliver_tohexastring(deliver))){
- TSK_DEBUG_INFO("SMS-DELIVER=%s", hex);
- TSK_FREE(hex);
- }
-
- TSK_OBJECT_SAFE_FREE(deliver);
- TSK_OBJECT_SAFE_FREE(buffer);
-
- printf("==========\n");
+ int ret;
+ tsms_tpdu_deliver_t* deliver = tsk_null;
+ tsk_buffer_t* buffer = tsk_null;
+ char* hex;
+
+ deliver = tsms_tpdu_deliver_create("+27381000015", "+46708251358");
+
+ /* sending */
+ if((buffer = tsms_pack_to_7bit(USER_DATA))) {
+ ret = tsms_tpdu_deliver_set_userdata(deliver, buffer, tsms_alpha_7bit);
+ if((hex = tsms_tpdu_deliver_tohexastring(deliver))) {
+ TSK_DEBUG_INFO("SMS-DELIVER=%s", hex);
+ TSK_FREE(hex);
+ }
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+
+ /* receiving */
+ buffer = tsk_buffer_create_null();
+ tsms_tpdu_deliver_serialize(deliver, buffer);
+
+ TSK_OBJECT_SAFE_FREE(deliver);
+
+ //{
+ // tsms_tpdu_message_t* sms_any = tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
+ // if(sms_any && sms_any->mti == tsms_tpdu_mti_deliver_mt){
+ // //tsms_tpdu_deliver_t* sms_deliver = TSMS_TPDU_DELIVER(sms_any); ==> Yes we can !
+ // char* ascii;
+ // if((ascii = tsms_tpdu_message_get_payload(sms_any))){
+ // TSK_DEBUG_INFO("Message=%s", ascii);
+ // TSK_FREE(ascii);
+ // }
+ // }
+ // TSK_OBJECT_SAFE_FREE(sms_any);
+ //}
+
+ deliver = (tsms_tpdu_deliver_t*)tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
+ if((hex = tsms_tpdu_deliver_tohexastring(deliver))) {
+ TSK_DEBUG_INFO("SMS-DELIVER=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ TSK_OBJECT_SAFE_FREE(deliver);
+ TSK_OBJECT_SAFE_FREE(buffer);
+
+ printf("==========\n");
}
void test_report()
{
- int ret;
- tsms_tpdu_report_t* report = tsk_null;
- tsk_buffer_t* buffer = tsk_null;
- char* hex;
- const char* smsc = "+331000009";
- tsk_bool_t isSUBMIT = tsk_false;
- tsk_bool_t isERROR = tsk_false;
-
- report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
-
- /* sending */
- if((buffer = tsms_pack_to_7bit(USER_DATA))){
- ret = tsms_tpdu_deliver_set_userdata(report, buffer, tsms_alpha_7bit);
- if((hex = tsms_tpdu_deliver_tohexastring(report))){
- TSK_DEBUG_INFO("SMS-DELIVER-REPORT for RP-ERROR=%s", hex);
- TSK_FREE(hex);
- }
- TSK_OBJECT_SAFE_FREE(buffer);
- }
-
- /* receiving */
- buffer = tsk_buffer_create_null();
- tsms_tpdu_report_serialize(report, buffer);
-
- TSK_OBJECT_SAFE_FREE(report);
- report = (tsms_tpdu_report_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);
- if((hex = tsms_tpdu_report_tohexastring(report))){
- TSK_DEBUG_INFO("SMS-DELIVER-REPORT for RP-ERROR=%s", hex);
- TSK_FREE(hex);
- }
-
- TSK_OBJECT_SAFE_FREE(report);
- TSK_OBJECT_SAFE_FREE(buffer);
-
- printf("==========\n");
+ int ret;
+ tsms_tpdu_report_t* report = tsk_null;
+ tsk_buffer_t* buffer = tsk_null;
+ char* hex;
+ const char* smsc = "+331000009";
+ tsk_bool_t isSUBMIT = tsk_false;
+ tsk_bool_t isERROR = tsk_false;
+
+ report = tsms_tpdu_report_create(smsc, isSUBMIT, isERROR);
+
+ /* sending */
+ if((buffer = tsms_pack_to_7bit(USER_DATA))) {
+ ret = tsms_tpdu_deliver_set_userdata(report, buffer, tsms_alpha_7bit);
+ if((hex = tsms_tpdu_deliver_tohexastring(report))) {
+ TSK_DEBUG_INFO("SMS-DELIVER-REPORT for RP-ERROR=%s", hex);
+ TSK_FREE(hex);
+ }
+ TSK_OBJECT_SAFE_FREE(buffer);
+ }
+
+ /* receiving */
+ buffer = tsk_buffer_create_null();
+ tsms_tpdu_report_serialize(report, buffer);
+
+ TSK_OBJECT_SAFE_FREE(report);
+ report = (tsms_tpdu_report_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);
+ if((hex = tsms_tpdu_report_tohexastring(report))) {
+ TSK_DEBUG_INFO("SMS-DELIVER-REPORT for RP-ERROR=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ TSK_OBJECT_SAFE_FREE(report);
+ TSK_OBJECT_SAFE_FREE(buffer);
+
+ printf("==========\n");
}
void test_command()
{
- tsms_tpdu_command_t* command = tsk_null;
- char* hex;
- tsk_buffer_t* buffer = tsk_null;
- const char* smsc = "+331000009";
- const char* destination = "+333361234567";
- uint8_t mr = 0xF5;
- uint8_t message_number = 0xF8;
-
- command = tsms_tpdu_command_create(mr, smsc, destination, message_number, tsms_tpdu_cmd_delete);
-
- /*sending*/
- if((hex = tsms_tpdu_command_tohexastring(command))){
- TSK_DEBUG_INFO("SMS-COMMAND=%s", hex);
- TSK_FREE(hex);
- }
-
- /* receiving */
- buffer = tsk_buffer_create_null();
- tsms_tpdu_command_serialize(command, buffer);
-
- TSK_OBJECT_SAFE_FREE(command);
- command = (tsms_tpdu_command_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);
- if((hex = tsms_tpdu_command_tohexastring(command))){
- TSK_DEBUG_INFO("SMS-COMMAND=%s", hex);
- TSK_FREE(hex);
- }
-
- TSK_OBJECT_SAFE_FREE(command);
- TSK_OBJECT_SAFE_FREE(buffer);
-
- printf("==========\n");
+ tsms_tpdu_command_t* command = tsk_null;
+ char* hex;
+ tsk_buffer_t* buffer = tsk_null;
+ const char* smsc = "+331000009";
+ const char* destination = "+333361234567";
+ uint8_t mr = 0xF5;
+ uint8_t message_number = 0xF8;
+
+ command = tsms_tpdu_command_create(mr, smsc, destination, message_number, tsms_tpdu_cmd_delete);
+
+ /*sending*/
+ if((hex = tsms_tpdu_command_tohexastring(command))) {
+ TSK_DEBUG_INFO("SMS-COMMAND=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ /* receiving */
+ buffer = tsk_buffer_create_null();
+ tsms_tpdu_command_serialize(command, buffer);
+
+ TSK_OBJECT_SAFE_FREE(command);
+ command = (tsms_tpdu_command_t*)tsms_tpdu_message_deserialize_mo(buffer->data, buffer->size);
+ if((hex = tsms_tpdu_command_tohexastring(command))) {
+ TSK_DEBUG_INFO("SMS-COMMAND=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ TSK_OBJECT_SAFE_FREE(command);
+ TSK_OBJECT_SAFE_FREE(buffer);
+
+ printf("==========\n");
}
void test_sreport()
{
- tsms_tpdu_status_report_t* sreport = tsk_null;
- char* hex;
- tsk_buffer_t* buffer = tsk_null;
-
- sreport = tsms_tpdu_status_report_create(__pdu_last_mr++, "+3310000", "+332666", tsms_tpdu_status_busy, tsk_true);
-
- if((hex = tsms_tpdu_report_tohexastring(sreport))){
- TSK_DEBUG_INFO("SMS-STATUS-REPORT=%s", hex);
- TSK_FREE(hex);
- }
-
- /* receiving */
- buffer = tsk_buffer_create_null();
- tsms_tpdu_status_report_serialize(sreport, buffer);
-
-
+ tsms_tpdu_status_report_t* sreport = tsk_null;
+ char* hex;
+ tsk_buffer_t* buffer = tsk_null;
+
+ sreport = tsms_tpdu_status_report_create(__pdu_last_mr++, "+3310000", "+332666", tsms_tpdu_status_busy, tsk_true);
+
+ if((hex = tsms_tpdu_report_tohexastring(sreport))) {
+ TSK_DEBUG_INFO("SMS-STATUS-REPORT=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ /* receiving */
+ buffer = tsk_buffer_create_null();
+ tsms_tpdu_status_report_serialize(sreport, buffer);
+
+
//tsms_tpdu_message_t* sms_any = tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
//if(sms_any && sms_any->mti == tsms_tpdu_mti_status_report_mt){
// tsms_tpdu_status_report_t* sms_status_report = TSMS_TPDU_STATUS_REPORT(sms_any);
@@ -223,28 +223,28 @@ void test_sreport()
// }
//}
//TSK_OBJECT_SAFE_FREE(sms_any);
-
- TSK_OBJECT_SAFE_FREE(sreport);
- sreport = (tsms_tpdu_status_report_t*)tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
- if((hex = tsms_tpdu_status_report_tohexastring(sreport))){
- TSK_DEBUG_INFO("SMS-STATUS-REPORT=%s", hex);
- TSK_FREE(hex);
- }
- TSK_OBJECT_SAFE_FREE(sreport);
- TSK_OBJECT_SAFE_FREE(buffer);
+ TSK_OBJECT_SAFE_FREE(sreport);
+ sreport = (tsms_tpdu_status_report_t*)tsms_tpdu_message_deserialize_mt(buffer->data, buffer->size);
+ if((hex = tsms_tpdu_status_report_tohexastring(sreport))) {
+ TSK_DEBUG_INFO("SMS-STATUS-REPORT=%s", hex);
+ TSK_FREE(hex);
+ }
+
+ TSK_OBJECT_SAFE_FREE(sreport);
+ TSK_OBJECT_SAFE_FREE(buffer);
- printf("==========\n");
+ printf("==========\n");
}
void test_tpdu()
{
- test_submit();
- test_deliver();
- test_report();
- test_command();
- test_sreport();
+ test_submit();
+ test_deliver();
+ test_report();
+ test_command();
+ test_sreport();
}
#endif /* _TEST_SMSTPDU_H */
OpenPOWER on IntegriCloud