Gammu internals  1.38.0
gsmdata.h File Reference
#include <gammu-wap.h>
#include <gammu-message.h>
Include dependency graph for gsmdata.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void NOKIA_EncodeWAPMMSSettingsSMSText (unsigned char *Buffer, size_t *Length, GSM_WAPSettings *settings, gboolean MMS)
 
void NOKIA_EncodeWAPBookmarkSMSText (unsigned char *Buffer, size_t *Length, GSM_WAPBookmark *bookmark)
 
void GSM_EncodeMMSIndicatorSMSText (unsigned char *Buffer, size_t *Length, GSM_MMSIndicator *Indicator)
 
void GSM_EncodeWAPIndicatorSMSText (unsigned char *Buffer, size_t *Length, char *Text, char *URL)
 

Function Documentation

§ GSM_EncodeMMSIndicatorSMSText()

void GSM_EncodeMMSIndicatorSMSText ( unsigned char *  Buffer,
size_t *  Length,
GSM_MMSIndicator Indicator 
)

Definition at line 307 of file gsmdata.c.

References GSM_MMSIndicator::Address, GSM_MMSIndicator::Class, GSM_MMS_Advertisement, GSM_MMS_Auto, GSM_MMS_Info, GSM_MMS_INVALID, GSM_MMS_None, GSM_MMS_Personal, GSM_MMSIndicator::MessageSize, GSM_MMSIndicator::Sender, and GSM_MMSIndicator::Title.

Referenced by GSM_EncodeMultiPartSMS().

308 {
309  unsigned char buffer[200];
310  int i;
311 
312 
313  /*
314  * WSP header
315  */
316 
317  /* Transaction ID (maybe this should be random?) */
318  Buffer[(*Length)++] = 0xe6;
319  /* PDU type push */
320  Buffer[(*Length)++] = 0x06;
321  /* Header length */
322  Buffer[(*Length)++] = 0x22;
323  /* MIME type (header) */
324  strcpy(Buffer+(*Length),"application/vnd.wap.mms-message");
325  (*Length)=(*Length)+31;
326  Buffer[(*Length)++] = 0x00;
327 
328  /* WAP push (x-wap-application.ua) */
329  Buffer[(*Length)++] = 0xaf;
330  Buffer[(*Length)++] = 0x84;
331 
332  /*
333  * MMS data
334  */
335 
336  /* Transaction type */
337  Buffer[(*Length)++] = 0x8c;
338  /* m-notification-ind */
339  Buffer[(*Length)++] = 0x82;
340 
341  /* Transaction ID, usually last part of address */
342  Buffer[(*Length)++] = 0x98;
343  i = strlen(Indicator->Address);
344  while (Indicator->Address[i] != '/' && i!=0) i--;
345  strcpy(Buffer+(*Length),Indicator->Address+i+1);
346  (*Length)=(*Length)+strlen(Indicator->Address+i+1);
347  Buffer[(*Length)++] = 0x00;
348 
349  /* MMS version */
350  Buffer[(*Length)++] = 0x8d;
351  /* 1.2 (0x90 is 1.0) */
352  Buffer[(*Length)++] = 0x92;
353 
354  /* Message class */
355  switch (Indicator->Class) {
356  case GSM_MMS_None:
357  case GSM_MMS_INVALID:
358  break;
359  case GSM_MMS_Personal:
360  Buffer[(*Length)++] = 0x8a;
361  Buffer[(*Length)++] = 0x80;
362  break;
364  Buffer[(*Length)++] = 0x8a;
365  Buffer[(*Length)++] = 0x81;
366  break;
367  case GSM_MMS_Info:
368  Buffer[(*Length)++] = 0x8a;
369  Buffer[(*Length)++] = 0x82;
370  break;
371  case GSM_MMS_Auto:
372  Buffer[(*Length)++] = 0x8a;
373  Buffer[(*Length)++] = 0x83;
374  break;
375  }
376 
377  if (Indicator->MessageSize > 0) {
378  /* Message size */
379  Buffer[(*Length)++] = 0x8e;
380  /* Length of size */
381  Buffer[(*Length)++] = 0x04;
382  Buffer[(*Length)++] = ((long)Indicator->MessageSize >> 24) & 0xff;
383  Buffer[(*Length)++] = ((long)Indicator->MessageSize >> 16) & 0xff;
384  Buffer[(*Length)++] = ((long)Indicator->MessageSize >> 8) & 0xff;
385  Buffer[(*Length)++] = ((long)Indicator->MessageSize >> 0) & 0xff;
386  }
387 
388  /* Sender address */
389  Buffer[(*Length)++] = 0x89;
390  sprintf(buffer,"%s/TYPE=PLMN",Indicator->Sender);
391  /* Field size */
392  Buffer[(*Length)++] = (unsigned char)(strlen(buffer) + 2);
393  /* Sender address is present */
394  Buffer[(*Length)++] = 0x80;
395  strcpy(Buffer+(*Length),buffer);
396  (*Length)=(*Length)+strlen(buffer);
397  /* Zero terminate */
398  Buffer[(*Length)++] = 0x00;
399 
400  /* Subject */
401  Buffer[(*Length)++] = 0x96;
402  strcpy(Buffer+(*Length),Indicator->Title);
403  (*Length)=(*Length)+strlen(Indicator->Title);
404  Buffer[(*Length)++] = 0x00;
405 
406  strcpy(Buffer+(*Length),"\x88\x05\x81\x03\x02\xA3\xA3");
407  (*Length)=(*Length)+7;
408 
409  /* Content location */
410  Buffer[(*Length)++] = 0x83;
411  strcpy(Buffer+(*Length),Indicator->Address);
412  (*Length)=(*Length)+strlen(Indicator->Address);
413  Buffer[(*Length)++] = 0x00;
414 }
char Address[500]
Definition: gammu-message.h:90
GSM_MMS_Class Class
char Sender[200]
Definition: gammu-message.h:98

§ GSM_EncodeWAPIndicatorSMSText()

void GSM_EncodeWAPIndicatorSMSText ( unsigned char *  Buffer,
size_t *  Length,
char *  Text,
char *  URL 
)

Encodes WAP indicator message.

Produced output is WBXML, as defined in WAP-167.

Definition at line 233 of file gsmdata.c.

Referenced by GSM_EncodeMultiPartSMS().

234 {
235  size_t i, len;
236 
237  Buffer[(*Length)++] = 0x01; /* Push ID */
238  Buffer[(*Length)++] = 0x06; /* PDU Type (push) */
239  Buffer[(*Length)++] = 0x01; /* Headers length */
240  Buffer[(*Length)++] = 0xAE; /* MIME-Type: application/vnd.wap.sic */
241 
242  Buffer[(*Length)++] = 0x02; /* WBXML 1.2 */
243  Buffer[(*Length)++] = 0x05; /* SI 1.0 Public Identifier */
244  Buffer[(*Length)++] = 0x6A; /* charset UTF-8 */
245  Buffer[(*Length)++] = 0x00; /* string table length */
246  Buffer[(*Length)++] = 0x45; /* SI with content */
247  Buffer[(*Length)++] = 0xC6; /* indication with content and attributes */
248  Buffer[(*Length)++] = 0x0B; /* address */
249  Buffer[(*Length)++] = 0x03; /* Inline string */
250  len = strlen(URL);
251  for (i = 0; i < len; i++) {
252  Buffer[(*Length)++] = URL[i];/* Text */
253  }
254  Buffer[(*Length)++] = 0x00; /* END Inline string */
255 
256 #if 0
257  Buffer[(*Length)++] = 0x0A; /* created... */
258  Buffer[(*Length)++] = 0xC3; /* OPAQUE */
259  Buffer[(*Length)++] = 0x07; /* length */
260  Buffer[(*Length)++] = 0x20; /* year */
261  Buffer[(*Length)++] = 0x08; /* year */
262  Buffer[(*Length)++] = 0x12; /* month */
263  Buffer[(*Length)++] = 0x10; /* day */
264  Buffer[(*Length)++] = 0x00; /* hour */
265  Buffer[(*Length)++] = 0x00; /* minute */
266  Buffer[(*Length)++] = 0x00; /* second */
267 
268  Buffer[(*Length)++] = 0x10; /* expires */
269  Buffer[(*Length)++] = 0xC3; /* OPAQUE */
270  Buffer[(*Length)++] = 0x04; /* length */
271  Buffer[(*Length)++] = 0x20; /* year */
272  Buffer[(*Length)++] = 0x10; /* year */
273  Buffer[(*Length)++] = 0x06; /* month */
274  Buffer[(*Length)++] = 0x25; /* day */
275 #endif
276 
277  Buffer[(*Length)++] = 0x01; /* END (indication) */
278  Buffer[(*Length)++] = 0x03; /* Inline string */
279  len = strlen(Text);
280  for (i = 0; i < len; i++) {
281  Buffer[(*Length)++] = Text[i]; /* Text */
282  }
283  Buffer[(*Length)++] = 0x00; /* END Inline string */
284  Buffer[(*Length)++] = 0x01; /* END (indication) */
285  Buffer[(*Length)++] = 0x01; /* END (SI) */
286 }

§ NOKIA_EncodeWAPBookmarkSMSText()

void NOKIA_EncodeWAPBookmarkSMSText ( unsigned char *  Buffer,
size_t *  Length,
GSM_WAPBookmark bookmark 
)

Definition at line 190 of file gsmdata.c.

References GSM_WAPBookmark::Address, AddWAPSMSParameterText(), EncodeUTF8(), and GSM_WAPBookmark::Title.

Referenced by GSM_EncodeMultiPartSMS().

191 {
192  unsigned char buffer[100];
193 
194  Buffer[(*Length)++] = 0x01; /* Push ID */
195  Buffer[(*Length)++] = 0x06; /* PDU Type (push) */
196  Buffer[(*Length)++] = 0x2D; /* Headers length (content type + headers) */
197  strcpy(Buffer+(*Length),"\x1F\x2B");
198  (*Length)=(*Length)+2; /* Value length */
199  strcpy(Buffer+(*Length),"application/x-wap-prov.browser-bookmarks");
200  (*Length)=(*Length)+40; /* MIME-Type */
201  Buffer[(*Length)++] = 0x00; /* end inline string */
202  strcpy(Buffer+(*Length),"\x81\xEA");
203  (*Length)=(*Length)+2; /* charset UTF-8 short int. */
204 
205  /* added by Joergen Thomsen */
206  Buffer[(*Length)++] = 0x01; /* Version WBXML 1.1 */
207  Buffer[(*Length)++] = 0x01; /* Unknown public identifier */
208  Buffer[(*Length)++] = 0x6A; /* charset UTF-8 */
209  Buffer[(*Length)++] = 0x00; /* string table length */
210 
211  Buffer[(*Length)++] = 0x45; /* CHARACTERISTIC-LIST with content */
212  /* URL */
213  Buffer[(*Length)++] = 0xC6; /* CHARACTERISTIC with content and attributes */
214  Buffer[(*Length)++] = 0x7F; /* TYPE = BOOKMARK */
215  Buffer[(*Length)++] = 0x01; /* END PARMeter */
216 
217  /* TITLE */
218  EncodeUTF8(buffer, bookmark->Title);
219  AddWAPSMSParameterText(Buffer, Length, 0x15, buffer, strlen(buffer));
220  /* URL */
221  EncodeUTF8(buffer, bookmark->Address);
222  AddWAPSMSParameterText(Buffer, Length, 0x17, buffer, strlen(buffer));
223 
224  Buffer[(*Length)++] = 0x01; /* END (CHARACTERISTIC) */
225  Buffer[(*Length)++] = 0x01; /* END (CHARACTERISTIC-LIST) */
226 }
static void AddWAPSMSParameterText(unsigned char *Buffer, size_t *Length, unsigned char ID, char *Text, int Len)
Definition: gsmdata.c:14
unsigned char Title[(50+1) *2]
Definition: gammu-wap.h:42
gboolean EncodeUTF8(char *dest, const unsigned char *src)
Definition: coding.c:1835
unsigned char Address[(255+1) *2]
Definition: gammu-wap.h:38

§ NOKIA_EncodeWAPMMSSettingsSMSText()

void NOKIA_EncodeWAPMMSSettingsSMSText ( unsigned char *  Buffer,
size_t *  Length,
GSM_WAPSettings settings,
gboolean  MMS 
)

Definition at line 41 of file gsmdata.c.

References AddWAPSMSParameterInt(), AddWAPSMSParameterText(), GSM_WAPSettings::Bearer, DecodeUnicodeString(), GSM_WAPSettings::DialUp, GSM_WAPSettings::HomePage, GSM_WAPSettings::IPAddress, GSM_WAPSettings::IsContinuous, GSM_WAPSettings::IsISDNCall, GSM_WAPSettings::IsNormalAuthentication, GSM_WAPSettings::IsSecurity, GSM_WAPSettings::ManualLogin, GSM_WAPSettings::Password, GSM_WAPSettings::Speed, GSM_WAPSettings::Title, UnicodeLength(), GSM_WAPSettings::User, WAPSETTINGS_BEARER_DATA, WAPSETTINGS_BEARER_GPRS, WAPSETTINGS_BEARER_SMS, WAPSETTINGS_BEARER_USSD, WAPSETTINGS_SPEED_14400, WAPSETTINGS_SPEED_9600, and WAPSETTINGS_SPEED_AUTO.

Referenced by GSM_EncodeMultiPartSMS().

42 {
43  int i;
44  unsigned char buffer[400];
45 
46  Buffer[(*Length)++] = 0x01; /* Push ID */
47  Buffer[(*Length)++] = 0x06; /* PDU Type (push) */
48  Buffer[(*Length)++] = 0x2C; /* Headers length (content type + headers) */
49  strcpy(Buffer+(*Length),"\x1F\x2A");
50  (*Length)=(*Length)+2; /* Value length */
51  strcpy(Buffer+(*Length),"application/x-wap-prov.browser-settings");
52  (*Length)=(*Length)+39; /* MIME-Type */
53  Buffer[(*Length)++] = 0x00; /* end inline string */
54  strcpy(Buffer+(*Length),"\x81\xEA");
55  (*Length)=(*Length)+2; /* charset UTF-8 short int. */
56  strcpy(Buffer+(*Length),"\x01\x01");
57  (*Length)=(*Length)+2; /* version WBXML 1.1 */
58  Buffer[(*Length)++] = 0x6A; /* charset UTF-8 */
59  Buffer[(*Length)++] = 0x00; /* string table length */
60 
61  Buffer[(*Length)++] = 0x45; /* CHARACTERISTIC-LIST with content */
62  Buffer[(*Length)++] = 0xC6; /* CHARACTERISTIC with content and attributes */
63  Buffer[(*Length)++] = 0x06; /* TYPE=ADDRESS */
64  Buffer[(*Length)++] = 0x01; /* END PARMeter */
65  switch (settings->Bearer) {
67  /* Bearer */
68  AddWAPSMSParameterInt(Buffer, Length, 0x12, 0x49);
69  /* PPP_LOGINTYPE (manual login or not) */
70  if (settings->ManualLogin) {
71  AddWAPSMSParameterInt(Buffer, Length, 0x1D, 0x65);
72  } else {
73  AddWAPSMSParameterInt(Buffer, Length, 0x1D, 0x64);
74  }
75  /* PPP_AUTHTYPE*/
76  if (settings->IsNormalAuthentication) {
77  /* OTA_CSD_AUTHTYPE_PAP */
78  AddWAPSMSParameterInt(Buffer, Length, 0x22, 0x70);
79  } else {
80  /* OTA_CSD_AUTHTYPE_CHAP */
81  AddWAPSMSParameterInt(Buffer, Length, 0x22, 0x71);
82  }
83  /* GPRS_ACCESSPOINTNAME */
84  AddWAPSMSParameterText(Buffer, Length, 0x1C, DecodeUnicodeString(settings->DialUp), UnicodeLength(settings->DialUp));
85  /* PROXY */
86  AddWAPSMSParameterText(Buffer, Length, 0x13, DecodeUnicodeString(settings->IPAddress), UnicodeLength(settings->IPAddress));
87  /* PPP_AUTHNAME (user) */
88  AddWAPSMSParameterText(Buffer, Length, 0x23, DecodeUnicodeString(settings->User), UnicodeLength(settings->User));
89  /* PPP_AUTHSECRET (password) */
90  AddWAPSMSParameterText(Buffer, Length, 0x24, DecodeUnicodeString(settings->Password), UnicodeLength(settings->Password));
91  break;
93  /* Bearer */
94  AddWAPSMSParameterInt(Buffer, Length, 0x12, 0x45);
95  /* CSD_DIALSTRING */
96  AddWAPSMSParameterText(Buffer, Length, 0x21, DecodeUnicodeString(settings->DialUp), UnicodeLength(settings->DialUp));
97  /* PROXY */
98  AddWAPSMSParameterText(Buffer, Length, 0x13, DecodeUnicodeString(settings->IPAddress), UnicodeLength(settings->IPAddress));
99  /* PPP_LOGINTYPE (manual login or not) */
100  if (settings->ManualLogin) {
101  AddWAPSMSParameterInt(Buffer, Length, 0x1D, 0x65);
102  } else {
103  AddWAPSMSParameterInt(Buffer, Length, 0x1D, 0x64);
104  }
105  /* PPP_AUTHTYPE*/
106  if (settings->IsNormalAuthentication) {
107  /* OTA_CSD_AUTHTYPE_PAP */
108  AddWAPSMSParameterInt(Buffer, Length, 0x22, 0x70);
109  } else {
110  /* OTA_CSD_AUTHTYPE_CHAP */
111  AddWAPSMSParameterInt(Buffer, Length, 0x22, 0x71);
112  }
113  /* CSD_CALLTYPE (type of call) */
114  if (settings->IsISDNCall) {
115  /* ISDN */
116  AddWAPSMSParameterInt(Buffer, Length, 0x28, 0x73);
117  } else {
118  /* analogue */
119  AddWAPSMSParameterInt(Buffer, Length, 0x28, 0x72);
120  }
121  /* CSD_CALLSPEED (speed of call) */
122  switch (settings->Speed) {
124  AddWAPSMSParameterInt(Buffer, Length, 0x29, 0x6A);
125  break;
127  AddWAPSMSParameterInt(Buffer, Length, 0x29, 0x6B);
128  break;
130  AddWAPSMSParameterInt(Buffer, Length, 0x29, 0x6C);
131  }
132  /* PPP_AUTHNAME (user) */
133  AddWAPSMSParameterText(Buffer, Length, 0x23, DecodeUnicodeString(settings->User), UnicodeLength(settings->User));
134  /* PPP_AUTHSECRET (password) */
135  AddWAPSMSParameterText(Buffer, Length, 0x24, DecodeUnicodeString(settings->Password), UnicodeLength(settings->Password));
136  break;
139  break;
140  }
141  /* PORT */
142  if (settings->IsSecurity) {
143  if (settings->IsContinuous) {
144  /* Port = 9203. Continuous */
145  AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x63);
146  } else {
147  /* Port = 9202. Temporary */
148  AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x62);
149  }
150  } else {
151  if (settings->IsContinuous) {
152  /* Port = 9201. Continuous */
153  AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x61);
154  } else {
155  /* Port = 9200. Temporary */
156  AddWAPSMSParameterInt(Buffer, Length, 0x14, 0x60);
157  }
158  }
159  Buffer[(*Length)++] = 0x01; /* END PARMeter */
160 
161  /* URL */
162  Buffer[(*Length)++] = 0x86; /* CHARACTERISTIC-LIST with attributes */
163  if (MMS) {
164  Buffer[(*Length)++] = 0x7C; /* TYPE = MMSURL */
165  } else {
166  Buffer[(*Length)++] = 0x07; /* TYPE = URL */
167  }
168  Buffer[(*Length)++] = 0x11; /* VALUE */
169  Buffer[(*Length)++] = 0x03; /* Inline string */
170  sprintf(buffer,"%s",DecodeUnicodeString(settings->HomePage));
171  for (i=0;i<(int)strlen(buffer);i++) {
172  Buffer[(*Length)++] = buffer[i];/* Text */
173  }
174  Buffer[(*Length)++] = 0x00; /* END Inline string */
175  Buffer[(*Length)++] = 0x01; /* END PARMeter */
176 
177  /* ISP_NAME (name) */
178  Buffer[(*Length)++] = 0xC6; /* CHARACTERISTIC with content and attributes */
179  Buffer[(*Length)++] = 0x08; /* TYPE=NAME */
180  Buffer[(*Length)++] = 0x01; /* END PARMeter */
181  /* Settings name */
182  AddWAPSMSParameterText(Buffer, Length, 0x15, DecodeUnicodeString(settings->Title), UnicodeLength(settings->Title));
183  Buffer[(*Length)++] = 0x01; /* END PARMeter */
184  Buffer[(*Length)++] = 0x01; /* END PARMeter */
185 }
char IPAddress[(20+1) *2]
Definition: gammu-wap.h:128
gboolean IsNormalAuthentication
Definition: gammu-wap.h:104
char * DecodeUnicodeString(const unsigned char *src)
Definition: coding.c:245
char Title[(20+1) *2]
Definition: gammu-wap.h:79
gboolean IsSecurity
Definition: gammu-wap.h:91
size_t UnicodeLength(const unsigned char *str)
Definition: coding.c:186
static void AddWAPSMSParameterInt(unsigned char *Buffer, size_t *Length, unsigned char ID, unsigned char Value)
Definition: gsmdata.c:30
WAPSettings_Bearer Bearer
Definition: gammu-wap.h:87
static void AddWAPSMSParameterText(unsigned char *Buffer, size_t *Length, unsigned char ID, char *Text, int Len)
Definition: gsmdata.c:14
char User[(50+1) *2]
Definition: gammu-wap.h:142
gboolean ManualLogin
Definition: gammu-wap.h:132
WAPSettings_Speed Speed
Definition: gammu-wap.h:152
gboolean IsISDNCall
Definition: gammu-wap.h:100
char Password[(50+1) *2]
Definition: gammu-wap.h:148
char DialUp[(20+1) *2]
Definition: gammu-wap.h:136
gboolean IsContinuous
Definition: gammu-wap.h:95
char HomePage[(100+1) *2]
Definition: gammu-wap.h:83