diff options
author | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-02-13 20:24:17 +0000 |
---|---|---|
committer | markster <markster@5390a7c7-147a-4af0-8ec9-7488f05a26cb> | 2002-02-13 20:24:17 +0000 |
commit | 872af797f8f0588df93271ee4af5bd387e44cd48 (patch) | |
tree | b9ee61298c9321a1ea5dac4adfc215b14d41c669 /ztcfg.c | |
parent | 6d4f5dcdbf90fd8dc38802d4d05d01eecddbf61b (diff) |
Version 0.1.6 from FTP
git-svn-id: http://svn.digium.com/svn/zaptel/trunk@59 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'ztcfg.c')
-rwxr-xr-x | ztcfg.c | 60 |
1 files changed, 59 insertions, 1 deletions
@@ -43,6 +43,9 @@ #define NUM_SPANS ZT_MAX_SPANS +/* Assume no more than 1024 dynamics */ +#define NUM_DYNAMIC 1024 + static int lineno=0; static FILE *cf; @@ -62,6 +65,8 @@ static struct zt_lineconfig lc[ZT_MAX_SPANS]; static struct zt_chanconfig cc[ZT_MAX_CHANNELS]; +static struct zt_dynamic_span zds[NUM_DYNAMIC]; + static char *sig[ZT_MAX_CHANNELS]; /* Signalling */ static int slineno[ZT_MAX_CHANNELS]; /* Line number where signalling specified */ @@ -74,6 +79,8 @@ static int verbose = 0; static int stopmode = 0; +static int numdynamic = 0; + static char zonestoload[ZT_TONE_ZONE_MAX][10]; static int numzones = 0; @@ -146,9 +153,44 @@ static int parseargs(char *input, char *output[], int maxargs, char sep) return pos; } +int dspanconfig(char *keyword, char *args) +{ + static char *realargs[10]; + int argc; + int res; + int chans; + int timing; + argc = res = parseargs(args, realargs, 4, ','); + if (res != 4) { + error("Incorrect number of arguments to 'dynamic' (should be <driver>,<address>,<num channels>, <timing>)\n"); + } + res = sscanf(realargs[2], "%d", &chans); + if ((res == 1) && (chans < 1)) + res = -1; + if (res != 1) { + error("Invalid number of channels '%s', should be a number > 0.\n", realargs[2]); + } + + res = sscanf(realargs[3], "%d", &timing); + if ((res == 1) && (timing < 0)) + res = -1; + if (res != 1) { + error("Invalid timing '%s', should be a number > 0.\n", realargs[3]); + } + + + strncpy(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver)); + strncpy(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr)); + zds[numdynamic].numchans = chans; + zds[numdynamic].timing = timing; + + numdynamic++; + return 0; +} + int spanconfig(char *keyword, char *args) { - static char *realargs[5]; + static char *realargs[10]; int res; int argc; int span; @@ -448,6 +490,10 @@ static void printconfig() x+1, ( lc[x].lineconfig & ZT_CONFIG_ESF ? "ESF" : "D4"), (lc[x].lineconfig & ZT_CONFIG_B8ZS ? "B8ZS" : "AMI"), lbostr[lc[x].lbo]); + for (x=0;x<numdynamic;x++) { + printf("Dynamic span %d: driver %s, addr %s, channels %d, timing %d\n", + x +1, zds[x].driver, zds[x].addr, zds[x].numchans, zds[x].timing); + } if (verbose > 1) { printf("\nChannel map:\n\n"); for (x=1;x<ZT_MAX_CHANNELS;x++) { @@ -475,6 +521,7 @@ static struct handler { int (*func)(char *keyword, char *args); } handlers[] = { { "span", spanconfig }, + { "dynamic", dspanconfig }, { "loadzone", registerzone }, { "defaultzone", defaultzone }, { "e&m", chanconfig }, @@ -613,6 +660,10 @@ int main(int argc, char *argv[]) if (fd < 0) error("Unable to open master device '%s'\n", MASTER_DEVICE); else { + for (x=0;x<numdynamic;x++) { + /* destroy them all */ + ioctl(fd, ZT_DYNAMIC_DESTROY, &zds[x]); + } if (stopmode) { for (x=0;x<spans;x++) { if (ioctl(fd, ZT_SHUTDOWN, &lc[x].span)) { @@ -629,6 +680,13 @@ int main(int argc, char *argv[]) exit(1); } } + for (x=0;x<numdynamic;x++) { + if (ioctl(fd, ZT_DYNAMIC_CREATE, &zds[x])) { + fprintf(stderr, "Zaptel dynamic span creation failed: %s\n", strerror(errno)); + close(fd); + exit(1); + } + } for (x=1;x<ZT_MAX_CHANNELS;x++) { if (debug & DEBUG_APPLY) { printf("Configuring device %d\n", x); |