Kannel: Open Source WAP and SMS gateway  svn-r5335
wap_push_pap_compiler.h File Reference
#include "wap/wap_events.h"
#include "gwlib/gwlib.h"

Go to the source code of this file.

Enumerations

enum  {
  ADDR_IPV4 = 0, ADDR_PLMN = 1, ADDR_USER = 2, ADDR_IPV6 = 3,
  ADDR_WINA = 4
}
 

Functions

int pap_compile (Octstr *pap_content, WAPEvent **e)
 
int parse_address (Octstr **attr_value, long *type_of_address)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
ADDR_IPV4 
ADDR_PLMN 
ADDR_USER 
ADDR_IPV6 
ADDR_WINA 

Definition at line 72 of file wap_push_pap_compiler.h.

Function Documentation

◆ pap_compile()

int pap_compile ( Octstr pap_content,
WAPEvent **  e 
)

Definition at line 350 of file wap_push_pap_compiler.c.

References error(), octstr_get_cstr, octstr_len(), octstr_search_char(), octstr_strip_blanks(), parse_document(), wap_event_destroy(), and warning().

Referenced by main(), pap_request_thread(), and receive_push_reply().

351 {
352  xmlDocPtr doc_p;
353  size_t oslen;
354  int ret;
355 
356  if (octstr_search_char(pap_content, '\0', 0) != -1) {
357  warning(0, "PAP COMPILER: pap_compile: pap source contained a \\0"
358  " character");
359  return -2;
360  }
361 
362  octstr_strip_blanks(pap_content);
363  oslen = octstr_len(pap_content);
364  doc_p = xmlParseMemory(octstr_get_cstr(pap_content), oslen);
365  if (doc_p == NULL) {
366  goto error;
367  }
368 
369  if ((ret = parse_document(doc_p, e)) < 0) {
370  goto parserror;
371  }
372 
373  xmlFreeDoc(doc_p);
374  return 0;
375 
376 parserror:
377  xmlFreeDoc(doc_p);
378  wap_event_destroy(*e);
379  *e = NULL;
380  return ret;
381 
382 error:
383  warning(0, "PAP COMPILER: pap_compile: parse error in pap source");
384  xmlFreeDoc(doc_p);
385  wap_event_destroy(*e);
386  *e = NULL;
387  return -2;
388 }
void error(int err, const char *fmt,...)
Definition: log.c:648
static int parse_document(xmlDocPtr doc_p, WAPEvent **e)
void octstr_strip_blanks(Octstr *text)
Definition: octstr.c:1346
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
long octstr_search_char(const Octstr *ostr, int ch, long pos)
Definition: octstr.c:1012
void warning(int err, const char *fmt,...)
Definition: log.c:660
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
void wap_event_destroy(WAPEvent *event)
Definition: wap_events.c:102

◆ parse_address()

int parse_address ( Octstr **  attr_value,
long *  type_of_address 
)

Definition at line 1492 of file wap_push_pap_compiler.c.

References info(), octstr_delete(), octstr_destroy(), octstr_duplicate, octstr_get_char(), octstr_get_cstr, octstr_len(), octstr_search_char(), parse_ppg_specifier(), parse_wappush_client_address(), and warning().

Referenced by parse_address_value().

1493 {
1494  long pos;
1495  Octstr *copy;
1496 
1497  pos = octstr_len(*address) - 1;
1498 /*
1499  * Delete first separator, if there is one. This will help our parsing later.
1500  */
1501  if (octstr_get_char(*address, 0) == '/')
1502  octstr_delete(*address, 0, 1);
1503 
1504 /*
1505  * WAP-209, chapter 8 states that addresses with telephone numbers
1506  * should not have a ppg specifier. WAP-151 grammar, however, makes it
1507  * mandatory. Best way to solve this contradiction seems to be regarding
1508  * ppg specifier optional - MMSC is very important type of pi.
1509  */
1510  if (octstr_search_char(*address, '@', 0) >= 0) {
1511  if ((pos = parse_ppg_specifier(address, pos)) < 0)
1512  return -2;
1513  }
1514 
1515  if ((pos = parse_wappush_client_address(address, pos,
1516  type_of_address)) == -2) {
1517  warning(0, "illegal client address");
1518  return -2;
1519  } else if (pos == -1) {
1520  warning(0, "unimplemented feature");
1521  return -1;
1522  }
1523 
1524  info(0, "client address was <%s>, accepted",
1525  octstr_get_cstr(copy = octstr_duplicate(*address)));
1526  octstr_destroy(copy);
1527 
1528  return pos;
1529 }
void info(int err, const char *fmt,...)
Definition: log.c:672
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
long octstr_search_char(const Octstr *ostr, int ch, long pos)
Definition: octstr.c:1012
static long parse_ppg_specifier(Octstr **address, long pos)
void octstr_delete(Octstr *ostr1, long pos, long len)
Definition: octstr.c:1527
static long parse_wappush_client_address(Octstr **address, long pos, long *type_of_address)
#define octstr_duplicate(ostr)
Definition: octstr.h:187
void warning(int err, const char *fmt,...)
Definition: log.c:660
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:324
long octstr_len(const Octstr *ostr)
Definition: octstr.c:342
Definition: octstr.c:118
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:406
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.