[Freeswitch-users] store sofia profile_name and hostname in sip_registrations

Leon de Rooij leon at scarlet-internet.nl
Tue Sep 23 09:14:33 PDT 2008


Hi all,

I'd like to keep track of on what switch and sofia profile_name a UA  
is registered. By default, FS automatically creates a table  
sip_registrations without these fields, so I started looking in  
mod_sofia to see whether the fields could be added, and to my  
surprise, I saw they should already be inserted (along with  
presence_hosts) !

sofia_reg.c in function sofia_reg_handle_register at line 774:

     sql = switch_mprintf("insert into sip_registrations "
                 
"(call_id 
,sip_user 
,sip_host 
,presence_hosts 
,contact 
,status 
,rpid 
,expires,user_agent,server_user,server_host,profile_name,hostname) "
                "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld,  
'%q', '%q', '%q', '%q', '%q')",
                call_id, to_user, reg_host, profile->presence_hosts ?  
profile->presence_hosts : reg_host,
                contact_str, reg_desc, rpid, (long)  
switch_timestamp(NULL) + (long) exptime * 2,
                agent, from_user, guess_ip4, profile->name,  
mod_sofia_globals.hostname);

(Is that the right spot ?)

So I tried just adding the fields as VARCHAR(255)'s to the table, and  
restarted the switch. It coredumped (for the first time btw), so I  
guessed the NULL values for the already present registrations were to  
blame, so I emptied the sip_registrations table and restarted. It  
started alright, but then gave errors on registrations this:

2008-09-23 17:57:26 [ERR] sofia_glue.c:2880  
sofia_glue_actually_execute_sql() ERR: [insert into sip_registrations  
values ('446BD213B8D1111 at 172.16.42.124',  
'00A0C5D4C03A-1','scarlet.nl','"user" <sip: 
00A0C5D4C03A-1 at 213.204.223.35:63747;fs_nat=yes>','Registered(UDP- 
NAT)', 'unknown', 1222192646, 'dunno', '00A0C5D4C03A-1',  
'213.204.232.18')]
[STATE: HY000 CODE 1136 ERROR: [unixODBC][MySQL][ODBC 3.51 Driver] 
[mysqld-5.0.51a-3ubuntu5.1]Column count doesn't match value count at  
row 1
]

How can this be ? This query is very different from the one before...

Is it already possible to save the hostname and sip_registrations (and  
presence_hosts) somehow ?

thanks,

Leon de Rooij
leon at scarlet-internet.nl




More information about the FreeSWITCH-users mailing list