diff --git a/etc/opensips_test.cfg b/etc/opensips_test.cfg deleted file mode 100644 index 12507d4b405..00000000000 --- a/etc/opensips_test.cfg +++ /dev/null @@ -1,313 +0,0 @@ -# -# $Id$ -# -# OpenSIPS residential configuration script -# by OpenSIPS Solutions -# -# This script was generated via "make menuconfig", from -# the "Residential" scenario. -# You can enable / disable more features / functionalities by -# re-generating the scenario with different options.# -# -# Please refer to the Core CookBook at: -# http://www.opensips.org/Resources/DocsCookbooks -# for a explanation of possible statements, functions and parameters. -# - - -####### Global Parameters ######### -log_level=3 -log_stderror=no -log_facility=LOG_LOCAL0 - -#fork=yes -children=4 - -/* uncomment the following lines to enable debugging */ -#open_files_limit=100000 -log_level=6 -#fork=yes -log_stderror=yes - -/* uncomment the next line to enable the auto temporary blacklisting of - not available destinations (default disabled) */ -#disable_dns_blacklist=no - -/* uncomment the next line to enable IPv6 lookup after IPv4 dns - lookup failures (default disabled) */ -#dns_try_ipv6=yes - -/* comment the next line to enable the auto discovery of local aliases - based on revers DNS on IPs */ -auto_aliases=no - - -#listen=udp:192.168.2.16:5060 # CUSTOMIZE ME -listen=udp:127.0.0.1:5060 # CUSTOMIZE ME -listen=tcp:127.0.0.1:5060 # CUSTOMIZE ME - - - -####### Modules Section ######## - -#set module path -mpath="./modules/" - -#### SIGNALING module -loadmodule "signaling.so" - -#### StateLess module -loadmodule "sl.so" - -#### Transaction Module -loadmodule "tm.so" -modparam("tm", "fr_timeout", 5) -modparam("tm", "fr_inv_timeout", 30) -modparam("tm", "restart_fr_on_each_reply", 0) -modparam("tm", "onreply_avp_mode", 1) - -#### Record Route Module -loadmodule "rr.so" -/* do not append from tag to the RR (no need for this script) */ -modparam("rr", "append_fromtag", 0) - -#### MAX ForWarD module -loadmodule "maxfwd.so" - -#### SIP MSG OPerationS module -loadmodule "sipmsgops.so" - -#### FIFO Management Interface -loadmodule "mi_fifo.so" -modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo") -modparam("mi_fifo", "fifo_mode", 0666) - - -#### URI module -loadmodule "uri.so" -modparam("uri", "use_uri_table", 0) - -#### USeR LOCation module -loadmodule "db_text.so" -loadmodule "usrloc.so" -modparam("usrloc", "nat_bflag", "NAT") -modparam("usrloc", "db_mode", 2) -modparam("usrloc", "db_url", "text:///home/bogdan/work/opensips/sip_server/opensips_head/scripts/dbtext/opensips") - -#### REGISTRAR module -loadmodule "registrar.so" - -/* uncomment the next line not to allow more than 10 contacts per AOR */ -#modparam("registrar", "max_contacts", 10) - -#### ACCounting module -loadmodule "acc.so" -/* what special events should be accounted ? */ -modparam("acc", "early_media", 0) -modparam("acc", "report_cancels", 0) -/* by default we do not adjust the direct of the sequential requests. - if you enable this parameter, be sure the enable "append_fromtag" - in "rr" module */ -modparam("acc", "detect_direction", 0) -modparam("acc", "failed_transaction_flag", "ACC_FAILED") -/* account triggers (flags) */ -modparam("acc", "log_flag", "ACC_DO") -modparam("acc", "log_missed_flag", "ACC_MISSED") - - -#### UDP protocol -loadmodule "proto_tcp.so" -loadmodule "proto_udp.so" - -loadmodule "cfgutils.so" -#loadmodule "httpd.so" -#loadmodule "mi_xmlrpc_ng.so" -loadmodule "db_mysql.so" -#loadmodule "dialplan.so" -#modparam("dialplan","db_url","mysql://opensips:opensipsrw@localhost/opensips") -loadmodule "alias_db.so" -modparam("alias_db","db_url","mysql://opensips:opensipsrw@localhost/opensips") - -####### Routing Logic ######## - -# main request routing logic - -route[after_sleep] -{ - xlog("-----after---\n"); -} - -route{ - - if (!mf_process_maxfwd_header("10")) { - sl_send_reply("483","Too Many Hops"); - exit; - } - - if (has_totag()) { - # sequential requests within a dialog should - # take the path determined by record-routing - if (loose_route()) { - - if (is_method("BYE")) { - setflag(ACC_DO); # do accounting ... - setflag(ACC_FAILED); # ... even if the transaction fails - } else if (is_method("INVITE")) { - # even if in most of the cases is useless, do RR for - # re-INVITEs alos, as some buggy clients do change route set - # during the dialog. - record_route(); - } - - if (is_method("BYE") ) { - setsflag(1); - t_reply("200","OK"); - resetsflag(1); - async( sleep("10") , after_sleep ); - exit; - } - # route it out to whatever destination was set by loose_route() - # in $du (destination URI). - route(relay); - } else { - - if ( is_method("ACK") ) { - if ( t_check_trans() ) { - # non loose-route, but stateful ACK; must be an ACK after - # a 487 or e.g. 404 from upstream server - t_relay(); - exit; - } else { - # ACK without matching transaction -> - # ignore and discard - exit; - } - } - sl_send_reply("404","Not here"); - } - exit; - } - - # CANCEL processing - if (is_method("CANCEL")) - { - if (t_check_trans()) - t_relay(); - exit; - } - - t_check_trans(); - - #if ( !(is_method("REGISTER") ) ) { - # if (from_uri==myself) - # { - # } else { - # # if caller is not local, then called number must be local - # if (!uri==myself) { - # send_reply("403","Rely forbidden"); - # exit; - # } - # } - #} - - # preloaded route checking - if (loose_route()) { - xlog("L_ERR", - "Attempt to route with preloaded Route's [$fu/$tu/$ru/$ci]"); - if (!is_method("ACK")) - sl_send_reply("403","Preload Route denied"); - exit; - } - - # record routing - if (!is_method("REGISTER|MESSAGE")) - record_route(); - - # account only INVITEs - if (is_method("INVITE")) { - - setflag(ACC_DO); # do accounting - } - - if (!uri==myself) { - append_hf("P-hint: outbound\r\n"); - route(relay); - } - - # requests for my domain - if (is_method("PUBLISH|SUBSCRIBE")) - { - sl_send_reply("503", "Service Unavailable"); - exit; - } - - if (is_method("REGISTER")) - { - if (!save("location")) - sl_reply_error(); - - exit; - } - - if ($rU==NULL) { - # request with no Username in RURI - sl_send_reply("484","Address Incomplete"); - exit; - } - - # do lookup with method filtering - if (!lookup("location","m")) { - t_newtran(); - t_reply("404", "Not Found"); - exit; - } - - # when routing via usrloc, log the missed calls also - setflag(ACC_MISSED); - route(relay); -} - - -route[relay] { - # for INVITEs enable some additional helper routes - if (is_method("INVITE")) { - t_on_branch("per_branch_ops"); - t_on_reply("handle_nat"); - t_on_failure("missed_call"); - } - - if (!t_relay()) { - send_reply("500","Internal Error"); - }; - exit; -} - - - -branch_route[per_branch_ops] { - xlog("new branch at $ru\n"); -} - - -onreply_route[handle_nat] { - - xlog("incoming reply\n"); -} - - -failure_route[missed_call] { - if (t_was_cancelled()) { - exit; - } - - # uncomment the following lines if you want to block client - # redirect based on 3xx replies. - ##if (t_check_status("3[0-9][0-9]")) { - ##t_reply("404","Not found"); - ## exit; - ##} - -} - - - diff --git a/modules/drouting/dr_cb.c b/modules/drouting/dr_cb.c deleted file mode 100644 index 9eb2b5604a2..00000000000 --- a/modules/drouting/dr_cb.c +++ /dev/null @@ -1,162 +0,0 @@ -/** - * - * drouting module callbacks - * - * Copyright (C) 2014-2106 OpenSIPS Solutions - * - * This file is part of opensips, a free SIP server. - * - * opensips is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version - * - * opensips is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * History - * ------- - * 2014-09-13 initial version (Mihai Tiganus) - * 2016-02-18 ported to 2.2 (bogdan) - */ - - -#include -#include "../../dprint.h" -#include "../../mem/shm_mem.h" -#include "../../mem/mem.h" -#include "dr_cb.h" - - -#define POINTER_CLOSED_MARKER ((void *)(-1)) - -unsigned char sort_algs[N_MAX_SORT_CBS] = {0,'O','W','Q'}; - -/* the array with all the cb lists (per type) */ -static struct dr_callback *dr_cbs[DRCB_MAX]; - -/* an array of sorting cbs registered by different modules */ -static struct dr_callback *dr_sort_cbs[N_MAX_SORT_CBS]; - - - -static void destroy_dr_callbacks_list(struct dr_callback *cb) -{ - struct dr_callback *cb_t; - - while(cb) { - cb_t = cb; - cb = cb->next; - if(cb_t->callback_param_free && cb_t->param) { - cb_t->callback_param_free(cb_t->param); - cb_t->param = NULL; - } - shm_free(cb_t); - } -} - - -void destroy_dr_cbs(void) -{ - int i; - struct dr_callback *dr_sort_cb_it; - - for( i=0 ; icallback_param_free && dr_sort_cb_it->param) { - dr_sort_cb_it->callback_param_free(dr_sort_cb_it->param); - dr_sort_cb_it->param = NULL; - } - } -} - - -/* TODO: param will be the index in the array */ -int register_dr_cb(enum drcb_types type, drouting_cb f, void *param, - param_free_cb ff) -{ - long int cb_sort_index = 0; - struct dr_callback *cb; - - cb = (struct dr_callback*)shm_malloc(sizeof(struct dr_callback)); - if (cb == 0) { - LM_ERR("no more shm memory\n"); - return -1; - } - - cb->callback = f; - cb->callback_param_free = ff; - cb->next = NULL; - - if (type!=DRCB_SORT_DST) { - cb->param = param; /* because now param holds the type of the - * sorting function */ - /* insert callback to the right list (based on type) */ - if( dr_cbs[type]==POINTER_CLOSED_MARKER) { - LM_CRIT("DRCB_SORT_DST registered after shut down!\n"); - goto error; - } - cb->next = dr_cbs[type]; - dr_cbs[type] = cb; - } else { - cb->param = NULL; - if(param == NULL) { - LM_ERR("no index supplied for sort callback registered at dr\n"); - goto error; - } - cb_sort_index = (long int)param; - if(cb_sort_index > N_MAX_SORT_CBS) { - LM_ERR("Sort cbs array not large enough to accomodate cb at dr\n"); - goto error; - } - if(dr_sort_cbs[cb_sort_index] != NULL) { - LM_WARN("[dr] sort callback at index '%ld' will be overwritten\n", - cb_sort_index); - } - dr_sort_cbs[cb_sort_index] = cb; - } - - return 0; -error: - shm_free(cb); - return -1; -} - - -/* runs a callback from an array - sort_cb_type will represent - * the index within the array */ -int run_dr_sort_cbs(sort_cb_type type, void *param) -{ - if(dr_sort_cbs[type] == NULL) { - LM_WARN("callback type '%d' not registered\n", type); - return -1; - } - dr_sort_cbs[type]->callback(param); - return 0; -} - - -int run_dr_cbs(enum drcb_types type, void *param) -{ - struct dr_callback *it; - - it = dr_cbs[type]; - while(it) { - it->callback(param); - it = it->next; - } - return 0; -} - diff --git a/modules/drouting/dr_cb.h b/modules/drouting/dr_cb.h deleted file mode 100644 index 963186a14ab..00000000000 --- a/modules/drouting/dr_cb.h +++ /dev/null @@ -1,94 +0,0 @@ -/** - * - * drouting module callbacks header - * - * Copyright (C) 2014-2106 OpenSIPS Foundation - * - * This file is part of opensips, a free SIP server. - * - * opensips is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version - * - * opensips is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * History - * ------- - * 2014-09-24 initial version (Mihai Tiganus) - * 2016-02-18 ported to 2.2 (bogdan) - */ - - -#ifndef _DR_CB_H_ -#define _DR_CB_H_ - -/* callback types used on top of DRouting */ -enum drcb_types { - DRCB_REG_CREATE_PARTS_LIST /* create a partitions list */, - /* params: */ - DRCB_REG_INIT_RULE, - DRCB_REG_GW, - DRCB_REG_CR, - DRCB_REG_ADD_RULE, - DRCB_REG_MARK_AS_RULE_LIST, - DRCB_REG_LINK_LISTS, - DRCB_REG_FREE_LIST, - DRCB_ACC_CALL, - DRCB_SORT_DST, - DRCB_SET_PROFILE, - DRCB_MAX /*keep this at the end*/ -}; - -/* callback function prototype */ -typedef void (drouting_cb) (void *param); -/* function to free callback param */ -typedef void(param_free_cb) (void *param); - -/* register callback function protoype */ -typedef int (*register_drcb_f)(enum drcb_types, drouting_cb f, void *param, - param_free_cb ff); -typedef int (*register_drcb_to_array_f)(enum drcb_types, drouting_cb f, - void *param, param_free_cb ff); - -struct dr_callback { - drouting_cb* callback; - void *param; - param_free_cb* callback_param_free; - struct dr_callback * next; -}; - - -/* sorting related data */ - -/* if new callbacks are added you must increase the N_MAX_SORT_CBS - * constant accordingly, add the letter which will be provided in the db - * to the sort_algs array, add the corresponding sorting algorithm id to the - * enum an register the callback to the dr_sort_cbs in the appropriate position*/ - -/* The maximum number of sorting functions provided by dr */ -#define N_MAX_SORT_CBS 4 - -typedef enum { NO_SORT = 1, WEIGHT_BASED_SORT = 2, QR_BASED_SORT = 3} - sort_cb_type; - -/* used for mapping the db information (sort_alg = a letter) to an index - * in the sort_cb_type enum */ -extern unsigned char sort_algs[N_MAX_SORT_CBS]; - - -int register_dr_cb(enum drcb_types type, drouting_cb f, void *param, - param_free_cb ff); -int run_dr_cbs(enum drcb_types type, void *params); -int run_dr_sort_cbs( sort_cb_type type, void *params); -void destroy_dr_cbs(void); - -#endif - diff --git a/modules/drouting/dr_cb_sorting.h b/modules/drouting/dr_cb_sorting.h deleted file mode 100644 index f733083bc44..00000000000 --- a/modules/drouting/dr_cb_sorting.h +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * drouting module sorting callbacks header - * - * Copyright (C) 2014-2016 OpenSIPS Solutions - * - * This file is part of opensips, a free SIP server. - * - * opensips is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version - * - * opensips is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Sui * 2016-02-18 ported to 2.2 (bogdan) -te 330, Boston, MA 02111-1307 USA - * - * History - * ------- - * 2014-10-10 initial version (Mihai Tiganus) - * 2016-02-18 ported to 2.2 (bogdan) -*/ - -#ifndef _DR_SORTING_CBS_H_ -#define _DR_SORTING_CBS_H_ - -#include "prefix_tree.h" - -/* if new callbacks are added you must increase the N_MAX_SORT_CBS - * constant accordingly, add the letter which will be provided in the db - * to the sort_algs array, add the corresponding sorting algorithm id to the - * enum an register the callback to the dr_sort_cbs in the appropriate position*/ - -/* The maximum number of sorting functions provided by dr */ -#define N_MAX_SORT_CBS 4 - -typedef enum { NO_SORT = 1, WEIGHT_BASED_SORT = 2, QR_BASED_SORT = 3} - sort_cb_type; - - -/* used for mapping the db information (sort_alg = a letter) to an index - * in the sort_cb_type enum */ -extern unsigned char sort_algs[N_MAX_SORT_CBS]; - -/* parameters needed for the registration of a gw */ -struct dr_reg_param { - void *rule; - int n_dst; /* the index of the destination within the rule */ - void *cr_or_gw; -}; - -struct dr_reg_init_rule_params { - void *rule; /* created at qr, set to dr */ - int n_dst; /* the number of destination for the new rule; - sent by dr */ - int r_id; /* the rule id: sent by dr */ -}; - -struct dr_acc_call_params { - void *rule; /* qr_handler/rule */ - int cr_id; /* destination id */ - int gw_id; /* in the case the destination is a carrier */ - struct sip_msg *msg; -}; - -struct dr_sort_params { - rt_info_t *dr_rule; /* dr_rule which contains the dst to be sorted */ - unsigned short dst_id; /* the size of pgwl */ - unsigned short *sorted_dst; /* returns an array with the - * indexes of the sorted dest */ - int rc; /* return code for the funciton */ -}; - -struct dr_set_profile_params { - void *qr_rule; /* qr_rule_t * to which the profile will be added. - * provided by dr */ - unsigned int profile; /* profile id, sent by dr to qr */ -}; - -struct dr_add_rule_params { - int part_index; /* partition index */ - str part_name; - void *qr_rule; /* rule to be added to list */ - void *qr_parts; /* the partitions list to which the rule will be added */ -}; - -struct dr_link_rule_list_params { - void **first_list; /* list to be appended to */ - void *second_list; /* list to be appended */ -}; - -struct dr_mark_as_main_list_params{ - void *qr_parts_new_list; /* list to become qr rules list */ - void **qr_parts_old_list; /* old list: to be freed */ -}; - -struct dr_free_qr_list_params { - void *old_list; -}; - -struct dr_create_partition_list_params { - void **part_list; /* the list of partitions created at QR returned for DR*/ - int n_parts; /* the number of partitions:provided by dr */ -}; - -#endif - -