[Freeswitch-svn] [commit] r9667 - freeswitch/trunk/src/mod/endpoints/mod_sofia

Freeswitch SVN anthm at freeswitch.org
Fri Sep 26 15:17:04 EDT 2008


Author: anthm
Date: Fri Sep 26 15:17:03 2008
New Revision: 9667

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c

Log:
deal with MODENDP-138

Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c	Fri Sep 26 15:17:03 2008
@@ -1279,63 +1279,87 @@
 			}
 		} else if (!strcasecmp(argv[0], "profile")) {
 			struct cb_helper cb;
+			char *sql = NULL;
 
 			if ((argv[1]) && (profile = sofia_glue_find_profile(argv[1]))) {
-				stream->write_function(stream, "%s\n", line);
-				stream->write_function(stream, "Name          \t\t%s\n", switch_str_nil(argv[1]));
-				stream->write_function(stream, "Domain Name   \t\t%s\n", profile->domain_name ? profile->domain_name : "N/A");
-				if (strcasecmp(argv[1], profile->name)) {
-					stream->write_function(stream, "Alias Of      \t\t%s\n", switch_str_nil(profile->name));
-				}
-				stream->write_function(stream, "DBName        \t\t%s\n", switch_str_nil(profile->dbname));
-				stream->write_function(stream, "Pres Hosts    \t\t%s\n", switch_str_nil(profile->presence_hosts));
-				stream->write_function(stream, "Dialplan      \t\t%s\n", switch_str_nil(profile->dialplan));
-				stream->write_function(stream, "Context       \t\t%s\n", switch_str_nil(profile->context));
-				stream->write_function(stream, "Challenge Realm\t\t%s\n", 
-									   switch_strlen_zero(profile->challenge_realm) ? "auto_to" : profile->challenge_realm);
-				stream->write_function(stream, "RTP-IP        \t\t%s\n", switch_str_nil(profile->rtpip));
-				if (profile->extrtpip) {
-					stream->write_function(stream, "Ext-RTP-IP    \t\t%s\n", profile->extrtpip);
-				}
+				if (!argv[2] || strcasecmp(argv[2], "reg")) {
+					stream->write_function(stream, "%s\n", line);
+					stream->write_function(stream, "Name          \t\t%s\n", switch_str_nil(argv[1]));
+					stream->write_function(stream, "Domain Name   \t\t%s\n", profile->domain_name ? profile->domain_name : "N/A");
+					if (strcasecmp(argv[1], profile->name)) {
+						stream->write_function(stream, "Alias Of      \t\t%s\n", switch_str_nil(profile->name));
+					}
+					stream->write_function(stream, "DBName        \t\t%s\n", switch_str_nil(profile->dbname));
+					stream->write_function(stream, "Pres Hosts    \t\t%s\n", switch_str_nil(profile->presence_hosts));
+					stream->write_function(stream, "Dialplan      \t\t%s\n", switch_str_nil(profile->dialplan));
+					stream->write_function(stream, "Context       \t\t%s\n", switch_str_nil(profile->context));
+					stream->write_function(stream, "Challenge Realm\t\t%s\n", 
+										   switch_strlen_zero(profile->challenge_realm) ? "auto_to" : profile->challenge_realm);
+					stream->write_function(stream, "RTP-IP        \t\t%s\n", switch_str_nil(profile->rtpip));
+					if (profile->extrtpip) {
+						stream->write_function(stream, "Ext-RTP-IP    \t\t%s\n", profile->extrtpip);
+					}
 
-				stream->write_function(stream, "SIP-IP        \t\t%s\n", switch_str_nil(profile->sipip));
-				if (profile->extsipip) {
-					stream->write_function(stream, "Ext-SIP-IP    \t\t%s\n", profile->extsipip);
-				}
-				stream->write_function(stream, "URL           \t\t%s\n", switch_str_nil(profile->url));
-				stream->write_function(stream, "BIND-URL      \t\t%s\n", switch_str_nil(profile->bindurl));
-				if (sofia_test_pflag(profile, PFLAG_TLS)) {
-					stream->write_function(stream, "TLS-URL      \t\t%s\n", switch_str_nil(profile->tls_url));
-					stream->write_function(stream, "TLS-BIND-URL      \t%s\n", switch_str_nil(profile->tls_bindurl));
-				}
-				stream->write_function(stream, "HOLD-MUSIC    \t\t%s\n", switch_strlen_zero(profile->hold_music) ? "N/A" : profile->hold_music);
-				stream->write_function(stream, "CODECS        \t\t%s\n", switch_str_nil(profile->codec_string));
-				stream->write_function(stream, "TEL-EVENT     \t\t%d\n", profile->te);
-				if (profile->dtmf_type == DTMF_2833) {
-					stream->write_function(stream, "DTMF-MODE     \t\trfc2833\n");
-				} else if (profile->dtmf_type == DTMF_INFO) {
-					stream->write_function(stream, "DTMF-MODE     \t\tinfo\n");
-				} else {
-					stream->write_function(stream, "DTMF-MODE     \t\tnone\n");
+					stream->write_function(stream, "SIP-IP        \t\t%s\n", switch_str_nil(profile->sipip));
+					if (profile->extsipip) {
+						stream->write_function(stream, "Ext-SIP-IP    \t\t%s\n", profile->extsipip);
+					}
+					stream->write_function(stream, "URL           \t\t%s\n", switch_str_nil(profile->url));
+					stream->write_function(stream, "BIND-URL      \t\t%s\n", switch_str_nil(profile->bindurl));
+					if (sofia_test_pflag(profile, PFLAG_TLS)) {
+						stream->write_function(stream, "TLS-URL      \t\t%s\n", switch_str_nil(profile->tls_url));
+						stream->write_function(stream, "TLS-BIND-URL      \t%s\n", switch_str_nil(profile->tls_bindurl));
+					}
+					stream->write_function(stream, "HOLD-MUSIC    \t\t%s\n", switch_strlen_zero(profile->hold_music) ? "N/A" : profile->hold_music);
+					stream->write_function(stream, "CODECS        \t\t%s\n", switch_str_nil(profile->codec_string));
+					stream->write_function(stream, "TEL-EVENT     \t\t%d\n", profile->te);
+					if (profile->dtmf_type == DTMF_2833) {
+						stream->write_function(stream, "DTMF-MODE     \t\trfc2833\n");
+					} else if (profile->dtmf_type == DTMF_INFO) {
+						stream->write_function(stream, "DTMF-MODE     \t\tinfo\n");
+					} else {
+						stream->write_function(stream, "DTMF-MODE     \t\tnone\n");
+					}
+					stream->write_function(stream, "CNG           \t\t%d\n", profile->cng_pt);
+					stream->write_function(stream, "SESSION-TO    \t\t%d\n", profile->session_timeout);
+					stream->write_function(stream, "MAX-DIALOG    \t\t%d\n", profile->max_proceeding);
+					stream->write_function(stream, "NOMEDIA       \t\t%s\n", switch_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
+					stream->write_function(stream, "LATE-NEG      \t\t%s\n", switch_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
+					stream->write_function(stream, "PROXY-MEDIA   \t\t%s\n", switch_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
+					stream->write_function(stream, "AGGRESSIVENAT \t\t%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
+					stream->write_function(stream, "STUN_ENABLED \t\t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
+					stream->write_function(stream, "STUN_AUTO_DISABLE \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
 				}
-				stream->write_function(stream, "CNG           \t\t%d\n", profile->cng_pt);
-				stream->write_function(stream, "SESSION-TO    \t\t%d\n", profile->session_timeout);
-				stream->write_function(stream, "MAX-DIALOG    \t\t%d\n", profile->max_proceeding);
-				stream->write_function(stream, "NOMEDIA       \t\t%s\n", switch_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
-				stream->write_function(stream, "LATE-NEG      \t\t%s\n", switch_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
-				stream->write_function(stream, "PROXY-MEDIA   \t\t%s\n", switch_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
-				stream->write_function(stream, "AGGRESSIVENAT \t\t%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
-				stream->write_function(stream, "STUN_ENABLED \t\t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
-				stream->write_function(stream, "STUN_AUTO_DISABLE \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
 				stream->write_function(stream, "\nRegistrations:\n%s\n", line);
 
 				cb.profile = profile;
 				cb.stream = stream;
+				
+				if (argv[3]) {
+					if (argv[4]) {
+						if (!strcasecmp(argv[3], "pres")) {
+							sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+												 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname"
+												 " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", 
+												 profile->name, argv[4]);
+						}
+					} else {
+						sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+											 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname"
+											 " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", 
+											 profile->name, argv[3]);
+					}
+				}
+
+				if (!sql) {
+					sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
+										 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname"
+										 " from sip_registrations where profile_name='%q'", 
+										 profile->name);
+				}
 
-				sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, 
-												"select call_id,sip_user,sip_host,contact,status,"
-												"rpid,expires,user_agent,server_user,server_host,profile_name,hostname"
-												" from sip_registrations", show_reg_callback, &cb);
+				sofia_glue_execute_sql_callback(profile, SWITCH_FALSE, profile->ireg_mutex, sql, show_reg_callback, &cb);
+				free(sql);
 
 				stream->write_function(stream, "%s\n", line);
 



More information about the Freeswitch-svn mailing list