Difference between revisions of "VoIP: OpenSIPS route ke arah Asterisk"
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
	
Onnowpurbo (talk | contribs)  (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 *)...)  | 
				Onnowpurbo (talk | contribs)   | 
				||
| Line 3: | Line 3: | ||
Contoh hook ke Asterisk  | 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  | |
| − | + | ||
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