Published on iptel.org (http://www.iptel.org)

How Can I Write Custom Text To The MySQL acc Table sip_status Column?

By lakmal
Created 2006-11-06 13:02

A good way to find out how your subscribers are using your VoIP platform is to examine call detail records that are stored in the MySQL acc table (assuming you have MySQL accounting enabled).

The sip_status column will show you the transaction status of each individual SIP message. Under normal circumstances an INVITE will have a 200 status which represents the "200 OK" that SER received.

This is fine for basic needs, but what happens if you have the same response code for different conditions in your ser.cfg file? For example, if you control access to 900 numbers, 911, international dialing, etc and all conditions return a "403 Forbidden" message when the caller is not allowed to access a particular destination, there would be extra work in determining what the actual failure condition was.

You can simplify this a bit by writing a custom response code to the sip_status column. This is done with the acc_db_request() function.

An example follows where we have permanently disabled access to E911 and 900 telephone numbers:

 route {
        # sanity checks
	if (uri=~"^sip:911@") {
		acc_db_request("403 - 911 Disabled", "acc");
		break;	};
	if (uri=~"^sip:9(00|76)0-9 [1]{7}@") {
		acc_db_request("403 - 900/976 Disabled", "acc");
        	break;
	};
        # normal processing
 }

The acc table sip_status column will now contain the text "403 - 911 Disabled" for any attempt to call 911 and "403 - 900/976 Disable" for any call to a 900 or 976 number.


Source URL:
http://www.iptel.org/write_custom_text_to_mysql_acc_table
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login