1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
|
From: Erin Yueh <erin_yueh@openmoko.com>
Subject: [PATCH] SMS status report
I made a patch for SMS status report. It can change SMS-Submit messages
and ask for a status report. When the destination address receives our
message, the service center will send a SMS-STATUS-REPORT to us. We can
tell what messages we sent by TP-MR (message reference number) value and
can know the sending result by TP-ST (Status) value from status report
messages.
PS. if you don't want to ask a status report, you can change this value
back. Replace "GSMD_SMS_TP_SRR_STATUS_REQUEST" with
"GSMD_SMS_TP_SRR_NOT_REQUEST".
header[pos ++] =
GSMD_SMS_TP_MTI_SUBMIT |
(0 << 2) | /* Reject Duplicates: 0 */
GSMD_SMS_TP_VPF_NOT_PRESENT |
- GSMD_SMS_TP_SRR_NOT_REQUEST |
+ GSMD_SMS_TP_SRR_STATUS_REQUEST |
(src->payload.has_header ? GSMD_SMS_TP_UDHI_WITH_HEADER :
GSMD_SMS_TP_UDHI_NO_HEADER) |
GSMD_SMS_TP_RP_NOT_SET;
Signed-off-by: Jim Huang <jserv@openmoko.org>
---
src/gsmd/sms_pdu.c | 54 +++++++++++++++++++++++++++++++++++++++++++-----------
src/util/event.c | 6 +++++-
2 files changed, 48 insertions(+), 12 deletions(-)
Index: gsm/src/gsmd/sms_pdu.c
===================================================================
--- gsm.orig/src/gsmd/sms_pdu.c 2007-09-06 11:14:34.000000000 +0800
+++ gsm/src/gsmd/sms_pdu.c 2007-09-17 23:39:20.000000000 +0800
@@ -139,6 +139,17 @@
/* Skip TP-PID */
len -= 9;
src += 9;
+
+ /* TP-UDL */
+ dst->payload.length = src[0];
+ i = sms_data_bytelen(dst->payload.coding_scheme, src[0]);
+
+ /* TP-UD */
+ if (len < 1 + i || i > GSMD_SMS_DATA_MAXLEN)
+ return 1;
+ memcpy(dst->payload.data, src + 1, i);
+ dst->payload.data[i] = 0;
+
break;
case GSMD_SMS_TP_MTI_SUBMIT:
if (len < 4)
@@ -179,23 +190,44 @@
src += vpf ? 3 : 2;
memset(dst->time_stamp, 0, 7);
+
+ /* TP-UDL */
+ dst->payload.length = src[0];
+ i = sms_data_bytelen(dst->payload.coding_scheme, src[0]);
+
+ /* TP-UD */
+ if (len < 1 + i || i > GSMD_SMS_DATA_MAXLEN)
+ return 1;
+ memcpy(dst->payload.data, src + 1, i);
+ dst->payload.data[i] = 0;
break;
case GSMD_SMS_TP_MTI_STATUS_REPORT:
- /* TODO */
+ if (len < 3)
+ return 1;
+
+ /* TP-MR set it gsmd_sms_list.index*/
+ dst->index = (int) src[1];
+ /* TP-STATUS set it to coding_scheme */
+ dst->payload.coding_scheme = (int) src[len-1];
+ /* TP-RA */
+ i = sms_number_bytelen(src[3], src[2]);
+ if (len < 13 + i)
+ return 1;
+ if (sms_address2ascii(&dst->addr, src + 2))
+ return 1;
+ len -= 4 + i;
+ src += 4 + i;
+ /* TP-SCTS */
+ memcpy(dst->time_stamp, src, 7);
+ /* TP-UD */
+ dst->payload.length = 0;
+ dst->payload.data[0] = 0;
+ break;
default:
/* Unknown PDU type */
return 1;
}
- /* TP-UDL */
- dst->payload.length = src[0];
- i = sms_data_bytelen(dst->payload.coding_scheme, src[0]);
-
- /* TP-UD */
- if (len < 1 + i || i > GSMD_SMS_DATA_MAXLEN)
- return 1;
- memcpy(dst->payload.data, src + 1, i);
- dst->payload.data[i] = 0;
return 0;
}
@@ -215,7 +247,7 @@
GSMD_SMS_TP_MTI_SUBMIT |
(0 << 2) | /* Reject Duplicates: 0 */
GSMD_SMS_TP_VPF_NOT_PRESENT |
- GSMD_SMS_TP_SRR_NOT_REQUEST |
+ GSMD_SMS_TP_SRR_STATUS_REQUEST |
(src->payload.has_header ? GSMD_SMS_TP_UDHI_WITH_HEADER :
GSMD_SMS_TP_UDHI_NO_HEADER) |
GSMD_SMS_TP_RP_NOT_SET;
Index: gsm/src/util/event.c
===================================================================
--- gsm.orig/src/util/event.c 2007-09-06 11:14:34.000000000 +0800
+++ gsm/src/util/event.c 2007-09-17 23:39:47.000000000 +0800
@@ -128,8 +128,12 @@
static int inds_handler(struct lgsm_handle *lh, int evt,
struct gsmd_evt_auxdata *aux)
{
- if (aux->u.ds.inlined)
+ if (aux->u.ds.inlined) {
+ struct gsmd_sms_list *sms;
+ sms = (struct gsmd_sms_list *) aux->data;
printf("EVENT: Incoming Status Report\n");
+ printf("message ref = %d, status = %d\n", sms->index,sms->payload.coding_scheme);
+ }
else
printf("EVENT: Incoming Status Report stored at location %i\n",
aux->u.ds.index);
|