[Serusers] Change URI before accounting ?

Kristian Larsson kristian at netatonce.se
Mon Mar 19 17:48:34 CET 2007


I have something along the lines of the following,
provided with a few comments for easier
understanding. Enjoy! :)


modparam("acc", "multi_leg_enabled", 1) 	#Enable multileg support
modparam("acc", "src_leg_avp_id", 110)		# Set the avp to save the src leg in $avp(i:110)
modparam("acc", "dst_leg_avp_id", 111)		# Set the avp to save the dst leg in $avp(i:111)

# Under my INVITE handler I have:
        #
	# Set the AVP for ACC source leg, this is
	# static.
	#
	avp_printf("$avp(i:110)","$fU");


	# If the URI begins with "blabla", we
	# account it by prepending shit and then
	# the number as before. When we dial our
	# PSTN trunk or whatever it is were
	# dialing we strip a digit first.
	#
	if(uri=~"sip:blabla@) {
		avp_printf("$avp(i:111)", "shit$fU");
		strip(1);
	} else {
		# In all other cases we just
		# account the URI as it is and
		# pass it along.
		#
		avp_printf("$avp(i:111)", "$fU");
	}

	route(1); # Send it to our normal relay route



Perhaps not the best example but you should get
the hang of it.

In your acc table you should get a post where
src_leg and dst_leg is set to the appropriate
values. Note that sip_to and all that will still
be what you're used to, it's only src/dst_leg that
changes.

Regards,
   Kristian.


On Mon, Mar 19, 2007 at 05:31:02PM +0100, inge wrote:
> Hi Kristian,
> 
> It's interresting if you can choose the column/source.
> 
> Can you tell me more about this by illustrating for example with somes
> lines from ser.cfg ?
> 
> Thanks
> 
> Le samedi 17 mars 2007 à 17:59 +0100, Kristian Larsson a écrit :
> > I haven't read all of these thread, accidentally
> > deleted half of it. Anyway, I am doing something
> > like this. I account one URI and use another. This
> > is done by settin src and dst legs in the acc
> > module. Just have a look at the acc module
> > documentation.
> > 
> >    Kristian.
> > 
> > On Fri, Mar 16, 2007 at 02:40:23PM +0100, inge wrote:
> > > Okay, it's more clear.
> > > 
> > > Thanks for your help. I decide to modify my billing program finally. ;)
> > > 
> > > Le jeudi 15 mars 2007 à 09:52 -0500, sip a écrit :
> > > > As far as I can tell: 
> > > > 
> > > > sip_from == full sip_from header (including tags, etc)
> > > > sip_to == full sip_to header (including tags, etc)
> > > > sip_status == SIP return code (i.e. 200, 487, etc)
> > > > sip_method == SIP method (INVITE, ACK, BYE, etc)
> > > > i_uri == inbound RURI (sip:1234567 at yourserver.com)
> > > > o_uri == outbound RURI (sip:55347 at yourserver.com)
> > > > from_uri == SIP from URI (doesn't include tags, comments, etc)
> > > > to_uri == SIP to URI (doesn't include tags, comments, etc)
> > > > sip_callid == SIP id tag (unique identifier) 
> > > > username == SER username
> > > > domain == SER domain
> > > > fromtag == JUST the tag portion of the From header
> > > > totag == JUST the tag portion of the To header
> > > > time == Date/Time
> > > > timestamp == timestamp
> > > > caller_deleted == not used?
> > > > callee_deleted == not used?
> > > > 
> > > > 
> > > > N.
> > > > 
> > > > 
> > > > 
> > > > On Thu, 15 Mar 2007 14:56:39 +0100, inge wrote
> > > > > Thanks for your support.
> > > > > 
> > > > > I think it's more easier to modify my billing application if it's not
> > > > > feasable to modify the sip_to.
> > > > > 
> > > > > Where can I read more information about o_uri etc... ? I'm not very
> > > > > fluent with the other field.
> > > > > 
> > > > > Le jeudi 15 mars 2007 à 07:11 -0500, sip a écrit :
> > > > > > I don't think there's a way to change what gets logged into the sip_to field
> > > > > > without actually altering the acc module's source code and recompiling. Sip_to
> > > > > > and RURI are different for a reason (and are stored in different places).
> > > > > > You'll find, if you forward to other machines, the sip_to can stay the same
> > > > > > across multiple forwards -- even if the ruri may change. 
> > > > > > 
> > > > > > I use the OpenSER 0.9.5 version of the acc module with out SER 0.9.6 code, as
> > > > > > it allows me to log extra parameters. In such a case, you could conceivably
> > > > > > log the field you wanted in an extra header and ONLY use it. 
> > > > > > 
> > > > > > However, it's probably easiest just to rewrite your billing code to handle
> > > > > > using the o_uri instead of the sip_to header if you want to ensure you have
> > > > > > the final, reformatted uri. 
> > > > > > 
> > > > > > N. 
> > > > > > 
> > > > > > 
> > > > > > On Thu, 15 Mar 2007 12:47:18 +0100, inge wrote
> > > > > > > Hi,
> > > > > > > 
> > > > > > > This is an ACC entry :
> > > > > > > 
> > > > > > > "\"0172292965\"
> > > > > > > 
> > > > > > >
> > > > > >
> > > > <sip:0172292965 at 192.168.0.2>;tag=e8381df069c5011eo1";"<sip:*92#0146446439 at 192.168.0.2>;tag=D9B57FE4-2621";"200";"BYE";"sip:0146446439 at 192.168.0.10:5060";"sip:0146446439 at 192.168.0.10:5060";"sip:0172292965 at 192.168.0.2";"sip:*92#0146446439 at 192.168.0.2";"a5fd93d8-7eb7c456 at 192.168.0.9";"0172292965";"192.168.0.2";"e8381df069c5011eo1";"D9B57FE4-2621";"2007-03-14
> > > > > > 16:00:15";"2007-03-14 17:00:15";"0";"0" "\"0172292965\"
> > > > > > >
> > > > > >
> > > > <sip:0172292965 at 192.168.0.2>;tag=e8381df069c5011eo1";"<sip:*92#0146446439 at 192.168.0.2>;tag=D9B57FE4-2621";"200";"INVITE";"sip:*92#0146446439 at 192.168.0.2";"sip:0146446439 at 192.168.0.10";"sip:0172292965 at 192.168.0.2";"sip:*92#0146446439 at 192.168.0.2";"a5fd93d8-7eb7c456 at 192.168.0.9";"0172292965";"192.168.0.2";"e8381df069c5011eo1";"D9B57FE4-2621";"2007-03-14
> > > > > > 16:00:10";"2007-03-14 17:00:10";"0";"0" "\"0172292965\"
> > > > > > >
> > > > > >
> > > > <sip:0172292965 at 192.168.0.2>;tag=e8381df069c5011eo1";"<sip:*92#0146446439 at 192.168.0.2>;tag=D9B57FE4-2621";"200";"ACK";"sip:0146446439 at 192.168.0.10:5060";"sip:0146446439 at 192.168.0.10:5060";"sip:0172292965 at 192.168.0.2";"sip:*92#0146446439 at 192.168.0.2";"a5fd93d8-7eb7c456 at 192.168.0.9";"0172292965";"192.168.0.2";"e8381df069c5011eo1";"D9B57FE4-2621";"2007-03-14
> > > > > > 16:00:10";"2007-03-14 17:00:10";"0";"0"
> > > > > > > 
> > > > > > > This is a complete INVITE/ACK/BYE. Indeed, in o_uri I've got the good
> > > > > > > URI. But is it possible to have the same in sip_to ? I use it for
> > > > > > > billing.
> > > > > > > 
> > > > > > > Thanks for your answer
> > > > > > > 
> > > > > > > Le jeudi 15 mars 2007 à 06:14 -0500, sip a écrit :
> > > > > > > > Can you show an example log entry? Your rewritten URI SHOULD be in the
> > > > o-ori
> > > > > > > > column. 
> > > > > > > > 
> > > > > > > > N. 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > 
> > > > > > > > On Thu, 15 Mar 2007 11:48:57 +0100, inge wrote
> > > > > > > > > No one have an idea ?
> > > > > > > > > 
> > > > > > > > > Le mercredi 14 mars 2007 à 16:19 +0100, inge a écrit :
> > > > > > > > > > Hi all,
> > > > > > > > > > 
> > > > > > > > > > When I modify an URI by stripping some words, in ACC table I've
> > > > got the
> > > > > > > > > > old URI, before the stripping.
> > > > > > > > > > 
> > > > > > > > > > So if INVITE contains sip:7000123456789, after strip he contains
> > > > > > > > > > sip:0123456789, in acc I've INVITE ACK and BYE with sip:7000123456789.
> > > > > > > > > > 
> > > > > > > > > > How can I solve it ?
> > > > > > > > > > 
> > > > > > > > > > Thanks for your help.
> > > > > > > > > > 
> > > > > > > > > > Regards,
> > > > > > > > > > 
> > > > > > > > > > Adrien
> > > > > > > > > > 
> > > > > > > > > > _______________________________________________
> > > > > > > > > > Serusers mailing list
> > > > > > > > > > Serusers at lists.iptel.org
> > > > > > > > > > http://lists.iptel.org/mailman/listinfo/serusers
> > > > > > > > > 
> > > > > > > > > _______________________________________________
> > > > > > > > > Serusers mailing list
> > > > > > > > > Serusers at lists.iptel.org
> > > > > > > > > http://lists.iptel.org/mailman/listinfo/serusers
> > > > > > > >
> > > > > >
> > > > > 
> > > > > _______________________________________________
> > > > > Serusers mailing list
> > > > > Serusers at lists.iptel.org
> > > > > http://lists.iptel.org/mailman/listinfo/serusers
> > > > 
> > > 
> > > _______________________________________________
> > > Serusers mailing list
> > > Serusers at lists.iptel.org
> > > http://lists.iptel.org/mailman/listinfo/serusers
> > 
> 

-- 
Kristian Larsson                                         KLL-RIPE
Network Engineer & Peering Coordinator      Net At Once [AS35706]
email: kristian at netatonce.se                      irc: kll at ircnet
phone: +46 470 592717                        cell: +46 704 910401                       



More information about the sr-users mailing list