SMPPOutboundRoutes *smpp_outbound_routes_create() { SMPPOutboundRoutes *smpp_outbound_routes = gw_malloc(sizeof(SMPPOutboundRoutes)); smpp_outbound_routes->system_id = NULL; smpp_outbound_routes->routes = NULL; smpp_outbound_routes->lock = gw_rwlock_create(); return smpp_outbound_routes; }
void smpp_route_init(SMPPServer *smpp_server) { SMPPRouting *smpp_routing = gw_malloc(sizeof(SMPPRouting)); smpp_server->routing = smpp_routing; smpp_routing->lock = gw_rwlock_create(); smpp_routing->inbound_routes = NULL; smpp_routing->outbound_routes = NULL; smpp_routing->reload = NULL; smpp_routing->route_message = NULL; smpp_routing->outbound_lock = gw_rwlock_create(); smpp_routing->initialized = 0; CfgGroup *grp = cfg_get_single_group(smpp_server->running_configuration, octstr_imm("smpp-routing")); long tmp; if(!grp) { warning(0, "No 'smpp-routing' group specified, using defaults (database)"); tmp = SMPP_ROUTING_DEFAULT_METHOD; } else { if(cfg_get_integer(&tmp, grp, octstr_imm("routing-method")) == -1) { tmp = SMPP_ROUTING_DEFAULT_METHOD; } } if(tmp == SMPP_ROUTING_METHOD_DATABASE) { info(0, "Initializing database based routing"); smpp_routing->reload = smpp_route_rebuild_database; smpp_routing->route_message = smpp_route_message_database; smpp_routing->shutdown = smpp_route_shutdown_database; } else if(tmp == SMPP_ROUTING_METHOD_HTTP) { smpp_routing->init = smpp_http_client_route_init; } smpp_route_init_method(smpp_server); smpp_route_rebuild(smpp_server); smpp_http_server_add_command(smpp_server, octstr_imm("rebuild-routes"), smpp_route_rebuild_command); }
Load* load_create_real(int heuristic) { struct load *load; load = gw_malloc(sizeof(*load)); load->len = 0; load->entries = NULL; load->heuristic = heuristic; load->lock = gw_rwlock_create(); return load; }
int smsbox_start(Cfg *cfg) { CfgGroup *grp; if (smsbox_running) return -1; debug("bb", 0, "starting smsbox connection module"); grp = cfg_get_single_group(cfg, octstr_imm("core")); if (cfg_get_integer(&smsbox_port, grp, octstr_imm("smsbox-port")) == -1) { error(0, "Missing smsbox-port variable, cannot start smsboxes"); return -1; } #ifdef HAVE_LIBSSL cfg_get_bool(&smsbox_port_ssl, grp, octstr_imm("smsbox-port-ssl")); #endif /* HAVE_LIBSSL */ if (smsbox_port_ssl) debug("bb", 0, "smsbox connection module is SSL-enabled"); if (cfg_get_integer(&smsbox_max_pending, grp, octstr_imm("smsbox-max-pending")) == -1) { smsbox_max_pending = SMSBOX_MAX_PENDING; info(0, "BOXC: 'smsbox-max-pending' not set, using default (%ld).", smsbox_max_pending); } smsbox_list = gwlist_create(); /* have a list of connections */ smsbox_list_rwlock = gw_rwlock_create(); if (!boxid) boxid = counter_create(); /* the smsbox routing specific inits */ smsbox_by_id = dict_create(10, NULL); /* and a hash directory of identified */ smsbox_by_smsc = dict_create(30, (void(*)(void *)) octstr_destroy); smsbox_by_receiver = dict_create(50, (void(*)(void *)) octstr_destroy); smsbox_by_smsc_receiver = dict_create(50, (void(*)(void *)) octstr_destroy); /* load the defined smsbox routing rules */ init_smsbox_routes(cfg); gwlist_add_producer(outgoing_sms); gwlist_add_producer(smsbox_list); smsbox_running = 1; if ((sms_dequeue_thread = gwthread_create(sms_to_smsboxes, NULL)) == -1) panic(0, "Failed to start a new thread for smsbox routing"); if (gwthread_create(smsboxc_run, &smsbox_port) == -1) panic(0, "Failed to start a new thread for smsbox connections"); return 0; }