81 #ifdef HAVE_WTLS_OPENSSL    82 #include <openssl/x509.h>   118 #ifdef HAVE_WTLS_OPENSSL   119 extern RSA* private_key;
   120 extern X509* x509_cert;
   121 extern void wtls_secmgr_init();
   141         panic(0, 
"No 'core' group in configuration.");
   144         panic(0, 
"No 'wapbox-port' in core group");
   159         panic(0, 
"No 'wapbox' group in configuration.");
   166     if (logfile != NULL) {
   168         info(0, 
"Starting to log to file %s level %ld", 
   182             debug(
"wap", 0, 
"syslog parameter is none");
   185             debug(
"wap", 0, 
"syslog parameter is %ld", level);
   190         debug(
"wap", 0, 
"no syslog parameter");
   213 #if (HAVE_WTLS_OPENSSL)   220                 debug(
"bbox", 0, 
"certificate file not set");
   225                 debug(
"bbox", 0, 
"certificate parameter is %s",
   230             panic(0, 
"No 'certificate-file' in wtls group");
   236                 debug(
"bbox", 0, 
"privatekey-file not set");
   241                 debug(
"bbox", 0, 
"certificate parameter is %s",
   248             panic(0, 
"No 'privatekey-file' in wtls group");
   288                 error(0, 
"SIGINT or SIGTERM received, let's die.");
   295             warning(0, 
"SIGHUP received, catching and re-opening logs");
   306             warning(0, 
"SIGQUIT received, reporting memory usage.");
   315     struct sigaction act;
   318     sigemptyset(&act.sa_mask);
   320     sigaction(SIGINT, &act, NULL);
   321     sigaction(SIGQUIT, &act, NULL);
   322     sigaction(SIGHUP, &act, NULL);
   323     sigaction(SIGPIPE, &act, NULL);
   335     tuple = dgram->
u.T_DUnitdata_Req.addr_tuple;
   336     msg->wdp_datagram.source_address =
   338     msg->wdp_datagram.source_port =
   339         dgram->
u.T_DUnitdata_Req.addr_tuple->local->port;
   340     msg->wdp_datagram.destination_address =
   342     msg->wdp_datagram.destination_port =
   343         dgram->
u.T_DUnitdata_Req.addr_tuple->remote->port;
   344     msg->wdp_datagram.user_data =
   389     tuple = dgram->
u.T_DUnitdata_Req.addr_tuple;
   394     msg->sms.time = time(NULL);
   395     if (dgram->
u.T_DUnitdata_Req.smsc_id != NULL)
   398         msg->sms.smsc_id = NULL;
   399     msg->sms.dlr_mask = dgram->
u.T_DUnitdata_Req.dlr_mask;
   400     if (dgram->
u.T_DUnitdata_Req.smsbox_id != NULL)
   403         msg->sms.boxc_id = NULL;
   404     if (dgram->
u.T_DUnitdata_Req.dlr_url != NULL)
   407         msg->sms.dlr_url = NULL;
   412     msg->sms.validity = time(NULL) + 1440;
   414     if (dgram->
u.T_DUnitdata_Req.service_name != NULL)
   439     static unsigned long msg_sequence = 0L;   
   442     sms_datagrams = NULL;
   445         error(0, 
"WDP: dispatch_datagram received empty datagram, ignoring.");
   447     else if (dgram->
type != T_DUnitdata_Req) {
   448         warning(0, 
"WDP: dispatch_datagram received event of unexpected type.");
   451     else if (dgram->
u.T_DUnitdata_Req.address_type == 
ADDR_IPV4) {
   452 #ifdef HAVE_WTLS_OPENSSL   466         debug(
"wap",0,
"WDP (wapbox): delivering %ld segments to bearerbox",
   486     if (reload && *o != *n) {
   487         info(0, 
"Reloading int '%s' from %ld to %ld", 
   495     if (reload && *o != *n) {
   496         info(0, 
"Reloading bool '%s' from %s to %s", 
   498              (*o ? 
"yes" : 
"no"), (*n ? 
"yes" : 
"no"));
   517     Octstr *http_interface_name;
   518     long http_proxy_port;
   519     int http_proxy_ssl = 0;
   520     List *http_proxy_exceptions;
   521     Octstr *http_proxy_username;
   522     Octstr *http_proxy_password;
   523     Octstr *http_proxy_exceptions_regex;
   524     int warn_map_url = 0;
   529         debug(
"config_reload", 0, 
"Reloading configuration");
   540         warning(0, 
"Couldn't %sload configuration from `%s'.", 
   548     http_proxy_port =  -1;
   556     http_proxy_exceptions_regex = 
cfg_get(grp, 
octstr_imm(
"http-proxy-exceptions-regex"));
   557     if (http_proxy_host != NULL && http_proxy_port > 0) {
   559                        http_proxy_exceptions, http_proxy_username, 
   560                        http_proxy_password, http_proxy_exceptions_regex);
   570         warning(0, 
"No 'wapbox' group in configuration.");
   582     if (http_interface_name != NULL) {
   599         warning(0, 
"'wml-strict' config directive has been set to no, "   600                    "this may make you vulnerable against XML bogus input.");
   631     debug(
"wap", 0, 
"map_url_max = %ld", map_url_max);
   633     for (i = 0; i <= map_url_max; i++) {
   643         warning(0, 
"'map-url' config directive and related are deprecated, "   644                    "please use wap-url-map group");
   650         Octstr *send_msisdn_header, *send_msisdn_format;
   663                         send_msisdn_format, accept_cookies);
   665         info(0, 
"Added wap-url-map <%s> with url <%s>, map-url <%s>, "   666                 "send-msisdn-query <%s>, send-msisdn-header <%s>, "   667                 "send-msisdn-format <%s>, accept-cookies <%s>", 
   687         info(0,
"Added wap-user-map <%s> with credentials <%s:%s> "   698 int main(
int argc, 
char **argv) 
   711     if (argv[cf_index] == NULL)
   724     info(0, 
"------------------------------------------------------------");
   725     info(0, GW_NAME 
" wapbox version %s starting up.", GW_VERSION);
   744 #if (HAVE_WTLS_OPENSSL)   769         info(0, GW_NAME 
"Could not start heartbeat.");
   779             error(0, 
"Bearerbox is gone, restarting");
   785         else if (
msg == NULL) 
   789         info(0, 
"Bearerbox told us to die");
   792         info(0, 
"Bearerbox told us to restart");
   800         switch (
msg->wdp_datagram.destination_port) {
   805                 msg->wdp_datagram.source_address,
   806                 msg->wdp_datagram.source_port,
   807                 msg->wdp_datagram.destination_address,
   808                 msg->wdp_datagram.destination_port);
   809             dgram->
u.T_DUnitdata_Ind.user_data = 
msg->wdp_datagram.user_data;
   810             msg->wdp_datagram.user_data = NULL;
   816 #if (HAVE_WTLS_OPENSSL)   823                 panic(0,
"Bad packet received! This shouldn't happen!");
   827         warning(0, 
"Received other message than wdp/admin, ignoring!");
   832     info(0, GW_NAME 
" wapbox terminating.");
 void wtp_initiator_init(wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *session_dispatch, long timer_freq)
 
static void dispatch_datagram(WAPEvent *dgram)
 
void error(int err, const char *fmt,...)
 
static void reload_int(int reload, Octstr *desc, long *o, long *n)
 
static Cfg * init_wapbox(Cfg *cfg)
 
void info(int err, const char *fmt,...)
 
void wsp_session_shutdown(void)
 
void wap_push_ota_dispatch_event(WAPEvent *e)
 
static void config_reload(int reload)
 
void wap_map_url_config_device_home(char *to)
 
gw_assert(wtls_machine->packet_to_send !=NULL)
 
void counter_destroy(Counter *counter)
 
static Msg * pack_ip_datagram(WAPEvent *dgram)
 
List * cfg_get_list(CfgGroup *grp, Octstr *varname)
 
static Octstr * pack_udhdata(WAPAddrTuple *tuple)
 
long gwlist_len(List *list)
 
int restart_box(char **argv)
 
void wtp_resp_shutdown(void)
 
int read_from_bearerbox(Msg **msg, double seconds)
 
void wtls_dispatch_event(WAPEvent *event)
 
static Octstr * bearerbox_host
 
#define cfg_get(grp, varname)
 
void wsp_push_client_init(wap_dispatch_func_t *dispatch_self, wap_dispatch_func_t *dispatch_wtp_resp)
 
int main(int argc, char **argv)
 
void wsp_push_client_dispatch_event(WAPEvent *e)
 
void get_cert_from_file(Octstr *s, X509 **x509)
 
int gwthread_shouldhandlesignal(int signal)
 
void radius_acct_init(CfgGroup *grp)
 
#define octstr_get_cstr(ostr)
 
List * sms_split(Msg *orig, Octstr *header, Octstr *footer, Octstr *nonlast_suffix, Octstr *split_chars, int catenate, unsigned long msg_sequence, int max_messages, int max_octets)
 
void wap_event_dump(WAPEvent *event)
 
static Msg * pack_sms_datagram(WAPEvent *dgram)
 
unsigned long counter_increase(Counter *counter)
 
#define BB_DEFAULT_WAPBOX_PORT
 
Cfg * cfg_create(Octstr *filename)
 
void wsp_unit_dispatch_event(WAPEvent *event)
 
void heartbeat_stop(long hb_thread)
 
void wap_map_add_user(Octstr *name, Octstr *user, Octstr *pass, Octstr *msisdn)
 
void wap_map_add_url(Octstr *name, Octstr *url, Octstr *map_url, Octstr *send_msisdn_query, Octstr *send_msisdn_header, Octstr *send_msisdn_format, int accept_cookies)
 
void wap_appl_shutdown(void)
 
static void reload_bool(int reload, Octstr *desc, int *o, int *n)
 
void get_privkey_from_file(Octstr *s, RSA **priv_key, Octstr *password)
 
static void signal_handler(int signum)
 
void wtls_init(wtls_dispatch_func_t *responder_dispatch)
 
Octstr * octstr_imm(const char *cstr)
 
void wap_push_ota_init(wap_dispatch_func_t *wsp_dispatch, wap_dispatch_func_t *wsp_unit_dispatch)
 
Counter * counter_create(void)
 
void cfg_destroy(Cfg *cfg)
 
void * gwlist_extract_first(List *list)
 
void wtls_dispatch_resp(WAPEvent *event)
 
void conn_config_ssl(CfgGroup *grp)
 
void connect_to_bearerbox(Octstr *host, int port, int ssl, Octstr *our_host)
 
void wap_map_url_config(char *s)
 
void log_set_log_level(enum output_level level)
 
#define octstr_duplicate(ostr)
 
List * cfg_get_multi_group(Cfg *cfg, Octstr *name)
 
void wap_map_user_destroy(void)
 
static Counter * sequence_counter
 
void wtp_initiator_shutdown(void)
 
void wap_push_ppg_init(wap_dispatch_func_t *ota_dispatch, wap_dispatch_func_t *appl_dispatch, Cfg *cfg)
 
void msg_destroy(Msg *msg)
 
static void setup_signal_handlers(void)
 
int octstr_case_compare(const Octstr *os1, const Octstr *os2)
 
#define wap_event_create(type)
 
void warning(int err, const char *fmt,...)
 
void log_set_syslog_facility(char *facility)
 
void alog_open(char *fname, int use_localtm, int use_markers)
 
Octstr * octstr_format(const char *fmt,...)
 
void octstr_destroy(Octstr *ostr)
 
void http_set_interface(const Octstr *our_host)
 
#define octstr_create(cstr)
 
void octstr_destroy_item(void *os)
 
void radius_acct_shutdown(void)
 
void wap_dispatch_datagram(WAPEvent *dgram)
 
void gwthread_sleep(double seconds)
 
static Octstr * config_filename
 
void log_set_syslog(const char *ident, int syslog_level)
 
#define SMS_PARAM_UNDEFINED
 
void wsp_unit_shutdown(void)
 
void close_connection_to_bearerbox(void)
 
void report_versions(const char *boxname)
 
int log_open(char *filename, int level, enum excl_state excl)
 
void wap_map_destroy(void)
 
static long bearerbox_port
 
void wtp_resp_dispatch_event(WAPEvent *event)
 
int cfg_get_bool(int *n, CfgGroup *grp, Octstr *varname)
 
#define DEFAULT_HEARTBEAT
 
void write_to_bearerbox(Msg *pmsg)
 
void wsp_session_dispatch_event(WAPEvent *event)
 
long heartbeat_start(hb_send_func_t *send_func, double freq, hb_load_func_t *load_func)
 
void http_use_proxy(Octstr *hostname, int port, int ssl, List *exceptions, Octstr *username, Octstr *password, Octstr *exceptions_regex)
 
void debug(const char *place, int err, const char *fmt,...)
 
long wap_appl_get_load(void)
 
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
 
void wsp_push_client_shutdown(void)
 
void wap_push_ppg_shutdown(void)
 
void wtp_resp_init(wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *session_dispatch, wap_dispatch_func_t *push_dispatch, long timer_freq)
 
void wsp_session_init(wap_dispatch_func_t *responder_dispatch, wap_dispatch_func_t *initiator_dispatch, wap_dispatch_func_t *application_dispatch, wap_dispatch_func_t *ota_dispatch)
 
WAPAddrTuple * wap_addr_tuple_create(Octstr *rmt_addr, long rmt_port, Octstr *lcl_addr, long lcl_port)
 
static int wml_xml_strict
 
long octstr_parse_long(long *nump, Octstr *ostr, long pos, int base)
 
void wap_push_ppg_dispatch_event(WAPEvent *e)
 
void octstr_format_append(Octstr *os, const char *fmt,...)
 
void gwlib_shutdown(void)
 
void wap_push_ota_shutdown(void)
 
void wap_appl_init(Cfg *cfg)
 
WAPEvent * wtls_unpack_wdp_datagram(Msg *msg)
 
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
 
void http_set_client_timeout(long timeout)
 
void wap_push_ota_bb_address_set(Octstr *in)
 
int get_and_set_debugs(int argc, char **argv, int(*find_own)(int index, int argc, char **argv))
 
static XMLRPCDocument * msg
 
void wtp_initiator_dispatch_event(WAPEvent *event)
 
void wml_init(int wml_xml_strict)
 
void wap_event_destroy(WAPEvent *event)
 
void wsp_unit_init(wap_dispatch_func_t *datagram_dispatch, wap_dispatch_func_t *application_dispatch)
 
void wap_appl_dispatch(WAPEvent *event)
 
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
 
void gwlist_destroy(List *list, gwlist_item_destructor_t *destructor)