[Asterisk-cvs]
asterisk/channels chan_alsa.c, 1.38, 1.39 chan_oss.c,
1.45, 1.46 iax2-parser.c, 1.38, 1.39
markster at lists.digium.com
markster at lists.digium.com
Mon Mar 28 22:55:39 CST 2005
- Previous message: [Asterisk-cvs] asterisk aesopt.h, 1.8, 1.9 dns.c, 1.11, 1.12 md5.c,
1.9, 1.10 rtp.c, 1.116, 1.117
- Next message: [Asterisk-cvs] asterisk/include/asterisk endian.h, NONE,
1.1 unaligned.h, NONE, 1.1 frame.h, 1.44, 1.45
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv6904/channels
Modified Files:
chan_alsa.c chan_oss.c iax2-parser.c
Log Message:
Simplify endianness and fix for unaligned reads (bug #3867)
Index: chan_alsa.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_alsa.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- chan_alsa.c 24 Mar 2005 00:55:40 -0000 1.38
+++ chan_alsa.c 29 Mar 2005 04:49:24 -0000 1.39
@@ -19,6 +19,7 @@
#include <asterisk/cli.h>
#include <asterisk/utils.h>
#include <asterisk/causes.h>
+#include <asterisk/endian.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -27,7 +28,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
-#include <endian.h>
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
Index: chan_oss.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_oss.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- chan_oss.c 24 Mar 2005 22:01:56 -0000 1.45
+++ chan_oss.c 29 Mar 2005 04:49:24 -0000 1.46
@@ -26,6 +26,7 @@
#include <asterisk/cli.h>
#include <asterisk/utils.h>
#include <asterisk/causes.h>
+#include <asterisk/endian.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -35,23 +36,6 @@
#include <stdlib.h>
#include <stdio.h>
-#if defined( __OpenBSD__ )
-# include <sys/endian.h>
-#elif defined( __FreeBSD__ ) || defined( __NetBSD__ )
-# include <sys/endian.h>
-#elif defined( BSD ) && ( BSD >= 199103 ) || defined(__APPLE__)
-# include <machine/endian.h>
-#elif defined ( SOLARIS )
-# include <solaris-compat/compat.h>
-#elif defined( __GNUC__ ) || defined( __GNU_LIBRARY__ )
-# include <endian.h>
-#if !defined(__APPLE__)
-# include <byteswap.h>
-#endif
-#elif defined( linux )
-# include <endian.h>
-#endif
-
#ifdef __linux
#include <linux/soundcard.h>
#elif defined(__FreeBSD__)
Index: iax2-parser.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/iax2-parser.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- iax2-parser.c 17 Mar 2005 23:12:15 -0000 1.38
+++ iax2-parser.c 29 Mar 2005 04:49:24 -0000 1.39
@@ -17,6 +17,7 @@
#include <netinet/in.h>
#include <asterisk/frame.h>
#include <asterisk/utils.h>
+#include <asterisk/unaligned.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
@@ -30,22 +31,6 @@
static int iframes = 0;
static int oframes = 0;
-#if defined(SOLARIS) && defined(__sparc__)
-static unsigned int get_uint32(unsigned char *p)
-{
- return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
-}
-
-static unsigned short get_uint16(unsigned char *p)
-{
- return (p[0] << 8) | p[1] ;
-}
-
-#else
-#define get_uint32(p) (*((unsigned int *)(p)))
-#define get_uint16(p) (*((unsigned short *)(p)))
-#endif
-
static void internaloutput(const char *str)
{
fputs(str, stdout);
@@ -102,7 +87,7 @@
static void dump_int(char *output, int maxlen, void *value, int len)
{
if (len == (int)sizeof(unsigned int))
- snprintf(output, maxlen, "%lu", (unsigned long)ntohl(get_uint32(value)));
+ snprintf(output, maxlen, "%lu", (unsigned long)ntohl(get_unaligned_uint32(value)));
else
snprintf(output, maxlen, "Invalid INT");
}
@@ -110,7 +95,7 @@
static void dump_short(char *output, int maxlen, void *value, int len)
{
if (len == (int)sizeof(unsigned short))
- snprintf(output, maxlen, "%d", ntohs(get_uint16(value)));
+ snprintf(output, maxlen, "%d", ntohs(get_unaligned_uint16(value)));
else
snprintf(output, maxlen, "Invalid SHORT");
}
@@ -140,8 +125,8 @@
{
char buf[256] = "";
if (len == (int)sizeof(unsigned int))
- snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(get_uint32(value)),
- iax_provflags2str(buf, sizeof(buf), ntohl(get_uint32(value))));
+ snprintf(output, maxlen, "%lu (%s)", (unsigned long)ntohl(get_unaligned_uint32(value)),
+ iax_provflags2str(buf, sizeof(buf), ntohl(get_unaligned_uint32(value))));
else
snprintf(output, maxlen, "Invalid INT");
}
@@ -600,14 +585,14 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting capability to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->capability = ntohl(get_uint32(data + 2));
+ ies->capability = ntohl(get_unaligned_uint32(data + 2));
break;
case IAX_IE_FORMAT:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting format to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->format = ntohl(get_uint32(data + 2));
+ ies->format = ntohl(get_unaligned_uint32(data + 2));
break;
case IAX_IE_LANGUAGE:
ies->language = data + 2;
@@ -617,21 +602,21 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting version to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->version = ntohs(get_uint16(data + 2));
+ ies->version = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_ADSICPE:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting adsicpe to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->adsicpe = ntohs(get_uint16(data + 2));
+ ies->adsicpe = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_SAMPLINGRATE:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting samplingrate to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->samprate = ntohs(get_uint16(data + 2));
+ ies->samprate = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_DNID:
ies->dnid = data + 2;
@@ -644,14 +629,14 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting authmethods to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->authmethods = ntohs(get_uint16(data + 2));
+ ies->authmethods = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_ENCRYPTION:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting encryption to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->encmethods = ntohs(get_uint16(data + 2));
+ ies->encmethods = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_CHALLENGE:
ies->challenge = data + 2;
@@ -670,21 +655,21 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting refresh to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->refresh = ntohs(get_uint16(data + 2));
+ ies->refresh = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_DPSTATUS:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting dpstatus to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->dpstatus = ntohs(get_uint16(data + 2));
+ ies->dpstatus = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_CALLNO:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting callno to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->callno = ntohs(get_uint16(data + 2));
+ ies->callno = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_CAUSE:
ies->cause = data + 2;
@@ -710,7 +695,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting msgcount to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->msgcount = ntohs(get_uint16(data + 2));
+ ies->msgcount = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_AUTOANSWER:
ies->autoanswer = 1;
@@ -723,21 +708,21 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting transferid to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->transferid = ntohl(get_uint32(data + 2));
+ ies->transferid = ntohl(get_unaligned_uint32(data + 2));
break;
case IAX_IE_DATETIME:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting date/time to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->datetime = ntohl(get_uint32(data + 2));
+ ies->datetime = ntohl(get_unaligned_uint32(data + 2));
break;
case IAX_IE_FIRMWAREVER:
if (len != (int)sizeof(unsigned short)) {
snprintf(tmp, (int)sizeof(tmp), "Expecting firmwarever to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->firmwarever = ntohs(get_uint16(data + 2));
+ ies->firmwarever = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_DEVICETYPE:
ies->devicetype = data + 2;
@@ -750,7 +735,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expected block desc to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else
- ies->fwdesc = ntohl(get_uint32(data + 2));
+ ies->fwdesc = ntohl(get_unaligned_uint32(data + 2));
break;
case IAX_IE_FWBLOCKDATA:
ies->fwdata = data + 2;
@@ -766,7 +751,7 @@
errorf(tmp);
} else {
ies->provverpres = 1;
- ies->provver = ntohl(get_uint32(data + 2));
+ ies->provver = ntohl(get_unaligned_uint32(data + 2));
}
break;
case IAX_IE_CALLINGPRES:
@@ -790,14 +775,14 @@
snprintf(tmp, (int)sizeof(tmp), "Expecting callingtns to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else
- ies->calling_tns = ntohs(get_uint16(data + 2));
+ ies->calling_tns = ntohs(get_unaligned_uint16(data + 2));
break;
case IAX_IE_RR_JITTER:
if (len != (int)sizeof(unsigned int)) {
snprintf(tmp, (int)sizeof(tmp), "Expected jitter rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else {
- ies->rr_jitter = ntohl(get_uint32(data + 2));
+ ies->rr_jitter = ntohl(get_unaligned_uint32(data + 2));
}
break;
case IAX_IE_RR_LOSS:
@@ -805,7 +790,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else {
- ies->rr_loss = ntohl(get_uint32(data + 2));
+ ies->rr_loss = ntohl(get_unaligned_uint32(data + 2));
}
break;
case IAX_IE_RR_PKTS:
@@ -813,7 +798,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else {
- ies->rr_pkts = ntohl(get_uint32(data + 2));
+ ies->rr_pkts = ntohl(get_unaligned_uint32(data + 2));
}
break;
case IAX_IE_RR_DELAY:
@@ -821,7 +806,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expected loss rr to be %d bytes long but was %d\n", (int)sizeof(unsigned short), len);
errorf(tmp);
} else {
- ies->rr_delay = ntohs(get_uint16(data + 2));
+ ies->rr_delay = ntohs(get_unaligned_uint16(data + 2));
}
break;
case IAX_IE_RR_DROPPED:
@@ -829,7 +814,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else {
- ies->rr_dropped = ntohl(get_uint32(data + 2));
+ ies->rr_dropped = ntohl(get_unaligned_uint32(data + 2));
}
break;
case IAX_IE_RR_OOO:
@@ -837,7 +822,7 @@
snprintf(tmp, (int)sizeof(tmp), "Expected packets rr to be %d bytes long but was %d\n", (int)sizeof(unsigned int), len);
errorf(tmp);
} else {
- ies->rr_ooo = ntohl(get_uint32(data + 2));
+ ies->rr_ooo = ntohl(get_unaligned_uint32(data + 2));
}
break;
default:
- Previous message: [Asterisk-cvs] asterisk aesopt.h, 1.8, 1.9 dns.c, 1.11, 1.12 md5.c,
1.9, 1.10 rtp.c, 1.116, 1.117
- Next message: [Asterisk-cvs] asterisk/include/asterisk endian.h, NONE,
1.1 unaligned.h, NONE, 1.1 frame.h, 1.44, 1.45
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list