[OpenSIPS-Users] Rewrite Username in URI when using userloc

Spencer Thomason spencer at 5ninesolutions.com
Fri May 20 01:02:06 CEST 2011


Hello all,
I'm using Opensips in between several Freeswitch and Asterisk boxes (each with multiple DIDs) and my ITSP's proxies.  The local IP PBXs register to Opensips and inbound routing is done via the userloc module.  The problem I have is that I need to send in incoming INVITE to the original username, not the registered contact so the PBXs can perform the proper routing.  Currently I set $rU=$Ou in the request route which works perfectly if there is only one contact registered.  If there is more than one contact registered, the INVITE is sent to the registered contact and then the PBX doesn't know how to route the call since it hits a default contact.  Is there a better way to do this?  I'm fairly new to Opensips and would appreciate any help. :-)

A snippet from my script:
route {
	...
	if (!lookup("location","m")) {
		switch ($retcode) {
			case -1:
			case -3:
				t_newtran();
				t_reply("404", "Not Found");
				exit;
			case -2:
				sl_send_reply("405", "Method Not Allowed");
				exit;
		}
	}

	$rU=$oU;
	route(1);
}


route[1] {
	if (is_method("INVITE")) {
		t_on_branch("2");
		t_on_reply("2");
		t_on_failure("1");
	}

	if (!t_relay()) {
		sl_reply_error();
	};
	exit;
}


branch_route[2] {
	xlog("new branch at $ru\n");
}


onreply_route[2] {
	xlog("incoming reply\n");
}


failure_route[1] {
	if (t_was_cancelled()) {
		exit;
	} 

	if (t_check_status("3[0-9][0-9]")) {
	t_reply("404","Not found");
		exit;
	}
}



Thanks,
Spencer





More information about the Users mailing list