some endian fixes for BIGENDIAN systems
This commit is contained in:
parent
f7f1173d06
commit
043a0bea89
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
.EXPORT_ALL_VARIABLES:
|
.EXPORT_ALL_VARIABLES:
|
||||||
|
|
||||||
export I4LVERSION = 3.9
|
export I4LVERSION = 3.10
|
||||||
|
|
||||||
all: do-it-all
|
all: do-it-all
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
|
* Revision 1.27 2005/05/09 08:21:57 calle
|
||||||
|
* - get_buffer() now returns 0, if no buffer is available.
|
||||||
|
*
|
||||||
* Revision 1.26 2005/03/04 11:00:31 calle
|
* Revision 1.26 2005/03/04 11:00:31 calle
|
||||||
* New functions: cleanup_buffers_for_ncci() and cleanup_buffers_for_plci()
|
* New functions: cleanup_buffers_for_ncci() and cleanup_buffers_for_plci()
|
||||||
* triggered by DISCONNECT_B3_RESP and DISCONNECT_IND to fix buffer leak.
|
* triggered by DISCONNECT_B3_RESP and DISCONNECT_IND to fix buffer leak.
|
||||||
|
@ -485,18 +488,22 @@ capi20_put_message (unsigned ApplID, unsigned char *Msg)
|
||||||
void *dataptr;
|
void *dataptr;
|
||||||
if (sizeof(void *) != 4) {
|
if (sizeof(void *) != 4) {
|
||||||
if (len >= 30) { /* 64Bit CAPI-extention */
|
if (len >= 30) { /* 64Bit CAPI-extention */
|
||||||
u_int64_t data64;
|
_cqword data64;
|
||||||
memcpy(&data64,Msg+22, sizeof(u_int64_t));
|
data64 = CAPIMSG_U64(Msg, 22);
|
||||||
if (data64 != 0) dataptr = (void *)(unsigned long)data64;
|
if (data64 != 0)
|
||||||
else dataptr = Msg + len; /* Assume data after message */
|
dataptr = (void *)(unsigned long)data64;
|
||||||
|
else
|
||||||
|
dataptr = Msg + len; /* Assume data after message */
|
||||||
} else {
|
} else {
|
||||||
dataptr = Msg + len; /* Assume data after message */
|
dataptr = Msg + len; /* Assume data after message */
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
u_int32_t data;
|
_cdword data;
|
||||||
memcpy(&data,Msg+12, sizeof(u_int32_t));
|
data = CAPIMSG_U32(Msg, 12);
|
||||||
if (data != 0) dataptr = (void *)(unsigned long)data;
|
if (data != 0)
|
||||||
else dataptr = Msg + len; /* Assume data after message */
|
dataptr = (void *)(unsigned long)data;
|
||||||
|
else
|
||||||
|
dataptr = Msg + len; /* Assume data after message */
|
||||||
}
|
}
|
||||||
if (len + datalen > SEND_BUFSIZ)
|
if (len + datalen > SEND_BUFSIZ)
|
||||||
return CapiMsgOSResourceErr;
|
return CapiMsgOSResourceErr;
|
||||||
|
|
|
@ -111,6 +111,7 @@ typedef enum { CAPI_COMPOSE = 0, CAPI_DEFAULT = 1 } _cmstruct;
|
||||||
#define CAPIMSG_U8(m, off) (m[off])
|
#define CAPIMSG_U8(m, off) (m[off])
|
||||||
#define CAPIMSG_U16(m, off) (m[off]|(m[(off)+1]<<8))
|
#define CAPIMSG_U16(m, off) (m[off]|(m[(off)+1]<<8))
|
||||||
#define CAPIMSG_U32(m, off) (m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24))
|
#define CAPIMSG_U32(m, off) (m[off]|(m[(off)+1]<<8)|(m[(off)+2]<<16)|(m[(off)+3]<<24))
|
||||||
|
#define CAPIMSG_U64(m, off) (((_cqword)CAPIMSG_U32(m, off))|(((_cqword)CAPIMSG_U32(m, off+4))<<32))
|
||||||
#define CAPIMSG_LEN(m) CAPIMSG_U16(m,0)
|
#define CAPIMSG_LEN(m) CAPIMSG_U16(m,0)
|
||||||
#define CAPIMSG_APPID(m) CAPIMSG_U16(m,2)
|
#define CAPIMSG_APPID(m) CAPIMSG_U16(m,2)
|
||||||
#define CAPIMSG_COMMAND(m) CAPIMSG_U8(m,4)
|
#define CAPIMSG_COMMAND(m) CAPIMSG_U8(m,4)
|
||||||
|
@ -141,6 +142,18 @@ static inline void capimsg_setu32(void *m, int off, _cdword val)
|
||||||
((_cbyte *)m)[off+3] = (val >> 24) & 0xff;
|
((_cbyte *)m)[off+3] = (val >> 24) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void capimsg_setu64(void *m, int off, _cqword val)
|
||||||
|
{
|
||||||
|
((_cbyte *)m)[off] = val & 0xff;
|
||||||
|
((_cbyte *)m)[off+1] = (val >> 8) & 0xff;
|
||||||
|
((_cbyte *)m)[off+2] = (val >> 16) & 0xff;
|
||||||
|
((_cbyte *)m)[off+3] = (val >> 24) & 0xff;
|
||||||
|
((_cbyte *)m)[off+4] = (val >> 32) & 0xff;
|
||||||
|
((_cbyte *)m)[off+5] = (val >> 40) & 0xff;
|
||||||
|
((_cbyte *)m)[off+6] = (val >> 48) & 0xff;
|
||||||
|
((_cbyte *)m)[off+7] = (val >> 56) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
#define CAPIMSG_SETLEN(m, len) capimsg_setu16(m, 0, len)
|
#define CAPIMSG_SETLEN(m, len) capimsg_setu16(m, 0, len)
|
||||||
#define CAPIMSG_SETAPPID(m, applid) capimsg_setu16(m, 2, applid)
|
#define CAPIMSG_SETAPPID(m, applid) capimsg_setu16(m, 2, applid)
|
||||||
#define CAPIMSG_SETCOMMAND(m,cmd) capimsg_setu8(m, 4, cmd)
|
#define CAPIMSG_SETCOMMAND(m,cmd) capimsg_setu8(m, 4, cmd)
|
||||||
|
@ -227,7 +240,8 @@ typedef struct {
|
||||||
unsigned char *Data;
|
unsigned char *Data;
|
||||||
|
|
||||||
/* intern */
|
/* intern */
|
||||||
unsigned l, p;
|
_cword l;
|
||||||
|
unsigned p;
|
||||||
unsigned char *par;
|
unsigned char *par;
|
||||||
_cbyte *m;
|
_cbyte *m;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
|
* Revision 1.19 2005/05/09 08:23:01 calle
|
||||||
|
* - added SendingComplete to CONNECT_RESP (no funktions changed).
|
||||||
|
*
|
||||||
* Revision 1.18 2005/03/08 07:26:47 keil
|
* Revision 1.18 2005/03/08 07:26:47 keil
|
||||||
* - add SENDING_COMPLETE to INFO_REQ CONNECT_REQ and CONNECT_IND
|
* - add SENDING_COMPLETE to INFO_REQ CONNECT_REQ and CONNECT_IND
|
||||||
* - remove SENDING_COMPLETE parameter (always NULL) from capi_fill_DISCONNECT_REQ
|
* - remove SENDING_COMPLETE parameter (always NULL) from capi_fill_DISCONNECT_REQ
|
||||||
|
@ -479,14 +482,14 @@ static unsigned char *cpars[] = {
|
||||||
/*-------------------------------------------------------*/
|
/*-------------------------------------------------------*/
|
||||||
|
|
||||||
#define byteTLcpy(x,y) *(_cbyte *)(x)=*(_cbyte *)(y);
|
#define byteTLcpy(x,y) *(_cbyte *)(x)=*(_cbyte *)(y);
|
||||||
#define wordTLcpy(x,y) *(_cword *)(x)=*(_cword *)(y);
|
#define wordTLcpy(x,y) capimsg_setu16(x, 0, *(_cword *)(y))
|
||||||
#define dwordTLcpy(x,y) memcpy(x,y,4);
|
#define dwordTLcpy(x,y) capimsg_setu32(x, 0, *(_cdword *)(y))
|
||||||
#define structTLcpy(x,y,l) memcpy (x,y,l)
|
#define structTLcpy(x,y,l) memcpy (x,y,l)
|
||||||
#define structTLcpyovl(x,y,l) memmove (x,y,l)
|
#define structTLcpyovl(x,y,l) memmove (x,y,l)
|
||||||
|
|
||||||
#define byteTRcpy(x,y) *(_cbyte *)(y)=*(_cbyte *)(x);
|
#define byteTRcpy(x,y) *(_cbyte *)(y)=*(_cbyte *)(x);
|
||||||
#define wordTRcpy(x,y) *(_cword *)(y)=*(_cword *)(x);
|
#define wordTRcpy(x,y) *(_cword *)(y)=CAPIMSG_U16((x), 0)
|
||||||
#define dwordTRcpy(x,y) memcpy(y,x,4);
|
#define dwordTRcpy(x,y) *(_cdword *)(y)=CAPIMSG_U32((x), 0)
|
||||||
#define structTRcpy(x,y,l) memcpy (y,x,l)
|
#define structTRcpy(x,y,l) memcpy (y,x,l)
|
||||||
#define structTRcpyovl(x,y,l) memmove (y,x,l)
|
#define structTRcpyovl(x,y,l) memmove (y,x,l)
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
|
* Revision 1.12 2005/03/04 10:55:52 calle
|
||||||
|
* changes for 64 bit arch
|
||||||
|
*
|
||||||
* Revision 1.11 2004/01/16 15:27:12 calle
|
* Revision 1.11 2004/01/16 15:27:12 calle
|
||||||
* remove several warnings.
|
* remove several warnings.
|
||||||
*
|
*
|
||||||
|
@ -154,8 +157,8 @@ int main(int argc, char **argv)
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAPI20_GET_PROFILE(0, (CAPI_MESSAGE)&cprofile);
|
CAPI20_GET_PROFILE(0, (CAPI_MESSAGE)buf);
|
||||||
ncontr = cprofile.ncontroller;
|
ncontr = CAPIMSG_U16(buf, 0);
|
||||||
printf("Number of Controllers : %d\n", ncontr);
|
printf("Number of Controllers : %d\n", ncontr);
|
||||||
|
|
||||||
//err = CAPI20_REGISTER(1, 1, 2048, &ApplId);
|
//err = CAPI20_REGISTER(1, 1, 2048, &ApplId);
|
||||||
|
@ -168,10 +171,16 @@ int main(int argc, char **argv)
|
||||||
for (i = 1; i <= ncontr; i++) {
|
for (i = 1; i <= ncontr; i++) {
|
||||||
isAVM = 0;
|
isAVM = 0;
|
||||||
printf("Controller %d:\n", i);
|
printf("Controller %d:\n", i);
|
||||||
CAPI20_GET_MANUFACTURER (i, buf);
|
if (!CAPI20_GET_MANUFACTURER (i, buf)) {
|
||||||
|
fprintf(stderr, "could not get manufacturer info for controller %d\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
printf("Manufacturer: %s\n", buf);
|
printf("Manufacturer: %s\n", buf);
|
||||||
if (strstr((char *)buf, "AVM") != 0) isAVM = 1;
|
if (strstr((char *)buf, "AVM") != 0) isAVM = 1;
|
||||||
CAPI20_GET_VERSION (i, buf);
|
if (!CAPI20_GET_VERSION (i, buf)) {
|
||||||
|
fprintf(stderr, "could not get capi version info for controller %d\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
vbuf = (unsigned int *)buf;
|
vbuf = (unsigned int *)buf;
|
||||||
printf("CAPI Version: %u.%u\n",vbuf[0], vbuf[1]);
|
printf("CAPI Version: %u.%u\n",vbuf[0], vbuf[1]);
|
||||||
if (isAVM) {
|
if (isAVM) {
|
||||||
|
@ -184,9 +193,21 @@ int main(int argc, char **argv)
|
||||||
} else {
|
} else {
|
||||||
printf("Manufacturer Version: %u.%u\n",vbuf[2], vbuf[3]);
|
printf("Manufacturer Version: %u.%u\n",vbuf[2], vbuf[3]);
|
||||||
}
|
}
|
||||||
CAPI20_GET_SERIAL_NUMBER (i, buf);
|
if (!CAPI20_GET_SERIAL_NUMBER (i, buf)) {
|
||||||
|
fprintf(stderr, "could not get serial number info for controller %d\n", i);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
printf("Serial Number: %s\n", (char *)buf);
|
printf("Serial Number: %s\n", (char *)buf);
|
||||||
CAPI20_GET_PROFILE(i, (CAPI_MESSAGE)&cprofile);
|
err = CAPI20_GET_PROFILE(i, (CAPI_MESSAGE)buf);
|
||||||
|
if (err != CapiNoError) {
|
||||||
|
fprintf(stderr, "could not get profile info for controller %d - %s (%#x)\n", i, capi_info2str(err), err);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
cprofile.nbchannel = CAPIMSG_U16(buf, 2);
|
||||||
|
cprofile.goptions = CAPIMSG_U32(buf, 4);
|
||||||
|
cprofile.support1 = CAPIMSG_U32(buf, 8);
|
||||||
|
cprofile.support2 = CAPIMSG_U32(buf, 12);
|
||||||
|
cprofile.support3 = CAPIMSG_U32(buf, 16);
|
||||||
printf("BChannels: %u\n", cprofile.nbchannel);
|
printf("BChannels: %u\n", cprofile.nbchannel);
|
||||||
printf("Global Options: 0x%08x\n", cprofile.goptions);
|
printf("Global Options: 0x%08x\n", cprofile.goptions);
|
||||||
showbitvalues(goptions, cprofile.goptions);
|
showbitvalues(goptions, cprofile.goptions);
|
||||||
|
@ -196,7 +217,7 @@ int main(int argc, char **argv)
|
||||||
showbitvalues(b2support, cprofile.support2);
|
showbitvalues(b2support, cprofile.support2);
|
||||||
printf("B3 protocols support: 0x%08x\n", cprofile.support3);
|
printf("B3 protocols support: 0x%08x\n", cprofile.support3);
|
||||||
showbitvalues(b3support, cprofile.support3);
|
showbitvalues(b3support, cprofile.support3);
|
||||||
for (j=0, s = (unsigned char *)&cprofile; j < sizeof(cprofile); j++) {
|
for (j=0, s = buf; j < sizeof(cprofile); j++) {
|
||||||
switch (j) {
|
switch (j) {
|
||||||
case 0: printf("\n "); break;
|
case 0: printf("\n "); break;
|
||||||
case 2: printf("\n "); break;
|
case 2: printf("\n "); break;
|
||||||
|
|
Loading…
Reference in New Issue