Hi Bogdan, below the piece of code that handle a serial forking call to more than one contact. The idea is to search on a DB a list of contact to add associated with a sip uri. For example when I call sip:[email protected] I add 3 contacts:
[email protected] [email protected] [email protected] I call the append_branch() function followed by a lookup function (to resolve the real IP address. If all the contacts have the same IP address, all goes fine, otherwise the call after the first one goes wrong because the outbound proxy isn't set. I'm using the opensips version 1.5.1. Loadmodule "registrar.so" modparam("registrar", "use_path", 1) modparam("registrar", "path_mode", 0) modparam("registrar", "path_use_received", 1) avp_db_query("SELECT count(*) FROM hunt_group WHERE username = '$oU' and domain='$od'","$avp(s:hg_row_count)"); if($avp(s:hg_row_count)!=0) { avp_db_query("SELECT id,domain FROM hunt_group WHERE username = '$oU' and domain='$od'","$avp(s:hg_id);$avp(s:hg_domain)"); xlog("L_INFO","Id <$avp(s:hg_id)>, domain<$avp(s:hg_domain)>\n"); route(11); avp_db_query("SELECT count(*) FROM hunt_group_detail WHERE hg_id = $avp(s:hg_id)","$avp(s:hgd_row_count)"); if($avp(s:hgd_row_count)!=0) { avp_db_query("SELECT s.username,h.q_value FROM subscriber s,hunt_group_detail h WHERE s.id=h.uuid AND hg_id = $avp(s:hg_id) ORDER BY h.q_value ASC","$avp(s:hgd_username);$avp(s:qvalue)"); $var(i)=0; $var(append_branch)=0; xlog("L_INFO","CHECK Number of hunt group users <$avp(s:hgd_row_count)>\n"); while ($var(i) < $avp(s:hgd_row_count)) { $var(sip_address) = "sip:" + $(avp(s:hgd_username)[$var(i)]) + "@" + $avp(s:hg_domain); $avp(s:q_value) = "0." + $(avp(s:qvalue)[$var(i)]); xlog("L_INFO","Try to add <$var(sip_address)> URI with qvalue <$avp(s:q_value)>\n"); if (registered("location","$var(sip_address)")) { if ($var(append_branch)!=0) { append_branch(); } $var(append_branch) = 1; $ru = $var(sip_address); xlog("L_INFO","Adding <$var(sip_address)> URI with qvalue <$avp(s:q_value)>\n"); lookup("location"); } $var(i) = $var(i) + 1; } xlog("L_INFO","CHECK serialize_branches\n"); serialize_branches(1); setflag(10); } t_on_failure(3); t_relay(); exit; } failure_route[3] { if (t_was_cancelled()) { exit(); } if (isflagset(10)) { if (t_check_status("4[0-9][0-9]|5[0-9][0-9]|6[0-9][0-9]")) { if (next_branches()) { t_on_failure(3); t_relay(); } else { xlog("L_INFO", "Service Unavailable - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n"); route(11); $avp(s:status_code)="503"; acc_db_request("Service Unavailable", "acc"); } } } } Regards, MD -----Messaggio originale----- Da: Bogdan-Andrei Iancu [mailto:[email protected]] Inviato: sabato 16 maggio 2009 09:15 A: Mauro Davi' Cc: [email protected] Oggetto: Re: [OpenSIPS-Devel] next_branch function, NAT and PATH (RFC 3327) Hi Mauro, The serialize_branches() and next_branch() should push the path and received field in the next serial branches - could you post the relevant part of the script where you do use these 2 functions (also what version on opensips are you using) ? Regards, Bogdan Mauro Davi' wrote: > > Hi All, > > I'm using a SIP Server connected to a SIP Proxy (load balancer) > > When a client behind NAT is connected to the SIP flatform all works > fine, except one issue: > > If I call an AOR via parallel fork all goes fine... > > But if I use a serial forking, when I call the next_branch function to > handle a serial forking the INVITE from the server isn't sent to the > SIP Proxy (the outbound proxy defined in the PATH HF of the REGISTER). > > It seems that also the received parameter isn't used... The INVITE go > direct to the private IP of the client behind NAT... > > It is a mistake in my opensips configuration or it is a real BUG... > > Could anyone give me a suggestion? > > Thanks in advance > > MD > > ------------------------------------------------------------------------ > > _______________________________________________ > Devel mailing list > [email protected] > http://lists.opensips.org/cgi-bin/mailman/listinfo/devel > _______________________________________________ Users mailing list [email protected] http://lists.opensips.org/cgi-bin/mailman/listinfo/users
