803
int tx_gain(char *keyword, char *args)
805
static char *realargs[10];
809
argc = res = parseargs(args, realargs, 1, ',');
811
error("Incorrect number of arguments to 'txgain' (should be <value>)\n");
813
res = sscanf(realargs[0], "%d", &val);
815
error("Invalid value '%s', should be a number > 0.\n", realargs[0]);
822
int rx_gain(char *keyword, char *args)
824
static char *realargs[10];
828
argc = res = parseargs(args, realargs, 1, ',');
830
error("Incorrect number of arguments to 'rxgain' (should be <value>)\n");
832
res = sscanf(realargs[0], "%d", &val);
834
error("Invalid value '%s', should be a number > 0.\n", realargs[0]);
841
int de_emp(char *keyword, char *args)
843
static char *realargs[10];
847
argc = res = parseargs(args, realargs, 1, ',');
849
error("Incorrect number of arguments to 'de-emp' (should be <value>)\n");
851
res = sscanf(realargs[0], "%d", &val);
852
if ((res == 1) && (val < 1))
855
error("Invalid value '%s', should be a number > 0.\n", realargs[0]);
862
int pre_emp(char *keyword, char *args)
864
static char *realargs[10];
868
argc = res = parseargs(args, realargs, 1, ',');
870
error("Incorrect number of arguments to 'pre_emp' (should be <value>)\n");
872
res = sscanf(realargs[0], "%d", &val);
873
if ((res == 1) && (val < 1))
876
error("Invalid value '%s', should be a number > 0.\n", realargs[0]);
779
883
int invert_cor(char *keyword, char *args)
781
885
static char *realargs[10];
928
1033
p.radpar = ZT_RADPAR_NUMTONES;
929
1034
if (ind_ioctl(x,fd,ZT_RADIO_GETPARAM,&p) == -1)
930
error("Cannot get number of tones for channel %d\n",x);
932
p.radpar = ZT_RADPAR_INITTONE;
933
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
934
error("Cannot init tones for channel %d\n",x);
935
if (!rxtones[0]) for(i = 1; i <= n; i++)
1035
n = 0; else n = p.data;
939
p.radpar = ZT_RADPAR_RXTONE;
942
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
943
error("Cannot set rxtone on channel %d\n",x);
947
p.radpar = ZT_RADPAR_RXTONECLASS;
950
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
951
error("Cannot set rxtag on channel %d\n",x);
1038
p.radpar = ZT_RADPAR_INITTONE;
1039
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
1040
error("Cannot init tones for channel %d\n",x);
1041
if (!rxtones[0]) for(i = 1; i <= n; i++)
1045
p.radpar = ZT_RADPAR_RXTONE;
1047
p.data = rxtones[i];
1048
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
1049
error("Cannot set rxtone on channel %d\n",x);
1053
p.radpar = ZT_RADPAR_RXTONECLASS;
1056
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
1057
error("Cannot set rxtag on channel %d\n",x);
1061
p.radpar = ZT_RADPAR_TXTONE;
1063
p.data = txtones[i];
1064
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
1065
error("Cannot set txtone on channel %d\n",x);
1067
} else { /* if we may have DCS receive */
1070
p.radpar = ZT_RADPAR_RXTONE;
1072
p.data = rxtones[0];
1073
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
1074
error("Cannot set DCS rxtone on channel %d\n",x);
955
1079
p.radpar = ZT_RADPAR_TXTONE;
958
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
959
error("Cannot set txtone on channel %d\n",x);
961
} else { /* if we may have DCS receive */
964
p.radpar = ZT_RADPAR_RXTONE;
1081
p.data = txtones[0];
967
1082
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
968
error("Cannot set DCS rxtone on channel %d\n",x);
1083
error("Cannot set default txtone on channel %d\n",x);
973
p.radpar = ZT_RADPAR_TXTONE;
976
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
977
error("Cannot set default txtone on channel %d\n",x);
979
1086
if (debouncetime)
981
1088
p.radpar = ZT_RADPAR_DEBOUNCETIME;
990
1097
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
991
1098
error("Cannot set bursttime on channel %d\n",x);
995
p.radpar = ZT_RADPAR_INVERTCOR;
997
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
998
error("Cannot set invertcor on channel %d\n",x);
1002
p.radpar = ZT_RADPAR_EXTRXTONE;
1004
if (ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p) == -1)
1005
error("Cannot set exttone on channel %d\n",x);
1100
p.radpar = ZT_RADPAR_DEEMP;
1102
ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p);
1103
p.radpar = ZT_RADPAR_PREEMP;
1105
ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p);
1106
p.radpar = ZT_RADPAR_TXGAIN;
1108
ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p);
1109
p.radpar = ZT_RADPAR_RXGAIN;
1111
ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p);
1112
p.radpar = ZT_RADPAR_INVERTCOR;
1114
ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p);
1115
p.radpar = ZT_RADPAR_EXTRXTONE;
1117
ind_ioctl(x,fd,ZT_RADIO_SETPARAM,&p);
1009
1120
p.radpar = ZT_RADPAR_CORTHRESH;
1232
1359
if (debug & DEBUG_APPLY) {
1233
1360
printf("About to open Master device\n");
1234
1361
fflush(stdout);
1236
if (fd == -1) fd = open(MASTER_DEVICE, O_RDWR);
1238
error("Unable to open master device '%s'\n", MASTER_DEVICE);
1363
for (x=0;x<numdynamic;x++) {
1364
/* destroy them all */
1365
ioctl(fd, ZT_DYNAMIC_DESTROY, &zds[x]);
1368
for (x=0;x<spans;x++) {
1369
if (ioctl(fd, ZT_SHUTDOWN, &lc[x].span)) {
1370
fprintf(stderr, "Zaptel shutdown failed: %s\n", strerror(errno));
1376
for (x=0;x<spans;x++) {
1377
if (ioctl(fd, ZT_SPANCONFIG, lc + x)) {
1378
fprintf(stderr, "ZT_SPANCONFIG failed on span %d: %s (%d)\n", lc[x].span, strerror(errno), errno);
1240
1383
for (x=0;x<numdynamic;x++) {
1241
/* destroy them all */
1242
ioctl(fd, ZT_DYNAMIC_DESTROY, &zds[x]);
1245
for (x=0;x<spans;x++) {
1246
if (ioctl(fd, ZT_SHUTDOWN, &lc[x].span)) {
1247
fprintf(stderr, "Zaptel shutdown failed: %s\n", strerror(errno));
1253
for (x=0;x<spans;x++) {
1254
if (ioctl(fd, ZT_SPANCONFIG, lc + x)) {
1255
fprintf(stderr, "ZT_SPANCONFIG failed on span %d: %s (%d)\n", lc[x].span, strerror(errno), errno);
1260
for (x=0;x<numdynamic;x++) {
1261
if (ioctl(fd, ZT_DYNAMIC_CREATE, &zds[x])) {
1262
fprintf(stderr, "Zaptel dynamic span creation failed: %s\n", strerror(errno));
1267
for (x=1;x<ZT_MAX_CHANNELS;x++) {
1268
struct zt_params current_state;
1270
int needupdate = force;
1272
if (debug & DEBUG_APPLY) {
1273
printf("Configuring device %d\n", x);
1280
memset(¤t_state, 0, sizeof(current_state));
1281
current_state.channo = cc[x].chan | ZT_GET_PARAMS_RETURN_MASTER;
1282
if (ioctl(fd, ZT_GET_PARAMS, ¤t_state))
1287
master = current_state.channo >> 16;
1289
if (cc[x].sigtype != current_state.sigtype) {
1292
printf("Changing signalling on channel %d from %s to %s\n",
1293
cc[x].chan, sigtype_to_str(current_state.sigtype),
1294
sigtype_to_str(cc[x].sigtype));
1297
if ((cc[x].deflaw != ZT_LAW_DEFAULT) && (cc[x].deflaw != current_state.curlaw)) {
1300
printf("Changing law on channel %d from %s to %s\n",
1301
cc[x].chan, laws[current_state.curlaw],
1302
laws[cc[x].deflaw]);
1305
if (cc[x].master != master) {
1308
printf("Changing master of channel %d from %d to %d\n",
1313
if (cc[x].idlebits != current_state.idlebits) {
1316
printf("Changing idle bits of channel %d from %d to %d\n",
1317
cc[x].chan, current_state.idlebits,
1322
if (needupdate && ioctl(fd, ZT_CHANCONFIG, &cc[x])) {
1323
fprintf(stderr, "ZT_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno);
1324
if (errno == EINVAL) {
1325
fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n"
1326
"and that FXO interfaces use FXS signalling?\n");
1332
for (x=0;x<numzones;x++) {
1333
if (debug & DEBUG_APPLY) {
1334
printf("Loading tone zone for %s\n", zonestoload[x]);
1337
if (tone_zone_register(fd, zonestoload[x]))
1384
if (ioctl(fd, ZT_DYNAMIC_CREATE, &zds[x])) {
1385
fprintf(stderr, "Zaptel dynamic span creation failed: %s\n", strerror(errno));
1390
for (x=1;x<ZT_MAX_CHANNELS;x++) {
1391
struct zt_params current_state;
1393
int needupdate = force;
1395
if (debug & DEBUG_APPLY) {
1396
printf("Configuring device %d\n", x);
1403
memset(¤t_state, 0, sizeof(current_state));
1404
current_state.channo = cc[x].chan | ZT_GET_PARAMS_RETURN_MASTER;
1405
if (ioctl(fd, ZT_GET_PARAMS, ¤t_state))
1410
master = current_state.channo >> 16;
1412
if (cc[x].sigtype != current_state.sigtype) {
1415
printf("Changing signalling on channel %d from %s to %s\n",
1416
cc[x].chan, sigtype_to_str(current_state.sigtype),
1417
sigtype_to_str(cc[x].sigtype));
1420
if ((cc[x].deflaw != ZT_LAW_DEFAULT) && (cc[x].deflaw != current_state.curlaw)) {
1423
printf("Changing law on channel %d from %s to %s\n",
1424
cc[x].chan, laws[current_state.curlaw],
1425
laws[cc[x].deflaw]);
1428
if (cc[x].master != master) {
1431
printf("Changing master of channel %d from %d to %d\n",
1436
if (cc[x].idlebits != current_state.idlebits) {
1439
printf("Changing idle bits of channel %d from %d to %d\n",
1440
cc[x].chan, current_state.idlebits,
1445
if (needupdate && ioctl(fd, ZT_CHANCONFIG, &cc[x])) {
1446
fprintf(stderr, "ZT_CHANCONFIG failed on channel %d: %s (%d)\n", x, strerror(errno), errno);
1447
if (errno == EINVAL) {
1448
fprintf(stderr, "Did you forget that FXS interfaces are configured with FXO signalling\n"
1449
"and that FXO interfaces use FXS signalling?\n");
1455
for (x=0;x<numzones;x++) {
1456
if (debug & DEBUG_APPLY) {
1457
printf("Loading tone zone for %s\n", zonestoload[x]);
1460
if (tone_zone_register(fd, zonestoload[x]))
1338
1462
error("Unable to register tone zone '%s'\n", zonestoload[x]);
1340
if (debug & DEBUG_APPLY) {
1341
printf("Doing startup\n");
1344
if (deftonezone > -1) {
1345
if (ioctl(fd, ZT_DEFAULTZONE, &deftonezone)) {
1346
fprintf(stderr, "ZT_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno);
1351
for (x=0;x<spans;x++) {
1352
if (ioctl(fd, ZT_STARTUP, &lc[x].span)) {
1353
fprintf(stderr, "Zaptel startup failed: %s\n", strerror(errno));
1464
if (debug & DEBUG_APPLY) {
1465
printf("Doing startup\n");
1468
if (deftonezone > -1) {
1469
if (ioctl(fd, ZT_DEFAULTZONE, &deftonezone)) {
1470
fprintf(stderr, "ZT_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno);
1475
for (x=0;x<spans;x++) {
1476
if (ioctl(fd, ZT_STARTUP, &lc[x].span)) {
1477
fprintf(stderr, "Zaptel startup failed: %s\n", strerror(errno));