Browse Source

Added SIP_TRACE_ROLE

drop_requests
Sergey Safarov 8 years ago
committed by lazedo
parent
commit
a3b21912c2
4 changed files with 114 additions and 14 deletions
  1. +25
    -14
      kamailio/default.cfg
  2. +19
    -0
      kamailio/defs.cfg
  3. +10
    -0
      kamailio/local.cfg
  4. +60
    -0
      kamailio/sip_trace-role.cfg

+ 25
- 14
kamailio/default.cfg View File

@ -8,7 +8,8 @@ flags
FLAG_ASSOCIATE_USER: 4, FLAG_ASSOCIATE_USER: 4,
FLAG_TRUSTED_SOURCE: 5, FLAG_TRUSTED_SOURCE: 5,
FLAG_SESSION_PROGRESS: 6, FLAG_SESSION_PROGRESS: 6,
FLAG_IS_REPLY: 7;
FLAG_IS_REPLY: 7,
FLAG_SIP_TRACE: 8;
####### Global Parameters ######### ####### Global Parameters #########
fork = yes fork = yes
@ -273,6 +274,9 @@ include_file "responder-role.cfg"
#!ifdef NODES_ROLE #!ifdef NODES_ROLE
include_file "nodes-role.cfg" include_file "nodes-role.cfg"
#!endif #!endif
#!ifdef SIP_TRACE_ROLE
include_file "sip_trace-role.cfg"
#!endif
####### Permissions module ########## ####### Permissions module ##########
@ -349,19 +353,19 @@ route
route(PUSHER_ROUTE); route(PUSHER_ROUTE);
#!endif #!endif
#!ifdef RESPONDER_ROLE
if (isflagset(FLAG_INTERNALLY_SOURCED)) { if (isflagset(FLAG_INTERNALLY_SOURCED)) {
#!ifdef RESPONDER_ROLE
route(HANDLE_RESPOND); route(HANDLE_RESPOND);
#!endif
route(INTERNAL_TO_EXTERNAL_RELAY);
exit();
} }
#!endif
#!ifdef DISPATCHER_ROLE #!ifdef DISPATCHER_ROLE
route(DISPATCHER_FIND_ROUTES);
if (!isflagset(FLAG_INTERNALLY_SOURCED)) {
route(DISPATCHER_FIND_ROUTES);
}
#!endif #!endif
route(EXTERNAL_TO_INTERNAL_RELAY);
route(RELAY);
} }
route[CHECK_RETRANS] route[CHECK_RETRANS]
@ -490,11 +494,11 @@ route[HANDLE_MESSAGE]
lookup("location"); lookup("location");
xlog("L_INFO", "$ci|log|routing to $ruid\n"); xlog("L_INFO", "$ci|log|routing to $ruid\n");
} }
route(INTERNAL_TO_EXTERNAL_RELAY);
#!ifdef TRAFFIC_FILTER_ROLE #!ifdef TRAFFIC_FILTER_ROLE
} else if (!isflagset(FLAG_TRUSTED_SOURCE) } else if (!isflagset(FLAG_TRUSTED_SOURCE)
&& $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") { && $rd =~ "[0-9]{1,3}\.[0-9]{1,3}.[0-9]{1,3}\.[0-9]{1,3}") {
xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain\n"); xlog("L_WARN", "$ci|end|dropping MESSAGE request with IP domain\n");
exit();
#!endif #!endif
} else { } else {
xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))\n"); xlog("L_WARN", "$ci|end|MESSAGE $(hdr(Content-Type))\n");
@ -506,19 +510,17 @@ route[HANDLE_MESSAGE]
sl_send_reply("202", "Accepted"); sl_send_reply("202", "Accepted");
} else { } else {
route(DISPATCHER_FIND_ROUTES); route(DISPATCHER_FIND_ROUTES);
route(EXTERNAL_TO_INTERNAL_RELAY);
} }
} }
exit();
route(RELAY);
} }
#!else #!else
if (is_method("MESSAGE")) { if (is_method("MESSAGE")) {
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
route(INTERNAL_TO_EXTERNAL_RELAY);
} else {
if (!isflagset(FLAG_INTERNALLY_SOURCED)) {
sl_send_reply("202", "delivered to /dev/null"); sl_send_reply("202", "delivered to /dev/null");
exit(); exit();
} }
route(RELAY);
} }
#!endif #!endif
} }
@ -621,8 +623,16 @@ route[PREPARE_INITIAL_REQUESTS]
route[RELAY] route[RELAY]
{ {
#!ifdef SIP_TRACE_ROLE
route(SEND_SIP_TRACE);
#!endif
if (isflagset(FLAG_INTERNALLY_SOURCED)) { if (isflagset(FLAG_INTERNALLY_SOURCED)) {
route(INTERNAL_TO_EXTERNAL_RELAY); route(INTERNAL_TO_EXTERNAL_RELAY);
#!ifdef MESSAGE_ROLE
} else if (is_method("MESSAGE") && src_ip == myself) {
route(INTERNAL_TO_EXTERNAL_RELAY);
#!endif
} else { } else {
route(EXTERNAL_TO_INTERNAL_RELAY); route(EXTERNAL_TO_INTERNAL_RELAY);
} }
@ -697,9 +707,10 @@ route[EXTERNAL_TO_INTERNAL_RELAY]
#!endif #!endif
remove_hf_re("^X-.*"); remove_hf_re("^X-.*");
append_hf("X-AUTH-IP: $si\r\n"); append_hf("X-AUTH-IP: $si\r\n");
append_hf("X-AUTH-PORT: $sp\r\n"); append_hf("X-AUTH-PORT: $sp\r\n");
#!ifdef REGISTRAR_ROLE #!ifdef REGISTRAR_ROLE
route(ADD_AUTHORIZATION_HEADERS); route(ADD_AUTHORIZATION_HEADERS);
#!endif #!endif


+ 19
- 0
kamailio/defs.cfg View File

@ -99,4 +99,23 @@
#!define KZ_PRESENCE_REQUEST_PROBE 1 #!define KZ_PRESENCE_REQUEST_PROBE 1
#!endif #!endif
#################################
## Defs related to SIP_TRACE_ROLE
##
#!ifdef SIP_TRACE_ROLE
#!trydef KZ_TRACE 0
#!trydef KZ_TRACE_INTERNAL 1
#!trydef KZ_TRACE_EXTERNAL 1
#!trydef KZ_TRACE_INTERNAL_INCOMING 1
#!trydef KZ_TRACE_INTERNAL_OUTGOING 1
#!trydef KZ_TRACE_EXTERNAL_INCOMING 1
#!trydef KZ_TRACE_EXTERNAL_OUTGOING 1
#!ifndef SIP_TRACE_URI
#!substdef "!SIP_TRACE_URI!sip:127.0.0.1:9060!g"
#!endif
#!ifndef HEP_CAPTURE_ID
#!substdef "!HEP_CAPTURE_ID!1!g"
#!endif
#!endif
# vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab # vim: tabstop=4 softtabstop=4 shiftwidth=4 expandtab

+ 10
- 0
kamailio/local.cfg View File

@ -22,6 +22,7 @@
# # #!trydef PUSHER_ROLE # # #!trydef PUSHER_ROLE
# # #!trydef REGISTRAR_SYNC_ROLE # # #!trydef REGISTRAR_SYNC_ROLE
# # #!trydef PRESENCE_NOTIFY_SYNC_ROLE # # #!trydef PRESENCE_NOTIFY_SYNC_ROLE
# # #!trydef SIP_TRACE_ROLE
################################################################################ ################################################################################
## SERVER INFORMATION ## SERVER INFORMATION
@ -82,6 +83,15 @@
## destination. This reduces performance. ## destination. This reduces performance.
mhomed=0 mhomed=0
################################################################################
## SIP traffic mirroring to SIP_TRACE server
################################################################################
## This parameter is OPTIONAL.
## If you have installed SIP_TRACE server (Homer as example),
## then you can mirror INVITE and MESSAGE here
# # #!substdef "!SIP_TRACE_URI!sip:127.0.0.1:9060!g"
# # #!substdef "!HEP_CAPTURE_ID!1!g"
## YOU SHOULD NOT HAVE TO CHANGE THESE! ## YOU SHOULD NOT HAVE TO CHANGE THESE!
## By setting MY_IP_ADDRESS above these will resolve ## By setting MY_IP_ADDRESS above these will resolve
## to the proper bindings. These are here ## to the proper bindings. These are here


+ 60
- 0
kamailio/sip_trace-role.cfg View File

@ -0,0 +1,60 @@
##############################################################
## Kamailio siptrace settings configration examples at runtime
## kamcmd siptrace.status on
## kamcmd cfg.seti kazoo trace_external 0
## kamcmd cfg.seti kazoo trace_internal 0
kazoo.trace_external = KZ_TRACE_INTERNAL descr "activates tracing from external sources"
kazoo.trace_internal = KZ_TRACE_EXTERNAL descr "activates tracing from internal sources"
kazoo.trace_internal_incoming = KZ_TRACE_INTERNAL_INCOMING descr "traces the original request as received from internal sources"
kazoo.trace_internal_outgoing = KZ_TRACE_INTERNAL_OUTGOING descr "traces the outgoing request to external sources after possible modification"
kazoo.trace_external_incoming = KZ_TRACE_EXTERNAL_INCOMING descr "traces the original request as received from external sources"
kazoo.trace_external_outgoing = KZ_TRACE_EXTERNAL_OUTGOING descr "traces the outgoing request to internal sources after possible modification"
####### Siptrace module ##########
loadmodule "siptrace.so"
modparam("siptrace", "duplicate_uri", "SIP_TRACE_URI")
modparam("siptrace", "hep_mode_on", 1)
modparam("siptrace", "hep_version", 3)
modparam("siptrace", "hep_capture_id", HEP_CAPTURE_ID)
modparam("siptrace", "trace_to_database", 0)
## `trace_flag` value must be equal to FLAG_SIP_TRACE value at head of "default.cfg" file
modparam("siptrace", "trace_flag", 8)
modparam("siptrace", "trace_on", KZ_TRACE)
route[SIP_TRACE_INTERNAL]
{
if(@cfg_get.kazoo.trace_internal == 0) {
return;
}
if(@cfg_get.kazoo.trace_internal_incoming == 1) {
sip_trace();
}
if(@cfg_get.kazoo.trace_internal_outgoing == 1) {
setflag(FLAG_SIP_TRACE);
}
}
route[SIP_TRACE_EXTERNAL]
{
if(@cfg_get.kazoo.trace_external == 0) {
return;
}
if(@cfg_get.kazoo.trace_external_incoming == 1) {
sip_trace();
}
if(@cfg_get.kazoo.trace_external_outgoing == 1) {
setflag(FLAG_SIP_TRACE);
}
}
route[SEND_SIP_TRACE]
{
if (isflagset(FLAG_INTERNALLY_SOURCED)) {
route(SIP_TRACE_INTERNAL);
} else {
route(SIP_TRACE_EXTERNAL);
}
}

Loading…
Cancel
Save