[asterisk-commits] markster: branch markster/usersconf r42652 - /team/markster/usersconf/channels/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Sep 10 12:36:06 MST 2006


Author: markster
Date: Sun Sep 10 14:36:06 2006
New Revision: 42652

URL: http://svn.digium.com/view/asterisk?rev=42652&view=rev
Log:
Support registration

Modified:
    team/markster/usersconf/channels/chan_iax2.c
    team/markster/usersconf/channels/chan_sip.c

Modified: team/markster/usersconf/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/channels/chan_iax2.c?rev=42652&r1=42651&r2=42652&view=diff
==============================================================================
--- team/markster/usersconf/channels/chan_iax2.c (original)
+++ team/markster/usersconf/channels/chan_iax2.c Sun Sep 10 14:36:06 2006
@@ -9027,14 +9027,17 @@
 	if (ucfg) {
 		struct ast_variable *gen;
 		int genhasiax;
-		char *hasiax;
+		int genregisteriax;
+		char *hasiax, *registeriax;
 		
 		genhasiax = ast_true(ast_variable_retrieve(ucfg, "general", "hasiax"));
+		genregisteriax = ast_true(ast_variable_retrieve(ucfg, "general", "registeriax"));
 		gen = ast_variable_browse(ucfg, "general");
 		cat = ast_category_browse(ucfg, NULL);
 		while (cat) {
 			if (strcasecmp(cat, "general")) {
 				hasiax = ast_variable_retrieve(ucfg, cat, "hasiax");
+				registeriax = ast_variable_retrieve(ucfg, cat, "registeriax");
 				if (ast_true(hasiax) || (!hasiax && genhasiax)) {
 					/* Start with general parameters, then specific parameters, user and peer */
 					user = build_user(cat, gen, ast_variable_browse(ucfg, cat), 0);
@@ -9050,6 +9053,25 @@
 						AST_LIST_UNLOCK(&peers);
 						if (ast_test_flag(peer, IAX_DYNAMIC))
 							reg_source_db(peer);
+					}
+				}
+				if (ast_true(registeriax) || (!registeriax && genregisteriax)) {
+					char tmp[256];
+					char *host = ast_variable_retrieve(ucfg, cat, "host");
+					char *username = ast_variable_retrieve(ucfg, cat, "username");
+					char *secret = ast_variable_retrieve(ucfg, cat, "secret");
+					if (!host)
+						host = ast_variable_retrieve(ucfg, "general", "host");
+					if (!username)
+						username = ast_variable_retrieve(ucfg, "general", "username");
+					if (!secret)
+						secret = ast_variable_retrieve(ucfg, "general", "secret");
+					if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
+						if (!ast_strlen_zero(secret))
+							snprintf(tmp, sizeof(tmp), "%s:%s@%s", username, secret, host);
+						else
+							snprintf(tmp, sizeof(tmp), "%s@%s", username, host);
+						iax2_register(tmp, 0);
 					}
 				}
 			}

Modified: team/markster/usersconf/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/channels/chan_sip.c?rev=42652&r1=42651&r2=42652&view=diff
==============================================================================
--- team/markster/usersconf/channels/chan_sip.c (original)
+++ team/markster/usersconf/channels/chan_sip.c Sun Sep 10 14:36:06 2006
@@ -15887,21 +15887,43 @@
 	ucfg = ast_config_load("users.conf");
 	if (ucfg) {
 		struct ast_variable *gen;
-		int genhassip;
-		char *hassip;
+		int genhassip, genregistersip;
+		char *hassip, *registersip;
 		
 		genhassip = ast_true(ast_variable_retrieve(ucfg, "general", "hassip"));
+		genregistersip = ast_true(ast_variable_retrieve(ucfg, "general", "registersip"));
 		gen = ast_variable_browse(ucfg, "general");
 		cat = ast_category_browse(ucfg, NULL);
 		while (cat) {
 			if (strcasecmp(cat, "general")) {
 				hassip = ast_variable_retrieve(ucfg, cat, "hassip");
+				registersip = ast_variable_retrieve(ucfg, cat, "registersip");
 				if (ast_true(hassip) || (!hassip && genhassip)) {
 					peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
 					if (peer) {
 						ASTOBJ_CONTAINER_LINK(&peerl,peer);
 						ASTOBJ_UNREF(peer, sip_destroy_peer);
 						peer_count++;
+					}
+				}
+				if (ast_true(registersip) || (!registersip && genregistersip)) {
+					char tmp[256];
+					char *host = ast_variable_retrieve(ucfg, cat, "host");
+					char *username = ast_variable_retrieve(ucfg, cat, "username");
+					char *secret = ast_variable_retrieve(ucfg, cat, "secret");
+					if (!host)
+						host = ast_variable_retrieve(ucfg, "general", "host");
+					if (!username)
+						username = ast_variable_retrieve(ucfg, "general", "username");
+					if (!secret)
+						secret = ast_variable_retrieve(ucfg, "general", "secret");
+					if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
+						if (!ast_strlen_zero(secret))
+							snprintf(tmp, sizeof(tmp), "%s:%s@%s", username, secret, host);
+						else
+							snprintf(tmp, sizeof(tmp), "%s@%s", username, host);
+						if (sip_register(v->value, v->lineno) == 0)
+							registry_count++;
 					}
 				}
 			}



More information about the asterisk-commits mailing list