Skip to content

Commit

Permalink
Fix routing. closes #330 (#333)
Browse files Browse the repository at this point in the history
* Fix routing. Reject calls when origination gateway is disabled. closes #330
  • Loading branch information
dmitry-sinina authored Jul 7, 2018
1 parent a9a1340 commit e327b28
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 39 deletions.
2 changes: 1 addition & 1 deletion app/models/cdr/auth_log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# origination_proto_id :integer
# username :string
# realm :string
# request_method :string
# method :string
# ruri :string
# from_uri :string
# to_uri :string
Expand Down
28 changes: 19 additions & 9 deletions db/migrate/20180620093010_switch16_dtmf_filtering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ def down
drop schema switch16 cascade;
delete from class4.disconnect_code where id=8005;
}

end

def up
execute %q{
INSERT INTO class4.disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, success, successnozerolen,store_cdr,silently_drop) VALUES (8005,0,true,true,403,'Origination gateway is disabled',false,false,true,false);
create table class4.gateway_inband_dtmf_filtering_modes(
id smallint primary key,
name varchar not null unique
Expand Down Expand Up @@ -2211,28 +2215,28 @@ def up
i_profile.aleg_rtp_filter_inband_dtmf=false;
i_profile.false_rtp_filter_inband_dtmf=false;
i_profile.bleg_rtp_filter_inband_dtmf=false;
if i_customer_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
elsif i_customer_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_vendor_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.aleg_rtp_filter_inband_dtmf=false
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true
i_profile.aleg_rtp_filter_inband_dtmf=false;
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;
if i_vendor_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
elsif i_vendor_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_customer_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.bleg_rtp_filter_inband_dtmf=false
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true
i_profile.bleg_rtp_filter_inband_dtmf=false;
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;
i_profile.rtprelay_force_dtmf_relay=i_vendor_gw.force_dtmf_relay;
Expand Down Expand Up @@ -2524,6 +2528,12 @@ def up
SELECT into v_orig_gw * from class4.gateways WHERE id=v_customer_auth_normalized.gateway_id;
if not v_orig_gw.enabled then
v_ret.disconnect_code_id=8005; -- Origination gateway is disabled
RETURN NEXT v_ret;
RETURN;
end if;
v_ret.resources:='';
if v_c_acc.origination_capacity is not null then
v_ret.resources:=v_ret.resources||'1:'||v_c_acc.id::varchar||':'||v_c_acc.origination_capacity::varchar||':1;';
Expand Down
1 change: 1 addition & 0 deletions db/seeds/main/class4.sql
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_orig
INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, rewrited_code, rewrited_reason, success, successnozerolen, store_cdr, silently_drop) VALUES (8002, 0, true, true, 403, 'Source number blacklisted', NULL, NULL, false, false, true, false);
INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, rewrited_code, rewrited_reason, success, successnozerolen, store_cdr, silently_drop) VALUES (8003, 0, true, true, 503, 'No response from LNP DB', NULL, NULL, false, false, true, false);
INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, success, successnozerolen,store_cdr,silently_drop) VALUES (8004,0,true,true,403,'Rejected by Auth record',false,false,true,false);
INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, success, successnozerolen,store_cdr,silently_drop) VALUES (8005,0,true,true,403,'Origination gateway is disabled',false,false,true,false);

INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, rewrited_code, rewrited_reason, success, successnozerolen, store_cdr, silently_drop) VALUES (1505, 1, false, false, 487, 'Ringing timeout', NULL, NULL, false, false, true, false);
INSERT INTO disconnect_code (id, namespace_id, stop_hunting, pass_reason_to_originator, code, reason, rewrited_code, rewrited_reason, success, successnozerolen, store_cdr, silently_drop) VALUES (2001, 3, true, false, 503, 'Radius response timeout', NULL, NULL, false, false, true, false);
Expand Down
75 changes: 46 additions & 29 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21215,28 +21215,28 @@ BEGIN


i_profile.aleg_rtp_filter_inband_dtmf=false;
i_profile.false_rtp_filter_inband_dtmf=false;
i_profile.bleg_rtp_filter_inband_dtmf=false;

if i_customer_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
elsif i_customer_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_vendor_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.aleg_rtp_filter_inband_dtmf=false
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true
i_profile.aleg_rtp_filter_inband_dtmf=false;
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;


if i_vendor_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
elsif i_vendor_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_customer_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.bleg_rtp_filter_inband_dtmf=false
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true
i_profile.bleg_rtp_filter_inband_dtmf=false;
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;


i_profile.rtprelay_force_dtmf_relay=i_vendor_gw.force_dtmf_relay;
Expand Down Expand Up @@ -21625,28 +21625,28 @@ BEGIN


i_profile.aleg_rtp_filter_inband_dtmf=false;
i_profile.false_rtp_filter_inband_dtmf=false;
i_profile.bleg_rtp_filter_inband_dtmf=false;

if i_customer_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
elsif i_customer_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_vendor_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.aleg_rtp_filter_inband_dtmf=false
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true
i_profile.aleg_rtp_filter_inband_dtmf=false;
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;


if i_vendor_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
elsif i_vendor_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_customer_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.bleg_rtp_filter_inband_dtmf=false
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true
i_profile.bleg_rtp_filter_inband_dtmf=false;
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;


i_profile.rtprelay_force_dtmf_relay=i_vendor_gw.force_dtmf_relay;
Expand Down Expand Up @@ -22015,28 +22015,28 @@ BEGIN


i_profile.aleg_rtp_filter_inband_dtmf=false;
i_profile.false_rtp_filter_inband_dtmf=false;
i_profile.bleg_rtp_filter_inband_dtmf=false;

if i_customer_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
elsif i_customer_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_vendor_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.aleg_rtp_filter_inband_dtmf=false
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true
i_profile.aleg_rtp_filter_inband_dtmf=false;
elsif i_vendor_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.aleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;


if i_vendor_gw.rx_inband_dtmf_filtering_mode_id=3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
elsif i_vendor_gw.rx_inband_dtmf_filtering_mode_id=1 then -- inherit
if i_customer_gw.tx_inband_dtmf_filtering_mode_id in (1,2) then -- inherit or disable filtering
i_profile.bleg_rtp_filter_inband_dtmf=false
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true
i_profile.bleg_rtp_filter_inband_dtmf=false;
elsif i_customer_gw.tx_inband_dtmf_filtering_mode_id = 3 then -- enable filtering
i_profile.bleg_rtp_filter_inband_dtmf=true;
end if;
endif;
end if;


i_profile.rtprelay_force_dtmf_relay=i_vendor_gw.force_dtmf_relay;
Expand Down Expand Up @@ -22323,6 +22323,12 @@ CREATE FUNCTION switch16.route(i_node_id integer, i_pop_id integer, i_protocol_i


SELECT into v_orig_gw * from class4.gateways WHERE id=v_customer_auth_normalized.gateway_id;
if not v_orig_gw.enabled then
v_ret.disconnect_code_id=8005; -- Origination gateway is disabled
RETURN NEXT v_ret;
RETURN;
end if;

v_ret.resources:='';
if v_c_acc.origination_capacity is not null then
v_ret.resources:=v_ret.resources||'1:'||v_c_acc.id::varchar||':'||v_c_acc.origination_capacity::varchar||':1;';
Expand Down Expand Up @@ -23319,6 +23325,12 @@ CREATE FUNCTION switch16.route_debug(i_node_id integer, i_pop_id integer, i_prot


SELECT into v_orig_gw * from class4.gateways WHERE id=v_customer_auth_normalized.gateway_id;
if not v_orig_gw.enabled then
v_ret.disconnect_code_id=8005; -- Origination gateway is disabled
RETURN NEXT v_ret;
RETURN;
end if;

v_ret.resources:='';
if v_c_acc.origination_capacity is not null then
v_ret.resources:=v_ret.resources||'1:'||v_c_acc.id::varchar||':'||v_c_acc.origination_capacity::varchar||':1;';
Expand Down Expand Up @@ -24287,6 +24299,12 @@ CREATE FUNCTION switch16.route_release(i_node_id integer, i_pop_id integer, i_pr


SELECT into v_orig_gw * from class4.gateways WHERE id=v_customer_auth_normalized.gateway_id;
if not v_orig_gw.enabled then
v_ret.disconnect_code_id=8005; -- Origination gateway is disabled
RETURN NEXT v_ret;
RETURN;
end if;

v_ret.resources:='';
if v_c_acc.origination_capacity is not null then
v_ret.resources:=v_ret.resources||'1:'||v_c_acc.id::varchar||':'||v_c_acc.origination_capacity::varchar||':1;';
Expand Down Expand Up @@ -33237,8 +33255,7 @@ ALTER TABLE ONLY sys.sensors
-- PostgreSQL database dump complete
--

SET search_path TO gui, public, switch, billing, class4, runtime_stats, sys, logs, data_import
;
SET search_path TO gui, public, switch, billing, class4, runtime_stats, sys, logs, data_import;

INSERT INTO "public"."schema_migrations" (version) VALUES
('20170822151410'),
Expand Down

0 comments on commit e327b28

Please sign in to comment.