From 04128951db339ddfd7905adf92990f00a3a01447 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Fri, 23 May 2008 15:16:24 +0000 Subject: yay, all the tools compile now git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@4339 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- dahdi_cfg.c | 372 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 185 insertions(+), 187 deletions(-) (limited to 'dahdi_cfg.c') diff --git a/dahdi_cfg.c b/dahdi_cfg.c index a880f3e..ec7299d 100644 --- a/dahdi_cfg.c +++ b/dahdi_cfg.c @@ -37,16 +37,14 @@ #include #include #include -#ifdef STANDALONE_ZAPATA -#include "kernel/zaptel.h" + +#include #include "tonezone.h" -#else -#include -#include -#endif -#include "ztcfg.h" -#define NUM_SPANS ZT_MAX_SPANS +#define CONFIG_FILENAME DAHDI_CONFIG +#define MASTER_DEVICE "/dev/dahdi/ctl" + +#define NUM_SPANS DAHDI_MAX_SPANS #define NUM_TONES 15 @@ -76,15 +74,15 @@ static int errcnt = 0; static int deftonezone = -1; -static struct zt_lineconfig lc[ZT_MAX_SPANS]; +static struct dahdi_lineconfig lc[DAHDI_MAX_SPANS]; -static struct zt_chanconfig cc[ZT_MAX_CHANNELS]; +static struct dahdi_chanconfig cc[DAHDI_MAX_CHANNELS]; -static struct zt_dynamic_span zds[NUM_DYNAMIC]; +static struct dahdi_dynamic_span zds[NUM_DYNAMIC]; -static const char *sig[ZT_MAX_CHANNELS]; /* Signalling */ +static const char *sig[DAHDI_MAX_CHANNELS]; /* Signalling */ -static int slineno[ZT_MAX_CHANNELS]; /* Line number where signalling specified */ +static int slineno[DAHDI_MAX_CHANNELS]; /* Line number where signalling specified */ static int spans=0; @@ -98,7 +96,7 @@ static int stopmode = 0; static int numdynamic = 0; -static char zonestoload[ZT_TONE_ZONE_MAX][10]; +static char zonestoload[DAHDI_TONE_ZONE_MAX][10]; static int numzones = 0; @@ -126,41 +124,41 @@ static const char *sigtype_to_str(const int sig) switch (sig) { case 0: return "Unused"; - case ZT_SIG_EM: + case DAHDI_SIG_EM: return "E & M"; - case ZT_SIG_EM_E1: + case DAHDI_SIG_EM_E1: return "E & M E1"; - case ZT_SIG_FXSLS: + case DAHDI_SIG_FXSLS: return "FXS Loopstart"; - case ZT_SIG_FXSGS: + case DAHDI_SIG_FXSGS: return "FXS Groundstart"; - case ZT_SIG_FXSKS: + case DAHDI_SIG_FXSKS: return "FXS Kewlstart"; - case ZT_SIG_FXOLS: + case DAHDI_SIG_FXOLS: return "FXO Loopstart"; - case ZT_SIG_FXOGS: + case DAHDI_SIG_FXOGS: return "FXO Groundstart"; - case ZT_SIG_FXOKS: + case DAHDI_SIG_FXOKS: return "FXO Kewlstart"; - case ZT_SIG_CAS: + case DAHDI_SIG_CAS: return "CAS / User"; - case ZT_SIG_DACS: + case DAHDI_SIG_DACS: return "DACS"; - case ZT_SIG_DACS_RBS: + case DAHDI_SIG_DACS_RBS: return "DACS w/RBS"; - case ZT_SIG_CLEAR: + case DAHDI_SIG_CLEAR: return "Clear channel"; - case ZT_SIG_SLAVE: + case DAHDI_SIG_SLAVE: return "Slave channel"; - case ZT_SIG_HDLCRAW: + case DAHDI_SIG_HDLCRAW: return "Raw HDLC"; - case ZT_SIG_HDLCNET: + case DAHDI_SIG_HDLCNET: return "Network HDLC"; - case ZT_SIG_HDLCFCS: + case DAHDI_SIG_HDLCFCS: return "HDLC with FCS check"; - case ZT_SIG_HARDHDLC: + case DAHDI_SIG_HARDHDLC: return "Hardware assisted D-channel"; - case ZT_SIG_MTP2: + case DAHDI_SIG_MTP2: return "MTP2"; default: return "Unknown"; @@ -169,12 +167,12 @@ static const char *sigtype_to_str(const int sig) int ind_ioctl(int channo, int fd, int op, void *data) { -ZT_INDIRECT_DATA ind; +DAHDI_INDIRECT_DATA ind; ind.chan = channo; ind.op = op; ind.data = data; - return ioctl(fd,ZT_INDIRECT,&ind); + return ioctl(fd,DAHDI_INDIRECT,&ind); } static void clear_fields() @@ -270,8 +268,8 @@ int dspanconfig(char *keyword, char *args) } - zap_copy_string(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver)); - zap_copy_string(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr)); + dahdi_copy_string(zds[numdynamic].driver, realargs[0], sizeof(zds[numdynamic].driver)); + dahdi_copy_string(zds[numdynamic].addr, realargs[1], sizeof(zds[numdynamic].addr)); zds[numdynamic].numchans = chans; zds[numdynamic].timing = timing; @@ -310,41 +308,41 @@ int spanconfig(char *keyword, char *args) return -1; } if (!strcasecmp(realargs[3], "d4")) { - lc[spans].lineconfig |= ZT_CONFIG_D4; - lc[spans].lineconfig &= ~ZT_CONFIG_ESF; - lc[spans].lineconfig &= ~ZT_CONFIG_CCS; + lc[spans].lineconfig |= DAHDI_CONFIG_D4; + lc[spans].lineconfig &= ~DAHDI_CONFIG_ESF; + lc[spans].lineconfig &= ~DAHDI_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; + lc[spans].lineconfig |= DAHDI_CONFIG_ESF; + lc[spans].lineconfig &= ~DAHDI_CONFIG_D4; + lc[spans].lineconfig &= ~DAHDI_CONFIG_CCS; } else if (!strcasecmp(realargs[3], "ccs")) { - lc[spans].lineconfig |= ZT_CONFIG_CCS; - lc[spans].lineconfig &= ~(ZT_CONFIG_ESF | ZT_CONFIG_D4); + lc[spans].lineconfig |= DAHDI_CONFIG_CCS; + lc[spans].lineconfig &= ~(DAHDI_CONFIG_ESF | DAHDI_CONFIG_D4); } else if (!strcasecmp(realargs[3], "cas")) { - lc[spans].lineconfig &= ~ZT_CONFIG_CCS; - lc[spans].lineconfig &= ~(ZT_CONFIG_ESF | ZT_CONFIG_D4); + lc[spans].lineconfig &= ~DAHDI_CONFIG_CCS; + lc[spans].lineconfig &= ~(DAHDI_CONFIG_ESF | DAHDI_CONFIG_D4); } else { 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 | ZT_CONFIG_HDB3); - lc[spans].lineconfig |= ZT_CONFIG_AMI; + lc[spans].lineconfig &= ~(DAHDI_CONFIG_B8ZS | DAHDI_CONFIG_HDB3); + lc[spans].lineconfig |= DAHDI_CONFIG_AMI; } else if (!strcasecmp(realargs[4], "b8zs")) { - lc[spans].lineconfig |= ZT_CONFIG_B8ZS; - lc[spans].lineconfig &= ~(ZT_CONFIG_AMI | ZT_CONFIG_HDB3); + lc[spans].lineconfig |= DAHDI_CONFIG_B8ZS; + lc[spans].lineconfig &= ~(DAHDI_CONFIG_AMI | DAHDI_CONFIG_HDB3); } else if (!strcasecmp(realargs[4], "hdb3")) { - lc[spans].lineconfig |= ZT_CONFIG_HDB3; - lc[spans].lineconfig &= ~(ZT_CONFIG_AMI | ZT_CONFIG_B8ZS); + lc[spans].lineconfig |= DAHDI_CONFIG_HDB3; + lc[spans].lineconfig &= ~(DAHDI_CONFIG_AMI | DAHDI_CONFIG_B8ZS); } else { 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; + lc[spans].lineconfig |= DAHDI_CONFIG_NOTOPEN; else if (!strcasecmp(realargs[5], "crc4")) { - lc[spans].lineconfig |= ZT_CONFIG_CRC4; + lc[spans].lineconfig |= DAHDI_CONFIG_CRC4; } else { error("Only valid fifth arguments are 'yellow' or 'crc4', not '%s'\n", realargs[5]); return -1; @@ -352,7 +350,7 @@ int spanconfig(char *keyword, char *args) } if (argc > 6) { if (!strcasecmp(realargs[6], "yellow")) - lc[spans].lineconfig |= ZT_CONFIG_NOTOPEN; + lc[spans].lineconfig |= DAHDI_CONFIG_NOTOPEN; else { error("Only valid sixth argument is 'yellow', not '%s'\n", realargs[6]); return -1; @@ -367,19 +365,19 @@ int spanconfig(char *keyword, char *args) int apply_channels(int chans[], char *argstr) { - char *args[ZT_MAX_CHANNELS+1]; + char *args[DAHDI_MAX_CHANNELS+1]; char *range[3]; int res,x, res2,y; int chan; int start, finish; char argcopy[256]; - res = parseargs(argstr, args, ZT_MAX_CHANNELS, ','); + res = parseargs(argstr, args, DAHDI_MAX_CHANNELS, ','); if (res < 0) - error("Too many arguments... Max is %d\n", ZT_MAX_CHANNELS); + error("Too many arguments... Max is %d\n", DAHDI_MAX_CHANNELS); for (x=0;x-.\n", args[x]); @@ -387,18 +385,18 @@ int apply_channels(int chans[], char *argstr) } res2 =sscanf(range[0], "%i", &start); if (res2 != 1) { - error("Syntax error. Start of range '%s' should be a number from 1 to %d\n", args[x], ZT_MAX_CHANNELS - 1); + error("Syntax error. Start of range '%s' should be a number from 1 to %d\n", args[x], DAHDI_MAX_CHANNELS - 1); return -1; - } else if ((start < 1) || (start >= ZT_MAX_CHANNELS)) { - error("Start of range '%s' must be between 1 and %d (not '%d')\n", args[x], ZT_MAX_CHANNELS - 1, start); + } else if ((start < 1) || (start >= DAHDI_MAX_CHANNELS)) { + error("Start of range '%s' must be between 1 and %d (not '%d')\n", args[x], DAHDI_MAX_CHANNELS - 1, start); return -1; } res2 =sscanf(range[1], "%i", &finish); if (res2 != 1) { - error("Syntax error. End of range '%s' should be a number from 1 to %d\n", args[x], ZT_MAX_CHANNELS - 1); + error("Syntax error. End of range '%s' should be a number from 1 to %d\n", args[x], DAHDI_MAX_CHANNELS - 1); return -1; - } else if ((finish < 1) || (finish >= ZT_MAX_CHANNELS)) { - error("end of range '%s' must be between 1 and %d (not '%d')\n", args[x], ZT_MAX_CHANNELS - 1, finish); + } else if ((finish < 1) || (finish >= DAHDI_MAX_CHANNELS)) { + error("end of range '%s' must be between 1 and %d (not '%d')\n", args[x], DAHDI_MAX_CHANNELS - 1, finish); return -1; } if (start > finish) { @@ -411,10 +409,10 @@ int apply_channels(int chans[], char *argstr) /* It's a single channel */ res2 =sscanf(args[x], "%i", &chan); if (res2 != 1) { - error("Syntax error. Channel should be a number from 1 to %d, not '%s'\n", ZT_MAX_CHANNELS - 1, args[x]); + error("Syntax error. Channel should be a number from 1 to %d, not '%s'\n", DAHDI_MAX_CHANNELS - 1, args[x]); return -1; - } else if ((chan < 1) || (chan >= ZT_MAX_CHANNELS)) { - error("Channel must be between 1 and %d (not '%d')\n", ZT_MAX_CHANNELS - 1, chan); + } else if ((chan < 1) || (chan >= DAHDI_MAX_CHANNELS)) { + error("Channel must be between 1 and %d (not '%d')\n", DAHDI_MAX_CHANNELS - 1, chan); return -1; } chans[chan]=1; @@ -431,13 +429,13 @@ int parse_idle(int *i, char *s) if (((a == '0') || (a == '1')) && ((b == '0') || (b == '1')) && ((c == '0') || (c == '1')) && ((d == '0') || (d == '1'))) { *i = 0; if (a == '1') - *i |= ZT_ABIT; + *i |= DAHDI_ABIT; if (b == '1') - *i |= ZT_BBIT; + *i |= DAHDI_BBIT; if (c == '1') - *i |= ZT_CBIT; + *i |= DAHDI_CBIT; if (d == '1') - *i |= ZT_DBIT; + *i |= DAHDI_DBIT; return 0; } } @@ -458,7 +456,7 @@ static int parse_channel(char *channel, int *startchan) static int chanconfig(char *keyword, char *args) { - int chans[ZT_MAX_CHANNELS]; + int chans[DAHDI_MAX_CHANNELS]; int res = 0; int x; int master=0; @@ -474,7 +472,7 @@ static int chanconfig(char *keyword, char *args) res = apply_channels(chans, args); if (res <= 0) return -1; - for (x=1;x= ZT_TONE_ZONE_MAX) { + if (numzones >= DAHDI_TONE_ZONE_MAX) { error("Too many tone zones specified\n"); return 0; } - zap_copy_string(zonestoload[numzones++], args, sizeof(zonestoload[0])); + dahdi_copy_string(zonestoload[numzones++], args, sizeof(zonestoload[0])); return 0; } @@ -960,19 +958,19 @@ int cor_thresh(char *keyword, char *args) int rad_apply_channels(int chans[], char *argstr) { - char *args[ZT_MAX_CHANNELS+1]; + char *args[DAHDI_MAX_CHANNELS+1]; char *range[3]; int res,x, res2,y; int chan; int start, finish; char argcopy[256]; - res = parseargs(argstr, args, ZT_MAX_CHANNELS, ','); + res = parseargs(argstr, args, DAHDI_MAX_CHANNELS, ','); if (res < 0) - error("Too many arguments... Max is %d\n", ZT_MAX_CHANNELS); + error("Too many arguments... Max is %d\n", DAHDI_MAX_CHANNELS); for (x=0;x-.\n", args[x]); @@ -980,18 +978,18 @@ int rad_apply_channels(int chans[], char *argstr) } res2 =sscanf(range[0], "%i", &start); if (res2 != 1) { - error("Syntax error. Start of range '%s' should be a number from 1 to %d\n", args[x], ZT_MAX_CHANNELS - 1); + error("Syntax error. Start of range '%s' should be a number from 1 to %d\n", args[x], DAHDI_MAX_CHANNELS - 1); return -1; - } else if ((start < 1) || (start >= ZT_MAX_CHANNELS)) { - error("Start of range '%s' must be between 1 and %d (not '%d')\n", args[x], ZT_MAX_CHANNELS - 1, start); + } else if ((start < 1) || (start >= DAHDI_MAX_CHANNELS)) { + error("Start of range '%s' must be between 1 and %d (not '%d')\n", args[x], DAHDI_MAX_CHANNELS - 1, start); return -1; } res2 =sscanf(range[1], "%i", &finish); if (res2 != 1) { - error("Syntax error. End of range '%s' should be a number from 1 to %d\n", args[x], ZT_MAX_CHANNELS - 1); + error("Syntax error. End of range '%s' should be a number from 1 to %d\n", args[x], DAHDI_MAX_CHANNELS - 1); return -1; - } else if ((finish < 1) || (finish >= ZT_MAX_CHANNELS)) { - error("end of range '%s' must be between 1 and %d (not '%d')\n", args[x], ZT_MAX_CHANNELS - 1, finish); + } else if ((finish < 1) || (finish >= DAHDI_MAX_CHANNELS)) { + error("end of range '%s' must be between 1 and %d (not '%d')\n", args[x], DAHDI_MAX_CHANNELS - 1, finish); return -1; } if (start > finish) { @@ -1004,10 +1002,10 @@ int rad_apply_channels(int chans[], char *argstr) /* It's a single channel */ res2 =sscanf(args[x], "%i", &chan); if (res2 != 1) { - error("Syntax error. Channel should be a number from 1 to %d, not '%s'\n", ZT_MAX_CHANNELS - 1, args[x]); + error("Syntax error. Channel should be a number from 1 to %d, not '%s'\n", DAHDI_MAX_CHANNELS - 1, args[x]); return -1; - } else if ((chan < 1) || (chan >= ZT_MAX_CHANNELS)) { - error("Channel must be between 1 and %d (not '%d')\n", ZT_MAX_CHANNELS - 1, chan); + } else if ((chan < 1) || (chan >= DAHDI_MAX_CHANNELS)) { + error("Channel must be between 1 and %d (not '%d')\n", DAHDI_MAX_CHANNELS - 1, chan); return -1; } chans[chan]=1; @@ -1018,108 +1016,108 @@ int rad_apply_channels(int chans[], char *argstr) static int rad_chanconfig(char *keyword, char *args) { - int chans[ZT_MAX_CHANNELS]; + int chans[DAHDI_MAX_CHANNELS]; int res = 0; int x,i,n; - struct zt_radio_param p; + struct dahdi_radio_param p; toneindex = 1; bzero(chans, sizeof(chans)); res = rad_apply_channels(chans, args); if (res <= 0) return -1; - for (x=1;x 1) { printf("\nChannel map:\n\n"); - for (x=1;x 1) printf("Changing law on channel %d from %s to %s\n", @@ -1442,8 +1440,8 @@ int main(int argc, char *argv[]) } } - if (needupdate && ioctl(fd, ZT_CHANCONFIG, &cc[x])) { - fprintf(stderr, "ZT_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno); + if (needupdate && ioctl(fd, DAHDI_CHANCONFIG, &cc[x])) { + fprintf(stderr, "DAHDI_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno); if (errno == EINVAL) { fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n" "and that FXO interfaces use FXS signalling?\n"); @@ -1466,14 +1464,14 @@ int main(int argc, char *argv[]) fflush(stdout); } if (deftonezone > -1) { - if (ioctl(fd, ZT_DEFAULTZONE, &deftonezone)) { - fprintf(stderr, "ZT_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno); + if (ioctl(fd, DAHDI_DEFAULTZONE, &deftonezone)) { + fprintf(stderr, "DAHDI_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno); close(fd); exit(1); } } for (x=0;x