[Serusers] Huntgroups

Amozurrutia Jesus jamozurrutia at mcmtelecom.com.mx
Tue Dec 14 02:17:56 CET 2004


Hi,

This is my problem:
I'm trying to implement a "hunt group" using t_on_failure directive and an
external script. The script gets the current URI and return the next URI in
the group.
The problem is that after the second INVITE, SER adds some characters before
the INVITE message, and some devices don't understand this "XX INVITES".

Has anyone done something similar? or had a similar poblem?

I'm using:
OS: Redhat Linux 9
Kernel: 2.4.20-16.9
SER: ser 0.8.12 (i386/linux)

For testing I'm using a couple Cisco ATAs, according to the diagram:

            ______
 Line 1 ---/      \   |
           | ATA1 |---|    ____     _  _  _  _     ____     _  _  _
 Line 2 ---\______/   |   /    \   / \/ \/ \/ \   /    \   / \/ \/ \
            ______    |---| FW |---|  IP Net  |---| GW |---| PSTN  |
 Line 3 ---/      \   |   \____/   \_/\_/\_/\_/   \____/   \_/\_/\_/
           | ATA2 |---|             |        |                 |
 Line 4 ---\______/   |             |        |                 |
                                    |        |                 |
                                   ---      ---               ---
                                  /   \    /   \             / O \
                                  |NAT|    |SER|              /_\
                                  |-T |    |   |
                                  \___/    \___/             Phone

My config file is:

######################################################################
# SER Config File
######################################################################
######################################################################
# Global prams
######################################################################

/* Uncomment these lines to enter debugging mode
debug=7
fork=no
log_stderror=yes
*/

check_via=no    # (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
#port=5060
#children=4
fifo="/tmp/ser_fifo"

######################################################################
# Load Modules
######################################################################

loadmodule "/usr/lib/ser/modules/mysql.so"   	/*MySQL DB Module*/
loadmodule "/usr/lib/ser/modules/sl.so"      	/*Stateless routing*/
loadmodule "/usr/lib/ser/modules/tm.so"      	/*Statefull routing*/
loadmodule "/usr/lib/ser/modules/rr.so"      	/*Record Routing*/
loadmodule "/usr/lib/ser/modules/maxfwd.so"  	/*Max-fwd header logic*/
loadmodule "/usr/lib/ser/modules/usrloc.so"  	/*User Location*/
loadmodule "/usr/lib/ser/modules/registrar.so"	/*SIP Register functions*/
loadmodule "/usr/lib/ser/modules/exec.so"    	/*Execute external
commands*/
loadmodule "/usr/lib/ser/modules/auth.so"    	/*User authentication*/
loadmodule "/usr/lib/ser/modules/auth_db.so" 	/*User auth. using MySQL
DB*/
loadmodule "/usr/lib/ser/modules/group.so"  	/*Group commands*/

######################################################################
# Module Params
######################################################################

# -- usrloc params --
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "db_url", "sql://user:pass@localhost/ser")
# -- auth params --
modparam("auth_db", "db_url", "sql://user:pass@localhost/ser")
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 0)
# -- group params --
modparam("group", "db_url", "sql://user:pass@localhost/ser")

######################################################################
# Server Aliases
######################################################################
alias="mcm.net.mx"
alias="X.X.81.94"

######################################################################
# Main Routing Logic
######################################################################

route{

	# Initial sanity checks 
	if (!mf_process_maxfwd_header("15")) {
		sl_send_reply("483","Too Many Hops");
		break;
	};
	if ( msg:len > max_len ) {
		sl_send_reply("513", "Message too big");
		break;
	};
	if (loose_route()) {
		setflag(2);
		t_relay();
		break;
	};
	record_route();

	# Registering routines
	if (method=="REGISTER") {
		if (!www_authorize("mcm.net.mx", "subscriber")) {
			www_challenge("mcm.net.mx", "0");
			log(1,"User Rejected, challenge sent.");
			break;
		};
		save("location");
		break;
	};

	# Check the source of call and auth. if required
	# If the call comes from the gateways, no authentication is
	# required (X.X.81.67 or X.X.84.67)
	if (src_ip==X.X.81.67 or src_ip==X.X.84.67) {
		# Check if the user accept calls
		log(1,"Call from pstn. \n");
	} else {
		if (method=="INVITE") {
			if (!proxy_authorize("mcm.net.mx", "subscriber")) {
				proxy_challenge("mcm.net.mx", "0");
				break;
			};
		}; # INVITE to authorized PSTN
	}

	# Routing plan
	if (uri=~"^sip:5559853[0-9][0-9][0-9]@.*") {
		if (!lookup("location")) {
			if (is_user_in("Request-URI", "hg")) {
				exec_dset("/usr/scripts/huntgroup2 $SIP_ORUI
1 ");
				if (uri=~"^sip:[0-9]+ at .*") {
					append_branch();
					# Set fealiure route for Hunt Groups
					t_on_failure("1");
					t_relay();
				};
			} else {
				setflag(3);
				sl_send_reply("404", "Not Found");
				break;
			};
		} else {
			if ( is_user_in("Request-URI", "hg") ) {
				# Set fealiure route for Hunt Groups
				t_on_failure("1");
			};
			# Try to send call to dest.
			if (!t_relay()) {
				sl_reply_error();
			};
		};
	# Forward numeric uri's to PSTN gateways
	} else if (uri=~"^sip:[0|1|2|3|5|8|9][0-9]*@.*") {
		rewritehost("X.X.81.67");
		t_relay();
	} else {
		sl_send_reply("403", "Call cannot be served here");
		break;
	};
}

# Hunt group routes
failure_route[1] {
	log(1,"First number bysy, try next.\n");
	# forwarding failed -- try again at another destination
	exec_dset("/usr/scripts/huntgroup2 $SIP_ORUI 1 ");
	append_branch();
	if (uri=~"^sip:[0-9]+ at .*") {
		# Set next faliure route
		t_on_failure("2");
	};
	t_relay();
}

failure_route[2] {
	log(1,"Next number busy, try next.\n");
	# forwarding failed -- try again at another destination
	exec_dset("/usr/scripts/huntgroup2 $SIP_ORUI 0 ");
	append_branch();
	if (uri=~"^sip:[0-9]+ at .*") {
		t_on_failure("2");
	};
	t_relay();
}
######################################################################
# End SER Config File
######################################################################

Next is a signaling diagram of a failed call. Lines 1 and 2 of the above
diagram were busy at the time of this trace.
The malformed INVITEs are shown as "XX INVITE".

 Gateway              SER                NAT-T               ATA1    ATA2
X.X.81.67          X.X.81.94           X.X.81.92            Y.Y.1.2 Y.Y.1.3
   |                   |                   |                   |       |
   |-- INVITE -------->|                   |                   |       |
   |<-- trying --------|                   |                   |       |
   |                   |-- INVITE -------->|                   |       |
   |                   |<-- Trying --------|                   |       |
   |                   |                   |-- INVITE -------->|       |
   |                   |                   |<-- Trying --------|       |
   |                   |                   |<-- Busy ----------|       |
   |                   |<-- Busy ----------|                   |       |
   |                   |-- ACK ----------->|                   |       |
   |                   |                   |-- ACK ----------->|       |
   |                   |-- INVITE -------->|                   |       |
   |                   |<-- Trying --------|                   |       |
   |                   |                   |-- INVITE -------->|       |
   |                   |                   |<-- Trying --------|       |
   |                   |                   |<-- Busy ----------|       |
   |                   |<-- Busy ----------|                   |       |
   |                   |-- ACK ----------->|                   |       |
   |                   |                   |-- ACK ----------->|       |
   |                   |-- XX INVITE ----->|                   |       |
   |                   |<-- Trying --------|                   |       |
   |                   |                   |-- XX INVITE ------------->|
   |                   |                   |-- XX INVITE ------------->|
   |                   |                   |-- XX INVITE ------------->|
   |                   |                   |-- XX INVITE ------------->|
   |                   |                   |-- XX INVITE ------------->|
   |                   |<-- Req. Timeout --|                   |       |
   |                   |                   |-- CANCEL ---------------->|
   |                   |-- ACK ----------->|                   |       |
   |                   |                   |-- ACK ------------------->|
   |                   |                   |<-- 481 CL/TDNE -----------|
   |                   |<-- 481 CL/TDNE ---|                   |       |
   |                   |-- XX INVITE ----->|                   |       |
   |                   |                   |-- XX INVITE ------------->|
   |                   |-- XX INVITE ----->|                   |       |
   |                   |                   |-- XX INVITE ------------->|
   |                   |                   |<-- Trying ----------------|
   |                   |<-- Trying --------|                   |       |
   |                   |                   |<-- Trying ----------------|
   |                   |<-- Trying --------|                   |       |
   |-- CANCEL -------->|                   |                   |       |
   |<-- cancelling ----|                   |                   |       |
   |<- Req. Candelled -|                   |                   |       |
   |-- ACK ----------->|                   |                   |       |
   |                   |-- CANCEL -------->|                   |       |
   |                   |                   |-- CANCEL ---------------->|
   |                   |-- CANCEL -------->|                   |       |
   |                   |                   |-- CANCEL ---------------->|
   |                   |                   |<-- 481 CL/TDNE -----------|
   |                   |<-- 481 CL/TDNE ---|                   |       |



Following I pasted the INVITE messages. Those were taken using ngrep.

The malformed INVITE looks like: (notice the extra spaces ath the begining)

#
U X.X.81.94:5060 -> X.X.81.92:5063 31525 at 0:1480




.`INVITE sip:5559853977*sip.mcm.net.mx=200.52.71.2+24225 at X.X.81.92:5063
SIP/2.0
Record-Route: <sip:5559853977 at X.X.81.94;ftag=5D03E50C-1912;lr>
Record-Route: <sip:5559853979 at X.X.81.94;ftag=5D03E50C-1912;lr>
Record-Route: <sip:5559853978 at X.X.81.94;ftag=5D03E50C-1912;lr>
Via: SIP/2.0/UDP X.X.81.94;branch=z9hG4bKf78b.baa0d9c3.0
Via: SIP/2.0/UDP X.X.81.94;branch=z9hG4bKf78b.aaa0d9c3.1
Via: SIP/2.0/UDP X.X.81.94;branch=z9hG4bKf78b.9aa0d9c3.1
Via: SIP/2.0/UDP  X.X.81.67:5060
From: <sip:5553500000 at X.X.81.67>;tag=5D03E50C-1912
To: <sip:5559853978 at X.X.81.94>
Date: Thu, 27 Apr 2000 11:34:27 GMT
Call-ID: 9F4D4C1D-1B6611D4-BFD5E894-B9E38BE3 at X.X.81.67
Supported: timer,100rel
Min-SE:  1800
Cisco-Guid: 2672603125-459674068-3218270356-3118697443
User-Agent: Cisco-SIPGateway/IOS-12.x
Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK,COMET, REFER, SUBSCRIBE,
NOTIFY, INFO
CSeq: 101 INVITE
Max-Forwards: 3
Remote-Party-ID:
<sip:5553500000 at X.X.81.67>;party=calling;screen=yes;privacy=off
Timestamp: 956835267
Contact: <sip:5553500000 at X.X.81.67:5060>
Expires: 180
Allow-Events: telephone-event
Content-Type: application/sdp
Content-Length: 324

v=0
o=CiscoSystemsSIP-GW-UserAgent 8289 4267 IN IP4 X.X.81.67
s=SIP Call
c=IN IP4 X.X.81.67
t=0 0
m=audio 18280 RTP/AVP 8 0 18 100 19
c=IN IP4 X.X.81.67
a=rtpmap:8 PCMA/8000
a=rtpmap:0PCMU/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=yes
a=rtpmap:100 X-N

While the first INVITE looks like:
#
U X.X.81.67:56763 -> X.X.81.94:5060

INVITE sip:5559853978 at X.X.81.94:5060 SIP/2.0
Via: SIP/2.0/UDP  X.X.81.67:5060
From: <sip:5553500000 at X.X.81.67>;tag=5D03A270-1598
To: <sip:5559853978 at X.X.81.94>
Date: Thu, 27 Apr 2000 11:34:10 GMT
Call-ID: 9523FA8C-1B6611D4-BFC2E894-B9E38BE3 at X.X.81.67
Supported: timer,100rel
Min-SE:  1800
Cisco-Guid: 2502123108-459674068-3217025172-3118697443
User-Agent: Cisco-SIPGateway/IOS-12.x
Allow: INVITE, OPTIONS, BYE, CANCEL, ACK, PRACK, COMET, REFER, SUBSCRIBE,
NOTIFY, INFO
CSeq: 101 INVITE
Max-Forwards: 6
Remote-Party-ID:
<sip:5553500000 at X.X.81.67>;party=calling;screen=yes;privacy=off
Timestamp: 956835250
Contact: <sip:5553500000 at X.X.81.67:5060>
Expires: 180
Allow-Events: telephone-event
Content-Type: application/sdp
Content-Length: 324

v=0
o=CiscoSystemsSIP-GW-UserAgent 8099 5647 IN IP4 X.X.81.67
s=SIP Call
c=IN IP4 X.X.81.67
t=0 0
m=audio 17162 RTP/AVP 8 0 18 100 19
c=IN IP4 X.X.81.67
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=yes
a=rtpmap:100 X-NSE/8000
a=fmtp:100 192-194
a=rtpmap:19 CN/8000

Jesus




More information about the sr-users mailing list