[asterisk-commits] mmichelson: branch mmichelson/queue-reset r110089 - in /team/mmichelson/queue...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 19 16:17:08 CDT 2008


Author: mmichelson
Date: Wed Mar 19 16:17:07 2008
New Revision: 110089

URL: http://svn.digium.com/view/asterisk?view=rev&rev=110089
Log:
Time for a little R&R...Resolve & Reset


Added:
    team/mmichelson/queue-reset/build_tools/cflags-devmode.xml
      - copied unchanged from r110087, trunk/build_tools/cflags-devmode.xml
Modified:
    team/mmichelson/queue-reset/   (props changed)
    team/mmichelson/queue-reset/CHANGES
    team/mmichelson/queue-reset/Makefile
    team/mmichelson/queue-reset/apps/app_chanspy.c
    team/mmichelson/queue-reset/apps/app_queue.c
    team/mmichelson/queue-reset/build_tools/cflags.xml
    team/mmichelson/queue-reset/channels/chan_sip.c
    team/mmichelson/queue-reset/channels/chan_zap.c
    team/mmichelson/queue-reset/codecs/log2comp.h
    team/mmichelson/queue-reset/configs/queues.conf.sample
    team/mmichelson/queue-reset/configs/res_ldap.conf.sample
    team/mmichelson/queue-reset/contrib/scripts/dbsep.cgi
    team/mmichelson/queue-reset/include/asterisk/_private.h
    team/mmichelson/queue-reset/include/asterisk/http.h
    team/mmichelson/queue-reset/main/config.c
    team/mmichelson/queue-reset/main/http.c
    team/mmichelson/queue-reset/main/manager.c
    team/mmichelson/queue-reset/main/pbx.c
    team/mmichelson/queue-reset/main/rtp.c
    team/mmichelson/queue-reset/main/utils.c
    team/mmichelson/queue-reset/res/res_config_ldap.c
    team/mmichelson/queue-reset/res/res_musiconhold.c
    team/mmichelson/queue-reset/res/res_phoneprov.c

Propchange: team/mmichelson/queue-reset/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/mmichelson/queue-reset/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/mmichelson/queue-reset/
            ('svnmerge-blocked' removed)

Propchange: team/mmichelson/queue-reset/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Mar 19 16:17:07 2008
@@ -1,1 +1,1 @@
-/trunk:1-109595
+/trunk:1-110088

Modified: team/mmichelson/queue-reset/CHANGES
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/CHANGES?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/CHANGES (original)
+++ team/mmichelson/queue-reset/CHANGES Wed Mar 19 16:17:07 2008
@@ -11,6 +11,12 @@
 ----------------------------------------
  * Channels can now be configured using named sections in zapata.conf, just
    like other channel drivers, including the use of templates.
+
+PBX Changes
+-----------
+ * It is now possible to specify a pattern match as a hint. Once a phone subscribes
+   to something that matches the pattern a hint will be created using the contents
+   and variables evaluated.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.4.X to Asterisk 1.6.0  -------------
@@ -169,6 +175,7 @@
      more information on how it is used.
   * Added a new configuration option "authfailureevents" that enables manager events when
     a peer can't authenticate properly. 
+  * Added DNS manager support to registrations not referencing a peer entry.
 
 IAX2 changes
 ------------
@@ -343,6 +350,9 @@
     "queue reload", "queue member reload", "queue reset stats". Also see "manager show
 	command QueueReload", "manager show command QueueReset", and "manager show command
 	QueueMemberReload".
+  * New configuration option: randomperiodicannounce. If a list of periodic announcements is
+    specified by the periodic-announce option, then one will be chosen randomly when it is time
+	to play a periodic announcment
 
 MeetMe Changes
 --------------

Modified: team/mmichelson/queue-reset/Makefile
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/Makefile?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/Makefile (original)
+++ team/mmichelson/queue-reset/Makefile Wed Mar 19 16:17:07 2008
@@ -847,7 +847,7 @@
 menuselect/makeopts:
 	$(MAKE_MENUSELECT) makeopts
 
-menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml build_tools/embed_modules.xml configure
+menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml configure
 	@echo "Generating input for menuselect ..."
 	@echo "<?xml version=\"1.0\"?>" > $@
 	@echo >> $@
@@ -855,6 +855,9 @@
 	@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SUBMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
 	@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SUBMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
 	@cat build_tools/cflags.xml >> $@
+	@if [ "${AST_DEVMODE}" = "yes" ]; then \
+		cat build_tools/cflags-devmode.xml >> $@; \
+	fi
 	@cat build_tools/embed_modules.xml >> $@
 	@cat sounds/sounds.xml >> $@
 	@echo "</menu>" >> $@

Modified: team/mmichelson/queue-reset/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_chanspy.c?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/apps/app_chanspy.c (original)
+++ team/mmichelson/queue-reset/apps/app_chanspy.c Wed Mar 19 16:17:07 2008
@@ -478,16 +478,15 @@
 
 	ast_mutex_lock(&chanspy_ds->lock);
 
-	chanspy_ds->chan = chan;
-
 	if (!(datastore = ast_channel_datastore_alloc(&chanspy_ds_info, NULL))) {
+		ast_mutex_unlock(&chanspy_ds->lock);
 		chanspy_ds = chanspy_ds_free(chanspy_ds);
 		ast_channel_unlock(chan);
 		return NULL;
 	}
-
+	
+	chanspy_ds->chan = chan;
 	datastore->data = chanspy_ds;
-
 	ast_channel_datastore_add(chan, datastore);
 
 	return chanspy_ds;
@@ -714,8 +713,10 @@
 					res = ast_streamfile(chan, peer_name, chan->language);
 					if (!res)
 						res = ast_waitstream(chan, "");
-					if (res)
+					if (res) {
+						chanspy_ds_free(peer_chanspy_ds);
 						break;
+					}
 				} else
 					res = ast_say_character_str(chan, peer_name, "", chan->language);
 				if ((num = atoi(ptr)))
@@ -731,6 +732,7 @@
 				goto exit;
 			} else if (res == -2) {
 				res = 0;
+				chanspy_ds_free(peer_chanspy_ds);
 				goto exit;
 			} else if (res > 1 && spec) {
 				struct ast_channel *next;

Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Wed Mar 19 16:17:07 2008
@@ -471,6 +471,8 @@
 	int announcefrequency;              /*!< How often to announce their position */
 	int minannouncefrequency;           /*!< The minimum number of seconds between position announcements (def. 15) */
 	int periodicannouncefrequency;      /*!< How often to play periodic announcement */
+	int numperiodicannounce;            /*!< The number of periodic announcements configured */
+	int randomperiodicannounce;         /*!< Are periodic announcments randomly chosen */
 	int roundingseconds;                /*!< How many seconds do we round to? */
 	int holdtime;                       /*!< Current avg holdtime, based on recursive boxcar filter */
 	int callscompleted;                 /*!< Number of queue calls completed */
@@ -679,63 +681,31 @@
  * Lock interface list find sc, iterate through each queues queue_member list for member to
  * update state inside queues
 */
-static void *handle_statechange(struct statechange *sc)
-{
+static int update_status(const char *interface, const int status)
+{
+	struct member *cur;
+	struct ao2_iterator mem_iter, queue_iter;
 	struct call_queue *q;
-	struct member *cur;
-	struct ao2_iterator mem_iter;
-	struct member_interface *curint;
-	struct ao2_iterator queue_iter;
-	char *loc;
-	char *technology;
-
-	technology = ast_strdupa(sc->dev);
-	loc = strchr(technology, '/');
-	if (loc) {
-		*loc++ = '\0';
-	} else {
-		return NULL;
-	}
-
-	AST_LIST_LOCK(&interfaces);
-	AST_LIST_TRAVERSE(&interfaces, curint, list) {
-		char *interface;
-		char *slash_pos;
-		interface = ast_strdupa(curint->interface);
-		if ((slash_pos = strchr(interface, '/')))
-			if ((slash_pos = strchr(slash_pos + 1, '/')))
-				*slash_pos = '\0';
-
-		if (!strcasecmp(interface, sc->dev))
-			break;
-	}
-	AST_LIST_UNLOCK(&interfaces);
-
-	if (!curint) {
-		ast_debug(3, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
-		return NULL;
-	}
-
-	ast_debug(1, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
+
 	queue_iter = ao2_iterator_init(queues, 0);
 	while ((q = ao2_iterator_next(&queue_iter))) {
 		ao2_lock(q);
 		mem_iter = ao2_iterator_init(q->members, 0);
 		while ((cur = ao2_iterator_next(&mem_iter))) {
-			char *interface;
+			char *tmp_interface;
 			char *slash_pos;
-			interface = ast_strdupa(cur->state_interface);
+			tmp_interface = ast_strdupa(cur->state_interface);
 			if ((slash_pos = strchr(interface, '/')))
 				if ((slash_pos = strchr(slash_pos + 1, '/')))
 					*slash_pos = '\0';
 
-			if (strcasecmp(sc->dev, interface)) {
+			if (strcasecmp(interface, tmp_interface)) {
 				ao2_ref(cur, -1);
 				continue;
 			}
 
-			if (cur->status != sc->state) {
-				cur->status = sc->state;
+			if (cur->status != status) {
+				cur->status = status;
 				if (q->maskmemberstatus) {
 					ao2_ref(cur, -1);
 					continue;
@@ -759,6 +729,49 @@
 		queue_unref(q);
 		ao2_unlock(q);
 	}
+
+	return 0;
+}
+
+/*! \brief set a member's status based on device state of that member's interface*/
+static void *handle_statechange(struct statechange *sc)
+{
+	struct member_interface *curint;
+	char *loc;
+	char *technology;
+
+	technology = ast_strdupa(sc->dev);
+	loc = strchr(technology, '/');
+	if (loc) {
+		*loc++ = '\0';
+	} else {
+		return NULL;
+	}
+
+	AST_LIST_LOCK(&interfaces);
+	AST_LIST_TRAVERSE(&interfaces, curint, list) {
+		char *interface;
+		char *slash_pos;
+		interface = ast_strdupa(curint->interface);
+		if ((slash_pos = strchr(interface, '/')))
+			if ((slash_pos = strchr(slash_pos + 1, '/')))
+				*slash_pos = '\0';
+
+		if (!strcasecmp(interface, sc->dev))
+			break;
+	}
+	AST_LIST_UNLOCK(&interfaces);
+
+	if (!curint) {
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
+		return NULL;
+	}
+
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
+
+	update_status(sc->dev, sc->state);
 
 	return NULL;
 }
@@ -940,6 +953,8 @@
 	q->weight = 0;
 	q->timeoutrestart = 0;
 	q->periodicannouncefrequency = 0;
+	q->randomperiodicannounce = 0;
+	q->numperiodicannounce = 0;
 	if (!q->members) {
 		if (q->strategy == QUEUE_STRATEGY_LINEAR)
 			/* linear strategy depends on order, so we have to place all members in a single bucket */
@@ -1241,11 +1256,15 @@
 				if (i == MAX_PERIODIC_ANNOUNCEMENTS)
 					break;
 			}
+			q->numperiodicannounce = i;
 		} else {
 			ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val);
+			q->numperiodicannounce = 1;
 		}
 	} else if (!strcasecmp(param, "periodic-announce-frequency")) {
 		q->periodicannouncefrequency = atoi(val);
+	} else if (!strcasecmp(param, "random-periodic-announce")) {
+		q->randomperiodicannounce = ast_true(val);
 	} else if (!strcasecmp(param, "retry")) {
 		q->retry = atoi(val);
 		if (q->retry <= 0)
@@ -1991,55 +2010,6 @@
 	}
 }
 
-static int update_status(struct call_queue *q, struct member *member, int status)
-{
-	struct member *cur;
-	struct ao2_iterator mem_iter;
-
-	/* Since a reload could have taken place, we have to traverse the list to
-		be sure it's still valid */
-	ao2_lock(q);
-	mem_iter = ao2_iterator_init(q->members, 0);
-	while ((cur = ao2_iterator_next(&mem_iter))) {
-		if (member != cur) {
-			ao2_ref(cur, -1);
-			continue;
-		}
-
-		cur->status = status;
-		if (!q->maskmemberstatus) {
-			manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
-				"Queue: %s\r\n"
-				"Location: %s\r\n"
-				"MemberName: %s\r\n"
-				"Membership: %s\r\n"
-				"Penalty: %d\r\n"
-				"CallsTaken: %d\r\n"
-				"LastCall: %d\r\n"
-				"Status: %d\r\n"
-				"Paused: %d\r\n",
-				q->name, cur->interface, cur->membername, cur->dynamic ? "dynamic" : cur->realtime ? "realtime": "static",
-				cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
-		}
-		ao2_ref(cur, -1);
-	}
-	ao2_unlock(q);
-	return 0;
-}
-
-static int update_dial_status(struct call_queue *q, struct member *member, int status)
-{
-	if (status == AST_CAUSE_BUSY)
-		status = AST_DEVICE_BUSY;
-	else if (status == AST_CAUSE_UNREGISTERED)
-		status = AST_DEVICE_UNAVAILABLE;
-	else if (status == AST_CAUSE_NOSUCHDRIVER)
-		status = AST_DEVICE_INVALID;
-	else
-		status = AST_DEVICE_UNKNOWN;
-	return update_status(q, member, status);
-}
-
 /*! 
  * \brief traverse all defined queues which have calls waiting and contain this member
  * \retval 0 if no other queue has precedence (higher weight) 
@@ -2196,7 +2166,8 @@
 		if (qe->chan->cdr)
 			ast_cdr_busy(qe->chan->cdr);
 		tmp->stillgoing = 0;
-		update_dial_status(qe->parent, tmp->member, status);
+
+		update_status(tmp->member->state_interface, ast_device_state(tmp->member->state_interface));
 
 		ao2_lock(qe->parent);
 		qe->parent->rrpos++;
@@ -2206,8 +2177,7 @@
 
 		(*busies)++;
 		return 0;
-	} else if (status != tmp->oldstatus)
-		update_dial_status(qe->parent, tmp->member, status);
+	}
 	
 	tmp->chan->appl = "AppQueue";
 	tmp->chan->data = "(Outgoing Line)";
@@ -2396,10 +2366,10 @@
 		ast_moh_stop(qe->chan);
 
 	ast_verb(3, "Playing periodic announcement\n");
-
-	/* Check to make sure we have a sound file. If not, reset to the first sound file */
-	if (qe->last_periodic_announce_sound >= MAX_PERIODIC_ANNOUNCEMENTS || 
-		!qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound] ||
+	
+	if (qe->parent->randomperiodicannounce) {
+		qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce;
+	} else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce || 
 		ast_strlen_zero(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]->str)) {
 		qe->last_periodic_announce_sound = 0;
 	}
@@ -2422,7 +2392,9 @@
 	qe->last_periodic_announce_time = now;
 
 	/* Update the current periodic announcement to the next announcement */
-	qe->last_periodic_announce_sound++;
+	if (!qe->parent->randomperiodicannounce) {
+		qe->last_periodic_announce_sound++;
+	}
 	
 	return res;
 }
@@ -2574,8 +2546,6 @@
 					ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
 					/* Setup parameters */
 					o->chan = ast_request(tech, in->nativeformats, stuff, &status);
-					if (status != o->oldstatus)
-						update_dial_status(qe->parent, o->member, status);						
 					if (!o->chan) {
 						ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s'\n", tech, stuff);
 						o->stillgoing = 0;
@@ -3288,8 +3258,8 @@
 		to = (qe->parent->timeout) ? qe->parent->timeout * 1000 : -1;
 	orig = to;
 	++qe->pending;
+	ao2_unlock(qe->parent);
 	ring_one(qe, outgoing, &numbusies);
-	ao2_unlock(qe->parent);
 	if (use_weight)
 		ao2_unlock(queues);
 	lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed);

Modified: team/mmichelson/queue-reset/build_tools/cflags.xml
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/build_tools/cflags.xml?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/build_tools/cflags.xml (original)
+++ team/mmichelson/queue-reset/build_tools/cflags.xml Wed Mar 19 16:17:07 2008
@@ -16,8 +16,6 @@
 		</member>
 		<member name="LOTS_OF_SPANS" displayname="More than 32 Zaptel spans">
 		</member>
-		<member name="MTX_PROFILE" displayname="Enable Code Profiling Using TSC Counters">
-		</member>
 		<member name="RADIO_RELAX" displayname="Relax DTMF for Radio Applications">
 		</member>
 		<member name="G711_NEW_ALGORITHM" displayname="Use the NEW ulaw/alaw codecs (slower, but cleaner)">
@@ -35,22 +33,7 @@
 		</member>
 		<member name="DEBUG_CHANNEL_LOCKS" displayname="Debug Channel Locking">
 		</member>
-		<member name="DEBUG_SCHEDULER" displayname="Enable Scheduler Debugging Output">
-		</member>
-		<member name="DEBUG_THREADLOCALS" displayname="Enable Thread-Local-Storage Debugging">
-		</member>
-		<member name="DETECT_DEADLOCKS" displayname="Detect Deadlocks">
-			<depend>DEBUG_THREADS</depend>
-		</member>
-		<member name="DUMP_SCHEDULER" displayname="Dump Scheduler Contents for Debugging">
-		</member>
 		<member name="MALLOC_DEBUG" displayname="Keep Track of Memory Allocations">
-		</member>
-		<member name="TRACE_FRAMES" displayname="Trace Frame Allocations">
-		</member>
-		<member name="DO_CRASH" displayname="Crash on fatal errors">
-		</member>
-		<member name="THREAD_CRASH" displayname="Crash on mutex errors">
 		</member>
 		<member name="BUSYDETECT_TONEONLY" displayname="Enable additional comparision of only the tone duration not the silence part">
 			<conflict>BUSYDETECT_COMPARE_TONE_AND_SILENCE</conflict>
@@ -63,6 +46,4 @@
 		<member name="BUSYDETECT_DEBUG" displayname="Enable additional busy detection debugging">
 			<defaultenabled>no</defaultenabled>
 		</member>
-		<member name="CHANNEL_TRACE" displayname="Enable CHANNEL(trace) function">
-		</member>
 	</category>

Modified: team/mmichelson/queue-reset/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/channels/chan_sip.c?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/channels/chan_sip.c (original)
+++ team/mmichelson/queue-reset/channels/chan_sip.c Wed Mar 19 16:17:07 2008
@@ -1303,7 +1303,6 @@
 	struct sip_st_dlg *stimer;		/*!< SIP Session-Timers */              
 };
 
-
 /*! Max entires in the history list for a sip_pvt */
 #define MAX_HISTORY_ENTRIES 50
 
@@ -1547,6 +1546,8 @@
 	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 */
 };
@@ -1959,7 +1960,7 @@
 static const struct sockaddr_in *sip_real_dst(const struct sip_pvt *p);
 static void build_via(struct sip_pvt *p);
 static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer);
-static int create_addr(struct sip_pvt *dialog, const char *opeer);
+static int create_addr(struct sip_pvt *dialog, const char *opeer, struct in_addr *sin);
 static char *generate_random_string(char *buf, size_t size);
 static void build_callid_pvt(struct sip_pvt *pvt);
 static void build_callid_registry(struct sip_registry *reg, struct in_addr ourip, const char *fromdomain);
@@ -2528,7 +2529,7 @@
 	int res = 0;
 	const struct sockaddr_in *dst = sip_real_dst(p);
 
-	ast_debug(1, "Trying to put '%.10s' onto %s socket...\n", data->str, get_transport(p->socket.type));
+	ast_debug(1, "Trying to put '%.10s' onto %s socket destined for %s\n", data->str, get_transport(p->socket.type), ast_inet_ntoa(dst->sin_addr));
 
 	if (sip_prepare_socket(p) < 0)
 		return XMIT_ERROR;
@@ -3100,6 +3101,7 @@
 		 __sip_reliable_xmit(p, seqno, 1, req->data, req->len, (reliable == XMIT_CRITICAL), req->method) :
 		__sip_xmit(p, req->data, req->len);
 	ast_free(req->data);
+	req->data = NULL;
 	if (res > 0)
 		return 0;
 	return res;
@@ -3133,8 +3135,10 @@
 	res = (reliable) ?
 		__sip_reliable_xmit(p, seqno, 0, req->data, req->len, (reliable == XMIT_CRITICAL), req->method) :
 		__sip_xmit(p, req->data, req->len);
-	if (req->data)
+	if (req->data) {
 		ast_free(req->data);
+		req->data = NULL;
+	}
 	return res;
 }
 
@@ -4054,7 +4058,7 @@
 /*! \brief create address structure from peer name
  *      Or, if peer not found, find it in the global DNS 
  *      returns TRUE (-1) on failure, FALSE on success */
-static int create_addr(struct sip_pvt *dialog, const char *opeer)
+static int create_addr(struct sip_pvt *dialog, const char *opeer, struct in_addr *sin)
 {
 	struct hostent *hp;
 	struct ast_hostent ahp;
@@ -4063,6 +4067,7 @@
 	int portno;
 	char host[MAXHOSTNAMELEN], *hostn;
 	char peername[256];
+	int srv_ret = 0;
 
 	ast_copy_string(peername, opeer, sizeof(peername));
 	port = strchr(peername, ':');
@@ -4094,27 +4099,32 @@
 
 	/* Let's see if we can find the host in DNS. First try DNS SRV records,
    	   then hostname lookup */
-
 	hostn = peername;
 	portno = port ? atoi(port) : (dialog->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT;
 	if (global_srvlookup) {
 		char service[MAXHOSTNAMELEN];
 		int tportno;
-		int ret;
 
 		snprintf(service, sizeof(service), "_sip._%s.%s", get_transport(dialog->socket.type), peername);
-		ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service);
-		if (ret > 0) {
+		srv_ret = ast_get_srv(NULL, host, sizeof(host), &tportno, service);
+		if (srv_ret > 0) {
 			hostn = host;
 			portno = tportno;
 		}
 	}
-	hp = ast_gethostbyname(hostn, &ahp);
-	if (!hp) {
-		ast_log(LOG_WARNING, "No such host: %s\n", peername);
-		return -1;
-	}
-	memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr));
+
+	if (sin && srv_ret <= 0) {
+		memcpy(&dialog->sa.sin_addr, sin, sizeof(dialog->sa.sin_addr));
+		ast_log(LOG_DEBUG, "IP lookup for hostname=%s, using dnsmgr resolved to %s...\n", peername, ast_inet_ntoa(*sin));
+	} else {
+		hp = ast_gethostbyname(hostn, &ahp);
+		if (!hp) {
+			ast_log(LOG_WARNING, "No such host: %s\n", peername);
+			return -1;
+		}
+		memcpy(&dialog->sa.sin_addr, hp->h_addr, sizeof(dialog->sa.sin_addr));
+	}
+
 	dialog->sa.sin_port = htons(portno);
 	dialog->recv = dialog->sa;
 	return 0;
@@ -4252,6 +4262,7 @@
 	AST_SCHED_DEL(sched, reg->timeout);
 	ast_string_field_free_memory(reg);
 	regobjs--;
+	ast_dnsmgr_release(reg->dnsmgr);
 	ast_free(reg);
 	
 }
@@ -4763,7 +4774,7 @@
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 
 	/* Start the process if it's not already started */
-	if (!p->alreadygone && !ast_strlen_zero(p->initreq.data->str)) {
+	if (!p->alreadygone && p->initreq.data && !ast_strlen_zero(p->initreq.data->str)) {
 		if (needcancel) {	/* Outgoing call, not up */
 			if (ast_test_flag(&p->flags[0], SIP_OUTGOING)) {
 				/* stop retransmitting an INVITE that has not received a response */
@@ -9138,6 +9149,11 @@
 	if (!r)
 		return 0;
 
+	if (r->dnsmgr) {
+		/* If the registration has timed out, maybe the IP changed.  Force a refresh. */
+		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.
@@ -9189,10 +9205,14 @@
 	struct sip_pvt *p;
 
 	/* 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))) {
+	if (r == NULL || ((auth == NULL) && (r->regstate == REG_STATE_REGSENT || r->regstate == REG_STATE_AUTHSENT))) {
 		ast_log(LOG_NOTICE, "Strange, trying to register %s@%s when registration already pending\n", r->username, r->hostname);
 		return 0;
 	}
+
+	if (r->dnsmgr == NULL) {
+		ast_dnsmgr_lookup(r->hostname, &r->us.sin_addr, &r->dnsmgr);
+	} 
 
 	if (r->call) {	/* We have a registration */
 		if (!auth) {
@@ -9221,7 +9241,7 @@
 		p->outboundproxy = obproxy_get(p, NULL);
 
 		/* Find address to hostname */
-		if (create_addr(p, r->hostname)) {
+		if (create_addr(p, r->hostname, &r->us.sin_addr)) {
 			/* we have what we hope is a temporary network error,
 			 * probably DNS.  We need to reschedule a registration try */
 			sip_destroy(p);
@@ -13865,7 +13885,7 @@
 			return CLI_FAILURE;
 		}
 
-		if (create_addr(p, a->argv[i])) {
+		if (create_addr(p, a->argv[i], NULL)) {
 			/* Maybe they're not registered, etc. */
 			sip_destroy(p);
 			ast_cli(a->fd, "Could not create address for '%s'\n", a->argv[i]);
@@ -18102,6 +18122,7 @@
 
 	if (req->headers < 2) {	/* Must have at least two headers */
 		ast_free(req->data);
+		req->data = NULL;
 		return 1;
 	}
 
@@ -19111,7 +19132,7 @@
 		ext = extension (user part of URI)
 		dnid = destination of the call (applies to the To: header)
 	*/
-	if (create_addr(p, host)) {
+	if (create_addr(p, host, NULL)) {
 		*cause = AST_CAUSE_UNREGISTERED;
 		ast_debug(3, "Cant create SIP call - target device not registred\n");
 		sip_destroy(p);

Modified: team/mmichelson/queue-reset/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/channels/chan_zap.c?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/channels/chan_zap.c (original)
+++ team/mmichelson/queue-reset/channels/chan_zap.c Wed Mar 19 16:17:07 2008
@@ -14105,7 +14105,7 @@
 		ast_mutex_unlock(&iflock);
 		ast_config_destroy(cfg);
 		if (ucfg) {
-			ast_config_destroy(cfg);
+			ast_config_destroy(ucfg);
 		}
 		return res;
 	}

Modified: team/mmichelson/queue-reset/codecs/log2comp.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/codecs/log2comp.h?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/codecs/log2comp.h (original)
+++ team/mmichelson/queue-reset/codecs/log2comp.h Wed Mar 19 16:17:07 2008
@@ -43,7 +43,7 @@
 		decl	%0			;\
 		bsrl	%1, %0		;\
 		"
-		: "=r" (a)
+		: "=&r" (a)
 		: "mr" (val)
 		: "cc"
 	);

Modified: team/mmichelson/queue-reset/configs/queues.conf.sample
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/configs/queues.conf.sample?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/configs/queues.conf.sample (original)
+++ team/mmichelson/queue-reset/configs/queues.conf.sample Wed Mar 19 16:17:07 2008
@@ -210,6 +210,10 @@
 ;
 ;periodic-announce-frequency=60
 ;
+; Should the periodic announcements be played in a random order? Default is no.
+;
+;random-periodic-announce=no
+;
 ; Should we include estimated hold time in position announcements?
 ; Either yes, no, or only once.
 ; Hold time will be announced as the estimated time.

Modified: team/mmichelson/queue-reset/configs/res_ldap.conf.sample
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/configs/res_ldap.conf.sample?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/configs/res_ldap.conf.sample (original)
+++ team/mmichelson/queue-reset/configs/res_ldap.conf.sample Wed Mar 19 16:17:07 2008
@@ -3,7 +3,7 @@
 ;
 
 ; Sample Asterisk config file for res_config_ldap
-; in extconfig.conf you can use it like this:
+; in extconfig.conf; you can use it like this:
 ; sipusers = ldap,"dc=myDomain,dc=myDomainExt",sip
 ; sippeers = ldap,"dc=myDomain,dc=myDomainExt",sip
 ; extensions = ldap,"dc=myDomain,dc=myDomainExt",extensions
@@ -11,20 +11,29 @@
 
 
 [_general]
-;host=192.168.1.1,ldap.mydomain.com	; LDAP host(s)
-;protocol=3		; Version of the LDAP protocol to use default is 3.
-;basedn=MyRootDN	; Base DN
-;pass=MyPassword	; Bind password
-;user=MyDN		; Bind DN
+;
+; Specify one of either host and port OR url.  URL is preferred, as you can
+; use more options.
+;host=192.168.1.1                    ; LDAP host
+;port=389
+;url=ldap://ldap3.mydomain.com:3890
+;protocol=3                          ; Version of the LDAP protocol to use; default is 3.
+;basedn=MyRootDN                     ; Base DN
+;user=MyDN                           ; Bind DN
+;pass=MyPassword                     ; Bind password
 
 ; Configuration Table
 [config]
-; addtional filter - This specifies an additional set of criteria to be used
+;
+; additionalFilter - This specifies an additional set of criteria to be used
 ; when querying the LDAP server.
+;
 additionalFilter=(objectClass=PBXConfig)
+;
 ; Attributes mapping (asterisk variable name = ldap attribute name)
 ; When Asterisk requests the variable by the name of the value on the left,
 ; this module will look up the attribute listed on the right.
+;
 filename = PBXConfigFilename
 category = PBXConfigCategory
 variable_name = PBXConfigVariableName
@@ -32,7 +41,9 @@
 cat_metric = PBXConfigCategoryMetric
 commented = PBXConfigCommented
 
+;
 ; Extensions Table
+;
 [extensions]
 context  =  PBXExtensionContext
 exten  =  PBXExtensionExten
@@ -41,7 +52,9 @@
 appdata = PBXExtensionApplicationData
 additionalFilter=(objectClass=PBXExtension)
 
+;
 ; Sip Users Table
+;
 [sip]
 name = uid
 amaflags = PBXAccountAMAFlags
@@ -77,7 +90,9 @@
 CanCallForward = PBXAccountCanCallForward
 additionalFilter=(objectClass=PBXAccountSIP)
 
+;
 ; IAX Users Table
+;
 [iax]
 amaflags = PBXAccountAMAFlags
 callerid = PBXAccountCallerID
@@ -100,7 +115,9 @@
 notransfer = PBXAccountNoTransfer
 additionalFilter=(objectClass=PBXAccountIAX)
 
+;
 ; A Test Family
+;
 [testfamily]
 MyUSERID = uid
 additionalFilter=(objectClass=*)

Modified: team/mmichelson/queue-reset/contrib/scripts/dbsep.cgi
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/contrib/scripts/dbsep.cgi?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/contrib/scripts/dbsep.cgi (original)
+++ team/mmichelson/queue-reset/contrib/scripts/dbsep.cgi Wed Mar 19 16:17:07 2008
@@ -45,7 +45,7 @@
 $ENV{PATH_INFO} =~ m/\/([^\/]*)\/([^\/]*)$/;
 ($table, $mode) = ($1, lc($2));
 
-print STDERR "PATH_INFO=$ENV{PATH_INFO}, table=$table, mode=$mode\n";
+#print STDERR "PATH_INFO=$ENV{PATH_INFO}, table=$table, mode=$mode\n";
 
 if ($mode eq 'single') {
 	# All parameters as POST

Modified: team/mmichelson/queue-reset/include/asterisk/_private.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/include/asterisk/_private.h?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/include/asterisk/_private.h (original)
+++ team/mmichelson/queue-reset/include/asterisk/_private.h Wed Mar 19 16:17:07 2008
@@ -33,7 +33,9 @@
 int astobj2_init(void);			/*!< Provided by astobj2.c */
 int ast_file_init(void);		/*!< Provided by file.c */
 int ast_features_init(void);            /*!< Provided by features.c */
-void ast_autoservice_init(void);    /*!< Provided by autoservice.c */
+void ast_autoservice_init(void);	/*!< Provided by autoservice.c */
+int ast_http_init(void);		/*!< Provided by http.c */
+int ast_http_reload(void);		/*!< Provided by http.c */
 
 /*!
  * \brief Reload asterisk modules.

Modified: team/mmichelson/queue-reset/include/asterisk/http.h
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/include/asterisk/http.h?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/include/asterisk/http.h (original)
+++ team/mmichelson/queue-reset/include/asterisk/http.h Wed Mar 19 16:17:07 2008
@@ -65,29 +65,37 @@
    content is specified) 
 \endverbatim
 */
-typedef struct ast_str *(*ast_http_callback)(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength);
 
-/*! \brief Definition of a URI reachable in the embedded HTTP server */
+enum ast_http_method {
+	AST_HTTP_GET = 0,
+	AST_HTTP_POST,
+};
+
+typedef struct ast_str *(*ast_http_callback)(struct ast_tcptls_session_instance *ser, const char *uri, enum ast_http_method method,
+					     struct ast_variable *params, int *status, char **title, int *contentlength);
+
+/*! \brief Definition of a URI handler */
 struct ast_http_uri {
 	AST_LIST_ENTRY(ast_http_uri) entry;
 	const char *description;
 	const char *uri;
+	ast_http_callback callback;
 	unsigned int has_subtree:1;
-	/*! This URI mapping serves static content */
+	/*! This handler serves static content */
 	unsigned int static_content:1;
-	ast_http_callback callback;
+	/*! This handler accepts GET requests */
+	unsigned int supports_get:1;
+	/*! This handler accepts POST requests */
+	unsigned int supports_post:1;
 };
 
-/*! \brief Link into the Asterisk HTTP server */
+/*! \brief Register a URI handler */
 int ast_http_uri_link(struct ast_http_uri *urihandler);
+
+/*! \brief Unregister a URI handler */
+void ast_http_uri_unlink(struct ast_http_uri *urihandler);
 
 /*! \brief Return an ast_str malloc()'d string containing an HTTP error message */
 struct ast_str *ast_http_error(int status, const char *title, const char *extra_header, const char *text);
 
-/*! \brief Destroy an HTTP server */
-void ast_http_uri_unlink(struct ast_http_uri *urihandler);
-
-int ast_http_init(void);
-int ast_http_reload(void);
-
 #endif /* _ASTERISK_SRV_H */

Modified: team/mmichelson/queue-reset/main/config.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/main/config.c?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/main/config.c (original)
+++ team/mmichelson/queue-reset/main/config.c Wed Mar 19 16:17:07 2008
@@ -1621,15 +1621,21 @@
 			if (!cat->precomments)
 				fprintf(f,"\n");
 			fprintf(f, "[%s]", cat->name);
-			if (cat->ignored)
-				fprintf(f, "(!)");
-			if (!AST_LIST_EMPTY(&cat->template_instances)) {
-				struct ast_category_template_instance *x;
+			if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) {
 				fprintf(f, "(");
-				AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
-					fprintf(f,"%s",x->name);
-					if (x != AST_LIST_LAST(&cat->template_instances))
-						fprintf(f,",");
+				if (cat->ignored) {
+					fprintf(f, "!");
+				}
+				if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) {
+					fprintf(f, ",");
+				}
+				if (!AST_LIST_EMPTY(&cat->template_instances)) {
+					struct ast_category_template_instance *x;
+					AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
+						fprintf(f,"%s",x->name);
+						if (x != AST_LIST_LAST(&cat->template_instances))
+							fprintf(f,",");
+					}
 				}
 				fprintf(f, ")");
 			}

Modified: team/mmichelson/queue-reset/main/http.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/main/http.c?view=diff&rev=110089&r1=110088&r2=110089
==============================================================================
--- team/mmichelson/queue-reset/main/http.c (original)
+++ team/mmichelson/queue-reset/main/http.c Wed Mar 19 16:17:07 2008
@@ -32,8 +32,6 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/paths.h"	/* use ast_config_AST_DATA_DIR */
-#include "asterisk/network.h"
 #include <time.h>
 #include <sys/time.h>
 #include <sys/stat.h>
@@ -44,6 +42,8 @@
 #include <gmime/gmime.h>
 #endif /* ENABLE_UPLOADS */
 
+#include "asterisk/paths.h"	/* use ast_config_AST_DATA_DIR */
+#include "asterisk/network.h"
 #include "asterisk/cli.h"
 #include "asterisk/tcptls.h"
 #include "asterisk/http.h"
@@ -53,6 +53,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/ast_version.h"
 #include "asterisk/manager.h"
+#include "asterisk/_private.h"
 
 #define MAX_PREFIX 80
 
@@ -135,17 +136,22 @@
 static const char *ftype2mtype(const char *ftype, char *wkspace, int wkspacelen)
 {
 	int x;
+
 	if (ftype) {
-		for (x=0;x<sizeof(mimetypes) / sizeof(mimetypes[0]); x++) {
-			if (!strcasecmp(ftype, mimetypes[x].ext))
+		for (x = 0; x < ARRAY_LEN(mimetypes); x++) {
+			if (!strcasecmp(ftype, mimetypes[x].ext)) {
 				return mimetypes[x].mtype;
-		}
-	}
-	snprintf(wkspace, wkspacelen, "text/%s", ftype ? ftype : "plain");
+			}
+		}
+	}
+
+	snprintf(wkspace, wkspacelen, "text/%s", S_OR(ftype, "plain"));
+
 	return wkspace;
 }
 
-static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser, const char *uri, struct ast_variable *vars, int *status, char **title, int *contentlength)
+static struct ast_str *static_callback(struct ast_tcptls_session_instance *ser, const char *uri, enum ast_http_method method,
+				       struct ast_variable *vars, int *status, char **title, int *contentlength)
 {
 	char *path;
 	char *ftype;
@@ -160,32 +166,43 @@
 
 	/* Yuck.  I'm not really sold on this, but if you don't deliver static content it makes your configuration 
 	   substantially more challenging, but this seems like a rather irritating feature creep on Asterisk. */
-	if (!enablestatic || ast_strlen_zero(uri))
+	if (!enablestatic || ast_strlen_zero(uri)) {
 		goto out403;
+	}
+
 	/* Disallow any funny filenames at all */
-	if ((uri[0] < 33) || strchr("./|~@#$%^&*() \t", uri[0]))
+	if ((uri[0] < 33) || strchr("./|~@#$%^&*() \t", uri[0])) {
 		goto out403;
-	if (strstr(uri, "/.."))
+	}
+
+	if (strstr(uri, "/..")) {
 		goto out403;
+	}
 		
-	if ((ftype = strrchr(uri, '.')))
+	if ((ftype = strrchr(uri, '.'))) {
 		ftype++;
+	}
+
 	mtype = ftype2mtype(ftype, wkspace, sizeof(wkspace));
 	
 	/* Cap maximum length */
-	len = strlen(uri) + strlen(ast_config_AST_DATA_DIR) + strlen("/static-http/") + 5;
-	if (len > 1024)
+	if ((len = strlen(uri) + strlen(ast_config_AST_DATA_DIR) + strlen("/static-http/") + 5)) {
 		goto out403;
+	}
 		
 	path = alloca(len);
 	sprintf(path, "%s/static-http/%s", ast_config_AST_DATA_DIR, uri);
-	if (stat(path, &st))
+	if (stat(path, &st)) {
 		goto out404;
-	if (S_ISDIR(st.st_mode))
+	}
+
+	if (S_ISDIR(st.st_mode)) {
 		goto out404;
-	fd = open(path, O_RDONLY);
-	if (fd < 0)
+	}
+
+	if ((fd = open(path, O_RDONLY)) < 0) {
 		goto out403;
+	}
 
 	ast_strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %Z", ast_localtime(&tv, &tm, "GMT"));
 	fprintf(ser->f, "HTTP/1.1 200 OK\r\n"
@@ -197,57 +214,69 @@
 		"Content-type: %s\r\n\r\n",
 		ast_get_version(), buf, (int) st.st_size, mtype);
 
-	while ((len = read(fd, buf, sizeof(buf))) > 0)
+	while ((len = read(fd, buf, sizeof(buf))) > 0) {
 		fwrite(buf, 1, len, ser->f);
+	}
 
 	close(fd);
+
 	return NULL;
 
 out404:
-	*status = 404;
-	*title = ast_strdup("Not Found");
-	return ast_http_error(404, "Not Found", NULL, "Nothing to see here.  Move along.");
+	return ast_http_error((*status = 404),
+			      (*title = ast_strdup("Not Found")),
+			       NULL, "Nothing to see here.  Move along.");
 
 out403:
-	*status = 403;
-	*title = ast_strdup("Access Denied");
-	return ast_http_error(403, "Access Denied", NULL, "Sorry, I cannot let you do that, Dave.");
-}
-
-

[... 1660 lines stripped ...]



More information about the asterisk-commits mailing list