Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

wap_push_ppg.c File Reference

#include <time.h>
#include <ctype.h>
#include "wap_push_ppg.h"
#include "wap/wap_events.h"
#include "wap/wsp_caps.h"
#include "wml_compiler.h"
#include "wap-appl.h"
#include "wap/wsp.h"
#include "wap/wsp_strings.h"
#include "wap_push_si_compiler.h"
#include "wap_push_sl_compiler.h"
#include "wap_push_pap_compiler.h"
#include "wap_push_pap_mime.h"
#include "wap_push_ppg_pushuser.h"
#include "wap_ppg_session_machine.def"
#include "wap_ppg_push_machine.def"

Include dependency graph for wap_push_ppg.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  content
struct  PAPEvent
struct  description_t

Defines

#define DEFAULT_PPG_URL   "/wappush"
#define INTEGER(name)   m->name = 0;
#define OCTSTR(name)   m->name = NULL;
#define ADDRTUPLE(name)   m->name = NULL;
#define PUSHMACHINES(name)   m->name = gwlist_create();
#define CAPABILITIES(name)   m->name = NULL;
#define MACHINE(fields)   fields
#define OCTSTR(name)   octstr_destroy(sm->name);
#define ADDRTUPLE(name)   wap_addr_tuple_destroy(sm->name);
#define INTEGER(name)   sm->name = 0;
#define PUSHMACHINES(name)   push_machines_list_destroy(sm->name);
#define CAPABILITIES(name)   wsp_cap_destroy_list(sm->name);
#define MACHINE(fields)   fields
#define INTEGER(name)   m->name = 0;
#define OCTSTR(name)   m->name = NULL;
#define OPTIONAL_OCTSTR(name)   m->name = NULL;
#define ADDRTUPLE(name)   m->name = NULL;
#define CAPABILITIES   m->name = NULL;
#define HTTPHEADER(name)   m->name = NULL;
#define MACHINE(fields)   fields
#define OCTSTR(name)   octstr_destroy(pm->name);
#define OPTIONAL_OCTSTR(name)   octstr_destroy(pm->name);
#define INTEGER(name)
#define ADDRTUPLE(name)   wap_addr_tuple_destroy(pm->name);
#define CAPABILITIES(name)   wap_cap_destroy_list(pm->name);
#define HTTPHEADER(name)   http_destroy_headers(pm->name);
#define MACHINE(fields)   fields
#define NUM_CONVERTERS   ((long) (sizeof(converters) / sizeof(converters[0])))
#define NUM_EXTRACTORS   ((long) (sizeof(extractors) / sizeof(extractors[0])))
#define NUMBER_OF_BEARERS   sizeof(bearers)/sizeof(bearers[0])
#define NUMBER_OF_NETWORKS   sizeof(networks)/sizeof(networks[0])
#define NUMBER_OF_WINA_URIS   sizeof(wina_uri)/sizeof(wina_uri[0])

Typedefs

typedef PAPEvent PAPEvent
typedef description_t description_t

Enumerations

enum  { TIME_EXPIRED = 0, TIME_TOO_EARLY = 1, NO_CONSTRAINTS = 2 }
enum  {
  DEFAULT_HTTP_PORT = 8080, NO_HTTPS_PORT = -1, DEFAULT_NUMBER_OF_PUSHES = 100, PI_TRUSTED = 1,
  SSL_CONNECTION_OFF = 0, DEFAULT_NUMBER_OF_USERS = 1024, USER_CONFIGURATION_NOT_ADDED = 0
}
enum  { USER_CONFIGURATION_ADDED = 1 }
enum  { limbo, running, terminating }
enum  { TYPE_HTTP = 0, TYPE_HTTPS = 1 }

Functions

void ota_read_thread (void *arg)
void http_read_thread (void *arg)
void https_read_thread (void *arg)
void handle_internal_event (WAPEvent *e)
void pap_request_thread (void *arg)
int handle_push_message (HTTPClient **c, WAPEvent *ppg_event, int status)
PAPEventpap_event_create (Octstr *ip, Octstr *url, List *push_headers, Octstr *mime_content, List *cgivars, HTTPClient *client)
void pap_event_destroy (PAPEvent *p)
void pap_event_destroy_item (void *p)
void pap_event_unpack (PAPEvent *p, Octstr **ip, Octstr **url, List **push_headers, Octstr **mime_content, List **cgivars, HTTPClient **client)
PPGSessionMachinesession_machine_create (WAPAddrTuple *tuple, WAPEvent *e)
void session_machine_destroy (void *p)
PPGPushMachinepush_machine_create (WAPEvent *e, WAPAddrTuple *tuple)
void push_machine_destroy (void *pm)
void push_machines_list_destroy (List *pl)
void create_session (WAPEvent *e, PPGPushMachine *pm)
void request_confirmed_push (long last, PPGPushMachine *pm, PPGSessionMachine *sm)
void request_unit_push (long last, PPGPushMachine *pm)
void request_push (long last, PPGPushMachine *sm)
int response_push_connection (WAPEvent *e, PPGSessionMachine *sm)
HTTPClientresponse_push_message (PPGPushMachine *pm, long code, int status)
PPGSessionMachinesession_find_using_pi_client_address (Octstr *addr)
PPGPushMachinefind_ppg_push_machine_using_pid (PPGSessionMachine *sm, long pid)
PPGPushMachinefind_ppg_push_machine_using_pi_push_id (PPGSessionMachine *sm, Octstr *pi_push_id)
PPGPushMachinefind_unit_ppg_push_machine_using_pi_push_id (Octstr *pi_push_id)
int push_has_pi_push_id (void *a, void *b)
int push_has_pid (void *a, void *b)
int session_has_pi_client_address (void *a, void *b)
int session_has_addr (void *a, void *b)
int session_has_sid (void *a, void *b)
int check_capabilities (List *requested, List *assumed)
int transform_message (WAPEvent **e, WAPAddrTuple **tuple, List *push_headers, int connected, Octstr **type)
long check_x_wap_application_id_header (List **push_headers)
int pap_convert_content (struct content *content)
int pap_get_content (struct content *content)
int select_bearer_network (WAPEvent **e)
int delivery_time_constraints (WAPEvent *e, PPGPushMachine *pm)
void deliver_confirmed_push (long last, PPGPushMachine *pm, PPGSessionMachine *sm)
PPGPushMachinedeliver_unit_push (long last, PPGPushMachine *pm, PPGSessionMachine *sm, int session_exists)
int store_push_data (PPGPushMachine **pm, PPGSessionMachine *sm, WAPEvent *e, WAPAddrTuple *tuple, int cless)
PPGPushMachineupdate_push_data_with_attribute (PPGSessionMachine **sm, PPGPushMachine *pm, long reason, long status)
void remove_push_data (PPGSessionMachine *sm, PPGPushMachine *pm, int cless)
void remove_session_data (PPGSessionMachine *sm, int status)
void remove_pushless_session (PPGSessionMachine *sm)
PPGSessionMachinestore_session_data (PPGSessionMachine *sm, WAPEvent *e, WAPAddrTuple *tuple, int *session_exists)
PPGSessionMachineupdate_session_data_with_headers (PPGSessionMachine *sm, PPGPushMachine *pm)
void deliver_pending_pushes (PPGSessionMachine *sm, int last)
PPGPushMachineabort_delivery (PPGSessionMachine *sm, int status)
PPGSessionMachineupdate_session_data (PPGSessionMachine *sm, long sid, long port, List *caps)
int confirmation_requested (WAPEvent *e)
int cless_accepted (WAPEvent *e, PPGSessionMachine *sm)
int headers_acceptable (List *push_headers, Octstr **content_header)
int type_is (Octstr *content_header, char *required_type)
int get_mime_boundary (List *push_headers, Octstr *content_header, Octstr **boundary)
void change_header_value (List **push_headers, char *name, char *value)
void remove_mime_headers (List **push_headers)
void remove_link_headers (List **push_headers)
void remove_x_kannel_headers (List **push_headers)
void send_bad_message_response (HTTPClient **c, Octstr *body_fragment, int code, int status)
HTTPClientsend_push_response (WAPEvent *e, int status)
void send_to_pi (HTTPClient **c, Octstr *reply_body, int status)
void tell_fatal_error (HTTPClient **c, WAPEvent *e, Octstr *url, int status, int code)
int read_ppg_config (Cfg *cfg)
int ip_allowed_by_ppg (Octstr *ip)
Octstrconvert_wml_to_wmlc (struct content *content)
Octstrconvert_si_to_sic (struct content *content)
Octstrconvert_sl_to_slc (struct content *content)
Octstrset_smsc_id (List *headers, Octstr *username, int trusted_pi)
Octstrset_dlr_url (List *headers, Octstr *username, int trusted_pi)
long set_dlr_mask (List *headers, Octstr *dlr_url)
Octstrset_smsbox_id (List *headers, Octstr *username, int trusted_pi)
Octstrset_service_name (void)
Octstrset_time (void)
int deliver_before_test_cleared (Octstr *before, struct tm now)
int deliver_after_test_cleared (Octstr *after, struct tm now)
void session_machine_assert (PPGSessionMachine *sm)
void push_machine_assert (PPGPushMachine *pm)
Octstrtell_ppg_name (void)
Octstrdescribe_code (long code)
long ota_abort_to_pap (long reason)
int content_transformable (List *push_headers)
WAPAddrTupleset_addr_tuple (Octstr *address, long cliport, long servport, long address_type, List *push_headers)
WAPAddrTupleaddr_tuple_change_cliport (WAPAddrTuple *tuple, long port)
void initialize_time_item_array (long time_data[], struct tm now)
int date_item_compare (Octstr *before, long time_data, long pos)
long parse_appid_header (Octstr **assigned_code)
Octstrescape_fragment (Octstr *fragment)
int coriented_deliverable (long code)
int is_phone_number (long type_of_address)
void replace_octstr_char (Octstr *os1, Octstr *os2, long *pos)
void wap_push_ppg_init (wap_dispatch_func_t *ota_dispatch, wap_dispatch_func_t *appl_dispatch, Cfg *cfg)
void wap_push_ppg_shutdown (void)
void wap_push_ppg_dispatch_event (WAPEvent *e)
PPGSessionMachinewap_push_ppg_have_push_session_for (WAPAddrTuple *tuple)
PPGSessionMachinewap_push_ppg_have_push_session_for_sid (long sid)
Octstrextract_base64 (struct content *content)

Variables

enum { ... }  run_status
Listppg_queue = NULL
Listpap_queue = NULL
Listppg_machines = NULL
Listppg_unit_pushes = NULL
Counterpush_id_counter = NULL
Dicthttp_clients = NULL
Dicturls = NULL
wap_dispatch_func_tdispatch_to_ota
wap_dispatch_func_tdispatch_to_appl
Octstrppg_url = NULL
long ppg_port = DEFAULT_HTTP_PORT
long ppg_ssl_port = NO_HTTPS_PORT
long number_of_pushes = DEFAULT_NUMBER_OF_PUSHES
int trusted_pi = PI_TRUSTED
long number_of_users = DEFAULT_NUMBER_OF_USERS
Octstrppg_deny_ip = NULL
Octstrppg_allow_ip = NULL
int user_configuration = USER_CONFIGURATION_NOT_ADDED
Octstrglobal_sender = NULL
Octstrppg_default_smsc = NULL
Octstrssl_server_cert_file = NULL
Octstrssl_server_key_file = NULL
Octstrppg_dlr_url = NULL
Octstrppg_smsbox_id = NULL
Octstrservice_name = NULL
struct {
   char *   type
   char *   result_type
   Octstr *(*   convert )(struct content *)
converters []
struct {
   char *   transfer_encoding
   Octstr *(*   extract )(struct content *)
extractors []
char * bearers []
char * networks []
description_t pap_desc []
size_t desc_tab_size = sizeof(pap_desc) / sizeof(pap_desc[0])
char * wina_uri []


Define Documentation

#define ADDRTUPLE name   )     wap_addr_tuple_destroy(pm->name);
 

#define ADDRTUPLE name   )     m->name = NULL;
 

#define ADDRTUPLE name   )     wap_addr_tuple_destroy(sm->name);
 

#define ADDRTUPLE name   )     m->name = NULL;
 

#define CAPABILITIES name   )     wap_cap_destroy_list(pm->name);
 

#define CAPABILITIES   m->name = NULL;
 

#define CAPABILITIES name   )     wsp_cap_destroy_list(sm->name);
 

#define CAPABILITIES name   )     m->name = NULL;
 

#define DEFAULT_PPG_URL   "/wappush"
 

Definition at line 113 of file wap_push_ppg.c.

#define HTTPHEADER name   )     http_destroy_headers(pm->name);
 

#define HTTPHEADER name   )     m->name = NULL;
 

#define INTEGER name   ) 
 

#define INTEGER name   )     m->name = 0;
 

#define INTEGER name   )     sm->name = 0;
 

#define INTEGER name   )     m->name = 0;
 

#define MACHINE fields   )     fields
 

#define MACHINE fields   )     fields
 

#define MACHINE fields   )     fields
 

#define MACHINE fields   )     fields
 

#define NUM_CONVERTERS   ((long) (sizeof(converters) / sizeof(converters[0])))
 

Definition at line 1982 of file wap_push_ppg.c.

#define NUM_EXTRACTORS   ((long) (sizeof(extractors) / sizeof(extractors[0])))
 

Definition at line 1992 of file wap_push_ppg.c.

#define NUMBER_OF_BEARERS   sizeof(bearers)/sizeof(bearers[0])
 

Definition at line 2061 of file wap_push_ppg.c.

#define NUMBER_OF_NETWORKS   sizeof(networks)/sizeof(networks[0])
 

Definition at line 2075 of file wap_push_ppg.c.

Referenced by select_bearer_network().

#define NUMBER_OF_WINA_URIS   sizeof(wina_uri)/sizeof(wina_uri[0])
 

Definition at line 2825 of file wap_push_ppg.c.

#define OCTSTR name   )     octstr_destroy(pm->name);
 

#define OCTSTR name   )     m->name = NULL;
 

#define OCTSTR name   )     octstr_destroy(sm->name);
 

#define OCTSTR name   )     m->name = NULL;
 

#define OPTIONAL_OCTSTR name   )     octstr_destroy(pm->name);
 

#define OPTIONAL_OCTSTR name   )     m->name = NULL;
 

#define PUSHMACHINES name   )     push_machines_list_destroy(sm->name);
 

#define PUSHMACHINES name   )     m->name = gwlist_create();
 


Typedef Documentation

typedef struct description_t description_t
 

Definition at line 2197 of file wap_push_ppg.c.

typedef struct PAPEvent PAPEvent
 

Definition at line 216 of file wap_push_ppg.c.

Referenced by http_read_thread(), https_read_thread(), pap_event_create(), and pap_request_thread().


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
TIME_EXPIRED 
TIME_TOO_EARLY 
NO_CONSTRAINTS 

Definition at line 92 of file wap_push_ppg.c.

00092      {
00093     TIME_EXPIRED = 0,
00094     TIME_TOO_EARLY = 1,
00095     NO_CONSTRAINTS = 2
00096 };

anonymous enum
 

Enumeration values:
DEFAULT_HTTP_PORT 
NO_HTTPS_PORT 
DEFAULT_NUMBER_OF_PUSHES 
PI_TRUSTED 
SSL_CONNECTION_OFF 
DEFAULT_NUMBER_OF_USERS 
USER_CONFIGURATION_NOT_ADDED 

Definition at line 101 of file wap_push_ppg.c.

00101      {
00102     DEFAULT_HTTP_PORT = 8080,
00103     NO_HTTPS_PORT = -1,
00104     DEFAULT_NUMBER_OF_PUSHES = 100,
00105     PI_TRUSTED = 1,
00106     SSL_CONNECTION_OFF = 0,
00107     DEFAULT_NUMBER_OF_USERS = 1024,
00108     USER_CONFIGURATION_NOT_ADDED = 0
00109 };

anonymous enum
 

Enumeration values:
USER_CONFIGURATION_ADDED 

Definition at line 111 of file wap_push_ppg.c.

00111 { USER_CONFIGURATION_ADDED = 1 };

anonymous enum
 

Enumeration values:
limbo 
running 
terminating 

Definition at line 128 of file wap_push_ppg.c.

00128 {limbo, running, terminating} run_status = limbo;

anonymous enum
 

Enumeration values:
TYPE_HTTP 
TYPE_HTTPS 

Definition at line 392 of file wap_push_ppg.c.

00392      {
00393     TYPE_HTTP = 0,
00394     TYPE_HTTPS = 1
00395 };


Function Documentation

PPGPushMachine * abort_delivery PPGSessionMachine sm,
int  status
[static]
 

Definition at line 2376 of file wap_push_ppg.c.

References code, gwlist_get(), gwlist_len(), PAP_ABORTED, pm, push_machine_assert(), reason, remove_push_data(), response_push_message(), session_machine_assert(), sm, and update_push_data_with_attribute().

Referenced by handle_internal_event().

02377 {
02378     PPGPushMachine *pm;
02379     long reason,
02380          code;
02381 
02382     session_machine_assert(sm);
02383 
02384     pm = NULL;
02385     reason = PAP_ABORT_USERPND;
02386     code = PAP_CAPABILITIES_MISMATCH;
02387     
02388     while (gwlist_len(sm->push_machines) > 0) {
02389         pm = gwlist_get(sm->push_machines, 0);
02390         push_machine_assert(pm);
02391 
02392         pm = update_push_data_with_attribute(&sm, pm, reason, PAP_ABORTED);
02393         response_push_message(pm, code, status);
02394 
02395         remove_push_data(sm, pm, sm == NULL);
02396     }
02397 
02398     return pm;
02399 }

Here is the call graph for this function:

WAPAddrTuple * addr_tuple_change_cliport WAPAddrTuple tuple,
long  port
[static]
 

Definition at line 2873 of file wap_push_ppg.c.

References WAPAddr::address, WAPAddrTuple::local, WAPAddr::port, port, WAPAddrTuple::remote, and wap_addr_tuple_create().

Referenced by create_session().

02874 {
02875     WAPAddrTuple *dubble;
02876 
02877     if (tuple == NULL)
02878         return NULL;
02879 
02880     dubble = wap_addr_tuple_create(tuple->remote->address,
02881                                    port,
02882                                    tuple->local->address,
02883                                    tuple->local->port);
02884 
02885     return dubble;
02886 }

Here is the call graph for this function:

void change_header_value List **  push_headers,
char *  name,
char *  value
[static]
 

Definition at line 2982 of file wap_push_ppg.c.

References http_header_add(), http_header_remove_all(), and name.

Referenced by pap_request_thread(), and transform_message().

02983 {
02984     http_header_remove_all(*push_headers, name);
02985     http_header_add(*push_headers, name, value);
02986 }

Here is the call graph for this function:

int check_capabilities List requested,
List assumed
[static]
 

Definition at line 1682 of file wap_push_ppg.c.

Referenced by response_push_connection().

01683 {
01684     int is_capable;
01685 
01686     is_capable = 1;
01687 
01688     return is_capable;
01689 }

long check_x_wap_application_id_header List **  push_headers  )  [static]
 

Definition at line 1849 of file wap_push_ppg.c.

References http_header_add(), http_header_find_first, http_header_remove_all(), octstr_destroy(), octstr_format(), octstr_get_cstr, and parse_appid_header().

Referenced by handle_push_message().

01850 {
01851     Octstr *appid_content;
01852     long coded_value;
01853     Octstr *cos;
01854     
01855     if (*push_headers == NULL)
01856         return -2;
01857 
01858     appid_content = http_header_find_first(*push_headers, 
01859         "X-WAP-Application-Id");
01860     
01861     if (appid_content == NULL) {
01862         octstr_destroy(appid_content);
01863         return -1;
01864     }
01865 
01866     if ((coded_value = parse_appid_header(&appid_content)) < 0) {
01867         octstr_destroy(appid_content);
01868         return -2;
01869     }
01870         
01871     if (coded_value == 2) {
01872         octstr_destroy(appid_content);
01873         http_header_remove_all(*push_headers, "X-WAP-Application-Id");
01874         return -1;
01875     }
01876 
01877     cos = octstr_format("%ld", coded_value);
01878     http_header_remove_all(*push_headers, "X-WAP-Application-Id");
01879     http_header_add(*push_headers, "X-WAP-Application-Id", octstr_get_cstr(cos));
01880     
01881     octstr_destroy(appid_content); 
01882     octstr_destroy(cos);
01883     
01884     return coded_value;  
01885 }

Here is the call graph for this function:

int cless_accepted WAPEvent e,
PPGSessionMachine sm
[static]
 

Definition at line 2650 of file wap_push_ppg.c.

References gw_assert, PAP_UNCONFIRMED, Push_Message, sm, WAPEvent::type, and WAPEvent::u.

Referenced by handle_push_message().

02651 {
02652     gw_assert(e->type == Push_Message);
02653     return (e->u.Push_Message.delivery_method == PAP_UNCONFIRMED ||
02654            e->u.Push_Message.delivery_method == PAP_NOT_SPECIFIED) &&
02655            (sm == NULL);
02656 }

int confirmation_requested WAPEvent e  )  [static]
 

Definition at line 2474 of file wap_push_ppg.c.

References gw_assert, PAP_CONFIRMED, Push_Message, WAPEvent::type, and WAPEvent::u.

Referenced by handle_push_message().

02475 {
02476     gw_assert(e->type = Push_Message);
02477 
02478     return e->u.Push_Message.delivery_method == PAP_CONFIRMED || 
02479            e->u.Push_Message.delivery_method == PAP_PREFERCONFIRMED;
02480 }

int content_transformable List push_headers  )  [static]
 

Definition at line 1890 of file wap_push_ppg.c.

References gw_assert, gwlist_len(), http_destroy_headers(), http_header_find_all(), http_header_get(), octstr_compare(), octstr_destroy(), and octstr_imm().

Referenced by transform_message().

01891 {
01892     List *cache_directives;
01893     long i;
01894     Octstr *header_name, 
01895            *header_value;
01896 
01897     gw_assert(push_headers);
01898 
01899     cache_directives = http_header_find_all(push_headers, "Cache-Control");
01900     if (gwlist_len(cache_directives) == 0) {
01901         http_destroy_headers(cache_directives);
01902         return 1;
01903     }
01904 
01905     i = 0;
01906     while (i < gwlist_len(cache_directives)) {
01907         http_header_get(cache_directives, i, &header_name, &header_value);
01908         if (octstr_compare(header_value, octstr_imm("no-transform")) == 0) {
01909             http_destroy_headers(cache_directives);
01910             octstr_destroy(header_name);
01911             octstr_destroy(header_value);
01912         return 0;
01913         }
01914         ++i;
01915     }
01916 
01917     http_destroy_headers(cache_directives);
01918     octstr_destroy(header_name);
01919     octstr_destroy(header_value);
01920  
01921     return 1;
01922 }

Here is the call graph for this function:

Octstr * convert_si_to_sic struct content content  )  [static]
 

Definition at line 1938 of file wap_push_ppg.c.

References content::body, content::charset, si_compile(), and warning().

01939 {
01940     Octstr *sic;
01941 
01942     if (si_compile(content->body, content->charset, &sic) == 0)
01943         return sic;
01944     warning(0, "PPG: si compilation failed");
01945     return NULL;
01946 }

Here is the call graph for this function:

Octstr * convert_sl_to_slc struct content content  )  [static]
 

Definition at line 1948 of file wap_push_ppg.c.

References content::body, content::charset, sl_compile(), and warning().

01949 {
01950     Octstr *slc;
01951 
01952     if (sl_compile(content->body, content->charset, &slc) == 0)
01953         return slc;
01954     warning(0, "PPG: sl compilation failed");
01955     return NULL;
01956 }

Here is the call graph for this function:

Octstr * convert_wml_to_wmlc struct content content  )  [static]
 

Definition at line 1928 of file wap_push_ppg.c.

References content::body, content::charset, warning(), and wml_compile().

01929 {
01930     Octstr *wmlc;
01931 
01932     if (wml_compile(content->body, content->charset, &wmlc, NULL) == 0)
01933         return wmlc;
01934     warning(0, "PPG: wml compilation failed");
01935     return NULL;
01936 }

Here is the call graph for this function:

int coriented_deliverable long  code  )  [static]
 

Definition at line 2661 of file wap_push_ppg.c.

Referenced by handle_push_message().

02662 {
02663     return appid_code > -1;
02664 }

void create_session WAPEvent e,
PPGPushMachine pm
[static]
 

Definition at line 1467 of file wap_push_ppg.c.

References addr_tuple_change_cliport(), CONNECTIONLESS_PUSH_CLIPORT, dispatch_to_ota, gw_assert, http_header_duplicate(), octstr_duplicate, pm, Pom_SessionRequest_Req, push_machine_assert(), Push_Message, service_name, WAPEvent::type, WAPEvent::u, and wap_event_create.

Referenced by handle_push_message().

01468 {
01469     WAPEvent *ota_event;
01470     List *push_headers;
01471     Octstr *smsc_id;
01472     Octstr *dlr_url;
01473     Octstr *smsbox_id;
01474     Octstr *service_name;
01475 
01476     gw_assert(e->type == Push_Message);
01477     push_machine_assert(pm);
01478     
01479     push_headers = http_header_duplicate(e->u.Push_Message.push_headers);
01480     smsc_id = octstr_duplicate(e->u.Push_Message.smsc_id);
01481     dlr_url = octstr_duplicate(e->u.Push_Message.dlr_url);
01482     smsbox_id = octstr_duplicate(e->u.Push_Message.smsbox_id);
01483     service_name = octstr_duplicate(e->u.Push_Message.service_name);
01484 
01485     ota_event = wap_event_create(Pom_SessionRequest_Req);
01486     ota_event->u.Pom_SessionRequest_Req.addr_tuple =
01487         addr_tuple_change_cliport(pm->addr_tuple,
01488                                   CONNECTIONLESS_PUSH_CLIPORT);
01489     ota_event->u.Pom_SessionRequest_Req.push_headers = push_headers;
01490     ota_event->u.Pom_SessionRequest_Req.push_id = pm->push_id;
01491     ota_event->u.Pom_SessionRequest_Req.address_type = pm->address_type;
01492     if (smsc_id != NULL)
01493         ota_event->u.Pom_SessionRequest_Req.smsc_id = smsc_id;
01494     else
01495         ota_event->u.Pom_SessionRequest_Req.smsc_id = NULL;
01496     if (dlr_url != NULL)
01497         ota_event->u.Pom_SessionRequest_Req.dlr_url = dlr_url;                                    
01498     else
01499         ota_event->u.Pom_SessionRequest_Req.dlr_url = NULL;
01500     ota_event->u.Pom_SessionRequest_Req.dlr_mask = e->u.Push_Message.dlr_mask;
01501     if (smsbox_id != NULL)
01502         ota_event->u.Pom_SessionRequest_Req.smsbox_id = smsbox_id;
01503     else
01504         ota_event->u.Pom_SessionRequest_Req.smsbox_id = NULL;
01505     ota_event->u.Pom_SessionRequest_Req.service_name = service_name;
01506         
01507     dispatch_to_ota(ota_event);
01508 }

Here is the call graph for this function:

int date_item_compare Octstr before,
long  time_data,
long  pos
[static]
 

Definition at line 2683 of file wap_push_ppg.c.

References condition, data, and octstr_parse_long().

Referenced by deliver_after_test_cleared(), and deliver_before_test_cleared().

02684 {
02685     long data;
02686 
02687     if (octstr_parse_long(&data, condition, pos, 10) < 0) {
02688         return 0;
02689     }
02690     if (data < time_data) {
02691         return -1;
02692     }
02693     if (data > time_data) {
02694         return 1;
02695     }
02696 
02697     return 0;
02698 }

Here is the call graph for this function:

int deliver_after_test_cleared Octstr after,
struct tm  now
[static]
 

Definition at line 2732 of file wap_push_ppg.c.

References date_item_compare(), initialize_time_item_array(), and octstr_len().

Referenced by delivery_time_constraints().

02733 {
02734     long time_data[6];
02735     long j;
02736 
02737     if (after == NULL)
02738         return 1;
02739     
02740     initialize_time_item_array(time_data, now);
02741     if (date_item_compare(after, time_data[0], 0) == -1)
02742         return 1;
02743     if (date_item_compare(after, time_data[0], 0) == 1)
02744         return 0;
02745 
02746     for (j = 5; j < octstr_len(after); j += 3) {
02747         if (date_item_compare(after, time_data[(j-5)/3 + 1], j) == -1)
02748             return 1;
02749         if (date_item_compare(after, time_data[(j-5)/3 + 1], j) == 1)
02750             return 0;
02751     }
02752 
02753     return 0;
02754 }

Here is the call graph for this function:

int deliver_before_test_cleared Octstr before,
struct tm  now
[static]
 

Definition at line 2704 of file wap_push_ppg.c.

References date_item_compare(), initialize_time_item_array(), and octstr_len().

Referenced by delivery_time_constraints().

02705 {  
02706     long time_data[6];
02707     long j;
02708 
02709     if (before == NULL)
02710         return 1;
02711 
02712     initialize_time_item_array(time_data, now);
02713     if (date_item_compare(before, time_data[0], 0) == 1)
02714         return 1;
02715     if (date_item_compare(before, time_data[0], 0) == -1)
02716         return 0;
02717 
02718     for (j = 5; j < octstr_len(before); j += 3) {
02719         if (date_item_compare(before, time_data[(j-5)/3 + 1], j) == 1)
02720             return 1;
02721         if (date_item_compare(before, time_data[(j-5)/3 + 1], j) == -1)
02722             return 0;
02723     }
02724 
02725     return 0;
02726 }

Here is the call graph for this function:

void deliver_confirmed_push long  last,
PPGPushMachine pm,
PPGSessionMachine sm
[static]
 

Definition at line 2313 of file wap_push_ppg.c.

References pm, request_confirmed_push(), and sm.

Referenced by handle_push_message().

02315 {
02316     request_confirmed_push(last, pm, sm);
02317 }

Here is the call graph for this function:

void deliver_pending_pushes PPGSessionMachine sm,
int  last
[static]
 

Definition at line 2347 of file wap_push_ppg.c.

References gw_assert, gwlist_get(), gwlist_len(), PAP_DELIVERED1, PAP_UNCONFIRMED, pm, push_machine_assert(), remove_push_data(), request_confirmed_push(), request_push(), session_machine_assert(), sm, and update_push_data_with_attribute().

Referenced by handle_internal_event().

02348 {
02349     PPGPushMachine *pm;    
02350     long i;
02351 
02352     session_machine_assert(sm);
02353     gw_assert(gwlist_len(sm->push_machines) > 0);
02354 
02355     i = 0;
02356     while (i < gwlist_len(sm->push_machines)) {
02357         pm = gwlist_get(sm->push_machines, i);
02358         push_machine_assert(pm);
02359 
02360         if (pm->delivery_method == PAP_UNCONFIRMED) {
02361             request_push(last, pm); 
02362             pm = update_push_data_with_attribute(&sm, pm, PAP_UNCONFIRMED, 
02363                  PAP_DELIVERED1);
02364             remove_push_data(sm, pm, sm == NULL);
02365         } else {
02366             request_confirmed_push(last, pm, sm);
02367             ++i;
02368         }
02369     }
02370 }     

Here is the call graph for this function:

PPGPushMachine * deliver_unit_push long  last,
PPGPushMachine pm,
PPGSessionMachine sm,
int  session_exists
[static]
 

Definition at line 2326 of file wap_push_ppg.c.

References info(), PAP_DELIVERED1, PAP_UNCONFIRMED, pm, push_machine_assert(), request_push(), request_unit_push(), sm, and update_push_data_with_attribute().

Referenced by handle_push_message().

02328 {
02329     push_machine_assert(pm);
02330     
02331     if (!session_exists)
02332         request_unit_push(last, pm);
02333     else
02334         request_push(last, pm);
02335 
02336     pm = update_push_data_with_attribute(&sm, pm, PAP_UNCONFIRMED, 
02337                                          PAP_DELIVERED1);
02338     info(0, "PPG: unconfirmed push delivered to OTA");
02339 
02340     return pm;
02341 }

Here is the call graph for this function:

int delivery_time_constraints WAPEvent e,
PPGPushMachine pm
[static]
 

Definition at line 2162 of file wap_push_ppg.c.

References debug(), deliver_after_test_cleared(), deliver_before_test_cleared(), gw_assert, gw_gmtime(), info(), pm, Push_Message, WAPEvent::type, and WAPEvent::u.

Referenced by handle_push_message().

02163 {
02164     Octstr *before,
02165            *after;
02166     struct tm now;
02167    
02168     gw_assert(e->type = Push_Message);
02169     
02170     before = e->u.Push_Message.deliver_before_timestamp;
02171     after = pm->deliver_after_timestamp;
02172     now = gw_gmtime(time(NULL));
02173 
02174     if (!deliver_before_test_cleared(before, now)) {
02175         info(0, "PPG: delivery deadline expired, dropping the push message");
02176         return 0;
02177     }
02178 
02179     if (!deliver_after_test_cleared(after, now)) {
02180         debug("wap.push.ppg", 0, "PPG: too early to push the message,"
02181               " waiting");
02182         return 1;
02183     }
02184 
02185     return 2;
02186 }

Here is the call graph for this function:

Octstr * describe_code long  code  )  [static]
 

Definition at line 2229 of file wap_push_ppg.c.

References description, octstr_create, octstr_imm(), pap_desc, and description_t::reason.

Referenced by response_push_message(), tell_fatal_error(), and update_push_data_with_attribute().

02230 {
02231     Octstr *desc;
02232     size_t i;
02233 
02234     for (i = 0; i < desc_tab_size; i++) {
02235         if (pap_desc[i].reason == code) {
02236             desc = octstr_create(pap_desc[i].description);
02237             return desc;
02238         }
02239     }
02240 
02241     return octstr_imm("unknown PAP code");
02242 }

Here is the call graph for this function:

Octstr * escape_fragment Octstr fragment  )  [static]
 

Definition at line 3214 of file wap_push_ppg.c.

References octstr_get_char(), octstr_imm(), octstr_len(), and replace_octstr_char().

Referenced by send_bad_message_response().

03215 {
03216     long i;
03217     int c;
03218 
03219     i = 0;
03220     while (i < octstr_len(fragment)) {
03221         if ((c = octstr_get_char(fragment, i)) == '"') {
03222             replace_octstr_char(fragment, octstr_imm("&quot;"), &i);
03223         } else if (c == '<') {
03224             replace_octstr_char(fragment, octstr_imm("&lt;"), &i);
03225         } else if (c == '>') {
03226             replace_octstr_char(fragment, octstr_imm("&gt;"), &i);
03227         } else if (c == '&') {
03228             replace_octstr_char(fragment, octstr_imm("&amp;"), &i);
03229         }
03230         ++i;
03231     }
03232 
03233     return fragment;
03234 }

Here is the call graph for this function:

Octstr* extract_base64 struct content content  )  [static]
 

Definition at line 1959 of file wap_push_ppg.c.

References content::body, octstr_base64_to_binary(), and octstr_duplicate.

01960 {
01961     Octstr *orig = octstr_duplicate(content->body);
01962     octstr_base64_to_binary(orig);
01963     return orig;
01964 }

Here is the call graph for this function:

PPGPushMachine * find_ppg_push_machine_using_pi_push_id PPGSessionMachine sm,
Octstr pi_push_id
[static]
 

Definition at line 2517 of file wap_push_ppg.c.

References gw_assert, gwlist_search(), pm, push_has_pi_push_id(), session_machine_assert(), and sm.

Referenced by store_push_data().

02519 {
02520     PPGPushMachine *pm;
02521 
02522     gw_assert(pi_push_id);
02523     session_machine_assert(sm);
02524 
02525     pm = gwlist_search(sm->push_machines, pi_push_id, push_has_pi_push_id);
02526 
02527     return pm;
02528 }

Here is the call graph for this function:

PPGPushMachine * find_ppg_push_machine_using_pid PPGSessionMachine sm,
long  pid
[static]
 

Definition at line 2493 of file wap_push_ppg.c.

References gw_assert, gwlist_search(), pm, push_has_pid(), session_machine_assert(), and sm.

Referenced by handle_internal_event().

02495 {
02496     PPGPushMachine *pm;
02497 
02498     gw_assert(pid >= 0);
02499     session_machine_assert(sm);
02500 
02501     pm = gwlist_search(sm->push_machines, &pid, push_has_pid);
02502 
02503     return pm;
02504 }

Here is the call graph for this function:

PPGPushMachine * find_unit_ppg_push_machine_using_pi_push_id Octstr pi_push_id  )  [static]
 

Definition at line 2530 of file wap_push_ppg.c.

References gw_assert, gwlist_search(), pm, ppg_unit_pushes, and push_has_pi_push_id().

Referenced by store_push_data().

02532 {
02533     PPGPushMachine *pm;
02534 
02535     gw_assert(pi_push_id);
02536     pm = gwlist_search(ppg_unit_pushes, pi_push_id, push_has_pi_push_id);
02537 
02538     return pm;
02539 }

Here is the call graph for this function:

int get_mime_boundary List push_headers,
Octstr content_header,
Octstr **  boundary
[static]
 

Definition at line 2950 of file wap_push_ppg.c.

References octstr_case_search(), octstr_copy, octstr_get_char(), octstr_imm(), octstr_len(), and warning().

Referenced by pap_request_thread().

02952 {
02953     long pos;
02954     Octstr *bos;
02955     int c, quoted = 0;
02956     long bstart;
02957 
02958     pos = 0;
02959     if ((pos = octstr_case_search(content_header, 
02960                                   bos = octstr_imm("boundary="), 0)) < 0) {
02961         warning(0, "PPG: get_mime_boundary: no boundary specified");
02962         return -1;
02963     }
02964 
02965     pos += octstr_len(bos);
02966     if (octstr_get_char(content_header, pos) == '"') {
02967         ++pos;
02968         quoted = 1;
02969     }
02970     
02971     bstart = pos;
02972     while ((c = octstr_get_char(content_header, pos)) != -1) {
02973         if (c == ';' || (quoted && c == '"') || (!quoted && c == ' '))
02974              break;
02975         ++pos;
02976     }
02977     *boundary = octstr_copy(content_header, bstart, pos - bstart);
02978 
02979     return 0;
02980 }

Here is the call graph for this function:

void handle_internal_event WAPEvent e  )  [static]
 

Definition at line 1190 of file wap_push_ppg.c.

References abort_delivery(), debug(), deliver_pending_pushes(), find_ppg_push_machine_using_pid(), NOT_LAST, PAP_ABORTED, PAP_CONFIRMED, PAP_DELIVERED2, pm, Po_ConfirmedPush_Cnf, Po_PushAbort_Ind, Pom_Connect_Ind, Pom_Disconnect_Ind, WAPAddr::port, port, push_machine_assert(), reason, WAPAddrTuple::remote, remove_push_data(), remove_session_data(), response_push_connection(), session_machine_assert(), sm, WAPEvent::type, WAPEvent::u, update_push_data_with_attribute(), update_session_data(), wap_event_destroy(), wap_event_dump(), wap_push_ppg_have_push_session_for(), and wap_push_ppg_have_push_session_for_sid().

Referenced by ota_read_thread().

01191 {
01192     long sid,
01193          pid,
01194          reason,
01195          port;
01196     int http_status;
01197     PPGPushMachine *pm;
01198     PPGSessionMachine *sm;
01199     WAPAddrTuple *tuple;
01200     List *caps;
01201         
01202     http_status = HTTP_OK;
01203     switch (e->type) {
01204 /*
01205  * Pap, Chapter 11.1.3 states that if client is incapable, we should abort the
01206  * push and inform PI. We do this here.
01207  * In addition, we store session id used as an alias for address tuple and do
01208  * all pushes pending for this initiator (or abort them).
01209  */
01210     case Pom_Connect_Ind:
01211          debug("wap.push.ppg", 0, "PPG: handle_internal_event: connect"
01212                " indication from OTA");
01213          sid = e->u.Pom_Connect_Ind.session_id;
01214          tuple = e->u.Pom_Connect_Ind.addr_tuple;
01215          port = tuple->remote->port;
01216          caps = e->u.Pom_Connect_Ind.requested_capabilities;
01217 
01218          sm = wap_push_ppg_have_push_session_for(tuple);
01219          sm = update_session_data(sm, sid, port, caps);
01220         
01221          if (!response_push_connection(e, sm)) {
01222          pm = abort_delivery(sm, http_status);
01223              wap_event_destroy(e);
01224              return;
01225          }
01226 
01227 /* 
01228  * hard-coded until we have bearer control implemented
01229  */
01230          deliver_pending_pushes(sm, NOT_LAST);  
01231          wap_event_destroy(e);
01232     break;
01233 
01234     case Pom_Disconnect_Ind:
01235         debug("wap.push.ppg", 0, "PPG: handle_internal_event: disconnect"
01236               " indication from OTA");
01237         sm = wap_push_ppg_have_push_session_for_sid(
01238                  e->u.Pom_Disconnect_Ind.session_handle);
01239         remove_session_data(sm, http_status);
01240         wap_event_destroy(e);
01241     break;
01242 
01243 /*
01244  * Only the client can close a session. So we leave session open, even when 
01245  * there are no active pushes. Note that we do not store PAP attribute very
01246  * long time. Point is that result notification message, if asked, will rep-
01247  * ort this fact to PI, after which there is no need to store it any more.
01248  */
01249     case Po_ConfirmedPush_Cnf:
01250         debug("wap.push.ppg", 0, "PPG: handle_internal_event: push"
01251               " confirmation from OTA");
01252         sid = e->u.Po_ConfirmedPush_Cnf.session_handle;
01253         pid = e->u.Po_ConfirmedPush_Cnf.server_push_id;
01254 
01255         sm = wap_push_ppg_have_push_session_for_sid(sid);
01256         pm = find_ppg_push_machine_using_pid(sm, pid);
01257         pm = update_push_data_with_attribute(&sm, pm, PAP_CONFIRMED, 
01258                                              PAP_DELIVERED2);
01259         wap_event_destroy(e);
01260         remove_push_data(sm, pm, 0);
01261     break;
01262 
01263 /*
01264  * Again, PAP attribute will be reported to PI by using result notification.
01265  */
01266     case Po_PushAbort_Ind:
01267         debug("wap.push.ppg", 0, "PPG: handle_internal_event: abort"
01268               " indication from OTA");
01269         sid = e->u.Po_PushAbort_Ind.session_handle;
01270         pid = e->u.Po_PushAbort_Ind.push_id;
01271 
01272         sm = wap_push_ppg_have_push_session_for_sid(sid);
01273         pm = find_ppg_push_machine_using_pid(sm, pid);
01274         session_machine_assert(sm);
01275         push_machine_assert(pm);
01276         reason = e->u.Po_PushAbort_Ind.reason;
01277         pm = update_push_data_with_attribute(&sm, pm, reason, PAP_ABORTED);
01278         remove_session_data(sm, http_status);
01279         wap_event_destroy(e);
01280     break;
01281 
01282 /*
01283  * FIXME TRU: Add timeout (a mandatory feature!)
01284  */
01285     default:
01286         debug("wap.ppg", 0, "PPG: handle_internal_event: an unhandled event");
01287         wap_event_dump(e);
01288         wap_event_destroy(e);
01289     break;
01290     }
01291 }

Here is the call graph for this function:

int handle_push_message HTTPClient **  c,
WAPEvent ppg_event,
int  status
[static]
 

Definition at line 1043 of file wap_push_ppg.c.

References check_x_wap_application_id_header(), cless_accepted(), confirmation_requested(), coriented_deliverable(), create_session(), deliver_confirmed_push(), deliver_unit_push(), delivery_time_constraints(), http_header_mark_transformation(), http_header_remove_all(), info(), NOT_LAST, octstr_destroy(), PAP_ACCEPTED_FOR_PROCESSING, PAP_ADDRESS_ERROR, PAP_BAD_REQUEST, PAP_DUPLICATE_PUSH_ID, PAP_EXPIRED, PAP_FORBIDDEN, PAP_PENDING, PAP_REQUIRED_BEARER_NOT_AVAILABLE, PAP_TRANSFORMATION_FAILURE, PAP_UNDELIVERABLE1, PAP_UNDELIVERABLE2, pm, remove_push_data(), remove_pushless_session(), response_push_message(), select_bearer_network(), session_find_using_pi_client_address(), sm, store_push_data(), store_session_data(), transform_message(), type, WAPEvent::u, update_push_data_with_attribute(), update_session_data_with_headers(), wap_addr_tuple_destroy(), wap_event_destroy(), and warning().

Referenced by pap_request_thread().

01044 {
01045     int cless,
01046         session_exists,
01047         bearer_supported,
01048         dummy,
01049         constraints,
01050         message_transformable,
01051         coriented_possible;
01052 
01053     long coded_appid_value;
01054 
01055     PPGPushMachine *pm;
01056     PPGSessionMachine *sm;
01057     WAPAddrTuple *tuple=NULL;
01058     Octstr *push_data=NULL;
01059     Octstr *cliaddr=NULL;
01060     Octstr *type=NULL;
01061 
01062     List *push_headers;
01063    
01064     push_data = e->u.Push_Message.push_data;
01065     push_headers = e->u.Push_Message.push_headers;
01066     cliaddr = e->u.Push_Message.address_value;
01067     session_exists = 0;
01068 
01069     sm = session_find_using_pi_client_address(cliaddr);
01070     coded_appid_value = check_x_wap_application_id_header(&push_headers);
01071     cless = cless_accepted(e, sm);
01072     message_transformable = transform_message(&e, &tuple, push_headers, cless, 
01073                                               &type);
01074 
01075     if (!sm && !cless) {
01076         sm = store_session_data(sm, e, tuple, &session_exists); 
01077     }
01078 
01079     if (!store_push_data(&pm, sm, e, tuple, cless)) {
01080         warning(0, "PPG: handle_push_message: duplicate push id");
01081         *c = response_push_message(pm, PAP_DUPLICATE_PUSH_ID, status);
01082         goto no_start;
01083     }
01084     
01085     if (!message_transformable) {
01086     pm = update_push_data_with_attribute(&sm, pm, 
01087         PAP_TRANSFORMATION_FAILURE, PAP_UNDELIVERABLE1);  
01088         if (tuple != NULL)   
01089         *c = response_push_message(pm, PAP_TRANSFORMATION_FAILURE, status);
01090         else
01091         *c = response_push_message(pm, PAP_ADDRESS_ERROR, status);
01092         goto no_transformation;
01093     }
01094     
01095     dummy = 0;
01096     pm = update_push_data_with_attribute(&sm, pm, dummy, PAP_PENDING);
01097     
01098     bearer_supported = select_bearer_network(&e);
01099     if (!bearer_supported) {
01100         pm = update_push_data_with_attribute(&sm, pm, dummy, 
01101             PAP_UNDELIVERABLE2);
01102         *c = response_push_message(pm, PAP_REQUIRED_BEARER_NOT_AVAILABLE, status);
01103         goto no_start;
01104     }
01105     
01106     if ((constraints = delivery_time_constraints(e, pm)) == TIME_EXPIRED) {
01107         pm = update_push_data_with_attribute(&sm, pm, PAP_FORBIDDEN, 
01108                                              PAP_EXPIRED);
01109         *c = response_push_message(pm, PAP_FORBIDDEN, status);
01110         goto no_start;
01111     }
01112 
01113 /*
01114  * If time is to early for delivering the push message, we do not remove push
01115  * data. We response PI here, so that "accepted for processing" means "no 
01116  * error messages to come".
01117  */ 
01118 
01119     *c = response_push_message(pm, PAP_ACCEPTED_FOR_PROCESSING, status);
01120     info(0, "PPG: handle_push_message: push message accepted for processing");
01121 
01122     if (constraints == TIME_TOO_EARLY)
01123         goto store_push;
01124 
01125     if (constraints == NO_CONSTRAINTS) {
01126     http_header_mark_transformation(pm->push_headers, pm->push_data, type);
01127         if (sm)
01128             sm = update_session_data_with_headers(sm, pm); 
01129 
01130         if (!confirmation_requested(e)) {
01131             pm = deliver_unit_push(NOT_LAST, pm, sm, session_exists);
01132             goto unit_push_delivered;
01133     } 
01134           
01135         if (session_exists) {
01136             deliver_confirmed_push(NOT_LAST, pm, sm);   
01137         } else { 
01138             coriented_possible = coriented_deliverable(coded_appid_value); 
01139         http_header_remove_all(e->u.Push_Message.push_headers, 
01140                                    "Content-Type");  
01141             if (coriented_possible) {
01142                 create_session(e, pm);
01143             } else {
01144                 warning(0, "PPG: handle_push_message: wrong app id for confirmed"
01145                         " push session creation");
01146                 *c = response_push_message(pm, PAP_BAD_REQUEST, status);
01147             }
01148         }
01149     }
01150 
01151     wap_addr_tuple_destroy(tuple);
01152     octstr_destroy(type);
01153     wap_event_destroy(e);
01154     return 1;
01155 
01156 unit_push_delivered:
01157     wap_addr_tuple_destroy(tuple);
01158     remove_push_data(sm, pm, cless);
01159     octstr_destroy(type);
01160     wap_event_destroy(e);
01161     return 1;
01162 
01163 store_push:
01164     wap_addr_tuple_destroy(tuple);
01165     octstr_destroy(type);
01166     wap_event_destroy(e);
01167     return 1;
01168 
01169 no_transformation:
01170     wap_addr_tuple_destroy(tuple);
01171     remove_push_data(sm, pm, cless);
01172     if (sm)
01173         remove_pushless_session(sm);
01174     wap_event_destroy(e);
01175     return 0;
01176 
01177 no_start:
01178     wap_addr_tuple_destroy(tuple);
01179     octstr_destroy(type);
01180     remove_push_data(sm, pm, cless);
01181     if (sm)
01182         remove_pushless_session(sm);
01183     wap_event_destroy(e);
01184     return 1;
01185 }

Here is the call graph for this function:

int headers_acceptable List push_headers,
Octstr **  content_header
[static]
 

Definition at line 2895 of file wap_push_ppg.c.

References error(), gw_assert, http_header_find_first, octstr_format(), type_is(), and warning().

Referenced by pap_request_thread().

02896 {
02897     gw_assert(push_headers);
02898     *content_header = http_header_find_first(push_headers, "Content-Type");
02899 
02900     if (*content_header == NULL) {
02901         *content_header = octstr_format("%s", "no content type header found");
02902         goto error;
02903     }
02904     
02905     if (!type_is(*content_header, "multipart/related")) {
02906         goto error;
02907     }
02908 
02909     if (!type_is(*content_header, "application/xml")) {
02910         goto error;
02911     }
02912 
02913     return 1;
02914 
02915 error:
02916     warning(0, "PPG: headers_acceptable: got unacceptable push headers");
02917     return 0;
02918 }

Here is the call graph for this function:

void http_read_thread void *  arg  )  [static]
 

Definition at line 685 of file wap_push_ppg.c.

References gwlist_produce(), http_accept_request(), pap_event_create(), pap_queue, PAPEvent, ppg_port, and run_status.

Referenced by wap_push_ppg_init(), and wap_push_ppg_shutdown().

00686 {
00687     PAPEvent *p;
00688     Octstr *ip; 
00689     Octstr *url; 
00690     List *push_headers;
00691     Octstr *mime_content; 
00692     List *cgivars;
00693     HTTPClient *client;
00694 
00695     while (run_status == running) {
00696         client = http_accept_request(ppg_port, &ip, &url, &push_headers, 
00697                                      &mime_content, &cgivars);
00698         if (client == NULL) 
00699             break;
00700 
00701         p = pap_event_create(ip, url, push_headers, mime_content, cgivars,
00702                              client);
00703         gwlist_produce(pap_queue, p);
00704     }
00705 }

Here is the call graph for this function:

void https_read_thread void *  arg  )  [static]
 

Definition at line 708 of file wap_push_ppg.c.

References gwlist_produce(), http_accept_request(), pap_event_create(), pap_queue, PAPEvent, ppg_ssl_port, and run_status.

Referenced by wap_push_ppg_init(), and wap_push_ppg_shutdown().

00709 {
00710     PAPEvent *p;
00711     Octstr *ip; 
00712     Octstr *url; 
00713     List *push_headers;
00714     Octstr *mime_content; 
00715     List *cgivars;
00716     HTTPClient *client;
00717 
00718     while (run_status == running) {
00719         client = http_accept_request(ppg_ssl_port, &ip, &url, &push_headers, 
00720                                      &mime_content, &cgivars); 
00721         if (client == NULL) 
00722         break;
00723         
00724         p = pap_event_create(ip, url, push_headers, mime_content, cgivars, 
00725                              client);
00726         gwlist_produce(pap_queue, p);
00727     }
00728 }

Here is the call graph for this function:

void initialize_time_item_array long  time_data[],
struct tm  now
[static]
 

Definition at line 2673 of file wap_push_ppg.c.

Referenced by deliver_after_test_cleared(), and deliver_before_test_cleared().

02674 {
02675     time_data[0] = now.tm_year + 1900;
02676     time_data[1] = now.tm_mon + 1;
02677     time_data[2] = now.tm_mday;
02678     time_data[3] = now.tm_hour;
02679     time_data[4] = now.tm_min;
02680     time_data[5] = now.tm_sec;
02681 }

int ip_allowed_by_ppg Octstr ip  )  [static]
 

Definition at line 583 of file wap_push_ppg.c.

References debug(), error(), octstr_compare(), octstr_imm(), panic, ppg_allow_ip, ppg_deny_ip, wap_push_ppg_pushuser_search_ip_from_wildcarded_list(), and warning().

Referenced by pap_request_thread().

00584 {
00585     if (ip == NULL)
00586         return 0;    
00587 
00588     if (trusted_pi)
00589         return 1;
00590 
00591     if (ppg_deny_ip == NULL && ppg_allow_ip == NULL) {
00592         warning(0, "Your ppg core configuration lacks allowed and denied" 
00593                    " ip lists");
00594         return 1;
00595     }
00596 
00597     if (ppg_deny_ip)
00598         if (octstr_compare(ppg_deny_ip, octstr_imm("*.*.*.*")) == 0) {
00599             panic(0, "Your ppg core configuration deny all ips, exiting");
00600             return 0;
00601         }
00602 
00603     if (ppg_allow_ip)
00604         if (octstr_compare(ppg_allow_ip, octstr_imm("*.*.*.*")) == 0) {
00605             warning(0, "Your ppg core configuration allow all ips");
00606             return 1;
00607         }
00608 
00609     if (ppg_deny_ip)
00610         if (wap_push_ppg_pushuser_search_ip_from_wildcarded_list(ppg_deny_ip, ip, 
00611             octstr_imm(";"), octstr_imm("."))) {
00612             error(0, "ip found from denied list");
00613             return 0;
00614         }
00615 
00616     if (ppg_allow_ip)
00617         if (wap_push_ppg_pushuser_search_ip_from_wildcarded_list(ppg_allow_ip, ip, 
00618             octstr_imm(";"), octstr_imm("."))) {
00619             debug("wap.push.ppg.pushuser", 0, "PPG: ip_allowed_by_ppg: ip found"
00620                   " from allowed list");
00621             return 1;
00622         }
00623 
00624     warning(0, "did not found ip from any of core lists, deny it");
00625     return 0;
00626 }

Here is the call graph for this function:

int is_phone_number long  type_of_address  )  [static]
 

Definition at line 3236 of file wap_push_ppg.c.

Referenced by pap_request_thread().

03237 {
03238     return address_type == ADDR_PLMN;
03239 }

long ota_abort_to_pap long  reason  )  [static]
 

Definition at line 2636 of file wap_push_ppg.c.

References reason.

Referenced by update_push_data_with_attribute().

02637 {
02638     long offset;
02639 
02640     offset = reason - 0xEA;
02641     reason = 5026 + offset;
02642 
02643     return reason;
02644 }

void ota_read_thread void *  arg  )  [static]
 

Definition at line 631 of file wap_push_ppg.c.

References gwlist_consume(), handle_internal_event(), ppg_queue, run_status, and running.

Referenced by wap_push_ppg_init(), and wap_push_ppg_shutdown().

00632 {
00633     WAPEvent *e;
00634 
00635     while (run_status == running && (e = gwlist_consume(ppg_queue)) != NULL) {
00636         handle_internal_event(e);
00637     } 
00638 }

Here is the call graph for this function:

int pap_convert_content struct content content  )  [static]
 

Definition at line 1998 of file wap_push_ppg.c.

References content::body, converters, octstr_compare(), octstr_create, octstr_destroy(), octstr_imm(), result_type, type, and content::type.

Referenced by transform_message().

01999 {
02000     long i;
02001     Octstr *new_body;
02002 
02003     for (i = 0; i < NUM_CONVERTERS; i++) {
02004         if (octstr_compare(content->type, 
02005             octstr_imm(converters[i].type)) == 0) {
02006         new_body = converters[i].convert(content);
02007             if (new_body == NULL)
02008             return 0;
02009             octstr_destroy(content->body);
02010             content->body = new_body;
02011             octstr_destroy(content->type); 
02012             content->type = octstr_create(converters[i].result_type);
02013             return 1;
02014         }
02015     }
02016 
02017     return 1;
02018 }

Here is the call graph for this function:

PAPEvent * pap_event_create Octstr ip,
Octstr url,
List push_headers,
Octstr mime_content,
List cgivars,
HTTPClient client
[static]
 

Definition at line 643 of file wap_push_ppg.c.

References PAPEvent::cgivars, PAPEvent::client, PAPEvent::ip, PAPEvent::mime_content, PAPEvent, PAPEvent::push_headers, and PAPEvent::url.

Referenced by http_read_thread(), and https_read_thread().

00646 {
00647     PAPEvent *p;
00648 
00649     p = gw_malloc(sizeof(PAPEvent));
00650     p->ip = ip;
00651     p->url = url;
00652     p->push_headers = push_headers;
00653     p->mime_content = mime_content;
00654     p->cgivars = cgivars;
00655     p->client = client;
00656 
00657     return p;
00658 }

void pap_event_destroy PAPEvent p  )  [static]
 

Definition at line 660 of file wap_push_ppg.c.

Referenced by pap_event_destroy_item(), and pap_request_thread().

00661 {
00662     if (p == NULL)
00663         return;
00664 
00665     gw_free(p);
00666 }

void pap_event_destroy_item void *  p  )  [static]
 

Definition at line 668 of file wap_push_ppg.c.

References pap_event_destroy().

Referenced by wap_push_ppg_shutdown().

00669 {
00670     pap_event_destroy(p);
00671 }

Here is the call graph for this function:

void pap_event_unpack PAPEvent p,
Octstr **  ip,
Octstr **  url,
List **  push_headers,
Octstr **  mime_content,
List **  cgivars,
HTTPClient **  client
[static]
 

Definition at line 673 of file wap_push_ppg.c.

References PAPEvent::cgivars, PAPEvent::client, PAPEvent::ip, PAPEvent::mime_content, PAPEvent::push_headers, and PAPEvent::url.

Referenced by pap_request_thread().

00676 {
00677     *ip = p->ip;
00678     *url = p->url;
00679     *push_headers = p->push_headers;
00680     *mime_content = p->mime_content;
00681     *cgivars = p->cgivars;
00682     *client = p->client;
00683 }

int pap_get_content struct content content  )  [static]
 

Definition at line 2025 of file wap_push_ppg.c.

References content::body, extractors, octstr_case_compare(), octstr_destroy(), octstr_imm(), transfer_encoding, and content::type.

Referenced by transform_message().

02026 {
02027     long i;
02028     Octstr *new_body;
02029 
02030     for (i = 0; i < NUM_EXTRACTORS; i++) {
02031         if (octstr_case_compare(content->type, 
02032             octstr_imm(extractors[i].transfer_encoding)) == 0) {
02033         
02034             new_body = extractors[i].extract(content);
02035             if (new_body == NULL)
02036             return 0;
02037             octstr_destroy(content->body);
02038             content->body = new_body;
02039         octstr_destroy(content->type);
02040         content->type = NULL;
02041             return 1;
02042         }
02043     }
02044 
02045     return 1;
02046 }

Here is the call graph for this function:

void pap_request_thread void *  arg  )  [static]
 

Definition at line 743 of file wap_push_ppg.c.

References change_header_value(), debug(), dict_put(), dict_put_once(), error(), get_mime_boundary(), gw_assert, gwlist_consume(), handle_push_message(), headers_acceptable(), http_append_headers(), http_clients, http_close_client(), http_destroy_cgiargs(), http_destroy_headers(), http_header_duplicate(), http_header_remove_all(), http_remove_hop_headers(), http_send_reply(), info(), ip_allowed_by_ppg(), is_phone_number(), mime_parse(), octstr_compare(), octstr_destroy(), octstr_duplicate, octstr_format(), octstr_get_cstr, octstr_imm(), octstr_len(), PAP_BAD_REQUEST, pap_compile(), PAP_DUPLICATE_PUSH_ID, pap_event_destroy(), pap_event_unpack(), PAP_FORBIDDEN, pap_queue, PAPEvent, ppg_url, remove_link_headers(), remove_mime_headers(), remove_x_kannel_headers(), run_status, running, send_bad_message_response(), set_dlr_mask(), set_dlr_url(), set_service_name(), set_smsbox_id(), set_smsc_id(), tell_fatal_error(), trusted_pi, WAPEvent::u, urls, user_configuration, username, wap_push_ppg_pushuser_authenticate(), wap_push_ppg_pushuser_client_phone_number_acceptable(), and warning().

Referenced by wap_push_ppg_init(), and wap_push_ppg_shutdown().

00744 {
00745     WAPEvent *ppg_event;
00746     PAPEvent *p;
00747     size_t push_len;
00748     Octstr *pap_content = NULL;
00749     Octstr *push_data = NULL;
00750     Octstr *rdf_content = NULL;
00751     Octstr *mime_content = NULL;
00752     Octstr *plos = NULL;               /* a temporary variable*/
00753     Octstr *boundary = NULL;
00754     Octstr *content_header = NULL;     /* Content-Type MIME header */
00755     Octstr *url = NULL;
00756     Octstr *ip = NULL;
00757     Octstr *not_found = NULL;
00758     Octstr *username = NULL;
00759     int compiler_status,
00760         http_status;
00761     List *push_headers,                /* MIME headers themselves */
00762          *content_headers,             /* Headers from the content entity, see
00763                                           pap chapters 8.2, 13.1. Rfc 2045 
00764                                           grammar calls these MIME-part-hea-
00765                                           ders */
00766          *cgivars;
00767     HTTPClient *client;
00768     Octstr *dlr_url;
00769     
00770     http_status = 0;
00771     url = ip = mime_content = username = NULL;                
00772   
00773     while (run_status == running && (p = gwlist_consume(pap_queue)) != NULL) {
00774 
00775         http_status = HTTP_NOT_FOUND;
00776         pap_event_unpack(p, &ip, &url, &push_headers, &mime_content, 
00777                          &cgivars, &client);      
00778 
00779         if (octstr_compare(url, ppg_url) != 0) {
00780             error(0,  "Request <%s> from <%s>: service not found", 
00781                   octstr_get_cstr(url), octstr_get_cstr(ip));
00782             debug("wap.push.ppg", 0, "your configuration uses %s",
00783                   octstr_get_cstr(ppg_url));           
00784             not_found = octstr_imm("Service not specified\n");
00785             http_send_reply(client, http_status, push_headers, not_found);
00786             goto ferror;
00787         }
00788 
00789         http_status = HTTP_UNAUTHORIZED;
00790    
00791         if (!ip_allowed_by_ppg(ip)) {
00792             error(0,  "Request <%s> from <%s>: ip forbidden, closing the"
00793                   " client", octstr_get_cstr(url), octstr_get_cstr(ip));
00794             http_close_client(client);
00795             goto ferror; 
00796         }
00797 
00798         if (!trusted_pi && user_configuration) {
00799         if (!wap_push_ppg_pushuser_authenticate(client, cgivars, ip, 
00800                                                     push_headers, &username)) {
00801                  error(0,  "Request <%s> from <%s>: authorisation failure",
00802                        octstr_get_cstr(url), octstr_get_cstr(ip));
00803                  goto ferror;
00804             }
00805         } else {                        /* Jörg, this wont disappear again */
00806         username = octstr_imm("");
00807     }
00808 
00809         http_status = HTTP_ACCEPTED;
00810         info(0, "PPG: Accept request <%s> from <%s>", octstr_get_cstr(url), 
00811              octstr_get_cstr(ip));
00812         
00813         if (octstr_len(mime_content) == 0) {
00814         warning(0, "PPG: No MIME content received, the request"
00815                     " unacceptable");
00816             send_bad_message_response(&client, octstr_imm("No MIME content"), 
00817                                       PAP_BAD_REQUEST, http_status);
00818             if (client == NULL)
00819                 break;
00820             goto ferror;
00821         }
00822 
00823         if (!push_headers) {
00824             warning(0, "PPG: No push headers received , the request"
00825                     " unacceptable");
00826             send_bad_message_response(&client, octstr_imm("No push headers"), 
00827                                       PAP_BAD_REQUEST, http_status);
00828             if (client == NULL)
00829                 break;
00830             goto ferror;
00831         }
00832         octstr_destroy(ip);
00833         
00834         http_remove_hop_headers(push_headers);
00835         remove_mime_headers(&push_headers);
00836         remove_link_headers(&push_headers);
00837 
00838         if (!headers_acceptable(push_headers, &content_header)) {
00839             warning(0,  "PPG: Unparsable push headers, the request"
00840                     " unacceptable");
00841             send_bad_message_response(&client, content_header, PAP_BAD_REQUEST,
00842                                       http_status);
00843             if (client == NULL)
00844                 break;
00845             goto herror;
00846         }
00847         
00848         if (get_mime_boundary(push_headers, content_header, &boundary) == -1) {
00849             warning(0, "PPG: No MIME boundary, the request unacceptable");
00850             send_bad_message_response(&client, content_header, PAP_BAD_REQUEST,
00851                                       http_status);
00852             if (client == NULL) 
00853                 break;
00854             goto berror;
00855         }
00856 
00857         gw_assert(mime_content);
00858         if (!mime_parse(boundary, mime_content, &pap_content, &push_data, 
00859                         &content_headers, &rdf_content)) {
00860             send_bad_message_response(&client, mime_content, PAP_BAD_REQUEST,
00861                                       http_status);
00862             if (client == NULL)
00863                 break;
00864             warning(0, "PPG: unable to parse mime content, the request"
00865                     " unacceptable");
00866             goto clean;
00867         } else {
00868             debug("wap.push.ppg", 0, "PPG: http_read_thread: pap multipart"
00869                   " accepted");
00870         }
00871         
00872         push_len = octstr_len(push_data); 
00873         http_header_remove_all(push_headers, "Content-Type");
00874     http_append_headers(push_headers, content_headers);
00875         change_header_value(&push_headers, "Content-Length", 
00876             octstr_get_cstr(plos = octstr_format("%d", push_len)));
00877         octstr_destroy(plos);
00878         octstr_destroy(content_header);
00879     http_destroy_headers(content_headers);
00880 
00881         ppg_event = NULL;
00882         if ((compiler_status = pap_compile(pap_content, &ppg_event)) == -2) {
00883         send_bad_message_response(&client, pap_content, PAP_BAD_REQUEST,
00884                                        http_status);
00885             if (client == NULL)
00886             break;
00887             warning(0, "PPG: pap control entity erroneous, the request" 
00888                     " unacceptable");
00889             goto no_compile;
00890         } else if (compiler_status == -1) {
00891             send_bad_message_response(&client, pap_content, PAP_BAD_REQUEST,
00892                                       http_status);
00893             if (client == NULL)
00894             break;
00895             warning(0, "PPG: non implemented pap feature requested, the"
00896                     " request unacceptable");
00897             goto no_compile;
00898         } else {
00899         if (!dict_put_once(http_clients, 
00900             ppg_event->u.Push_Message.pi_push_id, client)) {
00901                 warning(0, "PPG: duplicate push id, the request unacceptable");
00902             tell_fatal_error(&client, ppg_event, url, http_status, 
00903                                  PAP_DUPLICATE_PUSH_ID);
00904                 if (client == NULL)
00905                 break;
00906                 goto not_acceptable;
00907         } 
00908 
00909             dict_put(urls, ppg_event->u.Push_Message.pi_push_id, url); 
00910  
00911             if (is_phone_number(ppg_event->u.Push_Message.address_type)) {
00912                 if (!trusted_pi && user_configuration && 
00913                         !wap_push_ppg_pushuser_client_phone_number_acceptable(
00914                         username, ppg_event->u.Push_Message.address_value)) {
00915                     tell_fatal_error(&client, ppg_event, url, http_status, 
00916                                     PAP_FORBIDDEN);
00917                     if (client == NULL)
00918                     break;
00919                     goto not_acceptable;
00920                 }   
00921             }        
00922             
00923             debug("wap.push.ppg", 0, "PPG: http_read_thread: pap control"
00924                   " entity compiled ok");
00925             ppg_event->u.Push_Message.push_data = octstr_duplicate(push_data);
00926             ppg_event->u.Push_Message.smsc_id = set_smsc_id(push_headers, username,
00927                                                             trusted_pi);
00928             dlr_url = set_dlr_url(push_headers, username, trusted_pi);
00929             ppg_event->u.Push_Message.dlr_url = dlr_url;
00930             ppg_event->u.Push_Message.dlr_mask = set_dlr_mask(push_headers, dlr_url);
00931             ppg_event->u.Push_Message.smsbox_id = set_smsbox_id(push_headers, username,
00932                                                                 trusted_pi);
00933             ppg_event->u.Push_Message.service_name = set_service_name();
00934             remove_x_kannel_headers(&push_headers);
00935             ppg_event->u.Push_Message.push_headers = http_header_duplicate(push_headers);
00936             
00937             if (!handle_push_message(&client, ppg_event, http_status)) {
00938             if (client == NULL)
00939             break;
00940                 goto no_transform;
00941             }
00942         }
00943 
00944         pap_event_destroy(p);
00945         http_destroy_headers(push_headers);
00946         http_destroy_cgiargs(cgivars);
00947         octstr_destroy(username);
00948         octstr_destroy(mime_content);
00949         octstr_destroy(pap_content);
00950         octstr_destroy(push_data);
00951         octstr_destroy(rdf_content);
00952         octstr_destroy(boundary);
00953         continue;
00954 
00955 no_transform:
00956         pap_event_destroy(p);
00957         http_destroy_headers(push_headers);
00958         http_destroy_cgiargs(cgivars);
00959         octstr_destroy(username);
00960         octstr_destroy(mime_content);
00961         octstr_destroy(pap_content);
00962         octstr_destroy(push_data);
00963         octstr_destroy(rdf_content);
00964         octstr_destroy(boundary);
00965         continue;
00966 
00967 no_compile:
00968         pap_event_destroy(p);
00969         http_destroy_headers(push_headers);
00970         http_destroy_cgiargs(cgivars);
00971         octstr_destroy(username);
00972         octstr_destroy(mime_content);
00973         octstr_destroy(push_data);
00974         octstr_destroy(rdf_content);
00975         octstr_destroy(boundary);
00976         octstr_destroy(url);
00977         continue;
00978 
00979 not_acceptable:
00980         pap_event_destroy(p);
00981         http_destroy_headers(push_headers);
00982         http_destroy_cgiargs(cgivars);
00983         octstr_destroy(username);
00984         octstr_destroy(mime_content);
00985         octstr_destroy(pap_content);
00986         octstr_destroy(push_data);
00987         octstr_destroy(rdf_content);
00988         octstr_destroy(boundary);
00989         octstr_destroy(url);
00990         continue;
00991 
00992 clean:
00993         pap_event_destroy(p);
00994         http_destroy_headers(push_headers);
00995         http_destroy_headers(content_headers);
00996         octstr_destroy(pap_content);
00997         octstr_destroy(push_data);
00998         octstr_destroy(rdf_content);
00999         octstr_destroy(content_header);
01000         octstr_destroy(boundary);
01001         octstr_destroy(url);
01002         continue;
01003 
01004 ferror:
01005         pap_event_destroy(p);
01006         http_destroy_headers(push_headers);
01007         http_destroy_cgiargs(cgivars);
01008         octstr_destroy(username);
01009         octstr_destroy(url);
01010         octstr_destroy(ip);
01011         octstr_destroy(mime_content);
01012         continue;
01013 
01014 herror:
01015         pap_event_destroy(p);
01016         http_destroy_headers(push_headers);
01017         http_destroy_cgiargs(cgivars);
01018         octstr_destroy(username);
01019         octstr_destroy(url);
01020         continue;
01021 
01022 berror:
01023         pap_event_destroy(p);
01024         http_destroy_headers(push_headers);
01025         http_destroy_cgiargs(cgivars);
01026         octstr_destroy(username);
01027         octstr_destroy(mime_content);
01028         octstr_destroy(content_header);
01029         octstr_destroy(boundary);
01030         octstr_destroy(url);
01031         continue;
01032     }
01033 }

Here is the call graph for this function:

long parse_appid_header Octstr **  assigned_code  )  [static]
 

Definition at line 2836 of file wap_push_ppg.c.

References octstr_case_search(), octstr_delete(), octstr_destroy(), octstr_format(), octstr_imm(), octstr_len(), octstr_search(), and wina_uri.

Referenced by check_x_wap_application_id_header().

02837 {
02838     long pos,
02839          coded_value;
02840     size_t i;
02841 
02842     if ((pos = octstr_search(*appid_content, octstr_imm(";"), 0)) >= 0) {
02843         octstr_delete(*appid_content, pos, 
02844                       octstr_len(octstr_imm(";app-encoding=")));
02845         octstr_delete(*appid_content, 0, pos);         /* the URI part */
02846         return -1;
02847     } 
02848 
02849     i = 0;
02850     while (i < NUMBER_OF_WINA_URIS) {
02851         if ((pos = octstr_case_search(*appid_content, 
02852                 octstr_imm(wina_uri[i]), 0)) >= 0)
02853             break;
02854         ++i;
02855     }
02856 
02857     if (i == NUMBER_OF_WINA_URIS) {
02858         octstr_destroy(*appid_content);
02859         *appid_content = octstr_format("%ld", 2);      /* assigned number */
02860         return -1;                                     /* for wml ua */
02861     }
02862     
02863     octstr_delete(*appid_content, 0, pos);             /* again the URI */
02864     if ((coded_value = wsp_string_to_application_id(*appid_content)) >= 0) {
02865         octstr_destroy(*appid_content);
02866         *appid_content = octstr_format("%ld", coded_value);
02867         return coded_value;
02868     }
02869 
02870     return -1;
02871 }

Here is the call graph for this function:

int push_has_pi_push_id void *  a,
void *  b
[static]
 

Definition at line 2506 of file wap_push_ppg.c.

References octstr_compare(), and pm.

Referenced by find_ppg_push_machine_using_pi_push_id(), and find_unit_ppg_push_machine_using_pi_push_id().

02507 {
02508     Octstr *pi_push_id;
02509     PPGPushMachine *pm;
02510 
02511     pi_push_id = b;
02512     pm = a;
02513 
02514     return octstr_compare(pm->pi_push_id, pi_push_id) == 0;
02515 }

Here is the call graph for this function:

int push_has_pid void *  a,
void *  b
[static]
 

Definition at line 2482 of file wap_push_ppg.c.

References pm.

Referenced by find_ppg_push_machine_using_pid(), update_push_data_with_attribute(), and update_session_data_with_headers().

02483 {
02484     long *pid;
02485     PPGPushMachine *pm;
02486 
02487     pid = b;
02488     pm = a;
02489     
02490     return *pid == pm->push_id;
02491 }

void push_machine_assert PPGPushMachine pm  )  [static]
 

Definition at line 1718 of file wap_push_ppg.c.

References gw_assert, and pm.

Referenced by abort_delivery(), create_session(), deliver_pending_pushes(), deliver_unit_push(), handle_internal_event(), remove_push_data(), request_confirmed_push(), request_push(), request_unit_push(), response_push_message(), and update_push_data_with_attribute().

01719 {
01720     gw_assert(pm);
01721     gw_assert(pm->pi_push_id);
01722     gw_assert(pm->push_id >= 0);
01723     gw_assert(pm->session_id >= 0);
01724     gw_assert(pm->addr_tuple);
01725     gw_assert(pm->trusted == 1 || pm->trusted == 0);
01726     gw_assert(pm->authenticated  == 1 || pm->authenticated == 0);
01727 }

PPGPushMachine * push_machine_create WAPEvent e,
WAPAddrTuple tuple
[static]
 

Definition at line 1353 of file wap_push_ppg.c.

References counter_increase(), debug(), http_header_duplicate(), m, octstr_duplicate, push_id_counter, WAPEvent::u, and wap_addr_tuple_duplicate().

01354 {
01355     PPGPushMachine *m;
01356 
01357     m = gw_malloc(sizeof(PPGPushMachine));
01358 
01359     #define INTEGER(name) m->name = 0;
01360     #define OCTSTR(name) m->name = NULL;
01361     #define OPTIONAL_OCTSTR(name) m->name = NULL;
01362     #define ADDRTUPLE(name) m->name = NULL;
01363     #define CAPABILITIES m->name = NULL;
01364     #define HTTPHEADER(name) m->name = NULL;
01365     #define MACHINE(fields) fields
01366     #include "wap_ppg_push_machine.def"
01367 
01368     m->addr_tuple = wap_addr_tuple_duplicate(tuple);
01369     m->pi_push_id = octstr_duplicate(e->u.Push_Message.pi_push_id);
01370     m->push_id = counter_increase(push_id_counter);
01371     m->delivery_method = e->u.Push_Message.delivery_method;
01372     m->deliver_after_timestamp = 
01373         octstr_duplicate(e->u.Push_Message.deliver_after_timestamp);
01374     m->priority = e->u.Push_Message.priority;
01375     m->push_headers = http_header_duplicate(e->u.Push_Message.push_headers);
01376     m->push_data = octstr_duplicate(e->u.Push_Message.push_data);
01377 
01378     m->address_type = e->u.Push_Message.address_type;
01379     if (e->u.Push_Message.smsc_id != NULL)
01380         m->smsc_id = octstr_duplicate(e->u.Push_Message.smsc_id);
01381     else
01382         m->smsc_id = NULL;
01383     if (e->u.Push_Message.dlr_url != NULL)
01384         m->dlr_url = octstr_duplicate(e->u.Push_Message.dlr_url);                                 
01385     else
01386         m->dlr_url = NULL;
01387     m->dlr_mask = e->u.Push_Message.dlr_mask;
01388     if (e->u.Push_Message.smsbox_id != NULL)
01389         m->smsbox_id = octstr_duplicate(e->u.Push_Message.smsbox_id);
01390     else
01391         m->smsbox_id = NULL;
01392     m->service_name = octstr_duplicate(e->u.Push_Message.service_name);
01393 
01394     m->progress_notes_requested = e->u.Push_Message.progress_notes_requested;
01395     if (e->u.Push_Message.progress_notes_requested)
01396         m->ppg_notify_requested_to = 
01397             octstr_duplicate(e->u.Push_Message.ppg_notify_requested_to);
01398 
01399     debug("wap.push.ppg", 0, "PPG: push machine %ld created", m->push_id);
01400 
01401     return m;
01402 }

Here is the call graph for this function:

void push_machine_destroy void *  pm  )  [static]
 

Definition at line 1408 of file wap_push_ppg.c.

References debug(), and pm.

Referenced by push_machines_list_destroy(), and wap_push_ppg_shutdown().

01409 {
01410     PPGPushMachine *pm;
01411 
01412     if (p == NULL)
01413         return;
01414 
01415     pm = p;
01416 
01417     debug("wap.push.ppg", 0, "PPG: destroying push machine %ld", 
01418           pm->push_id); 
01419     #define OCTSTR(name) octstr_destroy(pm->name);
01420     #define OPTIONAL_OCTSTR(name) octstr_destroy(pm->name);
01421     #define INTEGER(name)
01422     #define ADDRTUPLE(name) wap_addr_tuple_destroy(pm->name);
01423     #define CAPABILITIES(name) wap_cap_destroy_list(pm->name);
01424     #define HTTPHEADER(name) http_destroy_headers(pm->name);
01425     #define MACHINE(fields) fields
01426     #include "wap_ppg_push_machine.def"
01427 
01428     gw_free(p);
01429 }

Here is the call graph for this function:

void push_machines_list_destroy List pl  )  [static]
 

Definition at line 1431 of file wap_push_ppg.c.

References gwlist_destroy(), and push_machine_destroy().

01432 {
01433     if (machines == NULL)
01434         return;
01435 
01436     gwlist_destroy(machines, push_machine_destroy);
01437 }

Here is the call graph for this function:

int read_ppg_config Cfg cfg  )  [static]
 

Definition at line 520 of file wap_push_ppg.c.

References cfg_destroy(), cfg_get, cfg_get_bool(), cfg_get_integer(), cfg_get_multi_group(), cfg_get_single_group(), global_sender, gwlist_destroy(), number_of_pushes, number_of_users, octstr_destroy(), octstr_format(), octstr_imm(), panic, ppg_allow_ip, ppg_default_smsc, ppg_deny_ip, ppg_dlr_url, ppg_port, ppg_smsbox_id, ppg_ssl_port, ppg_url, service_name, ssl_server_cert_file, ssl_server_key_file, trusted_pi, use_global_server_certkey_file(), and wap_push_ppg_pushuser_list_add().

Referenced by wap_push_ppg_init().

00521 {
00522      CfgGroup *grp;
00523      List *list;
00524 
00525      if (cfg == NULL)
00526          return USER_CONFIGURATION_NOT_ADDED;
00527 
00528      grp = cfg_get_single_group(cfg, octstr_imm("ppg"));
00529      if ((ppg_url = cfg_get(grp, octstr_imm("ppg-url"))) == NULL)
00530          ppg_url = octstr_imm("/wappush");
00531      cfg_get_integer(&ppg_port, grp, octstr_imm("ppg-port"));
00532      cfg_get_integer(&number_of_pushes, grp, octstr_imm("concurrent-pushes"));
00533      cfg_get_bool(&trusted_pi, grp, octstr_imm("trusted-pi"));
00534      cfg_get_integer(&number_of_users, grp, octstr_imm("users"));
00535      ppg_deny_ip = cfg_get(grp, octstr_imm("ppg-deny-ip"));
00536      ppg_allow_ip = cfg_get(grp, octstr_imm("ppg-allow-ip"));
00537      if ((global_sender = cfg_get(grp, octstr_imm("global-sender"))) == NULL)
00538          global_sender = octstr_format("%s", "1234");
00539      ppg_default_smsc = cfg_get(grp, octstr_imm("default-smsc"));
00540      ppg_dlr_url = cfg_get(grp, octstr_imm("default-dlr-url"));
00541      ppg_smsbox_id = cfg_get(grp, octstr_imm("ppg-smsbox-id"));
00542      if ((service_name = cfg_get(grp, octstr_imm("service-name"))) == NULL)
00543          service_name = octstr_format("%s", "ppg");
00544    
00545 #ifdef HAVE_LIBSSL
00546      cfg_get_integer(&ppg_ssl_port, grp, octstr_imm("ppg-ssl-port"));
00547      ssl_server_cert_file = cfg_get(grp, octstr_imm("ssl-server-cert-file"));
00548      ssl_server_key_file = cfg_get(grp, octstr_imm("ssl-server-key-file"));
00549      if (ppg_ssl_port != NO_HTTPS_PORT) {
00550         if (ssl_server_cert_file == NULL || ssl_server_key_file == NULL) 
00551             panic(0, "cannot continue without server cert and/or key files");
00552         use_global_server_certkey_file(ssl_server_cert_file, ssl_server_key_file);
00553      }        
00554      octstr_destroy(ssl_server_cert_file);
00555      octstr_destroy(ssl_server_key_file);
00556 #endif
00557 
00558      /* If pi is trusted, ignore possible user groups. */
00559      if (trusted_pi) {
00560         cfg_destroy(cfg);
00561         return USER_CONFIGURATION_ADDED;
00562      }
00563 
00564      /* But if it is not, we cannot continue without user groups.*/
00565      if ((list = cfg_get_multi_group(cfg, octstr_imm("wap-push-user")))
00566               == NULL) {
00567          panic(0, "No user group but ppg not trusted, stopping");
00568          gwlist_destroy(list, NULL);
00569          cfg_destroy(cfg); 
00570          return USER_CONFIGURATION_NOT_ADDED;
00571      }
00572     
00573      if (!wap_push_ppg_pushuser_list_add(list, number_of_pushes, 
00574                                          number_of_users)) {
00575          panic(0, "unable to create users configuration list, exiting");
00576          return USER_CONFIGURATION_NOT_ADDED;     
00577      }  
00578 
00579      cfg_destroy(cfg); 
00580      return USER_CONFIGURATION_ADDED;
00581 }

Here is the call graph for this function:

void remove_link_headers List **  push_headers  )  [static]
 

Definition at line 3000 of file wap_push_ppg.c.

References http_header_remove_all().

Referenced by pap_request_thread().

03001 {
03002     http_header_remove_all(*push_headers, "Host");
03003 }

Here is the call graph for this function:

void remove_mime_headers List **  push_headers  )  [static]
 

Definition at line 2992 of file wap_push_ppg.c.

References http_header_remove_all().

Referenced by pap_request_thread().

02993 {
02994     http_header_remove_all(*push_headers, "MIME-Version");
02995 }

Here is the call graph for this function:

void remove_push_data PPGSessionMachine sm,
PPGPushMachine pm,
int  cless
[static]
 

Definition at line 2248 of file wap_push_ppg.c.

References gwlist_delete_equal(), pm, ppg_unit_pushes, push_machine_assert(), push_machine_destroy(), session_machine_assert(), and sm.

Referenced by abort_delivery(), deliver_pending_pushes(), handle_internal_event(), handle_push_message(), and remove_session_data().

02250 {
02251     push_machine_assert(pm);
02252 
02253     if (cless) {
02254         gwlist_delete_equal(ppg_unit_pushes, pm);
02255     } else {
02256         session_machine_assert(sm);
02257         gwlist_delete_equal(sm->push_machines, pm);
02258     }
02259 
02260     push_machine_destroy(pm);
02261 }

Here is the call graph for this function:

void remove_pushless_session PPGSessionMachine sm  )  [static]
 

Definition at line 2428 of file wap_push_ppg.c.

References gwlist_delete_equal(), gwlist_len(), ppg_machines, session_machine_assert(), session_machine_destroy(), and sm.

Referenced by handle_push_message().

02429 {
02430     session_machine_assert(sm);
02431 
02432     if (gwlist_len(sm->push_machines) == 0) {
02433         gwlist_delete_equal(ppg_machines, sm);
02434         session_machine_destroy(sm);
02435     }
02436 }

Here is the call graph for this function:

void remove_session_data PPGSessionMachine sm,
int  status
[static]
 

Definition at line 2406 of file wap_push_ppg.c.

References code, gwlist_delete_equal(), gwlist_get(), gwlist_len(), pm, ppg_machines, remove_push_data(), response_push_message(), session_machine_assert(), session_machine_destroy(), and sm.

Referenced by handle_internal_event().

02407 {
02408     long code;
02409     PPGPushMachine *pm;
02410 
02411     session_machine_assert(sm);
02412 
02413     code = PAP_ABORT_USERPND;
02414     
02415     while (gwlist_len(sm->push_machines) > 0) {
02416         pm = gwlist_get(sm->push_machines, 0);
02417         response_push_message(pm, code, status);
02418         remove_push_data(sm, pm, sm == NULL);
02419     }
02420 
02421     gwlist_delete_equal(ppg_machines, sm);
02422     session_machine_destroy(sm);
02423 }

Here is the call graph for this function:

void remove_x_kannel_headers List **  push_headers  )  [static]
 

Definition at line 3008 of file wap_push_ppg.c.

References http_header_remove_all().

Referenced by pap_request_thread().

03009 {
03010     http_header_remove_all(*push_headers, "X-Kannel-SMSC");
03011     http_header_remove_all(*push_headers, "X-Kannel-DLR-Url");
03012     http_header_remove_all(*push_headers, "X-Kannel-DLR-Mask");
03013     http_header_remove_all(*push_headers, "X-Kannel-Smsbox-Id");
03014 }

Here is the call graph for this function:

void replace_octstr_char Octstr os1,
Octstr os2,
long *  pos
[static]
 

Definition at line 3241 of file wap_push_ppg.c.

References octstr_delete(), octstr_insert(), and octstr_len().

Referenced by escape_fragment().

03242 {
03243     octstr_delete(os1, *pos, 1);
03244     octstr_insert(os1, os2, *pos);
03245     *pos += octstr_len(os2) - 1;
03246 }

Here is the call graph for this function:

void request_confirmed_push long  last,
PPGPushMachine pm,
PPGSessionMachine sm
[static]
 

Definition at line 1514 of file wap_push_ppg.c.

References debug(), dispatch_to_ota, gw_assert, http_header_duplicate(), octstr_duplicate, pm, Po_ConfirmedPush_Req, push_machine_assert(), session_machine_assert(), sm, WAPEvent::u, and wap_event_create.

Referenced by deliver_confirmed_push(), and deliver_pending_pushes().

01516 {
01517     WAPEvent *ota_event;
01518     List *push_headers;
01519 
01520     gw_assert(last == 0 || last == 1);
01521     push_machine_assert(pm);
01522     session_machine_assert(sm);
01523     
01524     push_headers = http_header_duplicate(pm->push_headers);
01525 
01526     ota_event = wap_event_create(Po_ConfirmedPush_Req);
01527     ota_event->u.Po_ConfirmedPush_Req.server_push_id = pm->push_id;
01528     ota_event->u.Po_ConfirmedPush_Req.push_headers = push_headers;
01529     ota_event->u.Po_ConfirmedPush_Req.authenticated = pm->authenticated;
01530     ota_event->u.Po_ConfirmedPush_Req.trusted = pm->trusted;
01531     ota_event->u.Po_ConfirmedPush_Req.last = last;
01532  
01533     if (pm->push_data != NULL)
01534         ota_event->u.Po_ConfirmedPush_Req.push_body = 
01535             octstr_duplicate(pm->push_data);
01536     else
01537         ota_event->u.Po_ConfirmedPush_Req.push_body = NULL;
01538 
01539     ota_event->u.Po_ConfirmedPush_Req.session_handle = sm->session_id;
01540     debug("wap.push.ota", 0, "PPG: confirmed push request to OTA");
01541     
01542     dispatch_to_ota(ota_event);
01543 }

Here is the call graph for this function:

void request_push long  last,
PPGPushMachine sm
[static]
 

Definition at line 1591 of file wap_push_ppg.c.

References debug(), dispatch_to_ota, gw_assert, http_header_duplicate(), octstr_duplicate, pm, Po_Push_Req, push_machine_assert(), WAPEvent::u, and wap_event_create.

Referenced by deliver_pending_pushes(), and deliver_unit_push().

01592 {
01593     WAPEvent *ota_event;
01594     List *push_headers;
01595 
01596     gw_assert(last == 0 || last == 1);
01597     push_machine_assert(pm);
01598     
01599     push_headers = http_header_duplicate(pm->push_headers);
01600 
01601     ota_event = wap_event_create(Po_Push_Req);
01602     ota_event->u.Po_Push_Req.push_headers = push_headers;
01603     ota_event->u.Po_Push_Req.authenticated = pm->authenticated;
01604     ota_event->u.Po_Push_Req.trusted = pm->trusted;
01605     ota_event->u.Po_Push_Req.last = last;
01606 
01607     if (pm->push_data != NULL)
01608         ota_event->u.Po_Push_Req.push_body = 
01609             octstr_duplicate(pm->push_data);
01610     else
01611         ota_event->u.Po_Push_Req.push_body = NULL;        
01612 
01613     ota_event->u.Po_Push_Req.session_handle = pm->session_id;
01614     debug("wap.push.ppg", 0, "PPG: OTA request for push");
01615     
01616     dispatch_to_ota(ota_event);
01617 }

Here is the call graph for this function:

void request_unit_push long  last,
PPGPushMachine pm
[static]
 

Definition at line 1549 of file wap_push_ppg.c.

References debug(), dispatch_to_ota, gw_assert, http_header_duplicate(), octstr_duplicate, pm, Po_Unit_Push_Req, push_machine_assert(), WAPEvent::u, wap_addr_tuple_duplicate(), and wap_event_create.

Referenced by deliver_unit_push().

01550 {
01551     WAPEvent *ota_event;
01552     List *push_headers;
01553 
01554     gw_assert(last == 0 || last == 1);
01555     push_machine_assert(pm);
01556     
01557     push_headers = http_header_duplicate(pm->push_headers);
01558 
01559     ota_event = wap_event_create(Po_Unit_Push_Req);
01560     ota_event->u.Po_Unit_Push_Req.addr_tuple = 
01561         wap_addr_tuple_duplicate(pm->addr_tuple);
01562     ota_event->u.Po_Unit_Push_Req.push_id = pm->push_id;
01563     ota_event->u.Po_Unit_Push_Req.push_headers = push_headers;
01564     ota_event->u.Po_Unit_Push_Req.authenticated = pm->authenticated;
01565     ota_event->u.Po_Unit_Push_Req.trusted = pm->trusted;
01566     ota_event->u.Po_Unit_Push_Req.last = last;
01567 
01568     ota_event->u.Po_Unit_Push_Req.address_type = pm->address_type;
01569     if (pm->smsc_id != NULL)
01570         ota_event->u.Po_Unit_Push_Req.smsc_id = octstr_duplicate(pm->smsc_id);
01571     else
01572         ota_event->u.Po_Unit_Push_Req.smsc_id = NULL;
01573     if (pm->dlr_url != NULL)
01574         ota_event->u.Po_Unit_Push_Req.dlr_url = octstr_duplicate(pm->dlr_url);
01575     else
01576         ota_event->u.Po_Unit_Push_Req.dlr_url = NULL;
01577     ota_event->u.Po_Unit_Push_Req.dlr_mask = pm->dlr_mask;
01578     if (pm->smsbox_id != NULL)   
01579         ota_event->u.Po_Unit_Push_Req.smsbox_id = octstr_duplicate(pm->smsbox_id);
01580     else
01581         ota_event->u.Po_Unit_Push_Req.smsbox_id = NULL;
01582     if (pm->service_name != NULL)    
01583         ota_event->u.Po_Unit_Push_Req.service_name = octstr_duplicate(pm->service_name);
01584 
01585     ota_event->u.Po_Unit_Push_Req.push_body = octstr_duplicate(pm->push_data);
01586 
01587     dispatch_to_ota(ota_event);
01588     debug("wap.push.ppg", 0, "PPG: OTA request for unit push");
01589 }

Here is the call graph for this function:

int response_push_connection WAPEvent e,
PPGSessionMachine sm
[static]
 

Definition at line 1636 of file wap_push_ppg.c.

References check_capabilities(), dispatch_to_appl, gw_assert, Pom_Connect_Ind, Pom_Connect_Res, sm, WAPEvent::type, WAPEvent::u, wap_event_create, and wsp_cap_duplicate_list().

Referenced by handle_internal_event(), and main_thread().

01637 {
01638     WAPEvent *appl_event;
01639 
01640     gw_assert(e->type == Pom_Connect_Ind);
01641 
01642     if (sm->assumed_capabilities != NULL && check_capabilities(
01643             e->u.Pom_Connect_Ind.requested_capabilities, 
01644             sm->assumed_capabilities) == 0)
01645        return 0;
01646 
01647     appl_event = wap_event_create(Pom_Connect_Res);
01648     appl_event->u.Pom_Connect_Res.negotiated_capabilities = 
01649         wsp_cap_duplicate_list(e->u.Pom_Connect_Ind.requested_capabilities);
01650     appl_event->u.Pom_Connect_Res.session_id = e->u.Pom_Connect_Ind.session_id;
01651 
01652     dispatch_to_appl(appl_event);
01653 
01654     return 1;
01655 }

Here is the call graph for this function:

HTTPClient * response_push_message PPGPushMachine pm,
long  code,
int  status
[static]
 

Definition at line 1662 of file wap_push_ppg.c.

References code, describe_code(), octstr_duplicate, pm, push_machine_assert(), Push_Response, send_push_response(), set_time(), tell_ppg_name(), WAPEvent::u, and wap_event_create.

Referenced by abort_delivery(), handle_push_message(), and remove_session_data().

01663 {
01664     WAPEvent *e;
01665     HTTPClient *c;
01666 
01667     push_machine_assert(pm);
01668 
01669     e = wap_event_create(Push_Response);
01670     e->u.Push_Response.pi_push_id = octstr_duplicate(pm->pi_push_id);
01671     e->u.Push_Response.sender_name = tell_ppg_name();
01672     e->u.Push_Response.reply_time = set_time();
01673     e->u.Push_Response.code = code;
01674     e->u.Push_Response.desc = describe_code(code);
01675 
01676     c = send_push_response(e, status);
01677 
01678     return c;
01679 }

Here is the call graph for this function:

int select_bearer_network WAPEvent **  e  )  [static]
 

Definition at line 2083 of file wap_push_ppg.c.

References bearers, gw_assert, NUMBER_OF_NETWORKS, octstr_case_compare(), octstr_imm(), and Push_Message.

Referenced by handle_push_message().

02084 {
02085     Octstr *bearer,
02086            *network;
02087     int bearer_required,
02088         network_required;
02089     size_t i, 
02090            j;
02091 
02092     gw_assert((**e).type == Push_Message);
02093 
02094     bearer_required = (**e).u.Push_Message.bearer_required;
02095     network_required = (**e).u.Push_Message.network_required;
02096     bearer = octstr_imm("Any");
02097     network = octstr_imm("Any");
02098     
02099     if (!bearer_required || !network_required)
02100         return 1;
02101 
02102     if (bearer_required)
02103         bearer = (**e).u.Push_Message.bearer;
02104     if (network_required)
02105         network = (**e).u.Push_Message.network;
02106     
02107     for (i = 0; i < NUMBER_OF_NETWORKS ; ++i) {
02108         if (octstr_case_compare(bearer, octstr_imm(bearers[i])) == 0)
02109             break;
02110     }
02111     for (j = 0; j < NUMBER_OF_BEARERS ; ++j) {
02112         if (octstr_case_compare(bearer, octstr_imm(bearers[j])) == 0)
02113             break;
02114     }
02115     if (i == NUMBER_OF_NETWORKS || j == NUMBER_OF_BEARERS)
02116         return 0;
02117 
02118     return 1;
02119 }

Here is the call graph for this function:

void send_bad_message_response HTTPClient **  c,
Octstr body_fragment,
int  code,
int  status
[static]
 

Definition at line 3021 of file wap_push_ppg.c.

References code, debug(), escape_fragment(), octstr_destroy(), octstr_format(), octstr_format_append(), octstr_len(), and send_to_pi().

Referenced by pap_request_thread().

03023 {
03024     Octstr *reply_body;
03025 
03026     reply_body = octstr_format("%s", 
03027         "<?xml version=\"1.0\"?>"
03028         "<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 1.0//EN\""
03029                    " \"http://www.wapforum.org/DTD/pap_1.0.dtd\">"
03030         "<pap>"
03031              "<badmessage-response code=\"");
03032     octstr_format_append(reply_body, "%d", code);
03033     octstr_format_append(reply_body, "%s", "\""
03034                   " desc=\"");
03035     octstr_format_append(reply_body, "%s", "Not understood due to malformed"
03036                                            " syntax");
03037     octstr_format_append(reply_body, "%s", "\"");
03038 
03039     if (fragment != NULL && octstr_len(fragment) != 0) {
03040         octstr_format_append(reply_body, "%s", " bad-message-fragment=\"");
03041         octstr_format_append(reply_body, "%S", escape_fragment(fragment));
03042         octstr_format_append(reply_body, "%s", "\"");
03043     }
03044 
03045     octstr_format_append(reply_body, "%s", ">"
03046               "</badmessage-response>"
03047          "</pap>");
03048 
03049     debug("wap.push.ppg", 0, "PPG: send_bad_message_response: telling pi");
03050     send_to_pi(c, reply_body, status);
03051 
03052     octstr_destroy(fragment);
03053 }

Here is the call graph for this function:

HTTPClient * send_push_response WAPEvent e,
int  status
[static]
 

Definition at line 3061 of file wap_push_ppg.c.

References debug(), dict_get(), dict_remove(), gw_assert, http_clients, octstr_destroy(), octstr_format(), octstr_format_append(), Push_Response, send_to_pi(), WAPEvent::type, WAPEvent::u, urls, and wap_event_destroy().

Referenced by response_push_message().

03062 {
03063     Octstr *reply_body,
03064            *url;
03065     HTTPClient *c;
03066 
03067     gw_assert(e->type == Push_Response);
03068     url = dict_get(urls, e->u.Push_Response.pi_push_id);
03069     dict_remove(urls, e->u.Push_Response.pi_push_id);
03070 
03071     reply_body = octstr_format("%s", 
03072         "<?xml version=\"1.0\"?>"
03073         "<!DOCTYPE pap PUBLIC \"-//WAPFORUM//DTD PAP 1.0//EN\""
03074                    " \"http://www.wapforum.org/DTD/pap_1.0.dtd\">"
03075         "<pap>"
03076              "<push-response push-id=\"");
03077     octstr_format_append(reply_body, "%S", e->u.Push_Response.pi_push_id);
03078     octstr_format_append(reply_body, "%s", "\""); 
03079 
03080     if (e->u.Push_Response.sender_name != NULL) {
03081         octstr_format_append(reply_body, "%s",
03082                    " sender-name=\"");
03083         octstr_format_append(reply_body, "%S", 
03084             e->u.Push_Response.sender_name);
03085         octstr_format_append(reply_body, "%s", "\"");
03086     }
03087 
03088     if (e->u.Push_Response.reply_time != NULL) {
03089         octstr_format_append(reply_body, "%s",
03090                    " reply-time=\"");
03091         octstr_format_append(reply_body, "%S", 
03092             e->u.Push_Response.reply_time);
03093         octstr_format_append(reply_body, "%s", "\"");
03094     }
03095 
03096     if (url != NULL) {
03097         octstr_format_append(reply_body, "%s",
03098                    " sender-address=\"");
03099         octstr_format_append(reply_body, "%S", url);
03100         octstr_format_append(reply_body, "%s", "\"");
03101     }
03102 
03103     octstr_format_append(reply_body, "%s", ">"
03104              "<response-result code =\"");
03105     octstr_format_append(reply_body, "%d", e->u.Push_Response.code);
03106     octstr_format_append(reply_body, "%s", "\"");
03107 
03108     if (e->u.Push_Response.desc != NULL) {
03109         octstr_format_append(reply_body, "%s", " desc=\"");
03110         octstr_format_append(reply_body, "%S", e->u.Push_Response.desc);
03111         octstr_format_append(reply_body, "\"");
03112     }
03113     
03114     octstr_format_append(reply_body, "%s", ">"
03115               "</response-result>"
03116               "</push-response>"
03117           "</pap>");
03118 
03119     octstr_destroy(url);
03120 
03121     c = dict_get(http_clients, e->u.Push_Response.pi_push_id);
03122     dict_remove(http_clients, e->u.Push_Response.pi_push_id);
03123 
03124     debug("wap.push.ppg", 0, "PPG: send_push_response: telling pi");
03125     send_to_pi(&c, reply_body, status);
03126 
03127     wap_event_destroy(e);
03128     return c;
03129 }

Here is the call graph for this function:

void send_to_pi HTTPClient **  c,
Octstr reply_body,
int  status
[static]
 

Definition at line 3196 of file wap_push_ppg.c.

References http_create_empty_headers(), http_destroy_headers(), http_header_add(), http_send_reply(), and octstr_destroy().

Referenced by send_bad_message_response(), send_push_response(), and tell_fatal_error().

03196                                                                        {
03197     List *reply_headers;
03198 
03199     reply_headers = http_create_empty_headers();
03200     http_header_add(reply_headers, "Content-Type", "application/xml");
03201 
03202     if (*c != NULL)
03203         http_send_reply(*c, status, reply_headers, reply_body);
03204 
03205     octstr_destroy(reply_body);
03206     http_destroy_headers(reply_headers);
03207 }

Here is the call graph for this function:

PPGSessionMachine * session_find_using_pi_client_address Octstr addr  )  [static]
 

Definition at line 2136 of file wap_push_ppg.c.

References gwlist_search(), ppg_machines, session_has_pi_client_address(), and sm.

Referenced by handle_push_message().

02137 {
02138     PPGSessionMachine *sm;
02139     
02140     sm = gwlist_search(ppg_machines, caddr, session_has_pi_client_address);
02141 
02142     return sm;
02143 }

Here is the call graph for this function:

int session_has_addr void *  a,
void *  b
[static]
 

Definition at line 1439 of file wap_push_ppg.c.

References octstr_compare(), and sm.

Referenced by wap_push_ppg_have_push_session_for().

01440 {
01441     Octstr *cliaddr;
01442     PPGSessionMachine *sm;
01443 
01444     cliaddr = b;
01445     sm = a;
01446     
01447     return octstr_compare(sm->addr_tuple->remote->address, cliaddr) == 0;
01448 }

Here is the call graph for this function:

int session_has_pi_client_address void *  a,
void *  b
[static]
 

Definition at line 2121 of file wap_push_ppg.c.

References octstr_compare(), and sm.

Referenced by session_find_using_pi_client_address().

02122 {
02123     Octstr *caddr;
02124     PPGSessionMachine *sm;
02125 
02126     caddr = b;
02127     sm = a;
02128 
02129     return octstr_compare(caddr, sm->pi_client_address) == 0;
02130 }

Here is the call graph for this function:

int session_has_sid void *  a,
void *  b
[static]
 

Definition at line 1450 of file wap_push_ppg.c.

References sm.

Referenced by wap_push_ppg_have_push_session_for_sid().

01451 {
01452      PPGSessionMachine *sm;
01453      long *sid;
01454 
01455      sid = b;
01456      sm = a;
01457 
01458      return *sid == sm->session_id;
01459 }

void session_machine_assert PPGSessionMachine sm  )  [static]
 

Definition at line 1710 of file wap_push_ppg.c.

References gw_assert, and sm.

Referenced by abort_delivery(), deliver_pending_pushes(), find_ppg_push_machine_using_pi_push_id(), find_ppg_push_machine_using_pid(), handle_internal_event(), remove_push_data(), remove_pushless_session(), remove_session_data(), request_confirmed_push(), and update_session_data().

01711 {
01712     gw_assert(sm);
01713     gw_assert(sm->session_id >= 0);
01714     gw_assert(sm->addr_tuple);
01715     gw_assert(sm->pi_client_address);
01716 }

PPGSessionMachine * session_machine_create WAPAddrTuple tuple,
WAPEvent e
[static]
 

Definition at line 1298 of file wap_push_ppg.c.

References debug(), gw_assert, gwlist_append(), m, octstr_duplicate, ppg_machines, Push_Message, WAPEvent::type, WAPEvent::u, wap_addr_tuple_duplicate(), and wsp_cap_duplicate_list().

Referenced by store_session_data().

01300 {
01301     PPGSessionMachine *m;
01302 
01303     gw_assert(e->type = Push_Message);
01304 
01305     m = gw_malloc(sizeof(PPGSessionMachine));
01306     
01307     #define INTEGER(name) m->name = 0;
01308     #define OCTSTR(name) m->name = NULL;
01309     #define ADDRTUPLE(name) m->name = NULL;
01310     #define PUSHMACHINES(name) m->name = gwlist_create();
01311     #define CAPABILITIES(name) m->name = NULL;
01312     #define MACHINE(fields) fields
01313     #include "wap_ppg_session_machine.def"
01314 
01315     m->pi_client_address = octstr_duplicate(e->u.Push_Message.address_value);
01316     m->addr_tuple = wap_addr_tuple_duplicate(tuple);
01317     m->assumed_capabilities = 
01318         wsp_cap_duplicate_list(e->u.Push_Message.pi_capabilities);
01319     m->preferconfirmed_value = PAP_CONFIRMED;    
01320 
01321     gwlist_append(ppg_machines, m);
01322     debug("wap.push.ppg", 0, "PPG: Created PPGSessionMachine %ld",
01323           m->session_id);
01324 
01325     return m;
01326 }

Here is the call graph for this function:

void session_machine_destroy void *  p  )  [static]
 

Definition at line 1328 of file wap_push_ppg.c.

References debug(), and sm.

Referenced by remove_pushless_session(), remove_session_data(), and wap_push_ppg_shutdown().

01329 {
01330     PPGSessionMachine *sm;
01331 
01332     if (p == NULL)
01333         return;
01334 
01335     sm = p;
01336     debug("wap.push.ppg", 0, "PPG: destroying PPGSEssionMachine %ld", 
01337           sm->session_id);
01338     
01339     #define OCTSTR(name) octstr_destroy(sm->name);
01340     #define ADDRTUPLE(name) wap_addr_tuple_destroy(sm->name);
01341     #define INTEGER(name) sm->name = 0;
01342     #define PUSHMACHINES(name) push_machines_list_destroy(sm->name);
01343     #define CAPABILITIES(name) wsp_cap_destroy_list(sm->name);
01344     #define MACHINE(fields) fields
01345     #include "wap_ppg_session_machine.def"
01346     gw_free(sm);
01347 }

Here is the call graph for this function:

WAPAddrTuple * set_addr_tuple Octstr address,
long  cliport,
long  servport,
long  address_type,
List push_headers
[static]
 

Definition at line 2762 of file wap_push_ppg.c.

References gw_assert, http_header_remove_all(), http_header_value(), octstr_destroy(), octstr_imm(), and wap_addr_tuple_create().

Referenced by transform_message().

02764 {
02765     Octstr *cliaddr;
02766     Octstr *from = NULL;
02767     WAPAddrTuple *tuple;
02768     
02769     gw_assert(address);
02770 
02771     if (address_type == ADDR_PLMN) {
02772         from = http_header_value(push_headers, octstr_imm("X-Kannel-From"));
02773         cliaddr = from ? from : global_sender;
02774     } else {
02775         cliaddr = octstr_imm("0.0.0.0");
02776     }
02777 
02778     tuple = wap_addr_tuple_create(address, cliport, cliaddr, servport);
02779 
02780     octstr_destroy(from);
02781     http_header_remove_all(push_headers, "X-Kannel-From");
02782 
02783     return tuple;
02784 }

Here is the call graph for this function:

long set_dlr_mask List headers,
Octstr dlr_url
[static]
 

Definition at line 3305 of file wap_push_ppg.c.

References http_header_value(), octstr_destroy(), octstr_imm(), octstr_len(), octstr_parse_long(), and warning().

Referenced by pap_request_thread().

03306 {
03307     Octstr *dlrmaskos;
03308     long dlr_mask;
03309     long masklen;    
03310 
03311     if (dlr_url == NULL) {
03312         return 0; 
03313     }
03314 
03315     dlrmaskos = http_header_value(headers, octstr_imm("X-Kannel-DLR-Mask"));
03316     if (dlrmaskos == NULL) { 
03317         return 0;
03318     }
03319 
03320     if ((masklen = octstr_parse_long(&dlr_mask, dlrmaskos, 0, 10)) != -1 &&
03321              masklen == octstr_len(dlrmaskos) &&
03322              dlr_mask >= -1 && dlr_mask <= 31) {
03323          octstr_destroy(dlrmaskos);
03324          return dlr_mask;
03325     }
03326 
03327     warning(0, "unparsable dlr mask, rejected");
03328     octstr_destroy(dlrmaskos);
03329     return 0;
03330 }

Here is the call graph for this function:

Octstr * set_dlr_url List headers,
Octstr username,
int  trusted_pi
[static]
 

Definition at line 3282 of file wap_push_ppg.c.

References http_header_value(), octstr_duplicate, octstr_imm(), ppg_dlr_url, username, and wap_push_ppg_pushuser_dlr_url_get().

Referenced by pap_request_thread().

03283 {
03284     Octstr *dlr_url = NULL;
03285 
03286     dlr_url = http_header_value(headers, octstr_imm("X-Kannel-DLR-Url"));
03287     if (dlr_url) {
03288         return dlr_url;
03289     }
03290 
03291     if (!trusted_pi)
03292         dlr_url = wap_push_ppg_pushuser_dlr_url_get(username);
03293 
03294     dlr_url = dlr_url ?
03295         dlr_url : (ppg_dlr_url ? octstr_duplicate(ppg_dlr_url) : NULL);
03296 
03297     return dlr_url;
03298 }

Here is the call graph for this function:

Octstr * set_service_name void   )  [static]
 

Definition at line 3363 of file wap_push_ppg.c.

References octstr_duplicate, and service_name.

Referenced by pap_request_thread().

03364 {
03365     return octstr_duplicate(service_name);
03366 }

Octstr * set_smsbox_id List headers,
Octstr username,
int  trusted_pi
[static]
 

Definition at line 3341 of file wap_push_ppg.c.

References http_header_value(), octstr_duplicate, octstr_imm(), ppg_smsbox_id, username, and wap_push_ppg_pushuser_smsbox_id_get().

Referenced by pap_request_thread().

03342 {
03343     Octstr *smsbox_id = NULL;
03344 
03345     smsbox_id = http_header_value(headers, octstr_imm("X-Kannel-Smsbox-Id"));
03346     if (smsbox_id != NULL) {
03347         return smsbox_id;
03348     }
03349 
03350     if (!trusted_pi)
03351         smsbox_id = wap_push_ppg_pushuser_smsbox_id_get(username);
03352 
03353     smsbox_id = smsbox_id ?
03354         smsbox_id : (ppg_smsbox_id ? octstr_duplicate(ppg_smsbox_id) : NULL);
03355 
03356     return smsbox_id;
03357 
03358 }

Here is the call graph for this function:

Octstr * set_smsc_id List headers,
Octstr username,
int  trusted_pi
[static]
 

Definition at line 3256 of file wap_push_ppg.c.

References http_header_value(), octstr_duplicate, octstr_imm(), ppg_default_smsc, username, and wap_push_ppg_pushuser_smsc_id_get().

Referenced by pap_request_thread().

03257 {
03258     Octstr *smsc_id = NULL;
03259 
03260     smsc_id = http_header_value(headers, octstr_imm("X-Kannel-SMSC"));
03261     if (smsc_id) {
03262         return smsc_id;
03263     }
03264 
03265     if (!trusted_pi)
03266         smsc_id = wap_push_ppg_pushuser_smsc_id_get(username);
03267 
03268     smsc_id = smsc_id ? 
03269         smsc_id : (ppg_default_smsc ? octstr_duplicate(ppg_default_smsc) : NULL);
03270 
03271     return smsc_id;
03272 }

Here is the call graph for this function:

Octstr * set_time void   )  [static]
 

Definition at line 1696 of file wap_push_ppg.c.

References gw_gmtime(), and octstr_format().

Referenced by response_push_message(), tell_fatal_error(), and update_push_data_with_attribute().

01697 {
01698     Octstr *current_time;
01699     struct tm now;
01700 
01701     now = gw_gmtime(time(NULL));
01702     current_time = octstr_format("%04d-%02d-%02dT%02d:%02d:%02dZ", 
01703                                  now.tm_year + 1900, now.tm_mon + 1, 
01704                                  now.tm_mday, now.tm_hour, now.tm_min, 
01705                                  now.tm_sec);
01706 
01707     return current_time;
01708 }

Here is the call graph for this function:

int store_push_data PPGPushMachine **  pm,
PPGSessionMachine sm,
WAPEvent e,
WAPAddrTuple tuple,
int  cless
[static]
 

Definition at line 2273 of file wap_push_ppg.c.

References debug(), find_ppg_push_machine_using_pi_push_id(),