summaryrefslogtreecommitdiff
path: root/ztcfg.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-10-30 23:17:02 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2003-10-30 23:17:02 +0000
commit5de5efa71b183106b059157e4024d1e7bb434857 (patch)
treef7206ab483b5077b0f9faca16c017e0cd2eab18c /ztcfg.c
parent3e29b66d03ecccd8ce6c4f95d75a47afc603aa23 (diff)
Add DACS functionality to zaptel for cross connecting channels
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@262 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztcfg.c')
-rwxr-xr-xztcfg.c52
1 files changed, 45 insertions, 7 deletions
diff --git a/ztcfg.c b/ztcfg.c
index 583c4ce..3b100e7 100755
--- a/ztcfg.c
+++ b/ztcfg.c
@@ -355,17 +355,32 @@ int parse_idle(int *i, char *s)
return -1;
}
+static int parse_channel(char *channel, int *startchan)
+{
+ if (!channel || (sscanf(channel, "%i", startchan) != 1) ||
+ (*startchan < 1)) {
+ error("DACS requires a starting channel in the form ':x' where x is the channel\n");
+ return -1;
+ }
+ return 0;
+}
+
static int chanconfig(char *keyword, char *args)
{
int chans[ZT_MAX_CHANNELS];
- int res;
+ int res = 0;
int x;
int master=0;
+ int dacschan = 0;
char *idle;
bzero(chans, sizeof(chans));
strtok(args, ":");
idle = strtok(NULL, ":");
- res = apply_channels(chans, args);
+ if (!strcasecmp(keyword, "dacs")) {
+ res = parse_channel(idle, &dacschan);
+ }
+ if (!res)
+ res = apply_channels(chans, args);
if (res <= 0)
return -1;
for (x=1;x<ZT_MAX_CHANNELS;x++)
@@ -374,6 +389,14 @@ static int chanconfig(char *keyword, char *args)
error("Channel %d already configured as '%s' at line %d\n", x, sig[x], slineno[x]);
continue;
}
+ if (!strcasecmp(keyword, "dacs") && slineno[dacschan]) {
+ error("DACS Destination channel %d already configured as '%s' at line %d\n", dacschan, sig[dacschan], slineno[dacschan]);
+ continue;
+ } else {
+ cc[dacschan].chan = dacschan;
+ cc[dacschan].master = dacschan;
+ slineno[dacschan] = lineno;
+ }
cc[x].chan = x;
cc[x].master = x;
slineno[x] = lineno;
@@ -403,6 +426,16 @@ static int chanconfig(char *keyword, char *args)
return -1;
sig[x] = "CAS / User";
cc[x].sigtype = ZT_SIG_CAS;
+ } else if (!strcasecmp(keyword, "dacs")) {
+ /* Setup channel for monitor */
+ cc[x].idlebits = dacschan;
+ cc[x].sigtype = ZT_SIG_DACS;
+ sig[x] = "DACS";
+ /* Setup inverse */
+ cc[dacschan].idlebits = x;
+ cc[dacschan].sigtype = ZT_SIG_DACS;
+ sig[dacschan] = "DACS";
+ dacschan++;
} else if (!strcasecmp(keyword, "unused")) {
sig[x] = "Unused";
cc[x].sigtype = 0;
@@ -534,12 +567,16 @@ static void printconfig()
for (x=1;x<ZT_MAX_CHANNELS;x++) {
if ((cc[x].sigtype != ZT_SIG_SLAVE) && (cc[x].sigtype)) {
configs++;
- printf("Channel %02d: %s (%s)", x, sig[x], laws[cc[x].deflaw]);
ps = 0;
- for (y=1;y<ZT_MAX_CHANNELS;y++)
- if (cc[y].master == x) {
- printf("%s%02d", ps++ ? " " : " (Slaves: ", y);
- }
+ if (cc[x].sigtype == ZT_SIG_DACS)
+ printf("Channel %02d %s to %02d", x, sig[x], cc[x].idlebits);
+ else {
+ printf("Channel %02d: %s (%s)", x, sig[x], laws[cc[x].deflaw]);
+ for (y=1;y<ZT_MAX_CHANNELS;y++)
+ if (cc[y].master == x) {
+ printf("%s%02d", ps++ ? " " : " (Slaves: ", y);
+ }
+ }
if (ps) printf(")\n"); else printf("\n");
} else
if (cc[x].sigtype) configs++;
@@ -575,6 +612,7 @@ static struct handler {
{ "clear", chanconfig },
{ "unused", chanconfig },
{ "cas", chanconfig },
+ { "dacs", chanconfig },
{ "user", chanconfig },
{ "alaw", setlaw },
{ "mulaw", setlaw },