[Users] more on accounting

tele tele at plexia.com
Thu Jul 13 09:15:22 CEST 2006


Hi tamas,

Contact me if you need more information.
What you can do depend on your billing system.

This is what i have done from OpenSER:

# avpops params
modparam("avpops","avp_url","mysql://openser:openserrw@localhost/openser")
modparam("avpops", "avp_table", "usr_preferences")


# avp for accounting
modparam("avpops","avp_aliases","setup_time=s:setup_time")
modparam("avpops","avp_aliases","connect_time=s:connect_time")
modparam("avpops","avp_aliases","disconnect_time=s:disconnect_time")
modparam("avpops","avp_aliases","remote_address=s:remote_address")
modparam("avpops","avp_aliases","valid_call=s:valid_call")


   if (!method=="REGISTER")
      record_route();

   # ACCOUNTING
   if (is_method("INVITE"))
   {
      avp_write("$Ts","$avp(setup_time)");
      avp_db_store("$ci","$avp(setup_time)");

      # invite come from PSTN this call should not be accounted
      if (src_ip=='PSTNGW')
      {
         avp_write("no","$avp(valid_call)");
         avp_db_store("$ci","$avp(valid_call)");
      } else {
         # valid call this must accounted
         avp_write("yes","$avp(valid_call)");
         avp_db_store("$ci","$avp(valid_call)");
      };

   } else if (is_method("ACK")) {
      avp_write("$Ts","$avp(connect_time)");
      avp_db_store("$ci","$avp(connect_time)");
   } else if (is_method("BYE")) {
      avp_write("$Ts","$avp(disconnect_time)");
      avp_db_store("$ci","$avp(disconnect_time)");

      avp_write("82.215.163.5","$avp(remote_address)");
      avp_db_store("$ci","$avp(remote_address)");

   };

   if (is_method("BYE"))
   {  
      avp_db_query("select value from usr_preferences where uuid='$ci'
and attribute='setup_time'","$avp(setup_time)");
      avp_db_query("select value from usr_preferences where uuid='$ci'
and attribute='connect_time'","$avp(connect_time)");
      avp_db_query("select value from usr_preferences where uuid='$ci'
and attribute='disconnect_time'","$avp(disconnect_time)");
      avp_db_query("select value from usr_preferences where uuid='$ci'
and attribute='valid_call'","$avp(valid_call)");

      avp_db_load("$ci","$avp(remote_address)");
      avp_print();

      # BYE from announcement server or valid call
      # not account this call
      if (!src_ip=='ANNSERVER' and
avp_check("$avp(valid_call)","eq/yes/g"))
      {
	 # send radius acct
         setflag(3);
         setflag(5);
      };

   };
   
   # clean avps from db
   if (is_method("BYE|CANCEL"))
   {
      avp_db_delete("$ci","$avp(setup_time)");
      avp_db_delete("$ci","$avp(connect_time)");
      avp_db_delete("$ci","$avp(disconnect_time)");
      avp_db_delete("$ci","$avp(remote_address)");
      avp_db_delete("$ci","$avp(valid_call)");
   };


On Wed, 2006-07-12 at 14:53 +0200, Cseke Tamas wrote:
> > modparam("acc", "radius_extra", "h323-setup-time=$avp(setup_time); 
> > h323-connect-time=$avp(connect_time); 
> > h323-disconnect-time=$avp(disconnect_time); 
> 
> Hello,
> 
> I need this time informations for radius accounting, and  i must decide  
> to  make this  avps in openser, or  manage this times  in radius server
> (in BSDRadius it's not so difficult...)
> 
> I quess it'is not so easy to make this avps in openser,
>     -create timestamp for particular messages (invite, ack, bye)
>     -store the avps in database
>     -and send to radius this attributes on accounting-request
> 
> Do you use this method, or is there any better solution?
> 
> Thanks any help,
> Tamas





More information about the Users mailing list