Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
ota_prov.c File Reference
#include <string.h>
#include "gwlib/gwlib.h"
#include "msg.h"
#include "sms.h"
#include "ota_prov.h"
#include "ota_prov_attr.h"
#include "ota_compiler.h"
#include "wap/wsp_headers.h"

Go to the source code of this file.

Functions

static void ota_pack_udh (Msg **msg, Octstr *doc_type)
 
static int ota_pack_push_headers (Msg **msg, Octstr *mime_type, Octstr *sec, Octstr *pin, Octstr *ota_binary)
 
int ota_pack_message (Msg **msg, Octstr *ota_doc, Octstr *doc_type, Octstr *from, Octstr *phone_number, Octstr *sec, Octstr *pin)
 
Msgota_tokenize_settings (CfgGroup *grp, Octstr *from, Octstr *receiver)
 
Msgota_tokenize_bookmarks (CfgGroup *grp, Octstr *from, Octstr *receiver)
 

Function Documentation

int ota_pack_message ( Msg **  msg,
Octstr ota_doc,
Octstr doc_type,
Octstr from,
Octstr phone_number,
Octstr sec,
Octstr pin 
)

Definition at line 207 of file ota_prov.c.

References DC_8BIT, info(), msg_create, mt_push, octstr_destroy(), octstr_dump, octstr_duplicate, octstr_format_append(), octstr_get_cstr, octstr_imm(), ota_compile(), ota_pack_push_headers(), and ota_pack_udh().

Referenced by smsbox_req_sendota(), and smsbox_sendota_post().

209 {
210  Octstr *ota_binary;
211 
212  *msg = msg_create(sms);
213  (*msg)->sms.sms_type = mt_push;
214 
215  ota_pack_udh(msg, doc_type);
216 
217  if (ota_compile(ota_doc, octstr_imm("UTF-8"), &ota_binary) == -1)
218  goto cerror;
219 
220  if (!ota_pack_push_headers(msg, doc_type, sec, pin, ota_binary))
221  goto herror;
222 
223  octstr_format_append((*msg)->sms.msgdata, "%S", ota_binary);
224  (*msg)->sms.sender = octstr_duplicate(from);
225  (*msg)->sms.receiver = octstr_duplicate(phone_number);
226  (*msg)->sms.coding = DC_8BIT;
227  (*msg)->sms.time = time(NULL);
228 
229  octstr_dump((*msg)->sms.msgdata, 0);
230  info(0, "/cgi-bin/sendota: XML request for target <%s>", octstr_get_cstr(phone_number));
231 
232  octstr_destroy(ota_binary);
233  octstr_destroy(ota_doc);
234  octstr_destroy(doc_type);
235  octstr_destroy(from);
236  octstr_destroy(sec);
237  octstr_destroy(pin);
238  return 0;
239 
240 herror:
241  octstr_destroy(ota_binary);
242  octstr_destroy(ota_doc);
243  octstr_destroy(doc_type);
244  octstr_destroy(from);
245  octstr_destroy(sec);
246  octstr_destroy(pin);
247  return -2;
248 
249 cerror:
250  octstr_destroy(ota_doc);
251  octstr_destroy(doc_type);
252  octstr_destroy(from);
253  octstr_destroy(sec);
254  octstr_destroy(pin);
255  return -1;
256 }
void info(int err, const char *fmt,...)
Definition: log.c:636
int ota_compile(Octstr *ota_doc, Octstr *charset, Octstr **ota_binary)
Definition: ota_compiler.c:473
#define DC_8BIT
Definition: sms.h:111
#define msg_create(type)
Definition: msg.h:136
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
Definition: msg.h:108
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
#define octstr_duplicate(ostr)
Definition: octstr.h:187
#define octstr_dump(ostr, level,...)
Definition: octstr.h:564
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
Definition: octstr.c:118
static int ota_pack_push_headers(Msg **msg, Octstr *mime_type, Octstr *sec, Octstr *pin, Octstr *ota_binary)
Definition: ota_prov.c:114
void octstr_format_append(Octstr *os, const char *fmt,...)
Definition: octstr.c:2505
static void ota_pack_udh(Msg **msg, Octstr *doc_type)
Definition: ota_prov.c:99
static int ota_pack_push_headers ( Msg **  msg,
Octstr mime_type,
Octstr sec,
Octstr pin,
Octstr ota_binary 
)
static

Definition at line 114 of file ota_prov.c.

References EVP_MAX_MD_SIZE, octstr_append(), octstr_append_from_hex(), octstr_append_uintvar(), octstr_binary_to_hex(), octstr_case_compare(), octstr_create, octstr_create_from_data, octstr_destroy(), octstr_format_append(), octstr_get_cstr, octstr_imm(), octstr_len(), warning(), and wsp_pack_short_integer().

Referenced by ota_pack_message().

116 {
117  (*msg)->sms.msgdata = octstr_create("");
118  if (octstr_case_compare(mime_type, octstr_imm("settings")) == 0) {
119 
120  /* PUSH ID, PDU type, header length, value length */
121  octstr_append_from_hex((*msg)->sms.msgdata, "01062C1F2A");
122  /* MIME type for settings */
123  octstr_format_append((*msg)->sms.msgdata, "%s",
124  "application/x-wap-prov.browser-settings");
125  octstr_append_from_hex((*msg)->sms.msgdata, "00");
126  /* charset UTF-8 */
127  octstr_append_from_hex((*msg)->sms.msgdata, "81EA");
128 
129  } else if (octstr_case_compare(mime_type, octstr_imm("bookmarks")) == 0) {
130 
131  /* PUSH ID, PDU type, header length, value length */
132  octstr_append_from_hex((*msg)->sms.msgdata, "01062D1F2B");
133  /* MIME type for bookmarks */
134  octstr_format_append((*msg)->sms.msgdata, "%s",
135  "application/x-wap-prov.browser-bookmarks");
136  octstr_append_from_hex((*msg)->sms.msgdata, "00");
137  /* charset UTF-8 */
138  octstr_append_from_hex((*msg)->sms.msgdata, "81EA");
139 
140  } else if (octstr_case_compare(mime_type, octstr_imm("syncsettings")) == 0) {
141 
142  octstr_append_from_hex((*msg)->sms.msgdata, "3406060502020b81EA");
143 
144  } else if (octstr_case_compare(mime_type, octstr_imm("oma-settings")) == 0) {
145  Octstr *hdr = octstr_create(""), *mac;
146  unsigned char *p;
147  unsigned int mac_len;
148 #ifdef HAVE_LIBSSL
149  unsigned char macbuf[EVP_MAX_MD_SIZE];
150 #endif
151 
152  /* PUSH ID, PDU type, header length, value length */
153  octstr_append_from_hex((*msg)->sms.msgdata, "0106");
154 
155  octstr_append_from_hex(hdr, "1f2db6"); /* Content type + other type + sec param */
156  wsp_pack_short_integer(hdr, 0x11);
157  if (octstr_case_compare(sec, octstr_imm("netwpin")) == 0)
158  wsp_pack_short_integer(hdr, 0x0);
159  else if (octstr_case_compare(sec, octstr_imm("userpin")) == 0)
160  wsp_pack_short_integer(hdr, 0x01);
161  else if (octstr_case_compare(sec, octstr_imm("usernetwpin")) == 0)
162  wsp_pack_short_integer(hdr, 0x02);
163  else if (octstr_case_compare(sec, octstr_imm("userpinmac")) == 0)
164  wsp_pack_short_integer(hdr, 0x03); /* XXXX Although not quite supported now.*/
165  else {
166  warning(0, "OMA ProvCont: Unknown SEC pin type '%s'.", octstr_get_cstr(sec));
167  wsp_pack_short_integer(hdr, 0x01);
168  }
169  wsp_pack_short_integer(hdr, 0x12); /* MAC */
170 
171 #ifdef HAVE_LIBSSL
172  p = HMAC(EVP_sha1(), octstr_get_cstr(pin), octstr_len(pin),
173  (unsigned char *)octstr_get_cstr(ota_binary), octstr_len(ota_binary),
174  macbuf, &mac_len);
175 #else
176  mac_len = 0;
177  p = "";
178  warning(0, "OMA ProvCont: No SSL Support, '%s' not supported!", octstr_get_cstr(mime_type));
179 #endif
180  mac = octstr_create_from_data((char *)p, mac_len);
181  octstr_binary_to_hex(mac, 1);
182 
183  octstr_append(hdr, mac);
184  octstr_append_from_hex(hdr, "00");
185 
186  octstr_append_uintvar((*msg)->sms.msgdata, octstr_len(hdr));
187  octstr_append((*msg)->sms.msgdata, hdr);
188 
189  octstr_destroy(hdr);
190  octstr_destroy(mac);
191 
192  } else {
193  warning(0, "Unknown MIME type in OTA request, type '%s' is unsupported.",
194  octstr_get_cstr(mime_type));
195  return 0;
196  }
197 
198  return 1;
199 }
void octstr_append_from_hex(Octstr *ostr, char *hex)
Definition: octstr.c:449
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1502
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void octstr_binary_to_hex(Octstr *ostr, int uppercase)
Definition: octstr.c:463
void wsp_pack_short_integer(Octstr *packed, unsigned long integer)
Definition: wsp_headers.c:1800
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
int octstr_case_compare(const Octstr *os1, const Octstr *os2)
Definition: octstr.c:901
void warning(int err, const char *fmt,...)
Definition: log.c:624
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
void octstr_append_uintvar(Octstr *ostr, unsigned long value)
Definition: octstr.c:1929
Definition: octstr.c:118
void octstr_format_append(Octstr *os, const char *fmt,...)
Definition: octstr.c:2505
#define EVP_MAX_MD_SIZE
Definition: test_hmac.c:82
#define octstr_create_from_data(data, len)
Definition: octstr.h:134
static void ota_pack_udh ( Msg **  msg,
Octstr doc_type 
)
static

Definition at line 99 of file ota_prov.c.

References octstr_append_from_hex(), octstr_case_compare(), octstr_create, and octstr_imm().

Referenced by ota_pack_message().

100 {
101  (*msg)->sms.udhdata = octstr_create("");
102  if (octstr_case_compare(doc_type, octstr_imm("oma-settings")) == 0)
103  octstr_append_from_hex((*msg)->sms.udhdata, "0605040B840B84");
104  else if (octstr_case_compare(doc_type, octstr_imm("syncsettings")) == 0) {
105  octstr_append_from_hex((*msg)->sms.udhdata, "060504C34CC002");
106  } else
107  octstr_append_from_hex((*msg)->sms.udhdata, "060504C34FC002");
108  }
void octstr_append_from_hex(Octstr *ostr, char *hex)
Definition: octstr.c:449
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
int octstr_case_compare(const Octstr *os1, const Octstr *os2)
Definition: octstr.c:901
#define octstr_create(cstr)
Definition: octstr.h:125
Msg* ota_tokenize_bookmarks ( CfgGroup grp,
Octstr from,
Octstr receiver 
)

Definition at line 540 of file ota_prov.c.

References cfg_get, DC_8BIT, from, msg, msg_create, mt_push, name, octstr_append(), octstr_append_char(), octstr_append_from_hex(), octstr_create, octstr_destroy(), octstr_duplicate, octstr_format_append(), octstr_imm(), url, WBXML_TOK_END, WBXML_TOK_END_STR_I, WBXML_TOK_NAME_NAME, WBXML_TOK_NAME_URL, WBXML_TOK_STR_I, WBXML_TOK_TYPE_BOOKMARK, and WBXML_TOK_VALUE.

Referenced by smsbox_req_sendota().

541 {
542  Octstr *url, *name;
543  Msg *msg;
544 
545  url = NULL;
546  name = NULL;
547 
548  url = cfg_get(grp, octstr_imm("url"));
549  name = cfg_get(grp, octstr_imm("name"));
550 
551  msg = msg_create(sms);
552 
553  /*
554  * Append the User Data Header (UDH) including the length (UDHL)
555  * WDP layer (start WDP headers)
556  */
557 
558  msg->sms.sms_type = mt_push;
559  msg->sms.udhdata = octstr_create("");
560 
561  octstr_append_from_hex(msg->sms.udhdata, "060504C34FC002");
562  /* WDP layer (end WDP headers) */
563 
564  /*
565  * WSP layer (start WSP headers)
566  */
567 
568  msg->sms.msgdata = octstr_create("");
569  /* PUSH ID, PDU type, header length, value length */
570  octstr_append_from_hex(msg->sms.msgdata, "01062D1F2B");
571  /* MIME-type: application/x-wap-prov.browser-bookmarks */
572  octstr_format_append(msg->sms.msgdata, "%s",
573  "application/x-wap-prov.browser-bookmarks");
574  octstr_append_from_hex(msg->sms.msgdata, "00");
575  /* charset UTF-8 */
576  octstr_append_from_hex(msg->sms.msgdata, "81EA");
577  /* WSP layer (end WSP headers) */
578 
579  /*
580  * WSP layer (start WSP data field)
581  */
582 
583  /* WBXML version 1.1 */
584  octstr_append_from_hex(msg->sms.msgdata, "0101");
585  /* charset UTF-8 */
586  octstr_append_from_hex(msg->sms.msgdata, "6A00");
587 
588  /* CHARACTERISTIC_LIST */
589  octstr_append_from_hex(msg->sms.msgdata, "45");
590  /* CHARACTERISTIC with content and attributes */
591  octstr_append_from_hex(msg->sms.msgdata, "C6");
592  /* TYPE=BOOKMARK */
593  octstr_append_char(msg->sms.msgdata, WBXML_TOK_TYPE_BOOKMARK);
594  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
595 
596  /* name */
597  if (name != NULL) {
598  /* PARM with attributes */
599  octstr_append_from_hex(msg->sms.msgdata, "87");
600  /* NAME=PROXY, VALUE, inline string */
601  octstr_append_char(msg->sms.msgdata, WBXML_TOK_NAME_NAME);
602  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
603  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
604  octstr_append(msg->sms.msgdata, octstr_duplicate(name));
605  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
606  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
607  }
608  /* URL */
609  if (url != NULL) {
610  /* PARM with attributes */
611  octstr_append_from_hex(msg->sms.msgdata, "87");
612  /* NAME=PROXY, VALUE, inline string */
613  octstr_append_char(msg->sms.msgdata, WBXML_TOK_NAME_URL);
614  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
615  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
616  octstr_append(msg->sms.msgdata, octstr_duplicate(url));
617  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
618  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
619  }
620 
621  /* end of CHARACTERISTIC */
622  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
623  /* end of CHARACTERISTIC-LIST */
624  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
625  /* WSP layer (end WSP data field) */
626 
627  msg->sms.sender = from;
628  msg->sms.receiver = octstr_duplicate(receiver);
629  msg->sms.coding = DC_8BIT;
630 
631  msg->sms.time = time(NULL);
632 
633  octstr_destroy(name);
634  octstr_destroy(url);
635 
636  return msg;
637 }
void octstr_append_from_hex(Octstr *ostr, char *hex)
Definition: octstr.c:449
#define WBXML_TOK_TYPE_BOOKMARK
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1502
#define WBXML_TOK_NAME_NAME
void octstr_append_char(Octstr *ostr, int ch)
Definition: octstr.c:1515
#define cfg_get(grp, varname)
Definition: cfg.h:86
#define DC_8BIT
Definition: sms.h:111
#define msg_create(type)
Definition: msg.h:136
#define WBXML_TOK_END_STR_I
static Octstr * from
Definition: mtbatch.c:95
Definition: msg.h:108
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
Definition: msg.h:79
#define WBXML_TOK_NAME_URL
#define octstr_duplicate(ostr)
Definition: octstr.h:187
char * name
Definition: smsc_cimd2.c:212
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
#define WBXML_TOK_STR_I
Definition: octstr.c:118
void octstr_format_append(Octstr *os, const char *fmt,...)
Definition: octstr.c:2505
#define WBXML_TOK_VALUE
static Octstr * url
Definition: test_xmlrpc.c:84
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
#define WBXML_TOK_END
Msg* ota_tokenize_settings ( CfgGroup grp,
Octstr from,
Octstr receiver 
)

Definition at line 259 of file ota_prov.c.

References cfg_get, connection, DC_8BIT, from, msg, msg_create, mt_push, octstr_append(), octstr_append_char(), octstr_append_from_hex(), octstr_compare(), octstr_create, octstr_destroy(), octstr_duplicate, octstr_format_append(), octstr_get_cstr, octstr_imm(), url, username, WBXML_TOK_END, WBXML_TOK_END_STR_I, WBXML_TOK_NAME_BEARER, WBXML_TOK_NAME_CSD_CALLSPEED, WBXML_TOK_NAME_CSD_CALLTYPE, WBXML_TOK_NAME_CSD_DIALSTRING, WBXML_TOK_NAME_NAME, WBXML_TOK_NAME_PORT, WBXML_TOK_NAME_PPP_AUTHNAME, WBXML_TOK_NAME_PPP_AUTHSECRET, WBXML_TOK_NAME_PPP_AUTHTYPE, WBXML_TOK_NAME_PROXY, WBXML_TOK_STR_I, WBXML_TOK_TYPE_ADDRESS, WBXML_TOK_TYPE_NAME, WBXML_TOK_TYPE_URL, WBXML_TOK_VALUE, WBXML_TOK_VALUE_AUTH_CHAP, WBXML_TOK_VALUE_AUTH_PAP, WBXML_TOK_VALUE_CONN_ANALOGUE, WBXML_TOK_VALUE_CONN_ISDN, WBXML_TOK_VALUE_GSM_CSD, WBXML_TOK_VALUE_PORT_9200, WBXML_TOK_VALUE_PORT_9201, WBXML_TOK_VALUE_PORT_9202, WBXML_TOK_VALUE_PORT_9203, WBXML_TOK_VALUE_SPEED_14400, and WBXML_TOK_VALUE_SPEED_9600.

Referenced by smsbox_req_sendota().

260 {
261  Octstr *url, *desc, *ipaddr, *phonenum, *username, *passwd;
262  int speed, bearer, calltype, connection, security, authent;
263  Msg *msg;
264  Octstr *p;
265 
266  url = NULL;
267  desc = NULL;
268  ipaddr = NULL;
269  phonenum = NULL;
270  username = NULL;
271  passwd = NULL;
272  bearer = -1;
273  calltype = WBXML_TOK_VALUE_CONN_ISDN;
274  connection = WBXML_TOK_VALUE_PORT_9201;
275  security = 0;
276  authent = WBXML_TOK_VALUE_AUTH_PAP;
277 
278  url = cfg_get(grp, octstr_imm("location"));
279  desc = cfg_get(grp, octstr_imm("service"));
280  ipaddr = cfg_get(grp, octstr_imm("ipaddress"));
281  phonenum = cfg_get(grp, octstr_imm("phonenumber"));
282  p = cfg_get(grp, octstr_imm("bearer"));
283  if (p != NULL) {
284  if (strcasecmp(octstr_get_cstr(p), "data") == 0)
285  bearer = WBXML_TOK_VALUE_GSM_CSD;
286  else
287  bearer = -1;
288  octstr_destroy(p);
289  }
290  p = cfg_get(grp, octstr_imm("calltype"));
291  if (p != NULL) {
292  if (strcasecmp(octstr_get_cstr(p), "analog") == 0)
294  else
295  calltype = WBXML_TOK_VALUE_CONN_ISDN;
296  octstr_destroy(p);
297  }
298 
300  p = cfg_get(grp, octstr_imm("speed"));
301  if (p != NULL) {
302  if (octstr_compare(p, octstr_imm("14400")) == 0)
304  octstr_destroy(p);
305  }
306 
307  /* connection mode: UDP (port 9200) or TCP (port 9201)*/
308  p = cfg_get(grp, octstr_imm("connection"));
309  if (p != NULL) {
310  if (strcasecmp(octstr_get_cstr(p), "temp") == 0)
311  connection = WBXML_TOK_VALUE_PORT_9200;
312  else
313  connection = WBXML_TOK_VALUE_PORT_9201;
314  octstr_destroy(p);
315  }
316 
317  /* dial in security: CHAP or PAP */
318  p = cfg_get(grp, octstr_imm("pppsecurity"));
319  if (p != NULL) {
320  if (strcasecmp(octstr_get_cstr(p), "on") == 0)
321  authent = WBXML_TOK_VALUE_AUTH_CHAP;
322  else
323  authent = WBXML_TOK_VALUE_AUTH_PAP;
324  octstr_destroy(p);
325  }
326 
327  /* WTLS: for UDP (port 9202) or TCP (port 9203) */
328  p = cfg_get(grp, octstr_imm("authentication"));
329  if (p != NULL) {
330  if (strcasecmp(octstr_get_cstr(p), "secure") == 0)
331  security = 1;
332  else
333  security = WBXML_TOK_VALUE_PORT_9201;
334  octstr_destroy(p);
335  }
336  if (security == 1)
337  connection = (connection == WBXML_TOK_VALUE_PORT_9201)?
339 
340  username = cfg_get(grp, octstr_imm("login"));
341  passwd = cfg_get(grp, octstr_imm("secret"));
342 
343  msg = msg_create(sms);
344 
345  /*
346  * Append the User Data Header (UDH) including the length (UDHL)
347  * WDP layer (start WDP headers)
348  */
349 
350  msg->sms.sms_type = mt_push;
351  msg->sms.udhdata = octstr_create("");
352 
353  /*
354  * Within OTA spec this is "0B0504C34FC0020003040201", but it works
355  * with the following too?!
356  */
357  octstr_append_from_hex(msg->sms.udhdata, "060504C34FC002");
358  /* WDP layer (end WDP headers) */
359 
360  /*
361  * WSP layer (start WSP headers)
362  */
363 
364  msg->sms.msgdata = octstr_create("");
365  /* PUSH ID, PDU type, header length, value length */
366  octstr_append_from_hex(msg->sms.msgdata, "01062C1F2A");
367  /* MIME-type: application/x-wap-prov.browser-settings */
368  octstr_format_append(msg->sms.msgdata, "%s",
369  "application/x-wap-prov.browser-settings");
370  octstr_append_from_hex(msg->sms.msgdata, "00");
371  /* charset UTF-8 */
372  octstr_append_from_hex(msg->sms.msgdata, "81EA");
373  /* WSP layer (end WSP headers) */
374 
375  /*
376  * WSP layer (start WSP data field)
377  */
378 
379  /* WBXML version 1.1 */
380  octstr_append_from_hex(msg->sms.msgdata, "0101");
381  /* charset UTF-8 */
382  octstr_append_from_hex(msg->sms.msgdata, "6A00");
383 
384  /* CHARACTERISTIC_LIST */
385  octstr_append_from_hex(msg->sms.msgdata, "45");
386  /* CHARACTERISTIC with content and attributes */
387  octstr_append_from_hex(msg->sms.msgdata, "C6");
388  /* TYPE=ADDRESS */
389  octstr_append_char(msg->sms.msgdata, WBXML_TOK_TYPE_ADDRESS);
390  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
391 
392  /* bearer type */
393  if (bearer != -1) {
394  /* PARM with attributes */
395  octstr_append_from_hex(msg->sms.msgdata, "87");
396  /* NAME=BEARER, VALUE=GSM_CSD */
397  octstr_append_char(msg->sms.msgdata, WBXML_TOK_NAME_BEARER);
398  octstr_append_char(msg->sms.msgdata, bearer);
399  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
400  }
401  /* IP address */
402  if (ipaddr != NULL) {
403  /* PARM with attributes */
404  octstr_append_from_hex(msg->sms.msgdata, "87");
405  /* NAME=PROXY, VALUE, inline string */
406  octstr_append_char(msg->sms.msgdata, WBXML_TOK_NAME_PROXY);
407  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
408  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
409  octstr_append(msg->sms.msgdata, octstr_duplicate(ipaddr));
410  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
411  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
412  }
413  /* connection type */
414  if (connection != -1) {
415  /* PARM with attributes */
416  octstr_append_from_hex(msg->sms.msgdata, "87");
417  /* NAME=PORT, VALUE */
418  octstr_append_char(msg->sms.msgdata, WBXML_TOK_NAME_PORT);
419  octstr_append_char(msg->sms.msgdata, connection);
420  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
421  }
422  /* phone number */
423  if (phonenum != NULL) {
424  /* PARM with attributes */
425  octstr_append_from_hex(msg->sms.msgdata, "87");
426  /* NAME=CSD_DIALSTRING, VALUE, inline string */
428  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
429  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
430  octstr_append(msg->sms.msgdata, octstr_duplicate(phonenum));
431  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
432  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
433  }
434  /* authentication */
435  /* PARM with attributes */
436  octstr_append_from_hex(msg->sms.msgdata, "87");
437  /* NAME=PPP_AUTHTYPE, VALUE */
439  octstr_append_char(msg->sms.msgdata, authent);
440  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
441  /* user name */
442  if (username != NULL) {
443  /* PARM with attributes */
444  octstr_append_from_hex(msg->sms.msgdata, "87");
445  /* NAME=PPP_AUTHNAME, VALUE, inline string */
447  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
448  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
449  octstr_append(msg->sms.msgdata, octstr_duplicate(username));
450  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
451  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
452  }
453  /* password */
454  if (passwd != NULL) {
455  /* PARM with attributes */
456  octstr_append_from_hex(msg->sms.msgdata, "87");
457  /* NAME=PPP_AUTHSECRET, VALUE, inline string */
459  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
460  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
461  octstr_append(msg->sms.msgdata, octstr_duplicate(passwd));
462  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
463  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
464  }
465  /* data call type */
466  if (calltype != -1) {
467  /* PARM with attributes */
468  octstr_append_from_hex(msg->sms.msgdata, "87");
469  /* NAME=CSD_CALLTYPE, VALUE */
471  octstr_append_char(msg->sms.msgdata, calltype);
472  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
473  }
474  /* speed */
475  /* PARM with attributes */
476  octstr_append_from_hex(msg->sms.msgdata, "87");
477  /* NAME=CSD_CALLSPEED, VALUE */
479  octstr_append_char(msg->sms.msgdata, speed);
480  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
481 
482  /* end CHARACTERISTIC TYPE=ADDRESS */
483  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
484 
485  /* homepage */
486  if (url != NULL) {
487  /* CHARACTERISTIC with attributes */
488  octstr_append_from_hex(msg->sms.msgdata, "86");
489  /* TYPE=URL */
490  octstr_append_char(msg->sms.msgdata, WBXML_TOK_TYPE_URL);
491  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
492  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
493  octstr_append(msg->sms.msgdata, url);
494  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
495  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
496  }
497 
498  /* CHARACTERISTIC with content and attributes */
499  octstr_append_from_hex(msg->sms.msgdata, "C6");
500  /* TYPE=NAME */
501  octstr_append_char(msg->sms.msgdata, WBXML_TOK_TYPE_NAME);
502  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
503 
504  /* service description */
505  if (desc != NULL) {
506  /* PARAM with attributes */
507  octstr_append_from_hex(msg->sms.msgdata, "87");
508  /* NAME=NAME, VALUE, inline */
509  octstr_append_char(msg->sms.msgdata, WBXML_TOK_NAME_NAME);
510  octstr_append_char(msg->sms.msgdata, WBXML_TOK_VALUE);
511  octstr_append_char(msg->sms.msgdata, WBXML_TOK_STR_I);
512  octstr_append(msg->sms.msgdata, desc);
513  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END_STR_I);
514  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
515  }
516 
517  /* end of CHARACTERISTIC */
518  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
519  /* end of CHARACTERISTIC-LIST */
520  octstr_append_char(msg->sms.msgdata, WBXML_TOK_END);
521  /* WSP layer (end WSP data field) */
522 
523  msg->sms.sender = from;
524  msg->sms.receiver = octstr_duplicate(receiver);
525  msg->sms.coding = DC_8BIT;
526 
527  msg->sms.time = time(NULL);
528 
529  octstr_destroy(url);
530  octstr_destroy(desc);
531  octstr_destroy(ipaddr);
532  octstr_destroy(phonenum);
533  octstr_destroy(username);
534  octstr_destroy(passwd);
535 
536  return msg;
537 }
#define WBXML_TOK_NAME_CSD_CALLSPEED
void octstr_append_from_hex(Octstr *ostr, char *hex)
Definition: octstr.c:449
#define WBXML_TOK_NAME_PPP_AUTHSECRET
void octstr_append(Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:1502
#define WBXML_TOK_NAME_PPP_AUTHNAME
#define WBXML_TOK_VALUE_AUTH_PAP
#define WBXML_TOK_VALUE_PORT_9200
#define WBXML_TOK_NAME_NAME
static Octstr * connection
Definition: test_ppg.c:103
void octstr_append_char(Octstr *ostr, int ch)
Definition: octstr.c:1515
#define cfg_get(grp, varname)
Definition: cfg.h:86
#define DC_8BIT
Definition: sms.h:111
#define WBXML_TOK_NAME_BEARER
#define msg_create(type)
Definition: msg.h:136
#define WBXML_TOK_VALUE_PORT_9203
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
#define WBXML_TOK_TYPE_URL
unsigned char * username
Definition: test_cimd2.c:99
#define WBXML_TOK_END_STR_I
static Octstr * from
Definition: mtbatch.c:95
Definition: msg.h:108
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
Definition: msg.h:79
#define WBXML_TOK_VALUE_SPEED_9600
#define WBXML_TOK_VALUE_CONN_ANALOGUE
#define WBXML_TOK_NAME_CSD_DIALSTRING
#define WBXML_TOK_VALUE_CONN_ISDN
#define WBXML_TOK_NAME_PROXY
#define octstr_duplicate(ostr)
Definition: octstr.h:187
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define WBXML_TOK_TYPE_NAME
#define octstr_create(cstr)
Definition: octstr.h:125
#define WBXML_TOK_NAME_PORT
#define WBXML_TOK_TYPE_ADDRESS
#define WBXML_TOK_STR_I
Definition: octstr.c:118
#define WBXML_TOK_VALUE_PORT_9202
void octstr_format_append(Octstr *os, const char *fmt,...)
Definition: octstr.c:2505
#define WBXML_TOK_VALUE_SPEED_14400
#define WBXML_TOK_NAME_PPP_AUTHTYPE
#define WBXML_TOK_VALUE
#define WBXML_TOK_VALUE_AUTH_CHAP
static Octstr * url
Definition: test_xmlrpc.c:84
#define WBXML_TOK_VALUE_PORT_9201
#define WBXML_TOK_VALUE_GSM_CSD
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
#define WBXML_TOK_NAME_CSD_CALLTYPE
#define WBXML_TOK_END
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:869
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.