[svn-commits] oej: trunk r128343 - /trunk/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jul 6 03:10:27 CDT 2008


Author: oej
Date: Sun Jul  6 03:10:27 2008
New Revision: 128343

URL: http://svn.digium.com/view/asterisk?view=rev&rev=128343
Log:
Removing the CLI dumpdb command (see asterisk-dev discussion and decision)

Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=128343&r1=128342&r2=128343
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sun Jul  6 03:10:27 2008
@@ -1953,8 +1953,6 @@
 static char *sip_show_sched(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static char * _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[]);
 static char *sip_show_peers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
-static char *_sip_dbdump(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[]);
-static char *sip_dbdump(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static char *sip_show_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
 static void  print_group(int fd, ast_group_t group, int crlf);
 static const char *dtmfmode2str(int mode) attribute_const;
@@ -12300,287 +12298,6 @@
 	}
 
 	return _sip_show_peers(a->fd, NULL, NULL, NULL, a->argc, (const char **) a->argv);
-}
-
-/*! \brief Execute sip dbdump command 
-*/
-static char *sip_dbdump(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	switch (cmd) {
-	case CLI_INIT:
-		e->command = "sip dbdump";
-		e->usage =
-			"Usage: sip dbdump [<file>]\n"
-			"       dumps user/peer info to the screen in SQL INSERT command form\n"
-			"       Optional file path will be output instead of to console if present.\n";
-		return NULL;
-	case CLI_GENERATE:
-		return NULL;
-	}
-
-	return _sip_dbdump(a->fd, NULL, NULL, NULL, a->argc, (const char **) a->argv);
-}
-
-/*! \brief Actually execute sip dbdump command */
-static char *_sip_dbdump(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[])
-{
-	struct sip_peer *peer;
-	struct ao2_iterator i;
-	char fname[1024];
-	const char *id;
-	FILE *f1;
-	char idtext[256] = "";
-	int realtimepeers;
-
-	realtimepeers = ast_check_realtime("sippeers");
-
-	if (s) {	/* Manager - get ActionID */
-		id = astman_get_header(m, "ActionID");
-		if (!ast_strlen_zero(id))
-			snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id);
-	}
-
-	switch (argc) {
-	case 3:
-		strncpy(fname, argv[2], sizeof(fname));
-		f1 = fopen(fname, "w");
-		if (!f1) {
-			ast_cli(fd, "Sorry, could not open %s for writing!", fname);
-			return CLI_SHOWUSAGE;
-		}
-		break;
-	case 2:
-		ast_cli(fd, "Sorry, will only generate a file at the moment. Please run again with a file name to write to.\n");
-	default:
-		return CLI_SHOWUSAGE;
-	}
-
-	i = ao2_iterator_init(peers, 0);
-	while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) {	
-
-		peer = find_peer(peer->name, NULL, realtimepeers, TRUE); 
-
-		ao2_lock(peer);
-
-		fprintf(f1, "INSERT INTO sipbuddies (");
-		
-		/* print out the populated field names in order */
-		fprintf(f1,"name");
-		
-		if (peer->host_dynamic)
-			fprintf(f1, ",host");
-		if (ast_test_flag(&peer->flags[0], SIP_NAT))
-			fprintf(f1, ",nat");
-		fprintf(f1,",type");
-		if (!ast_strlen_zero(peer->accountcode))
-			fprintf(f1, ",accountcode");
-		if (peer->amaflags)
-			fprintf(f1, ",amaflags");
-		fprintf(f1, ",`call-limit`");
-		if (peer->callgroup)
-			fprintf(f1, ", callgroup");
-		if (!ast_strlen_zero(peer->cid_num))
-			fprintf(f1, ", callerid");
-		if (ast_test_flag(&peer->flags[0], SIP_REINVITE))
-			fprintf(f1, ",canreinvite");
-		if (!ast_strlen_zero(peer->context))
-			fprintf(f1, ",context");
-		if (peer->defaddr.sin_addr.s_addr)
-			fprintf(f1, ",defaultip");
-		if (ast_test_flag(&peer->flags[0], SIP_DTMF))
-			fprintf(f1, ",dtmfmode");
-		if (!ast_strlen_zero(peer->fromuser))
-			fprintf(f1, ",fromuser");
-		if (!ast_strlen_zero(peer->fromdomain))
-			fprintf(f1, ",fromdomain");
-		if (ast_test_flag(&peer->flags[0], SIP_INSECURE))
-			fprintf(f1, ",insecure");
-		if (!ast_strlen_zero(peer->language))
-			fprintf(f1, ",language");
-		if (!AST_LIST_EMPTY(&peer->mailboxes)) {
-			fprintf(f1, ",mailbox");
-		}
-		if (!ast_strlen_zero(peer->md5secret))
-			fprintf(f1, ",md5secret");
-		if (peer->ha) {
-			if (peer->ha->sense == AST_SENSE_DENY) {
-				fprintf(f1, ",deny");
-			}
-			if (peer->ha->next && peer->ha->next->sense == AST_SENSE_ALLOW) {
-				fprintf(f1, ",permit");
-			}
-		}
-		if (!ast_strlen_zero(peer->mohinterpret))
-			fprintf(f1, ",mohinterpret");
-		if (!ast_strlen_zero(peer->mohsuggest))
-			fprintf(f1, ",mohsuggest");
-		if (peer->pickupgroup)
-			fprintf(f1, ",pickupgroup");
-		if (peer->maxms)
-			fprintf(f1, ",qualify");
-		if (!ast_strlen_zero(peer->regexten))
-			fprintf(f1, ",regexten");
-		if (peer->rtptimeout)
-			fprintf(f1, ",rtptimeout");
-		if (peer->rtpholdtimeout)
-			fprintf(f1, ",rtpholdtimeout");
-		if (!ast_strlen_zero(peer->secret))
-			fprintf(f1, ",secret");
-		if (peer->chanvars)
-			fprintf(f1, ",setvar");
-		if (ast_codec_pref_index(&peer->prefs, 0)) { /* print the codecs wanted in order */
-			fprintf(f1, ",allow");
-		}
-		if (!ast_strlen_zero(peer->fullcontact))
-			fprintf(f1, ",fullcontact");
-		if (peer->addr.sin_addr.s_addr)
-			fprintf(f1, ",ipaddr");
-		if (peer->addr.sin_port)
-			fprintf(f1, ",port");
-		if (!ast_strlen_zero(peer->username))
-			fprintf(f1, ",username");
-		
-		/* print out the values in order */
-		fprintf(f1, ") VALUES (");
-		
-		fprintf(f1, "'%s'", peer->name);
-		
-		if (peer->host_dynamic)
-			fprintf(f1, ",'dynamic'");
-		if (ast_test_flag(&peer->flags[0], SIP_NAT)) {
-			fprintf(f1, ",'%s'", nat2strconfig(ast_test_flag(&peer->flags[0], SIP_NAT)));
-		}
-		fprintf(f1, ",'peer'");
-		if (!ast_strlen_zero(peer->accountcode))
-			fprintf(f1, ",'%s'", peer->accountcode);
-		if (peer->amaflags)
-			fprintf(f1, ",'%s'", ast_cdr_flags2str(peer->amaflags));
-		fprintf(f1, ",%d", peer->call_limit);
-		if (peer->callgroup) {
-			char buf[256];
-			
-			fprintf(f1, ",'%s'", ast_print_group(buf, sizeof(buf), peer->callgroup));
-		}
-		if (ast_test_flag(&peer->flags[0], SIP_REINVITE)) {
-			switch (ast_test_flag(&peer->flags[0], SIP_REINVITE)) {
-			case SIP_REINVITE_NONE:
-				fprintf(f1, ",'no'");
-				break;
-			case SIP_CAN_REINVITE:
-				fprintf(f1, ",'yes'");
-				break;
-			case SIP_CAN_REINVITE_NAT:
-				fprintf(f1, ",'nonat'");
-				break;
-			case SIP_REINVITE_UPDATE:
-				fprintf(f1, ",'update'");
-				break;
-			default:
-				fprintf(f1, ",'no'");
-				break;
-			}
-		}
-		if (!ast_strlen_zero(peer->context))
-			fprintf(f1, ",'%s'",peer->context);
-		if (peer->defaddr.sin_addr.s_addr)
-			fprintf(f1, ",'%s'",  ast_inet_ntoa(peer->defaddr.sin_addr));
-		if (ast_test_flag(&peer->flags[0], SIP_DTMF)) {
-			fprintf(f1, ",'%s'", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF)));
-		}
-		if (!ast_strlen_zero(peer->fromuser))
-			fprintf(f1, ",'%s'", peer->fromuser);
-		if (!ast_strlen_zero(peer->fromdomain))
-			fprintf(f1, ",'%s'", peer->fromdomain);
-		if (ast_test_flag(&peer->flags[0], SIP_INSECURE)) {
-			
-			fprintf(f1, ",'%s'", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE)));
-		}
-		if (!ast_strlen_zero(peer->language))
-			fprintf(f1, ",'%s'", peer->language);
-		
-		if (!AST_LIST_EMPTY(&peer->mailboxes)) {
-			struct ast_str *mailbox_str = ast_str_alloca(512);
-			peer_mailboxes_to_str(&mailbox_str, peer);
-			fprintf(f1, ",'%s'", mailbox_str->str);
-		}
-		
-		if (!ast_strlen_zero(peer->md5secret))
-			fprintf(f1, ",'%s'", peer->md5secret);
-		if (peer->ha) {
-			if (peer->ha->sense == AST_SENSE_DENY) {
-				fprintf(f1, ",'%s/%s'",  ast_inet_ntoa(peer->ha->netaddr), ast_inet_ntoa(peer->ha->netmask));
-			}
-			if (peer->ha->next && peer->ha->next->sense == AST_SENSE_ALLOW) {
-				fprintf(f1, ",'%s/%s'",  ast_inet_ntoa(peer->ha->next->netaddr), ast_inet_ntoa(peer->ha->next->netmask));
-			}
-		}
-		
-		if (!ast_strlen_zero(peer->mohinterpret))
-			fprintf(f1, ",'%s'", peer->mohinterpret);
-		if (!ast_strlen_zero(peer->mohsuggest))
-			fprintf(f1, ",'%s'", peer->mohsuggest);
-		if (peer->pickupgroup) {
-			char buf[256];
-			
-			fprintf(f1, ",'%s'", ast_print_group(buf, sizeof(buf), peer->pickupgroup));
-		}
-		if (peer->maxms)
-			fprintf(f1, ",'%d'", peer->maxms);
-		if (!ast_strlen_zero(peer->regexten))
-			fprintf(f1, ",'%s'", peer->regexten);
-		if (peer->rtptimeout)
-			fprintf(f1, ",'%d'", peer->rtptimeout);
-		if (peer->rtpholdtimeout)
-			fprintf(f1, ",'%d'", peer->rtpholdtimeout);
-		if (!ast_strlen_zero(peer->secret))
-			fprintf(f1, ",'%s'", peer->secret);
-		if (peer->chanvars) {
-			int first=1;
-			struct ast_variable *p1 = peer->chanvars;
-			fprintf(f1, ",'");
-			while (p1)
-			{
-				if (!first)
-					fprintf(f1, ";");
-				else
-					first = 0;
-					
-				fprintf(f1, "%s=%s", p1->name, p1->value);
-				p1 = p1->next;
-			}
-			fprintf(f1, "'");
-		}
-		
-		if (ast_codec_pref_index(&peer->prefs, 0)) { /* print the codecs wanted in order */
-			/* this code isn't general, it assumes deny=all; but that's pretty common.
-			   people who use this differently will have to modify the results by hand. sorry. */
-			int x, codec;
-			fprintf(f1, ",'");
-			for(x = 0; x < 32 ; x++) {
-				codec = ast_codec_pref_index(&peer->prefs, x);
-				if (!codec)
-					break;
-				fprintf(f1, "%s", ast_getformatname(codec));
-				fprintf(f1, ":%d", peer->prefs.framing[x]);
-				if (x < 31 && ast_codec_pref_index(&peer->prefs, x + 1))
-					fprintf(f1, ",");
-			}
-			fprintf(f1,"'");
-		}
-		
-		if (!ast_strlen_zero(peer->fullcontact))
-			fprintf(f1, ",'%s'", peer->fullcontact);
-		if (peer->addr.sin_addr.s_addr)
-			fprintf(f1, ",'%s'",  ast_inet_ntoa(peer->addr.sin_addr));
-		if (peer->addr.sin_port)
-			fprintf(f1, ",%d", peer->addr.sin_port);
-		if (!ast_strlen_zero(peer->username))
-			fprintf(f1, ",'%s'", peer->username);
-		
-		fprintf(f1, ");\n");
-	}
-	fclose(f1);
-	return CLI_SUCCESS;
 }
 
 int peercomparefunc(const void *a, const void *b);
@@ -22351,7 +22068,6 @@
 	AST_CLI_DEFINE(sip_show_inuse, "List all inuse/limits"),
 	AST_CLI_DEFINE(sip_show_objects, "List all SIP object allocations"),
 	AST_CLI_DEFINE(sip_show_peers, "List defined SIP peers"),
-	AST_CLI_DEFINE(sip_dbdump, "Dump peer info into realtime database SQL format"),
 	AST_CLI_DEFINE(sip_show_registry, "List SIP registration status"),
 	AST_CLI_DEFINE(sip_unregister, "Unregister (force expiration) a SIP peer from the registery\n"),
 	AST_CLI_DEFINE(sip_show_settings, "Show SIP global settings"),




More information about the svn-commits mailing list