tweak types

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@53 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Michael Jerris 2007-05-20 15:27:29 +00:00
parent 4ac6d61adc
commit da6aefb5cb
1 changed files with 145 additions and 145 deletions

View File

@ -33,34 +33,34 @@
/* sang_api.h(74) : warning C4201: nonstandard extension used : nameless struct/union */ /* sang_api.h(74) : warning C4201: nonstandard extension used : nameless struct/union */
/* wanpipe_defines.h(219) : warning C4214: nonstandard extension used : bit field types other than int */ /* wanpipe_defines.h(219) : warning C4214: nonstandard extension used : bit field types other than int */
/* wanpipe_defines.h(220) : warning C4214: nonstandard extension used : bit field types other than int */ /* wanpipe_defines.h(220) : warning C4214: nonstandard extension used : bit field types other than int */
/* this will break for any compilers that are strict ansi or strict c99 */ /* this will break for any compilers that are strict ansi or strict c99 */
/* The following definition for that struct should resolve this warning and work for 32 and 64 bit */ /* The following definition for that struct should resolve this warning and work for 32 and 64 bit */
#if 0 #if 0
struct iphdr { struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD) #if defined(__LITTLE_ENDIAN_BITFIELD)
unsigned ihl:4, unsigned ihl:4,
version:4; version:4;
#elif defined (__BIG_ENDIAN_BITFIELD) #elif defined (__BIG_ENDIAN_BITFIELD)
unsigned version:4, unsigned version:4,
ihl:4; ihl:4;
#else #else
# error "unknown byteorder!" # error "unknown byteorder!"
#endif #endif
unsigned tos:8; unsigned tos:8;
unsigned tot_len:16; unsigned tot_len:16;
unsigned id:16; unsigned id:16;
unsigned frag_off:16; unsigned frag_off:16;
__u8 ttl; __u8 ttl;
__u8 protocol; __u8 protocol;
__u16 check; __u16 check;
__u32 saddr; __u32 saddr;
__u32 daddr; __u32 daddr;
/*The options start here. */ /*The options start here. */
}; };
#endif /* #if 0 */ #endif /* #if 0 */
#define __inline__ __inline #define __inline__ __inline
@ -90,7 +90,7 @@ struct iphdr {
/* what should the returns from this function be?? */ /* what should the returns from this function be?? */
/* I dont think they are currently consistant between windows and *nix */ /* I dont think they are currently consistant between windows and *nix */
#ifdef __WINDOWS__ #ifdef __WINDOWS__
static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_cmd_t *tdm_api_cmd) static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api_cmd)
{ {
/* can we make the structure passed for this on nix and windows the same */ /* can we make the structure passed for this on nix and windows the same */
/* so we don't have to do the extra 2 memcpy's on windows for this ? */ /* so we don't have to do the extra 2 memcpy's on windows for this ? */
@ -129,7 +129,7 @@ static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_cmd_t *tdm_api
} }
#else #else
static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_cmd_t *tdm_api_cmd) static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api_cmd)
{ {
return ioctl(fd, SIOC_WANPIPE_TDM_API, tdm_api_cmd); return ioctl(fd, SIOC_WANPIPE_TDM_API, tdm_api_cmd);
} }
@ -291,22 +291,22 @@ static __inline__ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int flags)
/* we need some what to select if we are reading regular tdm msgs or events */ /* we need some what to select if we are reading regular tdm msgs or events */
/* need to either have 2 functions, 1 for events, 1 for regural read, or a flag on this function to choose */ /* need to either have 2 functions, 1 for events, 1 for regural read, or a flag on this function to choose */
/* 2 functions preferred. Need implementation for the event function for both nix and windows that is threadsafe */ /* 2 functions preferred. Need implementation for the event function for both nix and windows that is threadsafe */
static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen) static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, int datalen)
{ {
/* What do we need to do here to avoid having to do all */ /* What do we need to do here to avoid having to do all */
/* the memcpy's on windows and still maintain api compat with nix */ /* the memcpy's on windows and still maintain api compat with nix */
int rx_len=0; int rx_len=0;
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
static RX_DATA_STRUCT rx_data; static RX_DATA_STRUCT rx_data;
api_header_t *pri; api_header_t *pri;
wp_tdm_api_rx_hdr_t *tdm_api_rx_hdr; wp_tdm_api_rx_hdr_t *tdm_api_rx_hdr;
wp_tdm_api_rx_hdr_t *user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf; wp_tdm_api_rx_hdr_t *user_buf = (wp_tdm_api_rx_hdr_t*)hdrbuf;
DWORD ln; DWORD ln;
if(hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){ if(hdrlen != sizeof(wp_tdm_api_rx_hdr_t)){
return -1; return -1;
} }
if(!DeviceIoControl( if(!DeviceIoControl(
fd, fd,
IoctlReadCommand, IoctlReadCommand,
@ -316,111 +316,111 @@ static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen
sizeof(RX_DATA_STRUCT), sizeof(RX_DATA_STRUCT),
(LPDWORD)(&ln), (LPDWORD)(&ln),
(LPOVERLAPPED)NULL (LPOVERLAPPED)NULL
)){ )){
return -1; return -1;
} }
pri = &rx_data.api_header;
tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data;
user_buf->wp_tdm_api_event_type = pri->operation_status;
switch(pri->operation_status)
{
case SANG_STATUS_RX_DATA_AVAILABLE:
if(pri->data_length > datalen){
break;
}
memcpy(databuf, rx_data.data, pri->data_length);
rx_len = pri->data_length;
break;
default:
break;
}
#else
struct msghdr msg;
struct iovec iov[2];
memset(&msg,0,sizeof(struct msghdr));
iov[0].iov_len=hdrlen;
iov[0].iov_base=hdrbuf;
iov[1].iov_len=datalen;
iov[1].iov_base=databuf;
msg.msg_iovlen=2;
msg.msg_iov=iov;
rx_len = read(fd,&msg,datalen+hdrlen);
if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){
return -EINVAL;
}
rx_len-=sizeof(wp_tdm_api_rx_hdr_t);
#endif
return rx_len;
}
static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen) pri = &rx_data.api_header;
{ tdm_api_rx_hdr = (wp_tdm_api_rx_hdr_t*)rx_data.data;
/* What do we need to do here to avoid having to do all */
/* the memcpy's on windows and still maintain api compat with nix */ user_buf->wp_tdm_api_event_type = pri->operation_status;
int bsent = 0;
#if defined(__WINDOWS__) switch(pri->operation_status)
static TX_DATA_STRUCT local_tx_data; {
api_header_t *pri; case SANG_STATUS_RX_DATA_AVAILABLE:
DWORD ln; if(pri->data_length > datalen){
break;
/* Are these really not needed or used??? What about for nix?? */ }
(void)hdrbuf; memcpy(databuf, rx_data.data, pri->data_length);
(void)hdrlen; rx_len = pri->data_length;
break;
pri = &local_tx_data.api_header;
default:
pri->data_length = datalen; break;
memcpy(local_tx_data.data, databuf, pri->data_length); }
if(!DeviceIoControl( #else
fd, struct msghdr msg;
IoctlWriteCommand, struct iovec iov[2];
(LPVOID)&local_tx_data,
(ULONG)sizeof(TX_DATA_STRUCT), memset(&msg,0,sizeof(struct msghdr));
(LPVOID)&local_tx_data,
sizeof(TX_DATA_STRUCT), iov[0].iov_len=hdrlen;
(LPDWORD)(&ln), iov[0].iov_base=hdrbuf;
(LPOVERLAPPED)NULL
)){ iov[1].iov_len=datalen;
return -1; iov[1].iov_base=databuf;
}
msg.msg_iovlen=2;
if (local_tx_data.api_header.operation_status == SANG_STATUS_SUCCESS) { msg.msg_iov=iov;
bsent = datalen;
} rx_len = read(fd,&msg,datalen+hdrlen);
#else
struct msghdr msg; if (rx_len <= sizeof(wp_tdm_api_rx_hdr_t)){
struct iovec iov[2]; return -EINVAL;
}
memset(&msg,0,sizeof(struct msghdr));
rx_len-=sizeof(wp_tdm_api_rx_hdr_t);
iov[0].iov_len=hdrlen; #endif
iov[0].iov_base=hdrbuf; return rx_len;
}
iov[1].iov_len=datalen;
iov[1].iov_base=databuf; static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen, void *databuf, unsigned short datalen)
{
msg.msg_iovlen=2; /* What do we need to do here to avoid having to do all */
msg.msg_iov=iov; /* the memcpy's on windows and still maintain api compat with nix */
int bsent = 0;
bsent = write(fd,&msg,datalen+hdrlen); #if defined(__WINDOWS__)
if (bsent > 0){ static TX_DATA_STRUCT local_tx_data;
bsent-=sizeof(wp_tdm_api_tx_hdr_t); api_header_t *pri;
} DWORD ln;
#endif
return bsent; /* Are these really not needed or used??? What about for nix?? */
} (void)hdrbuf;
(void)hdrlen;
pri = &local_tx_data.api_header;
pri->data_length = datalen;
memcpy(local_tx_data.data, databuf, pri->data_length);
if(!DeviceIoControl(
fd,
IoctlWriteCommand,
(LPVOID)&local_tx_data,
(ULONG)sizeof(TX_DATA_STRUCT),
(LPVOID)&local_tx_data,
sizeof(TX_DATA_STRUCT),
(LPDWORD)(&ln),
(LPOVERLAPPED)NULL
)){
return -1;
}
if (local_tx_data.api_header.operation_status == SANG_STATUS_SUCCESS) {
bsent = datalen;
}
#else
struct msghdr msg;
struct iovec iov[2];
memset(&msg,0,sizeof(struct msghdr));
iov[0].iov_len=hdrlen;
iov[0].iov_base=hdrbuf;
iov[1].iov_len=datalen;
iov[1].iov_base=databuf;
msg.msg_iovlen=2;
msg.msg_iov=iov;
bsent = write(fd,&msg,datalen+hdrlen);
if (bsent > 0){
bsent-=sizeof(wp_tdm_api_tx_hdr_t);
}
#endif
return bsent;
}
#endif /* _SANGOMA_TDM_API_H */ #endif /* _SANGOMA_TDM_API_H */