[asterisk-commits] branch oej/sipregister r15429 - /team/oej/sipregister/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Mar 27 18:12:54 MST 2006


Author: oej
Date: Mon Mar 27 19:12:53 2006
New Revision: 15429

URL: http://svn.digium.com/view/asterisk?rev=15429&view=rev
Log:
Fix reload of peers that had register=yes before and now don't want to register
any more.
In this case we should also propably send a register with expire=0 to unregister
from the service provider.

Modified:
    team/oej/sipregister/channels/chan_sip.c

Modified: team/oej/sipregister/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/channels/chan_sip.c?rev=15429&r1=15428&r2=15429&view=diff
==============================================================================
--- team/oej/sipregister/channels/chan_sip.c (original)
+++ team/oej/sipregister/channels/chan_sip.c Mon Mar 27 19:12:53 2006
@@ -994,6 +994,7 @@
 static char *generate_random_string(char *buf, size_t size);
 static void set_peer_defaults(struct sip_peer *peer);
 static struct sip_peer *temp_peer(const char *name);
+static void sip_registry_destroy(struct sip_registry *reg);
 
 
 /*----- RTP interface functions */
@@ -1731,11 +1732,9 @@
 	peer->auth = (struct sip_auth *) NULL;
 	if (peer->dnsmgr)
 		ast_dnsmgr_release(peer->dnsmgr);
-	if (peer->registry) {
-		/* OEJ - NEeds to do a proper OBJECT dereference and delinking here */
-		//
-		//sip_registry_destroy(peer->registry);
-	}
+
+	if (peer->registry)
+		ASTOBJ_UNREF(peer->registry,sip_registry_destroy);
 	free(peer);
 }
 
@@ -12441,7 +12440,7 @@
 	peer->ha = NULL;
 	set_peer_defaults(peer);	/* Set peer defaults */
 	if (!found && name)
-			ast_copy_string(peer->name, name, sizeof(peer->name));
+		ast_copy_string(peer->name, name, sizeof(peer->name));
 
 	/* If we have channel variables, remove them (reload) */
 	if (peer->chanvars) {
@@ -12604,8 +12603,12 @@
 			}
 		} else if (!strcasecmp(v->name, "register")) {
 			if (ast_true(v->value)) {
-				ast_set_flag((&peer->flags_page2), SIP_PAGE2_PEER_REGISTER);
-				register_lineno = v->lineno;
+				if (realtime) {
+					ast_log(LOG_ERROR, "register=yes is not supported for realtime peers. (peer %s)\n", name);
+				} else {
+					ast_set_flag((&peer->flags[1]), SIP_PAGE2_PEER_REGISTER);
+					register_lineno = v->lineno;
+				}
 			}
 		} else if (!strcasecmp(v->name, "maxcallbitrate")) {
 			peer->maxcallbitrate = atoi(v->value);
@@ -12634,8 +12637,14 @@
 	ast_free_ha(oldha);
 
 	/* Start registration if needed */
-	if (ast_test_flag((&peer->flags_page2), SIP_PAGE2_PEER_REGISTER))
+	if (ast_test_flag((&peer->flags[1]), SIP_PAGE2_PEER_REGISTER)) {
 		sip_register(NULL, register_lineno, peer);
+	} else if (peer->registry) {
+		/* We have a registry entry for a peer that no longer wishes to
+		   be registered */
+		ASTOBJ_UNREF(peer->registry,sip_registry_destroy);
+		peer->registry = NULL;
+	}
 
 	return peer;
 }
@@ -13446,11 +13455,11 @@
 	{ { "sip", "show", "peer", NULL }, sip_show_peer, "Show details on specific SIP peer", show_peer_usage, complete_sip_show_peer },
 	{ { "sip", "show", "peers", NULL }, sip_show_peers, "Show defined SIP peers", show_peers_usage },
 	{ { "sip", "prune", "realtime", NULL }, sip_prune_realtime,
-	  "Prune cached Realtime object(s)", prune_realtime_usage },
+	"Prune cached Realtime object(s)", prune_realtime_usage },
 	{ { "sip", "prune", "realtime", "peer", NULL }, sip_prune_realtime,
-	  "Prune cached Realtime peer(s)", prune_realtime_usage, complete_sip_prune_realtime_peer },
+	"Prune cached Realtime peer(s)", prune_realtime_usage, complete_sip_prune_realtime_peer },
 	{ { "sip", "prune", "realtime", "user", NULL }, sip_prune_realtime,
-	  "Prune cached Realtime user(s)", prune_realtime_usage, complete_sip_prune_realtime_user },
+	"Prune cached Realtime user(s)", prune_realtime_usage, complete_sip_prune_realtime_user },
 	{ { "sip", "show", "inuse", NULL }, sip_show_inuse, "List all inuse/limits", show_inuse_usage },
 	{ { "sip", "show", "registry", NULL }, sip_show_registry, "Show SIP registration status", show_reg_usage },
 	{ { "sip", "history", NULL }, sip_do_history, "Enable SIP history", history_usage },
@@ -13508,7 +13517,7 @@
 
 	sip_poke_all_peers();	
 	sip_send_all_registers();
-	
+
 	/* And start the monitor for the first time */
 	restart_monitor();
 
@@ -13518,7 +13527,7 @@
 int unload_module()
 {
 	struct sip_pvt *p, *pl;
-	
+
 	/* First, take us out of the channel type list */
 	ast_channel_unregister(&sip_tech);
 



More information about the asterisk-commits mailing list