
Description | Cautions | Source Code | See Also
Name: |
int nr_scroute(devh1,devtype1,devh2,devtype2,mode) | |
Inputs: |
int devh1 |
|
|
unsigned short devtype1 |
|
|
int devh2 |
|
|
unsigned short devtype2 |
|
|
unsigned char mode |
|
Returns: |
0 on success |
|
|
-1 on error |
|
Includes: |
stdio.h, windows.h, srllib.h, dxxxlib.h and sctools.h. Optional - dtilib.h, msilib.h, and faxlib.h. | |
Category: |
Routing convenience | |
Mode: |
Synchronous | |
The nr_scroute( ) convenience function connects two Dialogic devices. This function makes a full or half-duplex connection between two Dialogic devices. This function is provided in a separate C source file called sctools.c in the <install drive>:\<install directory>\dialogic\sctools directory. A library version is also available as sctools.lib in the <install drive>:\<install directory>\dialogic\lib directory.
The nr_sc prefix to the function signifies network (analog and digital) devices and resource (voice and fax) devices accessible via the SCbus. See the Digital Network Interface Software Reference for digital interface device details and the FAX Software Reference for FAX device details.
Parameter |
Description | |
devh1: |
Dialogic device handle. | |
devtype1: |
Specifies the type of device for devh1. | |
|
SC_VOX |
voice channel device |
|
SC_LSI |
analog channel device |
|
SC_DTI |
digital time slot device |
|
SC_MSI |
MSI station device |
|
SC_FAX |
fax channel device |
devh2: |
Dialogic device handle. | |
devtype2: |
Specifies the type of device for devh2. See devtype1 for list of defines. | |
mode: |
Specifies half or full duplex connection. The mode parameter contains one of the following defines from sctools.h to specify full or half duplex: | |
|
SC_FULLDUP |
specifies make a full duplex connection |
|
SC_HALFDUP |
specifies make a half duplex connection. |
|
The default mode value is SC_FULLDUP. When SC_HALFDUP is specified, then the function returns with the second device listening to the SCbus time slot connected to the first device. | |
/*
* Include files.
*/
#include <windows.h>
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#ifdef DTISC
#include <dtilib.h>
#include <msilib.h>
#endif
#ifdef FAXSC
#include <faxlib.h>
#endif
#include "sctools.h"
/*
* Function prototypes
*/
static void nr_scerror(char *,...);
#if ( defined( __STDC__ ) || defined( __cplusplus ) )
int nr_scroute( int devh1, unsigned short devtype1,
int devh2, unsigned short devtype2, unsigned char mode )
#else
int nr_scroute( devh1, devtype1, devh2, devtype2, mode )
int devh1;
unsigned short devtype1;
int devh2;
unsigned short devtype2;
unsigned char mode;
#endif
{
SC_TSINFO sc_tsinfo; /* SCBus Timeslots information structure */
long scts; /* SCBus Timeslot */
/*
* Setup the SCBus Timeslots information structure.
*/
sc_tsinfo.sc_numts = 1;
sc_tsinfo.sc_tsarrayp = &scts;
/*
* Get the SCBus timeslot connected to the transmit of the first device.
*/
switch (devtype1) {
case SC_VOX:
if (dx_getxmitslot(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: dx_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh1),ATDV_ERRMSGP(devh1));
return -1;
}
break;
case SC_LSI:
if (ag_getxmitslot(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: ag_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh1),ATDV_ERRMSGP(devh1));
return -1;
}
break;
#ifdef DTISC
case SC_DTI:
if (dt_getxmitslot(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: dt_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh1),ATDV_ERRMSGP(devh1));
return -1;
}
break;
case SC_MSI:
if (ms_getxmitslot(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: ms_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh1),ATDV_ERRMSGP(devh1));
return -1;
}
break;
#endif
#ifdef FAXSC
case SC_FAX:
if (fx_getxmitslot(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: fx_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh1),ATDV_ERRMSGP(devh1));
return -1;
}
break;
#endif
default:
nr_scerror("nr_scroute: %s: ERROR: Invalid 1st device type\n",
ATDV_NAMEP(devh1));
return -1;
}
/*
* Make the second device type listen to the timeslot that the first
* device is transmitting on. If a half duplex connection is desired,
* then return. Otherwise, get the SCBus timeslot connected to the
* transmit of the second device.
*/
switch (devtype2) {
case SC_VOX:
if (dx_listen(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot dx_listen %d ERROR: %s\n",
ATDV_NAMEP(devh2),scts,ATDV_ERRMSGP(devh2));
return -1;
}
if (mode == SC_HALFDUP) {
return 0;
}
if (dx_getxmitslot(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: dx_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh2),ATDV_ERRMSGP(devh2));
return -1;
}
break;
case SC_LSI:
if (ag_listen(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot ag_listen %d ERROR: %s\n",
ATDV_NAMEP(devh2),scts,ATDV_ERRMSGP(devh2));
return -1;
}
if (mode == SC_HALFDUP) {
return 0;
}
if (ag_getxmitslot(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: ag_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh2),ATDV_ERRMSGP(devh2));
return -1;
}
break;
#ifdef DTISC
case SC_DTI:
if (dt_listen(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot dt_listen %d ERROR: %s\n",
ATDV_NAMEP(devh2),scts,ATDV_ERRMSGP(devh2));
return -1;
}
if (mode == SC_HALFDUP) {
return 0;
}
if (dt_getxmitslot(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: dt_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh2),ATDV_ERRMSGP(devh2));
return -1;
}
break;
case SC_MSI:
if (ms_listen(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot ms_listen %d ERROR: %s\n",
ATDV_NAMEP(devh2),scts,ATDV_ERRMSGP(devh2));
return -1;
}
if (mode == SC_HALFDUP) {
return 0;
}
if (ms_getxmitslot(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: ms_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh2),ATDV_ERRMSGP(devh2));
return -1;
}
break;
#endif
#ifdef FAXSC
case SC_FAX:
if (fx_listen(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot fx_listen %d ERROR: %s\n",
ATDV_NAMEP(devh2),scts,ATDV_ERRMSGP(devh2));
return -1;
}
if (mode == SC_HALFDUP) {
return 0;
}
if (fx_getxmitslot(devh2, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: fx_getxmitslot ERROR: %s\n",
ATDV_NAMEP(devh2),ATDV_ERRMSGP(devh2));
return -1;
}
break;
#endif
default:
nr_scerror("nr_scroute: %s: ERROR: Invalid 2nd device type\n",
ATDV_NAMEP(devh2));
return -1;
}
/*
* Now make the first device listen to the SCBus timeslot that the
* second device is transmitting on.
*/
switch (devtype1) {
case SC_VOX:
if (dx_listen(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot dx_listen %d ERROR: %s\n",
ATDV_NAMEP(devh1),scts,ATDV_ERRMSGP(devh1));
return -1;
}
break;
case SC_LSI:
if (ag_listen(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot ag_listen %d ERROR: %s\n",
ATDV_NAMEP(devh1),scts,ATDV_ERRMSGP(devh1));
return -1;
}
break;
#ifdef DTISC
case SC_DTI:
if (dt_listen(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot dt_listen %d ERROR: %s\n",
ATDV_NAMEP(devh1),scts,ATDV_ERRMSGP(devh1));
return -1;
}
break;
case SC_MSI:
if (ms_listen(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot ms_listen %d ERROR: %s\n",
ATDV_NAMEP(devh1),scts,ATDV_ERRMSGP(devh1));
return -1;
}
break;
#endif
#ifdef FAXSC
case SC_FAX:
if (fx_listen(devh1, &sc_tsinfo) == -1) {
nr_scerror("nr_scroute: %s: Cannot fx_listen %d ERROR: %s\n",
ATDV_NAMEP(devh1),scts,ATDV_ERRMSGP(devh1));
return -1;
}
break;
#endif
}
return 0;
}
void nr_scerror(char *fmt, )
#ifdef PRINTON
va_list args;
/*
* Make args point to the 1st unnamed argument and then print to stderr.
*/
va_start(args, fmt);
fmt = va_arg(args, char *);
vfprintf(stderr, fmt, args);
va_end(args);
#endif
}
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation