using kamailio version 5.4v
Please help me with a way to send replies/forwards to include VIA header with port, because i can see that its just sending IP but not the port in VIA header.
my kamailio cfg file for route & route relay looks like below.
route[RELAY] {
# enable additional event routes for forwarded requests
# - serial forking, RTP relaying handling, a.s.o.
if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
}
if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
}
if (is_method("INVITE")) {
if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
}
if (is_method("ACK|BYE")) {
$duri= $ruri;
t_relay();
exit;
}
if (!t_relay()) {
sl_reply_error();
}
exit;
}
# Per SIP request initial checks
route[REQINIT] {
#!ifdef WITH_ANTIFLOOD
# flood detection from same IP and traffic ban for a while
# be sure you exclude checking trusted peers, such as pstn gateways
# - local host excluded (e.g., loop to self)
if(src_ip!=myself) {
if($sht(ipban=>$si)!=$null) {
# ip is already blocked
xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
exit;
}
if (!pike_check_req()) {
xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");
$sht(ipban=>$si) = 1;
exit;
}
}
#!endif
if($ua =~ "friendly-scanner|sipcli|VaxSIPUserAgent") {
# silent drop for scanners - uncomment next line if want to reply
# sl_send_reply("200", "OK");
exit;
}
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}
if(is_method("OPTIONS") && uri==myself && $rU==$null) {
sl_send_reply("200","Keepalive");
exit;
}
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
if (is_method("INVITE")) {
send_reply("100", "Trying");
}
}
# Handle requests within SIP dialogs
route[WITHINDLG] {
if (!has_totag()) return;
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
} else if ( is_method("ACK") ) {
# ACK is forwarded statelessly
route(NATMANAGE);
} else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY);
exit;
}
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK|BYE") ) {
#xlog("started ACK if else condition line 622 \n");
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
route(RELAY);
exit;
} else {
route(RELAY);
# Added after observing ACK not being sent by CSCF
exit;
}
}
sl_send_reply("404","Not here");
exit;
}
# Caller NAT detection
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
if (nat_uac_test("19")) {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
if(is_first_hop()) {
set_contact_alias();
}
}
setflag(FLT_NATS);
}
#!endif
return;
}
# RTPProxy control and signaling updates for NAT traversal
route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
if(has_totag()) {
if(check_route_param("nat=yes")) {
setbflag(FLB_NATB);
}
}
}
if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB))) return;
if(nat_uac_test("8")) {
rtpproxy_manage("co");
} else {
rtpproxy_manage("cor");
}
if (is_request()) {
if (!has_totag()) {
if(t_is_branch_route()) {
add_rr_param(";nat=yes");
}
}
}
if (is_reply()) {
if(isbflagset(FLB_NATB)) {
if(is_first_hop())
set_contact_alias();
}
}
#!endif
return;
}
# URI update for dialog requests
route[DLGURI] {
#!ifdef WITH_NAT
if(!isdsturiset()) {
handle_ruri_alias();
}
#!endif
return;
}
# Routing to foreign domains
route[SIPOUT] {
if (uri==myself) return;
append_hf("P-hint: outbound\r\n");
route(RELAY);
exit;
}
# PSTN GW routing
route[PSTN] {
#!ifdef WITH_PSTN
$var(uri) = $sel(ruri);
xavp_params_explode("$(var(uri){s.unbracket})", "uri"); $var(cic) = $xavp(uri=>cic[0]);
if (($rU=~"^(\+)[0-9]{1,20}$")) {
if(mt_match("ace", "$rU","0")) {
insert_hf("Route: <sip:"+"$var(mtval)"+ ";lr\r\n");
route(SYLKSERVERPOST);
}
}
route(RELAY);
exit;
#!endif
return;
}
# Sylkserver routing
route[SYLKSERVERPOST] {
if(mt_match("ace", "$rU","0")) {
t_relay_to("udp:10.0.0.4", "0x01");
exit;
}
}
sample INVITE being forwarded
Session Initiation Protocol (SIP as raw text)
INVITE sip:[email protected] SIP/2.0\r\n
Record-Route: <sip:10.1.1.3;lr>\r\n
Route: <sip:10.1.1.4:5060;lr>\r\n
Via: SIP/2.0/UDP 10.1.1.3;branch=z9hG4bK4b7b.693512744570a1e2ea323648d7423180.0\r\n
From: <sip:[email protected]:5060>;tag=1\r\n
To: <sip:[email protected]:5060;user=phone>\r\n
Call-ID: [email protected]\r\n
Date: TUE, 13 DEC 2016 09:34:57 GMT\r\n
Supported: timer,resource-priority,replaces\r\n
Min-SE: 900\r\n
User-Agent: Cisco-CUCM10.5\r\n
Allow: INVITE, OPTIONS, INFO, BYE, CANCEL, ACK, PRACK, UPDATE, REFER, SUBSCRIBE, NOTIFY\r\n
CSeq: 101 INVITE\r\n
please help how to change below via header
Via: SIP/2.0/UDP 10.1.1.3;branch=z9hG4bK4b7b.693512744570a1e2ea323648d7423180.0
to
Via: SIP/2.0/UDP 10.1.1.3:5060;branch=z9hG4bK4b7b.693512744570a1e2ea323648d7423180.0
my kamailio server is already listing to IP:5060 port on UDP.
Please help thanks in advance.