[asterisk-commits] twilson: trunk r97634 - in /trunk: ./ configs/ doc/tex/ funcs/ include/asteri...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 9 15:37:27 CST 2008


Author: twilson
Date: Wed Jan  9 15:37:26 2008
New Revision: 97634

URL: http://svn.digium.com/view/asterisk?view=rev&rev=97634
Log:
Added a new module, res_phoneprov, which allows auto-provisioning of phones
based on configuration templates that use Asterisk dialplan function and
variable substitution.  It should be possible to create phone profiles and
templates that work for the majority of phones provisioned over http. It
is currently only intended to provision a single user account per phone.
An example profile and set of templates for Polycom phones is provided.
NOTE: Polycom firmware is not included, but should be placed in
AST_DATA_DIR/phoneprov/configs to match up with the included templates.


Added:
    trunk/configs/phoneprov.conf.sample
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/configs/phoneprov.conf.sample
    trunk/doc/tex/phoneprov.tex
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/doc/tex/phoneprov.tex
    trunk/phoneprov/
      - copied from r97633, team/twilson/private/phoneprov-update-trunk/phoneprov/
    trunk/phoneprov/000000000000-directory.xml
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/phoneprov/000000000000-directory.xml
    trunk/phoneprov/000000000000-phone.cfg
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/phoneprov/000000000000-phone.cfg
    trunk/phoneprov/000000000000.cfg
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/phoneprov/000000000000.cfg
    trunk/phoneprov/polycom.xml
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/phoneprov/polycom.xml
    trunk/res/res_phoneprov.c
      - copied unchanged from r97633, team/twilson/private/phoneprov-update-trunk/res/res_phoneprov.c
Modified:
    trunk/CHANGES
    trunk/Makefile
    trunk/configs/modules.conf.sample
    trunk/doc/tex/asterisk.tex
    trunk/funcs/func_strings.c
    trunk/include/asterisk/localtime.h
    trunk/main/acl.c
    trunk/main/stdtime/localtime.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Wed Jan  9 15:37:26 2008
@@ -436,3 +436,11 @@
   * Added a new codec translation module, codec_resample, which re-samples
      signed linear audio between 8 kHz and 16 kHz to help support wideband
      codecs.
+  * Added a new module, res_phoneprov, which allows auto-provisioning of phones
+     based on configuration templates that use Asterisk dialplan function and
+     variable substitution.  It should be possible to create phone profiles and
+     templates that work for the majority of phones provisioned over http. It
+     is currently only intended to provision a single user account per phone.
+     An example profile and set of templates for Polycom phones is provided.
+     NOTE: Polycom firmware is not included, but should be placed in
+     AST_DATA_DIR/phoneprov/configs to match up with the included templates. 

Modified: trunk/Makefile
URL: http://svn.digium.com/view/asterisk/trunk/Makefile?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/Makefile (original)
+++ trunk/Makefile Wed Jan  9 15:37:26 2008
@@ -450,6 +450,10 @@
 # Should static HTTP be installed during make samples or even with its own target ala
 # webvoicemail?  There are portions here that *could* be customized but might also be
 # improved a lot.  I'll put it here for now.
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
+	for x in phoneprov/*; do \
+		$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/phoneprov ; \
+	done
 	mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
 	for x in static-http/*; do \
 		$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \

Modified: trunk/configs/modules.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/modules.conf.sample?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/configs/modules.conf.sample (original)
+++ trunk/configs/modules.conf.sample Wed Jan  9 15:37:26 2008
@@ -18,6 +18,9 @@
 ;preload => res_odbc.so
 ;preload => res_config_odbc.so
 ;
+; res_phoneprov requires func_strings.so to be loaded:
+preload => func_strings.so
+;
 ; Uncomment the following if you wish to use the Speech Recognition API
 ;preload => res_speech.so
 ;

Modified: trunk/doc/tex/asterisk.tex
URL: http://svn.digium.com/view/asterisk/trunk/doc/tex/asterisk.tex?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/doc/tex/asterisk.tex (original)
+++ trunk/doc/tex/asterisk.tex Wed Jan  9 15:37:26 2008
@@ -32,7 +32,7 @@
 
 
 \author{Asterisk Development Team \\ Asterisk.org}
-\title{Asterisk Reference Information \\ Version ASTERISKVERSION}
+\title{Asterisk Reference Information \\ Version }
 
 \begin{document}
 \maketitle
@@ -132,6 +132,9 @@
   \section{Queue Logs}
   \input{queuelog.tex}
 
+\chapter{Phone Provisioning}
+  \input{phoneprov.tex}
+
 \chapter{Development}
   \section{Backtrace}
   \input{backtrace.tex}

Modified: trunk/funcs/func_strings.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_strings.c?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/funcs/func_strings.c (original)
+++ trunk/funcs/func_strings.c Wed Jan  9 15:37:26 2008
@@ -30,6 +30,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include <regex.h>
+#include <ctype.h>
 
 #include "asterisk/module.h"
 #include "asterisk/channel.h"
@@ -800,6 +801,40 @@
 	.desc = "Example:  ${KEYPADHASH(Les)} returns \"537\"\n",
 };
 
+static int string_toupper(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+	char *bufptr = buf, *dataptr = data;
+
+	while ((bufptr < buf + len - 1) && (*bufptr++ = toupper(*dataptr++)));
+
+	return 0;
+}
+
+static struct ast_custom_function toupper_function = {
+	.name = "TOUPPER",
+	.synopsis = "Convert the string to upper case.",
+	.syntax = "TOUPPER(<string>)",
+	.read = string_toupper,
+	.desc = "Example: ${TOUPPER(Example)} returns \"EXAMPLE\"\n",
+};
+
+static int string_tolower(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+	char *bufptr = buf, *dataptr = data;
+
+	while ((bufptr < buf + len - 1) && (*bufptr++ = tolower(*dataptr++)));
+
+	return 0;
+}
+
+static struct ast_custom_function tolower_function = {
+	.name = "TOLOWER",
+	.synopsis = "Convert the string to lower case.",
+	.syntax = "TOLOWER(<string>)",
+	.read = string_tolower,
+	.desc = "Example: ${TOLOWER(Example)} returns \"example\"\n",
+};
+
 static int unload_module(void)
 {
 	int res = 0;
@@ -818,6 +853,8 @@
 	res |= ast_custom_function_unregister(&hashkeys_function);
 	res |= ast_custom_function_unregister(&hash_function);
 	res |= ast_unregister_application(app_clearhash);
+	res |= ast_custom_function_unregister(&toupper_function);
+	res |= ast_custom_function_unregister(&tolower_function);
 
 	return res;
 }
@@ -840,6 +877,8 @@
 	res |= ast_custom_function_register(&hashkeys_function);
 	res |= ast_custom_function_register(&hash_function);
 	res |= ast_register_application(app_clearhash, exec_clearhash, syn_clearhash, desc_clearhash);
+	res |= ast_custom_function_register(&toupper_function);
+	res |= ast_custom_function_register(&tolower_function);
 
 	return res;
 }

Modified: trunk/include/asterisk/localtime.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/localtime.h?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/include/asterisk/localtime.h (original)
+++ trunk/include/asterisk/localtime.h Wed Jan  9 15:37:26 2008
@@ -41,6 +41,7 @@
 };
 
 struct ast_tm *ast_localtime(const struct timeval *timep, struct ast_tm *p_tm, const char *zone);
+void ast_get_dst_info(const time_t * const timep, int *dst_enabled, time_t *dst_start, time_t *dst_end, int *gmt_off, const char * const zone);
 struct timeval ast_mktime(struct ast_tm * const tmp, const char *zone);
 int ast_strftime(char *buf, size_t len, const char *format, const struct ast_tm *tm);
 

Modified: trunk/main/acl.c
URL: http://svn.digium.com/view/asterisk/trunk/main/acl.c?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/main/acl.c (original)
+++ trunk/main/acl.c Wed Jan  9 15:37:26 2008
@@ -38,11 +38,6 @@
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
 #include "asterisk/srv.h"
-
-struct my_ifreq {
-	char ifrn_name[IFNAMSIZ];	/* Interface name, e.g. "eth0", "ppp0", etc.  */
-	struct sockaddr_in ifru_addr;
-};
 
 /* Free HA structure */
 void ast_free_ha(struct ast_ha *ha)

Modified: trunk/main/stdtime/localtime.c
URL: http://svn.digium.com/view/asterisk/trunk/main/stdtime/localtime.c?view=diff&rev=97634&r1=97633&r2=97634
==============================================================================
--- trunk/main/stdtime/localtime.c (original)
+++ trunk/main/stdtime/localtime.c Wed Jan  9 15:37:26 2008
@@ -1144,6 +1144,121 @@
 }
 
 /*
+** This function provides informaton about daylight savings time 
+** for the given timezone.  This includes whether it can determine 
+** if daylight savings is used for this timezone, the UTC times for 
+** when daylight savings transitions, and the offset in seconds from 
+** UTC. 
+*/
+
+void ast_get_dst_info(const time_t * const timep, int *dst_enabled, time_t *dst_start, time_t *dst_end, int *gmt_off, const char * const zone)
+{
+	int i;	
+	int transition1 = -1;
+	int transition2 = -1;
+	time_t		seconds;
+	int  bounds_exceeded = 0;
+	time_t  t = *timep;
+	const struct state *sp;
+	
+	if (NULL == dst_enabled)
+		return;
+	*dst_enabled = 0;
+
+	if (NULL == dst_start || NULL == dst_end || NULL == gmt_off)
+		return;
+
+	*gmt_off = 0; 
+	
+	sp = ast_tzset(zone);
+	if (NULL == sp) 
+		return;
+	
+	/* If the desired time exceeds the bounds of the defined time transitions  
+	* then give give up on determining DST info and simply look for gmt offset 
+	* This requires that I adjust the given time using increments of Gregorian 
+	* repeats to place the time within the defined time transitions in the 
+	* timezone structure.  
+	*/
+	if ((sp->goback && t < sp->ats[0]) ||
+			(sp->goahead && t > sp->ats[sp->timecnt - 1])) {
+		time_t		tcycles;
+		int_fast64_t	icycles;
+
+		if (t < sp->ats[0])
+			seconds = sp->ats[0] - t;
+		else	seconds = t - sp->ats[sp->timecnt - 1];
+		--seconds;
+		tcycles = seconds / YEARSPERREPEAT / AVGSECSPERYEAR;
+		++tcycles;
+		icycles = tcycles;
+		if (tcycles - icycles >= 1 || icycles - tcycles >= 1)
+			return;
+		seconds = icycles;
+		seconds *= YEARSPERREPEAT;
+		seconds *= AVGSECSPERYEAR;
+		if (t < sp->ats[0])
+			t += seconds;
+		else
+			t -= seconds;
+		
+		if (t < sp->ats[0] || t > sp->ats[sp->timecnt - 1])
+			return;	/* "cannot happen" */
+
+		bounds_exceeded = 1;
+	}
+
+	if (sp->timecnt == 0 || t < sp->ats[0]) {
+		/* I have no transition times or I'm before time */
+		*dst_enabled = 0;
+		/* Find where I can get gmtoff */
+		i = 0;
+		while (sp->ttis[i].tt_isdst)
+			if (++i >= sp->typecnt) {
+			i = 0;
+			break;
+			}
+			*gmt_off = sp->ttis[i].tt_gmtoff;
+			return;
+	} 
+
+	for (i = 1; i < sp->timecnt; ++i) {
+		if (t < sp->ats[i]) {
+			transition1 = sp->types[i - 1];
+			transition2 = sp->types[i];
+			break;
+		} 
+	}
+	/* if I found transition times that do not bounded the given time and these correspond to 
+		or the bounding zones do not reflect a changes in day light savings, then I do not have dst active */
+	if (i >= sp->timecnt || 0 > transition1 || 0 > transition2 ||
+			(sp->ttis[transition1].tt_isdst == sp->ttis[transition2].tt_isdst)) {
+		*dst_enabled = 0;
+		*gmt_off 	 = sp->ttis[sp->types[sp->timecnt -1]].tt_gmtoff;
+	} else {
+		/* I have valid daylight savings information. */
+		if(sp->ttis[transition2].tt_isdst) 
+			*gmt_off = sp->ttis[transition1].tt_gmtoff;
+		else 
+			*gmt_off = sp->ttis[transition2].tt_gmtoff;
+
+		/* If I adjusted the time earlier, indicate that the dst is invalid */
+		if (!bounds_exceeded) {
+			*dst_enabled = 1;
+			/* Determine which of the bounds is the start of daylight savings and which is the end */
+			if(sp->ttis[transition2].tt_isdst) {
+				*dst_start = sp->ats[i];
+				*dst_end = sp->ats[i -1];
+			} else {
+				*dst_start = sp->ats[i -1];
+				*dst_end = sp->ats[i];
+			}
+		}
+	}	
+	return;
+}
+
+/*
 ** gmtsub is to gmtime as localsub is to localtime.
 */
 




More information about the asterisk-commits mailing list