[asterisk-commits] murf: branch murf/bug7978 r48660 - in /team/murf/bug7978: ./ apps/ channels/ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Dec 20 16:45:58 MST 2006


Author: murf
Date: Wed Dec 20 17:45:58 2006
New Revision: 48660

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48660
Log:
Merged revisions 48587-48589,48591,48593,48595,48597-48599,48638-48639 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r48587 | kpfleming | 2006-12-19 14:28:43 -0700 (Tue, 19 Dec 2006) | 10 lines

Merged revisions 48586 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48586 | kpfleming | 2006-12-19 15:28:04 -0600 (Tue, 19 Dec 2006) | 2 lines

suppress compiler warnings in this module until it can be improved

........

................
r48588 | rizzo | 2006-12-19 14:29:55 -0700 (Tue, 19 Dec 2006) | 5 lines

start documenting this code.
On passing, fix the bogus datalen on outgoing frames
just fixed in 1.4 rev.48583


................
r48589 | rizzo | 2006-12-19 14:32:31 -0700 (Tue, 19 Dec 2006) | 2 lines

block 48583

................
r48591 | file | 2006-12-19 14:59:33 -0700 (Tue, 19 Dec 2006) | 2 lines

OpenBSD does not have RLIMIT_AS or RLIMIT_VMEM so until someone finds the right rlimit to use then let's not support the -v option on OpenBSD. (issue #8543 reported by jtodd)

................
r48593 | file | 2006-12-19 15:02:27 -0700 (Tue, 19 Dec 2006) | 10 lines

Merged revisions 48592 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48592 | file | 2006-12-19 17:00:57 -0500 (Tue, 19 Dec 2006) | 2 lines

find is not the same as bind when it comes to documentation. (issue #8626 reported by johann8384)

........

................
r48595 | file | 2006-12-19 15:55:26 -0700 (Tue, 19 Dec 2006) | 2 lines

Update res_snmp to use new API declaration of pbx_builtin_serialize_variables (issue #8627 reported by johann8384)

................
r48597 | file | 2006-12-19 16:05:57 -0700 (Tue, 19 Dec 2006) | 10 lines

Merged revisions 48596 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48596 | file | 2006-12-19 18:04:30 -0500 (Tue, 19 Dec 2006) | 2 lines

Pass 'vms' pointer to record_and_review so it is then passed to the IMAP store file function. (issue #8614 reported by punknow)

........

................
r48598 | rizzo | 2006-12-19 16:56:08 -0700 (Tue, 19 Dec 2006) | 4 lines

formatting and code cleanup.
Still a lot of copy&pasted code here...


................
r48599 | rizzo | 2006-12-19 17:13:23 -0700 (Tue, 19 Dec 2006) | 5 lines

more formatting cleanup.
Move some code into a function sms_compose1() in preparation
for supporting protocol 2 as well.


................
r48638 | file | 2006-12-19 19:58:13 -0700 (Tue, 19 Dec 2006) | 10 lines

Merged revisions 48637 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48637 | file | 2006-12-19 21:56:09 -0500 (Tue, 19 Dec 2006) | 2 lines

vms doesn't exist on non-IMAP storage builds.

........

................
r48639 | file | 2006-12-19 21:32:59 -0700 (Tue, 19 Dec 2006) | 2 lines

Clean up app_page

................

Modified:
    team/murf/bug7978/   (props changed)
    team/murf/bug7978/apps/app_page.c
    team/murf/bug7978/apps/app_sms.c
    team/murf/bug7978/apps/app_voicemail.c
    team/murf/bug7978/channels/Makefile
    team/murf/bug7978/doc/snmp.txt
    team/murf/bug7978/res/res_limit.c
    team/murf/bug7978/res/snmp/agent.c

Propchange: team/murf/bug7978/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/murf/bug7978/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/murf/bug7978/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed Dec 20 17:45:58 2006
@@ -1,1 +1,1 @@
-/trunk:1-48585
+/trunk:1-48659

Modified: team/murf/bug7978/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/apps/app_page.c?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/apps/app_page.c (original)
+++ team/murf/bug7978/apps/app_page.c Wed Dec 20 17:45:58 2006
@@ -88,9 +88,12 @@
 static void *page_thread(void *data)
 {
 	struct calloutdata *cd = data;
+
 	ast_pbx_outgoing_app(cd->tech, AST_FORMAT_SLINEAR, cd->resource, 30000,
 		"MeetMe", cd->meetmeopts, NULL, 0, cd->cidnum, cd->cidname, cd->variables, NULL, NULL);
+
 	free(cd);
+
 	return NULL;
 }
 
@@ -102,42 +105,46 @@
 	struct ast_var_t *varptr;
 	pthread_t t;
 	pthread_attr_t attr;
-	if ((cd = ast_calloc(1, sizeof(*cd)))) {
-		ast_copy_string(cd->cidnum, chan->cid.cid_num ? chan->cid.cid_num : "", sizeof(cd->cidnum));
-		ast_copy_string(cd->cidname, chan->cid.cid_name ? chan->cid.cid_name : "", sizeof(cd->cidname));
-		ast_copy_string(cd->tech, tech, sizeof(cd->tech));
-		ast_copy_string(cd->resource, resource, sizeof(cd->resource));
-		ast_copy_string(cd->meetmeopts, meetmeopts, sizeof(cd->meetmeopts));
-
-		AST_LIST_TRAVERSE(&chan->varshead, varptr, entries) {
-			if (!(varname = ast_var_full_name(varptr)))
-				continue;
-			if (varname[0] == '_') {
-				struct ast_variable *newvar = NULL;
-
-				if (varname[1] == '_') {
-					newvar = ast_variable_new(varname, ast_var_value(varptr));
-				} else {
-					newvar = ast_variable_new(&varname[1], ast_var_value(varptr));
-				}
-
-				if (newvar) {
-					if (lastvar)
-						lastvar->next = newvar;
-					else
-						cd->variables = newvar;
-					lastvar = newvar;
-				}
-			}
+
+	if (!(cd = ast_calloc(1, sizeof(*cd))))
+		return;
+
+	/* Copy data from our page over */
+	ast_copy_string(cd->cidnum, chan->cid.cid_num ? chan->cid.cid_num : "", sizeof(cd->cidnum));
+	ast_copy_string(cd->cidname, chan->cid.cid_name ? chan->cid.cid_name : "", sizeof(cd->cidname));
+	ast_copy_string(cd->tech, tech, sizeof(cd->tech));
+	ast_copy_string(cd->resource, resource, sizeof(cd->resource));
+	ast_copy_string(cd->meetmeopts, meetmeopts, sizeof(cd->meetmeopts));
+	
+	AST_LIST_TRAVERSE(&chan->varshead, varptr, entries) {
+		struct ast_variable *newvar = NULL;
+
+		if (!(varname = ast_var_full_name(varptr)) || (varname[0] != '_'))
+			continue;
+			
+		if (varname[1] == '_')
+			newvar = ast_variable_new(varname, ast_var_value(varptr));
+		else
+			newvar = ast_variable_new(&varname[1], ast_var_value(varptr));
+		
+		if (newvar) {
+			if (lastvar)
+				lastvar->next = newvar;
+			else
+				cd->variables = newvar;
+			lastvar = newvar;
 		}
-
-		pthread_attr_init(&attr);
-		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-		if (ast_pthread_create(&t, &attr, page_thread, cd)) {
-			ast_log(LOG_WARNING, "Unable to create paging thread: %s\n", strerror(errno));
-			free(cd);
-		}
-	}
+	}
+
+	/* Spawn thread to handle this page */
+	pthread_attr_init(&attr);
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	if (ast_pthread_create(&t, &attr, page_thread, cd)) {
+		ast_log(LOG_WARNING, "Unable to create paging thread: %s\n", strerror(errno));
+		free(cd);
+	}
+
+	return;
 }
 
 static int page_exec(struct ast_channel *chan, void *data)
@@ -197,6 +204,7 @@
 		if (!res)
 			res = ast_waitstream(chan, "");
 	}
+
 	if (!res) {
 		snprintf(meetmeopts, sizeof(meetmeopts), "%ud|A%s%sqxd", confid, (ast_test_flag(&flags, PAGE_DUPLEX) ? "" : "t"), 
 			(ast_test_flag(&flags, PAGE_RECORD) ? "r" : "") );

Modified: team/murf/bug7978/apps/app_sms.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/apps/app_sms.c?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/apps/app_sms.c (original)
+++ team/murf/bug7978/apps/app_sms.c Wed Dec 20 17:45:58 2006
@@ -46,8 +46,7 @@
 #include "asterisk/alaw.h"
 #include "asterisk/callerid.h"
 
-/* output using Alaw rather than linear */
-/* #define OUTALAW */
+/* #define OUTALAW */ /* enable this to output Alaw rather than linear */
 
 /* ToDo */
 /* Add full VP support */
@@ -80,6 +79,12 @@
 	"smsq (a separate software) is a command to generate message\n"
 	"queues and send messages.\n";
 
+/*
+ * 80 samples of a single period of the wave. At 8000 Hz, it means these
+ * are the samples of a 100 Hz signal.
+ * To pick the two carriers (1300Hz for '1' and 2100 Hz for '0') used by
+ * the modulation, we should take one every 13 and 21 samples respectively.
+ */
 static signed short wave[] = {
 	0, 392, 782, 1167, 1545, 1913, 2270, 2612, 2939, 3247, 3536, 3802, 4045, 4263, 4455, 4619, 4755, 4862, 4938, 4985,
 	5000, 4985, 4938, 4862, 4755, 4619, 4455, 4263, 4045, 3802, 3536, 3247, 2939, 2612, 2270, 1913, 1545, 1167, 782, 392,
@@ -91,6 +96,13 @@
 
 #ifdef OUTALAW
 static unsigned char wavea[80];
+typedef unsigned char output_t;
+static const output_t *wave_out = wavea;	/* outgoing samples */
+#define __OUT_FMT AST_FORMAT_ALAW;
+#else
+typedef signed short output_t;
+static const output_t *wave_out = wave;		/* outgoing samples */
+#define __OUT_FMT AST_FORMAT_SLINEAR
 #endif
 
 
@@ -152,27 +164,27 @@
 	unsigned char obytep;        /*!< byte in data */
 	unsigned char obyten;        /*!< bytes in data */
 	unsigned char omsg[256];     /*!< data buffer (out) */
-	unsigned char imsg[200];     /*!< data buffer (in) */
+	unsigned char imsg[250];     /*!< data buffer (in) */
 	signed long long ims0,
 		imc0,
 		ims1,
 		imc1;                      /*!< magnitude averages sin/cos 0/1 */
 	unsigned int idle;
 	unsigned short imag;         /*!< signal level */
-	unsigned char ips0,
-		ips1,
-		ipc0,
-		ipc1;                      /*!< phase sin/cos 0/1 */
+	unsigned char ips0;	     /*!< phase sin for bit 0, start at  0 inc by 21 mod 80 */
+	unsigned char ips1;	     /*!< phase cos for bit 0, start at 20 inc by 21 mod 80 */
+	unsigned char ipc0;	     /*!< phase sin for bit 1, start at  0 inc by 13 mod 80 */
+	unsigned char ipc1;	     /*!< phase cos for bit 1, start at 20 inc by 13 mod 80 */
 	unsigned char ibitl;         /*!< last bit */
 	unsigned char ibitc;         /*!< bit run length count */
 	unsigned char iphasep;       /*!< bit phase (0-79) for 1200 bps */
 	unsigned char ibitn;         /*!< bit number in byte being received */
 	unsigned char ibytev;        /*!< byte value being received */
-	unsigned char ibytep;        /*!< byte pointer in messafe */
+	unsigned char ibytep;        /*!< byte pointer in message */
 	unsigned char ibytec;        /*!< byte checksum for message */
 	unsigned char ierr;          /*!< error flag */
 	unsigned char ibith;         /*!< history of last bits */
-	unsigned char ibitt;         /* total of 1's in last 3 bites */
+	unsigned char ibitt;         /*!< total of 1's in last 3 bytes */
 	/* more to go here */
 } sms_t;
 
@@ -674,22 +686,19 @@
 {
 	char line[1000];
 	FILE *s;
-	char dcsset = 0;				 /* if DSC set */
+	char dcsset = 0;		/* if DSC set */
 	ast_log (LOG_EVENT, "Sending %s\n", fn);
 	h->rx = h->udl = *h->oa = *h->da = h->pid = h->srr = h->udhi = h->rp = h->vp = h->udhl = 0;
 	h->mr = -1;
-	h->dcs = 0xF1;					/* normal messages class 1 */
+	h->dcs = 0xF1;			/* normal messages class 1 */
 	h->scts = time (0);
 	s = fopen (fn, "r");
-	if (s)
-	{
-		if (unlink (fn))
-		{								 /* concurrent access, we lost */
+	if (s) {
+		if (unlink (fn)) {	/* concurrent access, we lost */
 			fclose (s);
 			return;
 		}
-		while (fgets (line, sizeof (line), s))
-		{								 /* process line in file */
+		while (fgets (line, sizeof (line), s)) {	/* process line in file */
 			char *p;
 			void *pp = &p;
 			for (p = line; *p && *p != '\n' && *p != '\r'; p++);
@@ -697,26 +706,22 @@
 			p = line;
 			if (!*p || *p == ';')
 				continue;			  /* blank line or comment, ignore */
-			while (isalnum (*p))
-			{
+			while (isalnum (*p)) {
 				*p = tolower (*p);
 				p++;
 			}
 			while (isspace (*p))
 				*p++ = 0;
-			if (*p == '=')
-			{
+			if (*p == '=') {
 				*p++ = 0;
-				if (!strcmp (line, "ud"))
-				{						 /* parse message (UTF-8) */
+				if (!strcmp (line, "ud")) {	 /* parse message (UTF-8) */
 					unsigned char o = 0;
 					while (*p && o < SMSLEN)
 						h->ud[o++] = utf8decode(pp);
 					h->udl = o;
 					if (*p)
 						ast_log (LOG_WARNING, "UD too long in %s\n", fn);
-				} else
-				{
+				} else {
 					while (isspace (*p))
 						p++;
 					if (!strcmp (line, "oa") && strlen (p) < sizeof (h->oa))
@@ -725,8 +730,7 @@
 						numcpy (h->da, p);
 					else if (!strcmp (line, "pid"))
 						h->pid = atoi (p);
-					else if (!strcmp (line, "dcs"))
-					{
+					else if (!strcmp (line, "dcs")) {
 						h->dcs = atoi (p);
 						dcsset = 1;
 					} else if (!strcmp (line, "mr"))
@@ -737,16 +741,14 @@
 						h->vp = atoi (p);
 					else if (!strcmp (line, "rp"))
 						h->rp = (atoi (p) ? 1 : 0);
-					else if (!strcmp (line, "scts"))
-					{					 /* get date/time */
+					else if (!strcmp (line, "scts")) {	/* get date/time */
 						int Y,
 						  m,
 						  d,
 						  H,
 						  M,
 						  S;
-						if (sscanf (p, "%d-%d-%dT%d:%d:%d", &Y, &m, &d, &H, &M, &S) == 6)
-						{
+						if (sscanf (p, "%d-%d-%dT%d:%d:%d", &Y, &m, &d, &H, &M, &S) == 6) {
 							struct tm t;
 							t.tm_year = Y - 1900;
 							t.tm_mon = m - 1;
@@ -762,19 +764,14 @@
 					} else
 						ast_log (LOG_WARNING, "Cannot parse in %s: %s=%si\n", fn, line, p);
 				}
-			} else if (*p == '#')
-			{							 /* raw hex format */
+			} else if (*p == '#') {		/* raw hex format */
 				*p++ = 0;
-				if (*p == '#')
-				{
+				if (*p == '#') {
 					p++;
-					if (!strcmp (line, "ud"))
-					{					 /* user data */
+					if (!strcmp (line, "ud")) {	/* user data */
 						int o = 0;
-						while (*p && o < SMSLEN)
-						{
-							if (isxdigit (*p) && isxdigit (p[1]) && isxdigit (p[2]) && isxdigit (p[3]))
-							{
+						while (*p && o < SMSLEN) {
+							if (isxdigit (*p) && isxdigit (p[1]) && isxdigit (p[2]) && isxdigit (p[3])) {
 								h->ud[o++] =
 									(((isalpha (*p) ? 9 : 0) + (*p & 0xF)) << 12) +
 									(((isalpha (p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
@@ -788,13 +785,10 @@
 							ast_log (LOG_WARNING, "UD too long / invalid UCS-2 hex in %s\n", fn);
 					} else
 						ast_log (LOG_WARNING, "Only ud can use ## format, %s\n", fn);
-				} else if (!strcmp (line, "ud"))
-				{						 /* user data */
+				} else if (!strcmp (line, "ud")) {	/* user data */
 					int o = 0;
-					while (*p && o < SMSLEN)
-					{
-						if (isxdigit (*p) && isxdigit (p[1]))
-						{
+					while (*p && o < SMSLEN) {
+						if (isxdigit (*p) && isxdigit (p[1])) {
 							h->ud[o++] = (((isalpha (*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha (p[1]) ? 9 : 0) + (p[1] & 0xF));
 							p += 2;
 						} else
@@ -803,14 +797,11 @@
 					h->udl = o;
 					if (*p)
 						ast_log (LOG_WARNING, "UD too long / invalid UCS-1 hex in %s\n", fn);
-				} else if (!strcmp (line, "udh"))
-				{						 /* user data header */
+				} else if (!strcmp (line, "udh")) {	/* user data header */
 					unsigned char o = 0;
 					h->udhi = 1;
-					while (*p && o < SMSLEN)
-					{
-						if (isxdigit (*p) && isxdigit (p[1]))
-						{
+					while (*p && o < SMSLEN) {
+						if (isxdigit (*p) && isxdigit (p[1])) {
 							h->udh[o] = (((isalpha (*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha (p[1]) ? 9 : 0) + (p[1] & 0xF));
 							o++;
 							p += 2;
@@ -826,19 +817,15 @@
 				ast_log (LOG_WARNING, "Cannot parse in %s: %s\n", fn, line);
 		}
 		fclose (s);
-		if (!dcsset && packsms7 (0, h->udhl, h->udh, h->udl, h->ud) < 0)
-		{
-			if (packsms8 (0, h->udhl, h->udh, h->udl, h->ud) < 0)
-			{
+		if (!dcsset && packsms7 (0, h->udhl, h->udh, h->udl, h->ud) < 0) {
+			if (packsms8 (0, h->udhl, h->udh, h->udl, h->ud) < 0) {
 				if (packsms16 (0, h->udhl, h->udh, h->udl, h->ud) < 0)
 					ast_log (LOG_WARNING, "Invalid UTF-8 message even for UCS-2 (%s)\n", fn);
-				else
-				{
+				else {
 					h->dcs = 0x08;	/* default to 16 bit */
 					ast_log (LOG_WARNING, "Sending in 16 bit format (%s)\n", fn);
 				}
-			} else
-			{
+			} else {
 				h->dcs = 0xF5;		/* default to 8 bit */
 				ast_log (LOG_WARNING, "Sending in 8 bit format (%s)\n", fn);
 			}
@@ -1020,17 +1007,59 @@
 #define NAME_MAX 1024
 #endif
 
+/*! \brief compose a message for protocol 1 */
+static void sms_compose1(sms_t *h, int more)
+{
+	unsigned int p = 2;	/* next byte to write. Skip type and len */
+
+	h->omsg[0] = 0x91;		  /* SMS_DATA */
+	if (h->smsc) {			 /* deliver */
+		h->omsg[p++] = (more ? 4 : 0) + ((h->udhl > 0) ? 0x40 : 0);
+		p += packaddress (h->omsg + p, h->oa);
+		h->omsg[p++] = h->pid;
+		h->omsg[p++] = h->dcs;
+		packdate (h->omsg + p, h->scts);
+		p += 7;
+		p += packsms (h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud);
+	} else {			 /* submit */
+		h->omsg[p++] =
+			0x01 + (more ? 4 : 0) + (h->srr ? 0x20 : 0) + (h->rp ? 0x80 : 0) + (h->vp ? 0x10 : 0) + (h->udhi ? 0x40 : 0);
+		if (h->mr < 0)
+			h->mr = message_ref++;
+		h->omsg[p++] = h->mr;
+		p += packaddress (h->omsg + p, h->da);
+		h->omsg[p++] = h->pid;
+		h->omsg[p++] = h->dcs;
+		if (h->vp) {		 /* relative VP */
+			if (h->vp < 720)
+				h->omsg[p++] = (h->vp + 4) / 5 - 1;
+			else if (h->vp < 1440)
+				h->omsg[p++] = (h->vp - 720 + 29) / 30 + 143;
+			else if (h->vp < 43200)
+				h->omsg[p++] = (h->vp + 1439) / 1440 + 166;
+			else if (h->vp < 635040)
+				h->omsg[p++] = (h->vp + 10079) / 10080 + 192;
+			else
+				h->omsg[p++] = 255;		/* max */
+		}
+		p += packsms (h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud);
+	}
+	h->omsg[1] = p - 2;
+}
+
 /*! \brief find and fill in next message, or send a REL if none waiting */
 static void sms_nextoutgoing (sms_t * h)
 {          
 	char fn[100 + NAME_MAX] = "";
 	DIR *d;
 	char more = 0;
+
+	*h->da = *h->oa = '\0';			/* clear destinations */
 	ast_copy_string (fn, spool_dir, sizeof (fn));
-	mkdir (fn, 0777);				/* ensure it exists */
-	h->rx = 0;						 /* outgoing message */
+	mkdir(fn, 0777);			/* ensure it exists */
+	h->rx = 0;				/* outgoing message */
 	snprintf (fn + strlen (fn), sizeof (fn) - strlen (fn), "/%s", h->smsc ? "mttx" : "motx");
-	mkdir (fn, 0777);				/* ensure it exists */
+	mkdir (fn, 0777);			/* ensure it exists */
 	d = opendir (fn);
 	if (d) {
 		struct dirent *f = readdirqueue (d, h->queue);
@@ -1043,46 +1072,12 @@
 		closedir (d);
 	}
 	if (*h->da || *h->oa) {									 /* message to send */
-		unsigned char p = 2;
-		h->omsg[0] = 0x91;		  /* SMS_DATA */
-		if (h->smsc) {			 /* deliver */
-			h->omsg[p++] = (more ? 4 : 0) + ((h->udhl > 0) ? 0x40 : 0);
-			p += packaddress (h->omsg + p, h->oa);
-			h->omsg[p++] = h->pid;
-			h->omsg[p++] = h->dcs;
-			packdate (h->omsg + p, h->scts);
-			p += 7;
-			p += packsms (h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud);
-		} else {			 /* submit */
-			h->omsg[p++] =
-				0x01 + (more ? 4 : 0) + (h->srr ? 0x20 : 0) + (h->rp ? 0x80 : 0) + (h->vp ? 0x10 : 0) + (h->udhi ? 0x40 : 0);
-			if (h->mr < 0)
-				h->mr = message_ref++;
-			h->omsg[p++] = h->mr;
-			p += packaddress (h->omsg + p, h->da);
-			h->omsg[p++] = h->pid;
-			h->omsg[p++] = h->dcs;
-			if (h->vp) {		 /* relative VP */
-				if (h->vp < 720)
-					h->omsg[p++] = (h->vp + 4) / 5 - 1;
-				else if (h->vp < 1440)
-					h->omsg[p++] = (h->vp - 720 + 29) / 30 + 143;
-				else if (h->vp < 43200)
-					h->omsg[p++] = (h->vp + 1439) / 1440 + 166;
-				else if (h->vp < 635040)
-					h->omsg[p++] = (h->vp + 10079) / 10080 + 192;
-				else
-					h->omsg[p++] = 255;		/* max */
-			}
-			p += packsms (h->dcs, h->omsg + p, h->udhl, h->udh, h->udl, h->ud);
-		}
-		h->omsg[1] = p - 2;
-		sms_messagetx (h);
+		sms_compose1(h, more);
 	} else {				 /* no message */
 		h->omsg[0] = 0x94;		  /* SMS_REL */
 		h->omsg[1] = 0;
-		sms_messagetx (h);
-	}
+	}
+	sms_messagetx (h);
 }
 
 static void sms_debug (char *dir, unsigned char *msg)
@@ -1105,7 +1100,7 @@
 {
 	sms_debug ("RX", h->imsg);
 	/* testing */
-	switch (h->imsg[0]) {
+	switch (h->imsg[0]) {	/* PROTOCOL version 1 */
 	case 0x91:						/* SMS_DATA */
 		{
 			unsigned char cause = sms_handleincoming (h);
@@ -1157,30 +1152,28 @@
 static void sms_messagetx(sms_t * h)
 {
 	unsigned char c = 0, p;
-	for (p = 0; p < h->omsg[1] + 2; p++)
+	int len = h->omsg[1] + 2;	/* total message length excluding checksum */
+
+	for (p = 0; p < len; p++)	/* compute checksum */
 		c += h->omsg[p];
-	h->omsg[h->omsg[1] + 2] = 0 - c;
+	h->omsg[len] = 0 - c;		/* actually, (256 - (c & 0fxx)) & 0xff) */
 	sms_debug ("TX", h->omsg);
 	h->obyte = 1;
 	h->opause = 200;
 	if (h->omsg[0] == 0x93)
-		h->opause = 2400;			/* initial message delay 300ms (for BT) */
+		h->opause = 2400;	/* initial message delay 300ms (for BT) */
 	h->obytep = 0;
 	h->obitp = 0;
-	h->osync = 80;
-	h->obyten = h->omsg[1] + 3;
+	/* Note - setting osync triggers the generator */
+	h->osync = 80;			/* 80 sync bits */
+	h->obyten = len + 1;		/* bytes to send (including checksum) */
 }
 
 static int sms_generate (struct ast_channel *chan, void *data, int len, int samples)
 {
 	struct ast_frame f = { 0 };
 #define MAXSAMPLES (800)
-#ifdef OUTALAW
-	unsigned char *buf;
-#else
-	short *buf;
-#endif
-#define SAMPLE2LEN sizeof(*buf)
+	output_t *buf;
 	sms_t *h = data;
 	int i;
 
@@ -1189,16 +1182,12 @@
 			 MAXSAMPLES, samples);
 		samples = MAXSAMPLES;
 	}
-	len = samples * SAMPLE2LEN + AST_FRIENDLY_OFFSET;
+	len = samples * sizeof(*buf) + AST_FRIENDLY_OFFSET;
 	buf = alloca(len);
 
 	f.frametype = AST_FRAME_VOICE;
-#ifdef OUTALAW
-	f.subclass = AST_FORMAT_ALAW;
-#else
-	f.subclass = AST_FORMAT_SLINEAR;
-#endif
-	f.datalen = len;
+	f.subclass = __OUT_FMT;
+	f.datalen = samples * sizeof(*buf);
 	f.offset = AST_FRIENDLY_OFFSET;
 	f.mallocd = 0;
 	f.data = buf;
@@ -1206,27 +1195,20 @@
 	f.src = "app_sms";
 	/* create a buffer containing the digital sms pattern */
 	for (i = 0; i < samples; i++) {
-#ifdef OUTALAW
-		buf[i] = wavea[0];
-#else
-		buf[i] = wave[0];
-#endif
+		buf[i] = wave_out[0];	/* default is silence */
+
 		if (h->opause)
 			h->opause--;
-		else if (h->obyten || h->osync) {								 /* sending data */
-#ifdef OUTALAW
-			buf[i] = wavea[h->ophase];
-#else
-			buf[i] = wave[h->ophase];
-#endif
-			if ((h->ophase += ((h->obyte & 1) ? 13 : 21)) >= 80)
+		else if (h->obyten || h->osync) {		/* sending data */
+			buf[i] = wave_out[h->ophase];
+			h->ophase += (h->obyte & 1) ? 13 : 21;	/* compute next phase */
+			if (h->ophase >= 80)
 				h->ophase -= 80;
-			if ((h->ophasep += 12) >= 80) {							 /* next bit */
+			if ((h->ophasep += 12) >= 80) {		/* time to send the next bit */
 				h->ophasep -= 80;
-				if (h->osync)
+				if (h->osync) {
 					h->osync--;		/* sending sync bits */
-				else {
-					h->obyte >>= 1;
+				} else {
 					h->obitp++;
 					if (h->obitp == 1)
 						h->obyte = 0; /* start bit; */
@@ -1240,7 +1222,8 @@
 							h->obytep = h->obyten = 0; /* sent */
 							h->osync = 10;	  /* trailing marks */
 						}
-					}
+					} else
+						h->obyte >>= 1;
 				}
 			}
 		}
@@ -1250,10 +1233,21 @@
 		return -1;
 	}
 	return 0;
-#undef SAMPLE2LEN
 #undef MAXSAMPLES
 }
 
+/*!
+ * Process an incoming frame, trying to detect the carrier and
+ * decode the message. The two frequencies are 1300 and 2100 Hz.
+ * The decoder detects the amplitude of the signal over the last
+ * few samples, filtering the absolute values with a lowpass filter.
+ * If the magnitude (h->imag) is large enough, multiply the signal
+ * by the two carriers, and compute the amplitudes m0 and m1.
+ * Record the current sample as '0' or '1' depending on which one is greater.
+ * The last 3 bits are stored in h->ibith, with the count of '1'
+ * bits in h->ibitt.
+ * XXX the rest is to be determined.
+ */
 static void sms_process (sms_t * h, int samples, signed short *data)
 {
 	if (h->obyten || h->osync)
@@ -1266,12 +1260,17 @@
 			h->imag = h->imag * 7 / 8;
 		if (h->imag > 500) {
 			h->idle = 0;
+
+			/* multiply signal by the two carriers. */
 			h->ims0 = (h->ims0 * 6 + *data * wave[h->ips0]) / 7;
 			h->imc0 = (h->imc0 * 6 + *data * wave[h->ipc0]) / 7;
 			h->ims1 = (h->ims1 * 6 + *data * wave[h->ips1]) / 7;
 			h->imc1 = (h->imc1 * 6 + *data * wave[h->ipc1]) / 7;
+			/* compute the amplitudes */
 			m0 = h->ims0 * h->ims0 + h->imc0 * h->imc0;
 			m1 = h->ims1 * h->ims1 + h->imc1 * h->imc1;
+
+			/* advance the sin/cos pointers */
 			if ((h->ips0 += 21) >= 80)
 				h->ips0 -= 80;
 			if ((h->ipc0 += 21) >= 80)
@@ -1282,6 +1281,8 @@
 				h->ipc1 -= 80;
 			{
 				char bit;
+
+				/* set new bit to 1 or 0 depending on which value is stronger */
 				h->ibith <<= 1;
 				if (m1 > m0)
 					h->ibith |= 1;
@@ -1335,7 +1336,8 @@
 				h->hangup = 1;
 				h->err = 1;
 			}
-			if (h->ierr) {							 /* error */
+			if (h->ierr) {		/* error */
+				/* Protocol 1 */
 				h->err = 1;
 				h->omsg[0] = 0x92;  /* error */
 				h->omsg[1] = 1;
@@ -1470,11 +1472,7 @@
 	if (chan->_state != AST_STATE_UP)
 		ast_answer (chan);
 
-#ifdef OUTALAW
-	res = ast_set_write_format (chan, AST_FORMAT_ALAW);
-#else
-	res = ast_set_write_format (chan, AST_FORMAT_SLINEAR);
-#endif
+	res = ast_set_write_format (chan, __OUT_FMT);
 	if (res >= 0)
 		res = ast_set_read_format (chan, AST_FORMAT_SLINEAR);
 	if (res < 0) {
@@ -1490,11 +1488,21 @@
 	}
 
 	/* Do our thing here */
-	while (ast_waitfor (chan, -1) > -1 && !h.hangup)
-	{
+	for (;;) {
+		int i = ast_waitfor(chan, -1);
+		if (i < 0) {
+			ast_log(LOG_NOTICE, "waitfor failed\n");
+			break;
+		}
+		if (h.hangup) {
+			ast_log(LOG_NOTICE, "channel hangup\n");
+			break;
+		}
 		f = ast_read (chan);
-		if (!f)
+		if (!f) {
+			ast_log(LOG_NOTICE, "ast_read failed\n");
 			break;
+		}
 		if (f->frametype == AST_FRAME_VOICE) {
 			sms_process (&h, f->samples, f->data);
 		}

Modified: team/murf/bug7978/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/apps/app_voicemail.c?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/apps/app_voicemail.c (original)
+++ team/murf/bug7978/apps/app_voicemail.c Wed Dec 20 17:45:58 2006
@@ -358,7 +358,7 @@
 static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context);
 static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime,
 			char *fmt, int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir,
-			signed char record_gain);
+			signed char record_gain, struct vm_state *vms);
 static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain);
 static int vm_play_folder_name(struct ast_channel *chan, char *mbox);
 static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu, int msgnum, long duration, char *fmt, char *cidnum, char *cidname);
@@ -3085,8 +3085,12 @@
 				category ? category : ""); 
 		} else
 			ast_log(LOG_WARNING, "Error opening text file for output\n");
-		res = play_record_review(chan, NULL, tmptxtfile, vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain);
-				
+#ifdef IMAP_STORAGE
+		res = play_record_review(chan, NULL, tmptxtfile, vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain, vms);
+#else
+		res = play_record_review(chan, NULL, tmptxtfile, vmmaxmessage, fmt, 1, vmu, &duration, NULL, options->record_gain, NULL);
+#endif
+
 		if (txt) {
 			if (duration < vmminmessage) {
 				if (option_verbose > 2) 
@@ -3935,7 +3939,6 @@
 	char *temp;
 	char todir[256];
 	int todircount=0;
-	int duration;
 #endif
 	char username[70]="";
 	int res = 0, cmd = 0;
@@ -5767,7 +5770,7 @@
 	/* If forcename is set, have the user record their name */	
 	if (ast_test_flag(vmu, VM_FORCENAME)) {
 		snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
-		cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+		cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 		if (cmd < 0 || cmd == 't' || cmd == '#')
 			return cmd;
 	}
@@ -5775,11 +5778,11 @@
 	/* If forcegreetings is set, have the user record their greetings */
 	if (ast_test_flag(vmu, VM_FORCEGREET)) {
 		snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
-		cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+		cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 		if (cmd < 0 || cmd == 't' || cmd == '#')
 			return cmd;
 		snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
-		cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+		cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 		if (cmd < 0 || cmd == 't' || cmd == '#')
 			return cmd;
 	}
@@ -5813,15 +5816,15 @@
 		switch (cmd) {
 		case '1':
 			snprintf(prefile,sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, vms->username);
-			cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+			cmd = play_record_review(chan,"vm-rec-unv",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 			break;
 		case '2': 
 			snprintf(prefile,sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, vms->username);
-			cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+			cmd = play_record_review(chan,"vm-rec-busy",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 			break;
 		case '3': 
 			snprintf(prefile,sizeof(prefile), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, vms->username);
-			cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+			cmd = play_record_review(chan,"vm-rec-name",prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 			break;
 		case '4': 
 			cmd = vm_tempgreeting(chan, vmu, vms, fmtc, record_gain);
@@ -5909,12 +5912,12 @@
 			retries = 0;
 		RETRIEVE(prefile, -1);
 		if (ast_fileexists(prefile, NULL, NULL) <= 0) {
-			play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+			play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 			cmd = 't';	
 		} else {
 			switch (cmd) {
 			case '1':
-				cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain);
+				cmd = play_record_review(chan, "vm-rec-temp", prefile, maxgreet, fmtc, 0, vmu, &duration, NULL, record_gain, NULL);
 				break;
 			case '2':
 				DELETE(prefile, -1, prefile);
@@ -7972,7 +7975,7 @@
 
 static int play_record_review(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt,
 			int outsidecaller, struct ast_vm_user *vmu, int *duration, const char *unlockdir,
-			signed char record_gain)
+			signed char record_gain, struct vm_state *vms)
 {
 	/* Record message & let caller review or re-record it, or set options if applicable */
 	int res = 0;
@@ -8007,7 +8010,7 @@
 				if (option_verbose > 2)
 					ast_verbose(VERBOSE_PREFIX_3 "Saving message as is\n");
 				ast_stream_and_wait(chan, "vm-msgsaved", "");
-				STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, duration, vms);
+				STORE(recordfile, vmu->mailbox, vmu->context, -1, chan, vmu, fmt, *duration, vms);
 				DISPOSE(recordfile, -1);
 				cmd = 't';
 				return res;

Modified: team/murf/bug7978/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/channels/Makefile?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/channels/Makefile (original)
+++ team/murf/bug7978/channels/Makefile Wed Dec 20 17:45:58 2006
@@ -107,8 +107,10 @@
 	$(CMD_PREFIX) $(CXX) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
 endif
 
-chan_misdn.o: ASTCFLAGS+=-Imisdn 
+chan_misdn.o: ASTCFLAGS+=-Imisdn
 
-misdn_config.o: ASTCFLAGS+=-Imisdn 
+misdn_config.o: ASTCFLAGS+=-Imisdn
+
+misdn/isdn_lib.o: ASTCFLAGS+=-Wno-strict-aliasing
 
 $(if $(filter chan_misdn,$(EMBEDDED_MODS)),modules.link,chan_misdn.so): chan_misdn.o misdn_config.o misdn/isdn_lib.o misdn/isdn_msg_parser.o

Modified: team/murf/bug7978/doc/snmp.txt
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/doc/snmp.txt?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/doc/snmp.txt (original)
+++ team/murf/bug7978/doc/snmp.txt Wed Dec 20 17:45:58 2006
@@ -17,7 +17,7 @@
 SNMP support comes in two varieties -- as a sub-agent to a running SNMP
 daemon using the AgentX protocol, or as a full standalone agent.  If
 you wish to run a full standalone agent, Asterisk must run as root in
-order to find to port 161.
+order to bind to port 161.
 
 Configuring access when running as a full agent is something that is
 left as an exercise to the reader.

Modified: team/murf/bug7978/res/res_limit.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/res/res_limit.c?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/res/res_limit.c (original)
+++ team/murf/bug7978/res/res_limit.c Wed Dec 20 17:45:58 2006
@@ -25,6 +25,15 @@
 #include "asterisk/module.h"
 #include "asterisk/cli.h"
 
+/* Find proper rlimit for virtual memory */
+#ifdef RLIMIT_AS
+#define VMEM_DEF RLIMIT_AS
+#else
+#ifdef RLIMIT_VMEM
+#define VMEM_DEF RLIMIT_VMEM
+#endif
+#endif
+
 static struct limits {
 	int resource;
 	char limit[3];
@@ -41,10 +50,9 @@
 	{ RLIMIT_MEMLOCK, "-l", "amount of memory locked into RAM" },
 #endif
 	{ RLIMIT_NOFILE, "-n", "number of file descriptors" },
-#ifndef RLIMIT_AS	/* *BSD use RLIMIT_VMEM */
-#define	RLIMIT_AS	RLIMIT_VMEM
+#ifdef VMEM_DEF
+	{ VMEM_DEF, "-v", "virtual memory" },
 #endif
-	{ RLIMIT_AS, "-v", "virtual memory" },
 };
 
 static int str2limit(const char *string)
@@ -143,7 +151,9 @@
 "         -s  Process stack size [readonly]\n"
 "         -t  CPU usage [readonly]\n"
 "         -u  Child processes\n"
+#ifdef VMEM_DEF
 "         -v  Process virtual memory [readonly]\n"
+#endif
 "         -c  Core dump file size\n"
 "         -n  Number of file descriptors\n";
 

Modified: team/murf/bug7978/res/snmp/agent.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug7978/res/snmp/agent.c?view=diff&rev=48660&r1=48659&r2=48660
==============================================================================
--- team/murf/bug7978/res/snmp/agent.c (original)
+++ team/murf/bug7978/res/snmp/agent.c Wed Dec 20 17:45:58 2006
@@ -198,6 +198,7 @@
     struct timeval tval;
     u_char *ret;
     int i, bit;
+	struct ast_str *out = ast_str_alloca(2048);
 
     if (header_simple_table(vp, name, length, exact, var_len, write_method, ast_active_channels()))
 		return NULL;
@@ -478,9 +479,9 @@
 		ret = (u_char *)&long_ret;
 		break;
 	case ASTCHANVARIABLES:
-		if (pbx_builtin_serialize_variables(chan, string_ret, sizeof(string_ret))) {
-			*var_len = strlen(string_ret);
-			ret = (u_char *)string_ret;
+		if (pbx_builtin_serialize_variables(chan, &out)) {
+			*var_len = strlen(out->str);
+			ret = (u_char *)out->str;
 		}
 		else
 			ret = NULL;



More information about the asterisk-commits mailing list