[asterisk-commits] jpeeler: branch jpeeler/sip-dnsmgr r108889 - /team/jpeeler/sip-dnsmgr/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 14 18:00:58 CDT 2008


Author: jpeeler
Date: Fri Mar 14 18:00:57 2008
New Revision: 108889

URL: http://svn.digium.com/view/asterisk?view=rev&rev=108889
Log:
checkpoint, still need to have updated IP copied over to current registration

Modified:
    team/jpeeler/sip-dnsmgr/channels/chan_sip.c

Modified: team/jpeeler/sip-dnsmgr/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/jpeeler/sip-dnsmgr/channels/chan_sip.c?view=diff&rev=108889&r1=108888&r2=108889
==============================================================================
--- team/jpeeler/sip-dnsmgr/channels/chan_sip.c (original)
+++ team/jpeeler/sip-dnsmgr/channels/chan_sip.c Fri Mar 14 18:00:57 2008
@@ -191,7 +191,7 @@
 
 /* #define VOCAL_DATA_HACK */
 
-#define DEFAULT_DEFAULT_EXPIRY  120
+#define DEFAULT_DEFAULT_EXPIRY  10 /*this was 120 */
 #define DEFAULT_MIN_EXPIRY      60
 #define DEFAULT_MAX_EXPIRY      3600
 #define DEFAULT_REGISTRATION_TIMEOUT 20
@@ -1544,6 +1544,7 @@
 	struct timeval regtime;		/*!< Last successful registration time */
 	int callid_valid;		/*!< 0 means we haven't chosen callid for this registry yet. */
 	unsigned int ocseq;		/*!< Sequence number we got to for REGISTERs for this registry */
+	struct ast_dnsmgr_entry *dnsmgr;	/*!<  DNS refresh manager for register */
 	struct sockaddr_in us;		/*!< Who the server thinks we are */
 	int noncecount;			/*!< Nonce-count */
 	char lastmsg[256];		/*!< Last Message sent/received */
@@ -4250,6 +4251,7 @@
 	AST_SCHED_DEL(sched, reg->timeout);
 	ast_string_field_free_memory(reg);
 	regobjs--;
+	ast_dnsmgr_release(reg->dnsmgr);
 	ast_free(reg);
 	
 }
@@ -9131,6 +9133,8 @@
 	if (!r)
 		return 0;
 
+	//ast_dnsmgr_refresh(r->dnsmgr);
+
 	ast_log(LOG_NOTICE, "   -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts); 
 	/* If the initial tranmission failed, we may not have an existing dialog,
 	 * so it is possible that r->call == NULL.
@@ -9180,6 +9184,10 @@
 	char tmp[80];
 	char addr[80];
 	struct sip_pvt *p;
+	struct in_addr sin;
+	int changed = 0;
+
+	ast_log(LOG_DEBUG, "Transmit_Register\n");
 
 	/* exit if we are already in process with this registrar ?*/
 	if ( r == NULL || ((auth==NULL) && (r->regstate==REG_STATE_REGSENT || r->regstate==REG_STATE_AUTHSENT))) {
@@ -9187,16 +9195,33 @@
 		return 0;
 	}
 
-	if (r->call) {	/* We have a registration */
+	if (r->dnsmgr == NULL) {
+		ast_dnsmgr_lookup(r->hostname, &sin, &r->dnsmgr);
+		memcpy(&sin, &r->us.sin_addr, sizeof(sin));
+		ast_log(LOG_DEBUG, "dnsmgr was NULL\n");
+	} else {
+		changed = ast_dnsmgr_changed(r->dnsmgr);
+		ast_log(LOG_DEBUG, "Change status = %d\n", changed);
+	}
+
+	if (r->call && !changed) {	/* We have a registration and the IP has not changed*/
 		if (!auth) {
 			ast_log(LOG_WARNING, "Already have a REGISTER going on to %s@%s?? \n", r->username, r->hostname);
 			return 0;
 		} else {
+			ast_log(LOG_DEBUG, "registration valid and authorized\n");
 			p = r->call;
 			make_our_tag(p->tag, sizeof(p->tag));	/* create a new local tag for every register attempt */
 			ast_string_field_set(p, theirtag, NULL);	/* forget their old tag, so we don't match tags when getting response */
 		}
 	} else {
+		if (changed) {
+			ast_log(LOG_DEBUG, "IP change detected, cancelling current registration\n");
+			//ast_dnsmgr_get(r->hostname, &sin);
+			//memcpy(&sin, &r->us.sin_addr, sizeof(sin));
+			//r->call = sip_destroy(r->call);
+		}
+
 		/* Build callid for registration if we haven't registered before */
 		if (!r->callid_valid) {
 			build_callid_registry(r, internip.sin_addr, default_fromdomain);




More information about the asterisk-commits mailing list