Difference between revisions of "VoIP: OpenSIPS route ke arah Asterisk"

From OnnoWiki
Jump to navigation Jump to search
(New page: Sumber: http://www.opensips.org/Documentation/Tutorials-OpenSIPSAsteriskIntegration-1-8 Contoh hook ke Asterisk # ASTERISK HOOK - BEGIN # media service number? (digits starting with *)...)
 
Line 3: Line 3:
 
Contoh hook ke Asterisk
 
Contoh hook ke Asterisk
  
−
# ASTERISK HOOK - BEGIN
+
# ASTERISK HOOK - BEGIN
−
# media service number? (digits starting with *)
+
# media service number? (digits starting with *)
−
if ($rU=~"^\*[1-9]+") {
+
if ($rU=~"^\*[1-9]+") {
−
# we do provide access to media services only to our
+
# we do provide access to media services only to our
−
# subscribers, who were previously authenticated  
+
# subscribers, who were previously authenticated  
−
if (!is_from_local()) {
+
if (!is_from_local()) {
−
send_reply("403","Forbidden access to media service");
+
send_reply("403","Forbidden access to media service");
−
exit;
+
exit;
−
}
+
}
−
#identify the services and translate to Asterisk extensions
+
#identify the services and translate to Asterisk extensions
−
if ($rU=="*1111") {
+
if ($rU=="*1111") {
−
# access to own voicemail IVR
+
# access to own voicemail IVR
−
$ru = "sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT";
+
$ru = "sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT";
−
} else
+
} else
−
if ($rU=="*2111") {
+
if ($rU=="*2111") {
−
# access to the "say time" announcement  
+
# access to the "say time" announcement  
−
$ru = "sip:AN_time@ASTERISK_IP:ASTERISK_PORT";
+
$ru = "sip:AN_time@ASTERISK_IP:ASTERISK_PORT";
−
} else
+
} else
−
if ($rU=="*2112") {
+
if ($rU=="*2112") {
−
# access to the "say date" announcement  
+
# access to the "say date" announcement  
−
$ru = "sip:AN_date@ASTERISK_IP:ASTERISK_PORT";
+
$ru = "sip:AN_date@ASTERISK_IP:ASTERISK_PORT";
−
} else
+
} else
−
if ($rU=="*2113") {
+
if ($rU=="*2113") {
−
# access to the "echo" service
+
# access to the "echo" service
−
$ru = "sip:AN_echo@ASTERISK_IP:ASTERISK_PORT";
+
$ru = "sip:AN_echo@ASTERISK_IP:ASTERISK_PORT";
−
} else
+
} else
−
if ($rU=~"\*3[0-9]{3}") {
+
if ($rU=~"\*3[0-9]{3}") {
−
# access to the conference service  
+
# access to the conference service  
−
# remove the "*3" prefix and place the "CR_" prefix
+
# remove the "*3" prefix and place the "CR_" prefix
−
strip(2);
+
strip(2);
−
prefix("CR_");
+
prefix("CR_");
−
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
+
rewritehostport("ASTERISK_IP:ASTERISK_PORT");
−
} else {
+
} else {
−
# unknown service
+
# unknown service
−
$ru = "sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT";
+
$ru = "sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT";
−
}
+
}
−
# after setting the proper RURI (to point to corresponding ASTERISK extension),
+
# after setting the proper RURI (to point to corresponding ASTERISK extension),
−
# simply forward the call
+
# simply forward the call
−
t_relay();
+
t_relay();
−
exit;
+
exit;
−
}
+
}
−
# ASTERISK HOOK - END
+
# ASTERISK HOOK - END
−
 
+
  
  

Revision as of 08:50, 20 January 2014

Sumber: http://www.opensips.org/Documentation/Tutorials-OpenSIPSAsteriskIntegration-1-8

Contoh hook ke Asterisk

	# ASTERISK HOOK - BEGIN
	# media service number? (digits starting with *)
	if ($rU=~"^\*[1-9]+") {
		# we do provide access to media services only to our
		# subscribers, who were previously authenticated 
		if (!is_from_local()) {
			send_reply("403","Forbidden access to media service");
			exit;
		}
		#identify the services and translate to Asterisk extensions
		if ($rU=="*1111") {
			# access to own voicemail IVR
			$ru = "sip:VM_pickup@ASTERISK_IP:ASTERISK_PORT";
		} else
		if ($rU=="*2111") {
			# access to the "say time" announcement 
			$ru = "sip:AN_time@ASTERISK_IP:ASTERISK_PORT";
		} else
		if ($rU=="*2112") {
			# access to the "say date" announcement 
			$ru = "sip:AN_date@ASTERISK_IP:ASTERISK_PORT";
		} else
		if ($rU=="*2113") {
			# access to the "echo" service
			$ru = "sip:AN_echo@ASTERISK_IP:ASTERISK_PORT";
		} else
		if ($rU=~"\*3[0-9]{3}") {
			# access to the conference service 
			# remove the "*3" prefix and place the "CR_" prefix
			strip(2);
			prefix("CR_");
			rewritehostport("ASTERISK_IP:ASTERISK_PORT");
		} else {
			# unknown service
			$ru = "sip:AN_notavailable@ASTERISK_IP:ASTERISK_PORT";
		}
		# after setting the proper RURI (to point to corresponding ASTERISK extension),
		# simply forward the call
		t_relay();
		exit;
	}
	# ASTERISK HOOK - END


Referensi