summaryrefslogtreecommitdiff
path: root/ztcfg.c
diff options
context:
space:
mode:
authormarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2001-12-07 19:45:53 +0000
committermarkster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2001-12-07 19:45:53 +0000
commit954abd6c016492772dab9990f66857b969ec03dc (patch)
tree15aed0abc8822b314baae85bf9cccb05214bf0c8 /ztcfg.c
parent07d2942df868bbed234e7c7c3c23ba7356c977f4 (diff)
Version 0.1.4 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@35 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztcfg.c')
-rwxr-xr-xztcfg.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/ztcfg.c b/ztcfg.c
index 7153ce2..5b37dfb 100755
--- a/ztcfg.c
+++ b/ztcfg.c
@@ -89,6 +89,12 @@ static char *lbostr[] = {
"-22.5db (CSU)"
};
+static char *laws[] = {
+ "Default",
+ "Mu-law",
+ "A-law"
+};
+
static int error(char *fmt, ...)
{
int res;
@@ -173,28 +179,49 @@ int spanconfig(char *keyword, char *args)
if (!strcasecmp(realargs[3], "d4")) {
lc[spans].lineconfig |= ZT_CONFIG_D4;
lc[spans].lineconfig &= ~ZT_CONFIG_ESF;
+ lc[spans].lineconfig &= ~ZT_CONFIG_CCS;
} else if (!strcasecmp(realargs[3], "esf")) {
lc[spans].lineconfig |= ZT_CONFIG_ESF;
lc[spans].lineconfig &= ~ZT_CONFIG_D4;
+ lc[spans].lineconfig &= ~ZT_CONFIG_CCS;
+ } else if (!strcasecmp(realargs[3], "ccs")) {
+ lc[spans].lineconfig |= ZT_CONFIG_CCS;
+ lc[spans].lineconfig &= ~(ZT_CONFIG_ESF | ZT_CONFIG_D4);
+ } else if (!strcasecmp(realargs[3], "cas")) {
+ lc[spans].lineconfig &= ~ZT_CONFIG_CCS;
+ lc[spans].lineconfig &= ~(ZT_CONFIG_ESF | ZT_CONFIG_D4);
} else {
- error("Framing must be one of 'd4' or 'esf', not '%s'\n", realargs[3]);
+ error("Framing(T1)/Signalling(E1) must be one of 'd4', 'esf', 'cas' or 'ccs', not '%s'\n", realargs[3]);
return -1;
}
if (!strcasecmp(realargs[4], "ami")) {
- lc[spans].lineconfig &= ~ZT_CONFIG_B8ZS;
+ lc[spans].lineconfig &= ~(ZT_CONFIG_B8ZS | ZT_CONFIG_HDB3);
lc[spans].lineconfig |= ZT_CONFIG_AMI;
} else if (!strcasecmp(realargs[4], "b8zs")) {
lc[spans].lineconfig |= ZT_CONFIG_B8ZS;
- lc[spans].lineconfig &= ~ZT_CONFIG_AMI;
+ lc[spans].lineconfig &= ~(ZT_CONFIG_AMI | ZT_CONFIG_HDB3);
+ } else if (!strcasecmp(realargs[4], "hdb3")) {
+ lc[spans].lineconfig |= ZT_CONFIG_HDB3;
+ lc[spans].lineconfig &= ~(ZT_CONFIG_AMI | ZT_CONFIG_B8ZS);
} else {
- error("Coding must be one of 'ami' or 'b8zs', not '%s'\n", realargs[4]);
+ error("Coding must be one of 'ami', 'b8zs' or 'hdb3', not '%s'\n", realargs[4]);
return -1;
}
if (argc > 5) {
if (!strcasecmp(realargs[5], "yellow"))
lc[spans].lineconfig |= ZT_CONFIG_NOTOPEN;
+ else if (!strcasecmp(realargs[5], "crc4")) {
+ lc[spans].lineconfig |= ZT_CONFIG_CRC4;
+ } else {
+ error("Only valid fifth arguments are 'yellow' or 'crc4', not '%s'\n", realargs[5]);
+ return -1;
+ }
+ }
+ if (argc > 6) {
+ if (!strcasecmp(realargs[6], "yellow"))
+ lc[spans].lineconfig |= ZT_CONFIG_NOTOPEN;
else {
- error("Only valid fourth argument is 'yellow', not '%s'\n", realargs[5]);
+ error("Only valid sixth argument is 'yellow', not '%s'\n", realargs[6]);
return -1;
}
}
@@ -352,6 +379,34 @@ static int chanconfig(char *keyword, char *args)
return 0;
}
+static int setlaw(char *keyword, char *args)
+{
+ int res;
+ int law;
+ int x;
+ int chans[ZT_MAX_CHANNELS];
+
+ bzero(chans, sizeof(chans));
+ res = apply_channels(chans, args);
+ if (res <= 0)
+ return -1;
+ if (!strcasecmp(keyword, "alaw")) {
+ law = ZT_LAW_ALAW;
+ } else if (!strcasecmp(keyword, "mulaw")) {
+ law = ZT_LAW_MULAW;
+ } else if (!strcasecmp(keyword, "deflaw")) {
+ law = ZT_LAW_DEFAULT;
+ } else {
+ fprintf(stderr, "Huh??? Don't know about '%s' law\n", keyword);
+ return -1;
+ }
+ for (x=0;x<ZT_MAX_CHANNELS;x++) {
+ if (chans[x])
+ cc[x].deflaw = law;
+ }
+ return 0;
+}
+
static int registerzone(char *keyword, char *args)
{
if (numzones >= ZT_TONE_ZONE_MAX) {
@@ -398,7 +453,7 @@ 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 ", x, sig[x]);
+ 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) {
@@ -437,6 +492,9 @@ static struct handler {
{ "indclear", chanconfig },
{ "clear", chanconfig },
{ "unused", chanconfig },
+ { "alaw", setlaw },
+ { "mulaw", setlaw },
+ { "deflaw", setlaw },
};
static char *readline()