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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <libgsmd/libgsmd.h>
#include <libgsmd/misc.h>
#include <libgsmd/sms.h>
#include <gsmd/usock.h>
#include <gsmd/event.h>
#include "lgsm_internals.h"
int lgsm_sms_list(struct lgsm_handle *lh, enum gsmd_msg_sms_type stat)
{
/* FIXME: only support PDU mode now */
struct gsmd_msg_hdr *gmh;
int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_SMS,
GSMD_SMS_LIST, sizeof(int));
if (!gmh)
return -ENOMEM;
*(int *) gmh->data = stat;
rc = lgsm_send(lh, gmh);
if (rc < gmh->len + sizeof(*gmh)) {
lgsm_gmh_free(gmh);;
return -EIO;
}
lgsm_gmh_free(gmh);
return 0;
}
int lgsm_sms_read(struct lgsm_handle *lh, int index)
{
struct gsmd_msg_hdr *gmh;
int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_SMS,
GSMD_SMS_READ, sizeof(int));
if (!gmh)
return -ENOMEM;
*(int *) gmh->data = index;
rc = lgsm_send(lh, gmh);
if (rc < gmh->len + sizeof(*gmh)) {
lgsm_gmh_free(gmh);;
return -EIO;
}
lgsm_gmh_free(gmh);
return 0;
}
int lgsmd_sms_delete(struct lgsm_handle *lh,
const struct lgsm_sms_delete *sms_del)
{
struct gsmd_msg_hdr *gmh;
struct gsmd_sms_delete *gsd;
int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_SMS,
GSMD_SMS_DELETE, sizeof(*gsd));
if (!gmh)
return -ENOMEM;
gsd = (struct gsmd_sms_delete *) gmh->data;
gsd->index = sms_del->index;
gsd->delflg = sms_del->delflg;
rc = lgsm_send(lh, gmh);
if (rc < gmh->len + sizeof(*gmh)) {
lgsm_gmh_free(gmh);
return -EIO;
}
lgsm_gmh_free(gmh);
return 0;
}
int lgsmd_sms_send(struct lgsm_handle *lh,
const struct lgsm_sms *sms)
{
/* FIXME: only support PDU mode */
struct gsmd_msg_hdr *gmh;
struct gsmd_sms *gs;
int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_SMS,
GSMD_SMS_SEND, sizeof(*gs));
if (!gmh)
return -ENOMEM;
gs = (struct gsmd_sms *) gmh->data;
rc = lgsm_send(lh, gmh);
if (rc < gmh->len + sizeof(*gmh)) {
lgsm_gmh_free(gmh);
return -EIO;
}
lgsm_gmh_free(gmh);
return 0;
}
int lgsmd_sms_write(struct lgsm_handle *lh,
const struct lgsm_sms_write *sms_write)
{
/* FIXME: only support PDU mode */
struct gsmd_msg_hdr *gmh;
struct gsmd_sms_write *gsw;
int rc;
gmh = lgsm_gmh_fill(GSMD_MSG_SMS,
GSMD_SMS_WRITE, sizeof(*gsw));
if (!gmh)
return -ENOMEM;
gsw = (struct gsmd_sms_write *) gmh->data;
rc = lgsm_send(lh, gmh);
if (rc < gmh->len + sizeof(*gmh)) {
lgsm_gmh_free(gmh);
return -EIO;
}
lgsm_gmh_free(gmh);
return 0;
}
int packing_7bit_character(char *src, char *dest)
{
int i,j = 0;
unsigned char ch1, ch2;
char tmp[2];
int shift = 0;
*dest = '\0';
for ( i=0; i<strlen(src); i++ ) {
ch1 = src[i] & 0x7F;
ch1 = ch1 >> shift;
ch2 = src[(i+1)] & 0x7F;
ch2 = ch2 << (7-shift);
ch1 = ch1 | ch2;
j = strlen(dest);
sprintf(tmp, "%x", (ch1 >> 4));
dest[j++] = tmp[0];
sprintf(tmp, "%x", (ch1 & 0x0F));
dest[j++] = tmp[0];
dest[j++] = '\0';
shift++;
if ( 7 == shift ) {
shift = 0;
i++;
}
}
return 0;
}
int unpacking_7bit_character(char *src, char *dest)
{
unsigned char ch1, ch2 = '\0';
int i, j;
char buf[8];
int shift = 0;
*dest = '\0';
for ( i=0; i<strlen(src); i+=2 ) {
sprintf(buf, "%c%c", src[i], src[i+1]);
ch1 = strtol(buf, NULL, 16);
j = strlen(dest);
dest[j++] = ((ch1 & (0x7F >> shift)) << shift) | ch2;
dest[j++] = '\0';
ch2 = ch1 >> (7-shift);
shift++;
}
return 0;
}
/* Refer to 3GPP TS 11.11 Annex B */
int packing_UCS2_80(char *src, char *dest)
{
return 0;
}
/* Refer to 3GPP TS 11.11 Annex B */
int unpacking_UCS2_80(char *src, char *dest)
{
return 0;
}
/* Refer to 3GPP TS 11.11 Annex B */
int packing_UCS2_81(char *src, char *dest)
{
return 0;
}
/* Refer to 3GPP TS 11.11 Annex B */
int unpacking_UCS2_81(char *src, char *dest)
{
return 0;
}
/* Refer to 3GPP TS 11.11 Annex B */
int packing_UCS2_82(char *src, char *dest)
{
return 0;
}
/* Refer to 3GPP TS 11.11 Annex B */
int unpacking_UCS2_82(char *src, char *dest)
{
return 0;
}
|