Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1292ea9078 | ||
|
|
cfee27106b | ||
|
|
066fa2aff3 | ||
|
|
bce5afacf1 | ||
|
|
dd752529f0 | ||
|
|
27d07446ef | ||
|
|
8e2a5def27 | ||
|
|
e553ffde2b | ||
|
|
d1fb614ac8 | ||
|
|
98ecc272d1 | ||
|
|
91768d360c | ||
|
|
63842cc4f3 | ||
|
|
b8d1e467e4 | ||
|
|
de1ee8494a | ||
|
|
d3feed5c4c | ||
|
|
b621c02b7f | ||
|
|
451a8b4d6f | ||
|
|
09fd3f53b1 | ||
|
|
c3b020a155 | ||
|
|
7f826a7d35 | ||
|
|
cdedf024ae | ||
|
|
a6203e151f | ||
|
|
69ce6f07e0 | ||
|
|
9989b8779c | ||
|
|
a4f79134c9 | ||
|
|
d8074f434f | ||
|
|
15875924f0 | ||
|
|
a5bf1d3a2e | ||
|
|
bf960799ea | ||
|
|
4f259cd569 | ||
|
|
4d5ca04ad6 | ||
|
|
2d3580a3db | ||
|
|
d96be70986 | ||
|
|
41a725adea | ||
|
|
6ed0adc086 | ||
|
|
5e75fa48f4 | ||
|
|
4ab8e95d0b | ||
|
|
5ca600c7c7 | ||
|
|
98736e1add |
14
.gitignore
vendored
14
.gitignore
vendored
@@ -1,10 +1,13 @@
|
||||
*.o
|
||||
.*.o.d
|
||||
.*.lo.d
|
||||
*.asciidoc
|
||||
*.html
|
||||
build_tools/menuselect-deps
|
||||
config.log
|
||||
config.status
|
||||
dahdi_cfg
|
||||
dahdi_diag
|
||||
dahdi_maint
|
||||
dahdi_monitor
|
||||
dahdi_scan
|
||||
@@ -12,11 +15,22 @@ dahdi_speed
|
||||
dahdi_test
|
||||
dahdi_tool
|
||||
fxotune
|
||||
fxstest
|
||||
genconf_parameters.sample
|
||||
hdlcgen
|
||||
hdlcstress
|
||||
hdlctest
|
||||
hdlcverify
|
||||
libtonezone.a
|
||||
libtonezone.so
|
||||
makeopts
|
||||
patgen
|
||||
patlooptest
|
||||
pattest
|
||||
sethdlc
|
||||
timertest
|
||||
tonezone.lo
|
||||
tonezones.txt
|
||||
version.c
|
||||
xpp/.depend
|
||||
xpp/.octasic.depend
|
||||
|
||||
29
Makefile
29
Makefile
@@ -60,6 +60,8 @@ MODULES_FILE = /etc/dahdi/modules
|
||||
GENCONF_FILE = /etc/dahdi/genconf_parameters
|
||||
MODPROBE_FILE = /etc/modprobe.d/dahdi.conf
|
||||
BLACKLIST_FILE = /etc/modprobe.d/dahdi.blacklist.conf
|
||||
BASH_COMP_DIR = /etc/bash_completion.d
|
||||
BASH_COMP_FILE = $(BASH_COMP_DIR)/dahdi
|
||||
|
||||
NETSCR_DIR := $(firstword $(wildcard $(DESTDIR)/etc/sysconfig/network-scripts ))
|
||||
ifneq (,$(NETSCR_DIR))
|
||||
@@ -103,12 +105,23 @@ endif
|
||||
ifeq (1,$(PBX_HDLC))
|
||||
BINS += sethdlc
|
||||
endif
|
||||
ASSIGNED_DATA_SCRIPTS:=dahdi_handle_device dahdi_span_config
|
||||
ASSIGNED_UTILS:=dahdi_span_assignments dahdi_span_types
|
||||
ASSIGNED_DATA_SCRIPTS:=\
|
||||
dahdi_handle_device \
|
||||
dahdi_span_config \
|
||||
dahdi_auto_assign_compat \
|
||||
span_config.d/10-dahdi-cfg \
|
||||
span_config.d/20-fxotune \
|
||||
span_config.d/50-asterisk \
|
||||
handle_device.d/10-span-types \
|
||||
handle_device.d/20-span-assignments
|
||||
|
||||
ASSIGNED_UTILS:=dahdi_span_assignments dahdi_span_types \
|
||||
dahdi_waitfor_span_assignments
|
||||
ASSIGNED_CONF:=assigned-spans.conf.sample span-types.conf.sample
|
||||
|
||||
MAN_PAGES:=$(wildcard $(BINS:%=doc/%.8))
|
||||
MAN_PAGES:=$(wildcard $(ASSIGNED_UTILS:%=doc/%.8))
|
||||
MAN_PAGES:= \
|
||||
$(wildcard $(BINS:%=doc/%.8)) \
|
||||
$(wildcard $(ASSIGNED_UTILS:%=doc/%.8))
|
||||
|
||||
TEST_BINS:=patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest dahdi_maint
|
||||
# All the man pages. Not just installed ones:
|
||||
@@ -167,7 +180,7 @@ $(LTZ_SO): $(LTZ_SO_OBJS)
|
||||
$(CC) $(CFLAGS) -shared -Wl,-soname,$(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) -o $@ $^ -lm
|
||||
|
||||
dahdi_cfg: $(LTZ_A)
|
||||
dahdi_cfg: LIBS+=-lm
|
||||
dahdi_cfg: LIBS+=-lm -lpthread
|
||||
dahdi_pcap:
|
||||
$(CC) $(CFLAGS) dahdi_pcap.c -lpcap -o $@ $<
|
||||
|
||||
@@ -195,7 +208,7 @@ genconf_parameters.sample: xpp/genconf_parameters
|
||||
README.html: README system.conf.asciidoc init.conf.asciidoc tonezones.txt \
|
||||
UPGRADE.txt genconf_parameters.asciidoc assigned-spans.conf.asciidoc \
|
||||
span-types.conf.asciidoc
|
||||
$(ASCIIDOC) -n -a toc -a toclevels=3 $<
|
||||
$(ASCIIDOC) -n -a toc -a toclevels=4 $<
|
||||
|
||||
README.Astribank.html: xpp/README.Astribank
|
||||
$(ASCIIDOC) -o $@ -n -a toc -a toclevels=4 $<
|
||||
@@ -230,9 +243,11 @@ ifeq (,$(wildcard $(DESTDIR)$(CONFIG_FILE)))
|
||||
$(INSTALL) -m 644 system.conf.sample $(DESTDIR)$(CONFIG_FILE)
|
||||
endif
|
||||
install -d $(DESTDIR)$(DATA_DIR)
|
||||
install $(ASSIGNED_DATA_SCRIPTS) $(DESTDIR)$(DATA_DIR)/
|
||||
tar cf - -C hotplug $(ASSIGNED_DATA_SCRIPTS) | tar xf - -C $(DESTDIR)$(DATA_DIR)/
|
||||
install $(ASSIGNED_UTILS) $(DESTDIR)/$(BIN_DIR)/
|
||||
install -m 644 $(ASSIGNED_CONF) $(DESTDIR)/$(CONFIG_DIR)/
|
||||
install -d $(DESTDIR)$(BASH_COMP_DIR)
|
||||
install -m 644 dahdi-bash-completion $(DESTDIR)$(BASH_COMP_FILE)
|
||||
|
||||
install-libs: libs
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)/$(LIB_DIR)
|
||||
|
||||
148
README
148
README
@@ -49,15 +49,18 @@ There are some make targets that are provided to build or install just
|
||||
parts of DAHDI:
|
||||
|
||||
. Build targets:
|
||||
- make: Build DAHDI user-space programs. partial
|
||||
- make: Build DAHDI user-space programs and libraries. partial
|
||||
targets of it:
|
||||
* make 'utilname': builds 'utilname' alone (e.g: `make dahdi_diag`)
|
||||
* make utils: Build libtonezone.
|
||||
* make utils: Build just the programs.
|
||||
* make libs: Build libtonezone.
|
||||
* make tests: Build testing binaries.
|
||||
. Install targets:
|
||||
- make install: Installs user space tools into /usr/sbin/ (TODO - list
|
||||
partial targets)
|
||||
- make config: should be run once to configure
|
||||
- make install: Install everything. Sub-targets of it:
|
||||
* make install-utils: Installs most things.
|
||||
* make install-libs: Installs libtonezone.
|
||||
- make config: install configuration files (overriding existing ones).
|
||||
- make install-test: Install testing binaries.
|
||||
|
||||
|
||||
Installation to a Subtree
|
||||
@@ -117,29 +120,29 @@ set at the beginning of the init.d script.
|
||||
Reference Configuration
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Sample system.conf
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
include::system.conf.asciidoc[]
|
||||
|
||||
|
||||
Sample init.conf
|
||||
~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^
|
||||
include::init.conf.asciidoc[]
|
||||
|
||||
|
||||
Sample genconf_parameters
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
FIXME: still not properly formatted.
|
||||
|
||||
include::genconf_parameters.asciidoc[]
|
||||
|
||||
|
||||
Sample assigned-spans.conf
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
include::assigned-spans.conf.asciidoc[]
|
||||
|
||||
|
||||
Sample span-types.conf
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
include::span-types.conf.asciidoc[]
|
||||
|
||||
|
||||
@@ -212,6 +215,131 @@ that is included in the ppp/ subdirectory. To install it:
|
||||
CONFIG_HDLC .
|
||||
|
||||
|
||||
Initialization
|
||||
--------------
|
||||
This section documents the start up sequence of the DAHDI modules.
|
||||
|
||||
There are generally two options: explicit (using an init script) and
|
||||
implicit (run from UDEV hook scripts).
|
||||
|
||||
Explicit
|
||||
~~~~~~~~
|
||||
The dahdi init scripts does the following tasks:
|
||||
|
||||
* Loading the module dahdi and any other module listed in
|
||||
/etc/dahdi/modules.
|
||||
* For xpp (Astribanks) - some specific initializations. See
|
||||
README.Astribank.
|
||||
* Runs link:doc/dahdi_cfg.8.html[dahdi_cfg] after all modules were
|
||||
loaded.
|
||||
* A number of other tools may need to be run:
|
||||
** link:doc/fxotune.8.html[fxotune]
|
||||
** dahdihpec_enable
|
||||
|
||||
Only at this point Asterisk (or any other user of DAHDI) can be run.
|
||||
|
||||
|
||||
Implicit
|
||||
~~~~~~~~
|
||||
(Also known as "hot-plug" or "pinned-spans". This requires:
|
||||
|
||||
* dahdi >= 2.8.0
|
||||
* Setting the module parameter auto_assign_spans of dahdi to 0
|
||||
* (Recommended) Asterisk >= 12 - which supports "dahdi create channels".
|
||||
|
||||
When a device driver of a DAHDI device finishes initialization, it
|
||||
creates a dahdi_device kernel object. A dahdi_device represents a single
|
||||
DAHDI device (such as a PCI card) and may have several spans. If the
|
||||
value of auto_assign_spans is 1 when dahdi_device is created, spans are
|
||||
assigned automatically - each new span gets the first available span
|
||||
number and range of channels. However if it is set to 0, spans will not
|
||||
get assigned, and user space programs need to assign them. The
|
||||
low-level interface for doing so is explained in the section "Span
|
||||
Assignment" in the README of DAHDI-Linux.
|
||||
|
||||
New Devices
|
||||
^^^^^^^^^^^
|
||||
When a kernel object is created or destroyed, the kernel sends an event
|
||||
to user space. Those events are normally handled by udevd. Configurations
|
||||
for udevd ("udev rules") may be placed in /etc/udev/rules.d or
|
||||
/lib/udev/rules.d. This package installs rules that instruct udevd to
|
||||
run the script `/usr/share/dahdi/dahdi_handle_device` on each new
|
||||
device, which runs all the scripts in `/usr/share/dahdi/handle_device.d`.
|
||||
Those scripts will:
|
||||
|
||||
* If `/etc/dahdi/span-types.conf` exists, apply it to the device. It is
|
||||
used for E1/T1/J1 settings. See
|
||||
<<_sample_span_types_conf,sample span-types.conf>>.
|
||||
|
||||
* If `/etc/dahdi/assigned-spans.conf` exists, assign the span according
|
||||
to it (if it is not specified there: don't assign it).
|
||||
used for E1/T1/J1 settings. See
|
||||
<<_sample_assigned_spans_conf,sample assigned-spans.conf>>.
|
||||
|
||||
* But if that file does not exist, assign the span to the first
|
||||
available place.
|
||||
|
||||
This script mainly uses the commands
|
||||
link:doc/dahdi_span_types.8.html[dahdi_span_types] and
|
||||
link:doc/dahdi_span_assignments.8.html[dahdi_span_assignments].
|
||||
|
||||
DAHDI devices are listed under `/sys/bus/dahdi_devices/devices`.
|
||||
|
||||
If you want to disable running this script, add the following line to
|
||||
`/etc/dahdi/init.conf`:
|
||||
.............................
|
||||
DAHDI_UDEV_DISABLE_DEVICES=yes
|
||||
.............................
|
||||
|
||||
|
||||
New Spans
|
||||
^^^^^^^^^
|
||||
Once a span is assigned, a kernel object will appear for it. It will be
|
||||
listed under its device. As a new kernel object was created, an event is
|
||||
sent to udev.
|
||||
|
||||
The standard DAHDI udev rules instruct udevd to run the script
|
||||
`/usr/share/dahdi/dahdi_span_config` which runs all the scripts in
|
||||
`/usr/share/dahdi/span_config.d`. Those script configures the new
|
||||
span:
|
||||
|
||||
* If system.conf does not exist, generates a temporary configuration
|
||||
for the span using link:doc/dahdi_genconf.8.html[dahdi_genconf
|
||||
system].
|
||||
|
||||
* Runs link:doc/dahdi_cfg.8.html[dahdi_cfg] on the new span (using `-S`
|
||||
and -C`).
|
||||
|
||||
* Runs `asterisk -rx 'dahdi create channels'` to add the new channels
|
||||
and spans to Asterisk (if they were configured in advance).
|
||||
|
||||
If you want to disable running this script, add the following line to
|
||||
`/etc/dahdi/init.conf`:
|
||||
.............................
|
||||
DAHDI_UDEV_DISABLE_SPANS=yes
|
||||
.............................
|
||||
|
||||
|
||||
New Channels
|
||||
^^^^^^^^^^^^
|
||||
DAHDI channels have their own representation in the kernel. The standard
|
||||
udev rules that dahdi-tools includes for them, however, don't run a
|
||||
script for each device. Each DAHDI channel creates a block device file
|
||||
at /dev/dahdi/chan/'span'/'rel-chan', where 'span' and 'rel-chan' are
|
||||
each three-digit numbers (e.g: 035). 'span' is the span number and
|
||||
'rel-chan' is the channel number relative to the span.
|
||||
|
||||
The udev rules generate the following extra symlinks under /dev/dahdi:
|
||||
|
||||
* /dev/dahdi/'num' - the channel number. As it was originally (but
|
||||
continues beyond 250).
|
||||
* /dev/dahdi/devices/'hardware_id'/'rel-span'/'rel-chan' - if the DAHDI
|
||||
device has a hardware ID field, provide listing of the device's span
|
||||
and channels.
|
||||
* /dev/dahdi/devices/@'hardware_id'/'rel-span'/'rel-chan' - likewise for
|
||||
the connector field. It has a "@" prefix.
|
||||
|
||||
|
||||
include::UPGRADE.txt[]
|
||||
|
||||
|
||||
|
||||
133
dahdi-bash-completion
Normal file
133
dahdi-bash-completion
Normal file
@@ -0,0 +1,133 @@
|
||||
# Check for bash
|
||||
[ -z "$BASH_VERSION" ] && return
|
||||
|
||||
__dahdi_span_assignments() {
|
||||
local cur prev has_cmd i
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
has_cmd=0
|
||||
for (( i=0; i < COMP_CWORD; i++)); do
|
||||
case "${COMP_WORDS[$i]}" in
|
||||
add | auto | dumpconfig | list | remove)
|
||||
has_cmd=1
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case "$prev" in
|
||||
-k | --key) COMPREPLY=( $(compgen -W 'devpath hwid location' -- $cur) ) ;;
|
||||
*)
|
||||
case "$cur" in
|
||||
-*) COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'-h -k -n -v --help --key --dry-run --verbose' -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
if [ "$has_cmd" = 1 ]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(shopt -s nullglob; \
|
||||
echo /sys/bus/dahdi_devices/devices/* ) )
|
||||
else
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'add auto dumpconfig list remove' -- $cur) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dahdi_span_assignments dahdi_span_assignments
|
||||
|
||||
__dahdi_span_types() {
|
||||
local cur prev has_cmd i
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
has_cmd=0
|
||||
for (( i=0; i < COMP_CWORD; i++)); do
|
||||
case "${COMP_WORDS[$i]}" in
|
||||
dumpconfig | list | set)
|
||||
has_cmd=1
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case "$prev" in
|
||||
-k | --key) COMPREPLY=( $(compgen -W 'devpath hwid location' -- $cur) ) ;;
|
||||
--line-type) COMPREPLY=( $(compgen -W 'E1 J1 T1' -- $cur) ) ;;
|
||||
*)
|
||||
case "$cur" in
|
||||
-*) COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'-h -k -n -v --help --key --dry-run --line-type --verbose' -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
if [ "$has_cmd" = 1 ]; then
|
||||
# FIXME: check if devices are settable?
|
||||
COMPREPLY=( ${COMPREPLY[@]} $( \
|
||||
grep -l '[EJT]1' /sys/devices/pci0000:00/0000:00:10.4/usb1/1-1/xbus-00/*/spantype 2>/dev/null | sed -e 's|/spantype||') )
|
||||
else
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'dumpconfig list set' -- $cur) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dahdi_span_types dahdi_span_types
|
||||
|
||||
|
||||
__dahdi_genconf() {
|
||||
local cur
|
||||
COMPREPLY=()
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
case "$prev" in
|
||||
--line-type) COMPREPLY=( $(compgen -W 'E1 J1 T1' -- $cur) ) ;;
|
||||
*)
|
||||
case "$cur" in
|
||||
-*) COMPREPLY+=( $(compgen -W '-F -v -V --freepbx --version --verbose --line-type' -- $cur ) ) ;;
|
||||
*)
|
||||
COMPREPLY+=( $(compgen -W "$( perl -e 'my $file = "\u$ARGV[0]";
|
||||
# Complete module name. Translate the case of the
|
||||
# first letter
|
||||
my @pats = map {"$_/Dahdi/Config/Gen/$file*.pm"} @INC;
|
||||
foreach (@pats) {
|
||||
foreach(glob) {
|
||||
s|.*/||;
|
||||
s|.pm$||;
|
||||
s|^(.)|lc($1)|e;
|
||||
print "$_ "
|
||||
}
|
||||
}')" -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dahdi_genconf dahdi_genconf
|
||||
|
||||
__dahdi_cfg() {
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
case "$prev" in
|
||||
-c) COMPREPLY=( $(compgen -f -- $cur) ) ;;
|
||||
-S) COMPREPLY=( $(ls -d /sys/bus/dahdi_spans/devices/* 2>/dev/null | sed -e 's/.*-//') ) ;;
|
||||
# FIXME: A similar completion for -C (<chan1>-<chan2>)
|
||||
*)
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'-c -C -f -h -s -S -t -v ' -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Disable until -c works properly
|
||||
#complete -F __dahdi_cfg dahdi_cfg
|
||||
13
dahdi.init
13
dahdi.init
@@ -148,11 +148,6 @@ xpp_startup() {
|
||||
if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
|
||||
|
||||
hotplug_exit_after_load
|
||||
|
||||
# overriding locales for the above two, as perl can be noisy
|
||||
# when locales are missing.
|
||||
# No register all the devices if they didn't auto-register:
|
||||
LC_ALL=C dahdi_registration on
|
||||
}
|
||||
|
||||
|
||||
@@ -237,11 +232,6 @@ if [ ! -x "$DAHDI_CFG" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ ! -f /etc/dahdi/system.conf ]; then
|
||||
echo "/etc/dahdi/system.conf not found. Nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
|
||||
# See how we were called.
|
||||
@@ -268,6 +258,9 @@ case "$1" in
|
||||
|
||||
xpp_startup
|
||||
|
||||
# Assign all spans that weren't handled via udev + /etc/dahdi/assigned-spans.conf
|
||||
/usr/share/dahdi/dahdi_auto_assign_compat
|
||||
|
||||
if [ $system = debian ]; then
|
||||
echo -n "Running dahdi_cfg: "
|
||||
$DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
|
||||
|
||||
@@ -8,11 +8,11 @@ SUBSYSTEM=="dahdi", OWNER="asterisk", GROUP="asterisk", MODE="0660"
|
||||
SUBSYSTEM=="dahdi_channels", SYMLINK+="dahdi/%m"
|
||||
|
||||
# Add persistant names as well
|
||||
SUBSYSTEM=="dahdi_channels", SYSFS{hardware_id}!="", SYMLINK+="dahdi/devices/%s{hardware_id}/%s{local_spanno}/%n"
|
||||
SUBSYSTEM=="dahdi_channels", SYSFS{location}!="", SYMLINK+="dahdi/devices/@%s{location}/%s{local_spanno}/%n"
|
||||
SUBSYSTEM=="dahdi_channels", ATTRS{hardware_id}!="", SYMLINK+="dahdi/devices/%s{hardware_id}/%s{local_spanno}/%n"
|
||||
SUBSYSTEM=="dahdi_channels", ATTRS{location}!="", SYMLINK+="dahdi/devices/@%s{location}/%s{local_spanno}/%n"
|
||||
|
||||
LABEL="dahdi_add_end"
|
||||
|
||||
# hotplug scripts
|
||||
SUBSYSTEM=="dahdi_devices", RUN="%E{DAHDI_TOOLS_ROOTDIR}/usr/share/dahdi/dahdi_handle_device"
|
||||
SUBSYSTEM=="dahdi_spans", RUN="%E{DAHDI_TOOLS_ROOTDIR}/usr/share/dahdi/dahdi_span_config"
|
||||
SUBSYSTEM=="dahdi_devices", RUN+="%E{DAHDI_TOOLS_ROOTDIR}/usr/share/dahdi/dahdi_handle_device"
|
||||
SUBSYSTEM=="dahdi_spans", RUN+="%E{DAHDI_TOOLS_ROOTDIR}/usr/share/dahdi/dahdi_span_config"
|
||||
|
||||
193
dahdi_cfg.c
193
dahdi_cfg.c
@@ -35,7 +35,11 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "tonezone.h"
|
||||
@@ -137,6 +141,97 @@ static const char *laws[] = {
|
||||
"A-law"
|
||||
};
|
||||
|
||||
static bool _are_all_spans_assigned(const char *device_path)
|
||||
{
|
||||
char attribute[1024];
|
||||
int res;
|
||||
FILE *fp;
|
||||
int span_count;
|
||||
DIR *dirp;
|
||||
struct dirent *dirent;
|
||||
|
||||
snprintf(attribute, sizeof(attribute) - 1,
|
||||
"%s/span_count", device_path);
|
||||
fp = fopen(attribute, "r");
|
||||
if (NULL == fp) {
|
||||
fprintf(stderr, "Failed to open '%s'.\n", attribute);
|
||||
return false;
|
||||
}
|
||||
res = fscanf(fp, "%d", &span_count);
|
||||
fclose(fp);
|
||||
|
||||
if (EOF == res) {
|
||||
fprintf(stderr, "Failed to read '%s'.\n", attribute);
|
||||
return false;
|
||||
}
|
||||
|
||||
dirp = opendir(device_path);
|
||||
while (span_count) {
|
||||
dirent = readdir(dirp);
|
||||
if (NULL == dirent)
|
||||
break;
|
||||
if (!strncmp("span-", dirent->d_name, 5)) {
|
||||
--span_count;
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
return (span_count > 0) ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* are_all_spans_assigned - Look in sysfs to see if all spans for a device are assigned.
|
||||
*
|
||||
* Returns true if there are $span_count child spans of all devices, or false
|
||||
* otherwise.
|
||||
*/
|
||||
static bool are_all_spans_assigned(void)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dirent;
|
||||
bool res = true;
|
||||
char device_path[1024];
|
||||
|
||||
dirp = opendir("/sys/bus/dahdi_devices/devices");
|
||||
if (!dirp) {
|
||||
/* If we cannot open dahdi_devices, either dahdi isn't loaded,
|
||||
* or we're using an older version of DAHDI that doesn't use
|
||||
* sysfs. */
|
||||
return true;
|
||||
}
|
||||
|
||||
while (true && res) {
|
||||
|
||||
dirent = readdir(dirp);
|
||||
if (NULL == dirent)
|
||||
break;
|
||||
|
||||
if (!strcmp(dirent->d_name, ".") ||
|
||||
!strcmp(dirent->d_name, ".."))
|
||||
continue;
|
||||
|
||||
snprintf(device_path, sizeof(device_path)-1,
|
||||
"/sys/bus/dahdi_devices/devices/%s", dirent->d_name);
|
||||
res = _are_all_spans_assigned(device_path);
|
||||
}
|
||||
|
||||
closedir(dirp);
|
||||
errno = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool wait_for_all_spans_assigned(unsigned long timeout_sec)
|
||||
{
|
||||
bool all_assigned = are_all_spans_assigned();
|
||||
unsigned int timeout = 10*timeout_sec;
|
||||
|
||||
while (!all_assigned && --timeout) {
|
||||
usleep(100000);
|
||||
all_assigned = are_all_spans_assigned();
|
||||
}
|
||||
|
||||
return all_assigned;
|
||||
}
|
||||
|
||||
static const char *sigtype_to_str(const int sig)
|
||||
{
|
||||
switch (sig) {
|
||||
@@ -714,7 +809,7 @@ static int setfiftysixkhdlc(char *keyword, char *args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apply_fiftysix(void)
|
||||
static int apply_fiftysix(void)
|
||||
{
|
||||
int x;
|
||||
int rate;
|
||||
@@ -728,7 +823,7 @@ static void apply_fiftysix(void)
|
||||
fprintf(stderr,
|
||||
"Couldn't open /dev/dahdi/channel: %s\n",
|
||||
strerror(errno));
|
||||
exit(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(chanfd, DAHDI_SPECIFY, &x)) {
|
||||
@@ -749,6 +844,7 @@ static void apply_fiftysix(void)
|
||||
}
|
||||
close(chanfd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setechocan(char *keyword, char *args)
|
||||
@@ -1450,6 +1546,9 @@ int main(int argc, char *argv[])
|
||||
char *buf;
|
||||
char *key, *value;
|
||||
int x,found;
|
||||
sem_t *lock = SEM_FAILED;
|
||||
const char *SEM_NAME = "dahdi_cfg";
|
||||
int exit_code = 0;
|
||||
|
||||
while((c = getopt(argc, argv, "fthc:vsd::C:S:")) != -1) {
|
||||
switch(c) {
|
||||
@@ -1495,6 +1594,15 @@ int main(int argc, char *argv[])
|
||||
fprintf(stderr, "%s\n", dahdi_tools_version);
|
||||
}
|
||||
|
||||
if (!restrict_channels && !only_span) {
|
||||
bool all_assigned = wait_for_all_spans_assigned(5);
|
||||
|
||||
if (!all_assigned) {
|
||||
fprintf(stderr,
|
||||
"Timeout waiting for all spans to be assigned.\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (fd == -1) fd = open(MASTER_DEVICE, O_RDWR);
|
||||
if (fd < 0) {
|
||||
error("Unable to open master device '%s'\n", MASTER_DEVICE);
|
||||
@@ -1561,10 +1669,27 @@ finish:
|
||||
printf("About to open Master device\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
for (x=0;x<numdynamic;x++) {
|
||||
/* destroy them all */
|
||||
ioctl(fd, DAHDI_DYNAMIC_DESTROY, &zds[x]);
|
||||
|
||||
lock = sem_open(SEM_NAME, O_CREAT, O_RDWR, 1);
|
||||
if (SEM_FAILED == lock) {
|
||||
perror("Unable to create 'dahdi_cfg' mutex");
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
|
||||
if (-1 == sem_wait(lock)) {
|
||||
perror("Failed to wait for 'dahdi_cfg' mutex");
|
||||
exit_code = 1;
|
||||
goto unlink_sem;
|
||||
}
|
||||
|
||||
if (!restrict_channels && !only_span) {
|
||||
for (x=0;x<numdynamic;x++) {
|
||||
/* destroy them all */
|
||||
ioctl(fd, DAHDI_DYNAMIC_DESTROY, &zds[x]);
|
||||
}
|
||||
}
|
||||
|
||||
if (stopmode) {
|
||||
for (x=0;x<spans;x++) {
|
||||
if (only_span && lc[x].span != only_span)
|
||||
@@ -1572,10 +1697,12 @@ finish:
|
||||
if (ioctl(fd, DAHDI_SHUTDOWN, &lc[x].span)) {
|
||||
fprintf(stderr, "DAHDI shutdown failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
}
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
for (x=0;x<spans;x++) {
|
||||
if (only_span && lc[x].span != only_span)
|
||||
@@ -1583,16 +1710,32 @@ finish:
|
||||
if (ioctl(fd, DAHDI_SPANCONFIG, lc + x)) {
|
||||
fprintf(stderr, "DAHDI_SPANCONFIG failed on span %d: %s (%d)\n", lc[x].span, strerror(errno), errno);
|
||||
close(fd);
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
}
|
||||
for (x=0;x<numdynamic;x++) {
|
||||
if (ioctl(fd, DAHDI_DYNAMIC_CREATE, &zds[x])) {
|
||||
fprintf(stderr, "DAHDI dynamic span creation failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
exit(1);
|
||||
|
||||
if (!restrict_channels && !only_span) {
|
||||
|
||||
sem_post(lock);
|
||||
|
||||
for (x=0;x<numdynamic;x++) {
|
||||
if (ioctl(fd, DAHDI_DYNAMIC_CREATE, &zds[x])) {
|
||||
fprintf(stderr, "DAHDI dynamic span creation failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
wait_for_all_spans_assigned(1);
|
||||
}
|
||||
|
||||
if (-1 == sem_wait(lock)) {
|
||||
perror("Failed to wait for 'dahdi_cfg' mutex after creating dynamic spans");
|
||||
exit_code = 1;
|
||||
goto unlink_sem;
|
||||
}
|
||||
}
|
||||
|
||||
for (x=1;x<DAHDI_MAX_CHANNELS;x++) {
|
||||
struct dahdi_params current_state;
|
||||
int master;
|
||||
@@ -1715,7 +1858,8 @@ finish:
|
||||
" to channel 16 of an E1 CAS span\n");
|
||||
}
|
||||
close(fd);
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
|
||||
ae[x].chan = x;
|
||||
@@ -1726,7 +1870,8 @@ finish:
|
||||
if (ioctl(fd, DAHDI_ATTACH_ECHOCAN, &ae[x])) {
|
||||
fprintf(stderr, "DAHDI_ATTACH_ECHOCAN failed on channel %d: %s (%d)\n", x, strerror(errno), errno);
|
||||
close(fd);
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
}
|
||||
if (0 == numzones) {
|
||||
@@ -1753,7 +1898,8 @@ finish:
|
||||
if (ioctl(fd, DAHDI_DEFAULTZONE, &deftonezone)) {
|
||||
fprintf(stderr, "DAHDI_DEFAULTZONE failed: %s (%d)\n", strerror(errno), errno);
|
||||
close(fd);
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
}
|
||||
for (x=0;x<spans;x++) {
|
||||
@@ -1762,9 +1908,18 @@ finish:
|
||||
if (ioctl(fd, DAHDI_STARTUP, &lc[x].span)) {
|
||||
fprintf(stderr, "DAHDI startup failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
exit(1);
|
||||
exit_code = 1;
|
||||
goto release_sem;
|
||||
}
|
||||
}
|
||||
apply_fiftysix();
|
||||
exit(0);
|
||||
exit_code = apply_fiftysix();
|
||||
|
||||
release_sem:
|
||||
if (SEM_FAILED != lock)
|
||||
sem_post(lock);
|
||||
|
||||
unlink_sem:
|
||||
if (SEM_FAILED != lock)
|
||||
sem_unlink(SEM_NAME);
|
||||
exit(exit_code);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ fi
|
||||
if [ "$#" -gt 0 ]; then
|
||||
DEVICES="$@"
|
||||
else
|
||||
DEVICES=`echo $devbase/*`
|
||||
DEVICES=`ls -d $devbase/* 2>/dev/null`
|
||||
fi
|
||||
|
||||
# Beware of special characters in attributes
|
||||
|
||||
175
dahdi_span_types
175
dahdi_span_types
@@ -27,6 +27,19 @@
|
||||
# - "@location" - Location attribute from sysfs (embeded inside '<>')
|
||||
# - "/devpath" - The sysfs absolute devpath
|
||||
#
|
||||
# * Wildcard are allowed in the configuration file:
|
||||
# - In the device specifiers (keys)
|
||||
# - In the span numbers
|
||||
# - Example for "match-all": * *:T1
|
||||
#
|
||||
# * During "set":
|
||||
# - If there are multiple matches, for a span, all are applied
|
||||
# - They are always applied in their order in the configuration file
|
||||
# - This means the last match wins
|
||||
# - Example:
|
||||
# * *:T1 # All span on all devices are T1
|
||||
# usb:X1234567 [34]:E1 # Except spans 3,4 on specific device
|
||||
#
|
||||
# * During "dumpconfig", for each device we take the first available key:
|
||||
# - The preference is: "hwid" or else "@location" or else "/devpath"
|
||||
# - This can be overriden via the SPAN_ASSIGNMENTS_KEY environment variable
|
||||
@@ -34,6 +47,8 @@
|
||||
#
|
||||
# Command line options:
|
||||
# - The '-h|--help' show a usage message.
|
||||
# - The '-v|--verbose' show debugging messages (on stderr)
|
||||
# - The '-n|--dry-run' During "set", only show what would be done
|
||||
# - The '-k <key>|--key <key>' overrides the SPAN_ASSIGNMENTS_KEY environment
|
||||
# variable.
|
||||
#
|
||||
@@ -53,18 +68,21 @@ SPAN_ASSIGNMENTS_KEY=${SPAN_ASSIGNMENTS_KEY:-hwid}
|
||||
usage() {
|
||||
echo >&2 "Usage: $0 [options] action [devpath ...]"
|
||||
echo >&2 " action:"
|
||||
echo >&2 " set - set spans to E1/T1 according to configuration"
|
||||
echo >&2 " set - set spans to E1/T1 according to /etc/dahdi/span-types.conf"
|
||||
echo >&2 " list - human-readable list of all spans"
|
||||
echo >&2 " dumpconfig - dump current state as new configuration"
|
||||
echo >&2 " dumpconfig - dump current state in /etc/dahdi/span-types.conf format"
|
||||
echo >&2 ""
|
||||
echo >&2 " options:"
|
||||
echo >&2 " -h|--help - Show this help"
|
||||
echo >&2 " -v|--verbose' - Show debugging messages (on stderr)"
|
||||
echo >&2 " -n|--dry-run' - During 'set', only show what would be done"
|
||||
echo >&2 " -k|--key <k> - Override prefered key during dumpconfig action"
|
||||
echo >&2 " --line-mode <m> - Set default line mode to <m> (E1/T1/J1)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse command line options
|
||||
TEMP=`getopt -o hk: --long help,key: -n "$0" -- "$@"`
|
||||
TEMP=`getopt -o hnvk: --long help,dry-run,verbose,key:,line-mode: -n "$0" -- "$@"`
|
||||
if [ $? != 0 ]; then
|
||||
echo >&2 "Bad options"
|
||||
usage
|
||||
@@ -78,11 +96,24 @@ while true ; do
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
-n|--dry-run)
|
||||
shift
|
||||
dry_run=true
|
||||
;;
|
||||
-v|--verbose)
|
||||
shift
|
||||
verbose=true
|
||||
;;
|
||||
-k|--key)
|
||||
SPAN_ASSIGNMENTS_KEY="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--line-mode)
|
||||
DEFAULT_LINE_MODE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@@ -106,7 +137,17 @@ case "$SPAN_ASSIGNMENTS_KEY" in
|
||||
hwid|location|devpath)
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Bad SPAN_ASSIGNMENTS_KEY='$SPAN_ASSIGNMENTS_KEY' (should be: hwid|location|devpath)"
|
||||
echo >&2 "Bad --key='$SPAN_ASSIGNMENTS_KEY' (should be: hwid|location|devpath)"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
# Validate DEFAULT_LINE_MODE
|
||||
case "$DEFAULT_LINE_MODE" in
|
||||
E1|T1|J1|'')
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Bad --line-mode='$DEFAULT_LINE_MODE' (should be: E1|T1|J1)"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
@@ -120,12 +161,12 @@ fi
|
||||
if [ "$#" -gt 0 ]; then
|
||||
DEVICES="$@"
|
||||
else
|
||||
DEVICES=`echo $devbase/*`
|
||||
DEVICES=`ls -d $devbase/* 2>/dev/null`
|
||||
fi
|
||||
|
||||
# Beware of special characters in attributes
|
||||
attr_clean() {
|
||||
cat "$1" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
|
||||
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
|
||||
}
|
||||
|
||||
show_spantypes() {
|
||||
@@ -138,11 +179,12 @@ show_spantypes() {
|
||||
cat "$device/spantype" | while read st; do
|
||||
case "$st" in
|
||||
*:[ETJ]1)
|
||||
printf "%-10s %-20s %s\n" \
|
||||
"$st" "[$hardware_id]" "$location"
|
||||
printf "%-10s %-20s %-30s %s\n" \
|
||||
"$st" "[$hardware_id]" "$location" \
|
||||
"$devpath"
|
||||
;;
|
||||
esac
|
||||
done | sort -n
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
@@ -150,9 +192,24 @@ dump_config() {
|
||||
echo '#'
|
||||
echo "# Autogenerated by $0 on `date`"
|
||||
echo "# Map PRI DAHDI devices to span types for E1/T1/J1"
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
echo "# Was run with '--line-mode=$DEFAULT_LINE_MODE' -- so will:"
|
||||
echo "# * Generate default wildcard entry"
|
||||
echo "# * Generate commented-out device list (for overrides)"
|
||||
fi
|
||||
echo ''
|
||||
fmt="%-65s %s\n"
|
||||
printf "$fmt" '# @location/hardware_id' 'span_type'
|
||||
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
echo ""
|
||||
echo "# Wildcard line-mode $DEFAULT_LINE_MODE".
|
||||
printf "$fmt" "*" "*:$DEFAULT_LINE_MODE"
|
||||
echo ""
|
||||
echo "# A list of commented out configurations for spans."
|
||||
echo "# Each item may be un-commented to provide an override."
|
||||
echo ""
|
||||
fi
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
@@ -169,7 +226,11 @@ dump_config() {
|
||||
cat "$device/spantype" | while read st; do
|
||||
case "$st" in
|
||||
*:[ETJ]1)
|
||||
printf "$fmt" "$id" "$st"
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
printf "#$fmt" "$id" "$st"
|
||||
else
|
||||
printf "$fmt" "$id" "$st"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
#echo "# Skipped local span `echo $st | sed 's/:/ -- /'`"
|
||||
@@ -185,70 +246,78 @@ filter_conf() {
|
||||
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$DAHDISPANTYPESCONF"
|
||||
}
|
||||
|
||||
conf_spans() {
|
||||
hardware_id="$1"
|
||||
location="$2"
|
||||
devpath="$3"
|
||||
filter_conf | (
|
||||
# Collect device spans
|
||||
# in a subshell, so $SPANS is not lost
|
||||
SPANS=''
|
||||
while read id spans; do
|
||||
handle_span() {
|
||||
device="$1"
|
||||
spantype="$2"
|
||||
attr_file="$device/spantype"
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
devname=`echo "$device" | sed "s,$devbase/,,"`
|
||||
location='@'`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
spanno=`echo "$spantype" | cut -d: -f1`
|
||||
#echo >&2 "DEBUG: $device $spanno ($spantype)"
|
||||
filter_conf | while read id span_spec; do
|
||||
sn=`echo "$span_spec" | cut -d: -f1`
|
||||
val=`echo "$span_spec" | cut -d: -f2`
|
||||
case "$spanno" in
|
||||
$sn)
|
||||
;;
|
||||
*)
|
||||
#echo >&2 "no-match($device $spanno): $sn"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
found=no
|
||||
# GLOBBING
|
||||
case "$location" in
|
||||
$id)
|
||||
#echo >&2 "match($id): $spans"
|
||||
SPANS="$SPANS $spans"
|
||||
#echo >&2 "match($id): $span_spec"
|
||||
found=yes
|
||||
;;
|
||||
esac
|
||||
case "$hardware_id" in
|
||||
$id)
|
||||
#echo >&2 "match([$id]): $spans"
|
||||
SPANS="$SPANS $spans"
|
||||
#echo >&2 "match([$id]): $span_spec"
|
||||
found=yes
|
||||
;;
|
||||
esac
|
||||
case "$devpath" in
|
||||
$id)
|
||||
#echo >&2 "match([$id]): $spans"
|
||||
SPANS="$SPANS $spans"
|
||||
#echo >&2 "match([$id]): $span_spec"
|
||||
found=yes
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "$SPANS"
|
||||
)
|
||||
}
|
||||
|
||||
device_set_spantype() {
|
||||
device="$1"
|
||||
attr_file="$device/spantype"
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
location='@'`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
spanspecs=`conf_spans "$hardware_id" "$location" "$devpath"`
|
||||
#echo >&2 "MATCHED($device): $spanspecs"
|
||||
cut -d: -f1 "$attr_file" | while read spanno; do
|
||||
for sp in $spanspecs
|
||||
do
|
||||
s=`echo "$sp" | cut -d: -f1`
|
||||
v=`echo "$sp" | cut -d: -f2`
|
||||
case "$spanno" in
|
||||
$s)
|
||||
#echo >&2 "conf($attr_file): $spanno:$v"
|
||||
echo "$spanno:$v" > "$attr_file"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [ "$found" = 'yes' ]; then
|
||||
if [ "$dry_run" = 'true' -o "$verbose" = 'true' ]; then
|
||||
echo >&2 "Set $devname span $spanno = $val"
|
||||
fi
|
||||
if [ "$dry_run" != 'true' ]; then
|
||||
echo "$spanno:$val" > "$attr_file"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
set_spantypes() {
|
||||
set_all_devices() {
|
||||
if [ ! -f "$DAHDISPANTYPESCONF" ]; then
|
||||
echo >&2 "$0: Missing configuration '$DAHDISPANTYPESCONF'"
|
||||
exit 1
|
||||
fi
|
||||
for device in $DEVICES
|
||||
do
|
||||
device_set_spantype "$device"
|
||||
devname=`echo "$device" | sed "s,$devbase/,,"`
|
||||
cat "$device/spantype" | while read spantype; do
|
||||
case "$spantype" in
|
||||
*:[ETJ]1)
|
||||
handle_span "$device" "$spantype"
|
||||
;;
|
||||
*)
|
||||
if [ "$dry_run" = 'true' -o "$verbose" = 'true' ]; then
|
||||
echo >&2 "Skipping non-E1/T1/J1 span ($devname -- $spantype)"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
@@ -260,7 +329,7 @@ dumpconfig)
|
||||
dump_config
|
||||
;;
|
||||
set)
|
||||
set_spantypes
|
||||
set_all_devices
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
|
||||
73
dahdi_waitfor_span_assignments
Executable file
73
dahdi_waitfor_span_assignments
Executable file
@@ -0,0 +1,73 @@
|
||||
#! /bin/sh
|
||||
|
||||
usage() {
|
||||
echo >&2 "Usage: $0 {assigned|unassigned}"
|
||||
echo >&2 "# wait until all spans known are assigned/unassigned"
|
||||
exit 1
|
||||
}
|
||||
|
||||
TIMEOUT=5 # How much time to wait for spans
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
wanted_event="$1"
|
||||
shift
|
||||
|
||||
case "$wanted_event" in
|
||||
assigned)
|
||||
;;
|
||||
unassigned)
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
devbase='/sys/bus/dahdi_devices/devices'
|
||||
|
||||
spans_of() {
|
||||
dev="$1"
|
||||
wc -l < "$dev/spantype"
|
||||
}
|
||||
|
||||
assigned_spans_of() {
|
||||
dev="$1"
|
||||
ls -d "$dev/span-"* 2>/dev/null | wc -l
|
||||
}
|
||||
|
||||
|
||||
waitfor_span_assignments() {
|
||||
wanted_state="$1"
|
||||
device_list=`ls -d "$devbase/"* 2> /dev/null`
|
||||
finished=''
|
||||
count="$TIMEOUT"
|
||||
echo -n "Waiting for spans to become $wanted_state: "
|
||||
while [ "$count" -gt 0 ]; do
|
||||
finished='yes'
|
||||
for dev in $device_list
|
||||
do
|
||||
spans=`spans_of "$dev"`
|
||||
assigned_spans=`assigned_spans_of "$dev"`
|
||||
if [ "$wanted_state" = 'assigned' -a "$assigned_spans" -ne "$spans" ]; then
|
||||
finished='no'
|
||||
elif [ "$wanted_state" = 'unassigned' -a "$assigned_spans" -ne 0 ]; then
|
||||
finished='no'
|
||||
fi
|
||||
done
|
||||
if [ "$finished" = 'yes' ]; then
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
echo -n "."
|
||||
fi
|
||||
count=`expr "$count" - 1`
|
||||
done
|
||||
if [ "$finished" = 'yes' ]; then
|
||||
echo "done"
|
||||
else
|
||||
echo "timeout"
|
||||
fi
|
||||
}
|
||||
|
||||
waitfor_span_assignments "$wanted_event"
|
||||
@@ -4,7 +4,7 @@
|
||||
dahdi_cfg \- configures DAHDI kernel modules from /etc/dahdi/system.conf
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_cfg [\-c \fICFG_FILE\fB] [\-S\fINUM\fB [-S\fICHANS\fB]] [\-s] [\-f] [\-t] [\-v [\-v ... ] ]
|
||||
.B dahdi_cfg [\-c \fICFG_FILE\fB] [\-S\fINUM\fB [\-S\fICHANS\fB]] [\-s] [\-f] [\-t] [\-v [\-v ... ] ]
|
||||
|
||||
.B dahdi_cfg \-h
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ Insert an error of a specific type
|
||||
.SH EXAMPLES
|
||||
Enable network line loopback on span 1:
|
||||
|
||||
dahdi_maint -s 1 --loopback networkline
|
||||
dahdi_maint \-s 1 \-\-loopback networkline
|
||||
|
||||
Disable network line loopback on span 1:
|
||||
|
||||
dahdi_maint -s 1 --loopback off
|
||||
dahdi_maint \-s 1 \-\-loopback off
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
|
||||
@@ -35,7 +35,7 @@ Normally there's a different option that you need that implies it.
|
||||
|
||||
.B \-o
|
||||
.RS
|
||||
Plays the output to OSS (/dev/dsp). Requires -m not to be used.
|
||||
Plays the output to OSS (/dev/dsp). Requires \-m not to be used.
|
||||
.RE
|
||||
|
||||
.B \-v
|
||||
@@ -44,7 +44,7 @@ Display Visual audio levels. With two v-s, Verbose mode is enabled, that
|
||||
shows the actual levels as numbers. Note that this requires a terminal
|
||||
wider than 80 columns to be properly displayed.
|
||||
|
||||
Implies -m.
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-f \fIFILE
|
||||
@@ -62,14 +62,14 @@ to a file.
|
||||
.RS
|
||||
Record the content of the Rx channel to a file.
|
||||
|
||||
Implies -m.
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-R \fIFILE
|
||||
.RS
|
||||
Record the content of the R channel before the echo canceler to a file.
|
||||
|
||||
Implies -m.
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-s \fIFILE
|
||||
@@ -87,47 +87,47 @@ canceler to a file.
|
||||
.RS
|
||||
Record the content of the Tx channel to a file.
|
||||
|
||||
Implies -m.
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-T \fIFILE
|
||||
.RS
|
||||
Record the content of the Tx channel before the echo canceler to a file.
|
||||
|
||||
Implies -m.
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.SH EXAMPLES
|
||||
|
||||
Visualize audio levels on DAHDI channel 2:
|
||||
|
||||
dahdi_monitor 2 -v
|
||||
dahdi_monitor 2 \-v
|
||||
|
||||
|
||||
Record channel 3 to a file:
|
||||
|
||||
dahdi_monitor 3 -f output.raw
|
||||
dahdi_monitor 3 \-f output.raw
|
||||
|
||||
This will create a raw PCM file (signed-linear, 8kHz, mono, 16 bits per
|
||||
sample). Both the Tx and Rx will be multiplexed in a single channel.
|
||||
It can be converted to a WAV file using e.g.:
|
||||
|
||||
sox -s -c1 -2 -r8000 output.raw output.wav
|
||||
sox \-s \-c1 \-2 \-r8000 output.raw output.wav
|
||||
|
||||
|
||||
Record Tx and Rx of channel 5 to separate files. This time directly to
|
||||
WAV files:
|
||||
|
||||
dahdi_monitor 5 -r output_rx.wav -t output_tx.wav
|
||||
dahdi_monitor 5 \-r output_rx.wav \-t output_tx.wav
|
||||
|
||||
|
||||
Record channel 8 to a stereo file (Tx and Rx on its two channels):
|
||||
|
||||
dahdi_monitor 8 -s output.raw
|
||||
dahdi_monitor 8 \-s output.raw
|
||||
|
||||
Converting it to a WAV file:
|
||||
|
||||
sox -s -c2 -2 -r8000 output.raw output.wav
|
||||
sox \-s \-c2 \-2 \-r8000 output.raw output.wav
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,55 +1,82 @@
|
||||
.TH "SPAN_ASSIGNMENTS" "8" "13 Oct 2013" "" ""
|
||||
.TH "DAHDI_SPAN_ASSIGNMENTS" "8" "23 Jan 2014" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_span_assignments \- handle DAHDI spans registration
|
||||
dahdi_span_assignments \- handle DAHDI spans assignments
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] [\-n|\-\-dry\-run] <add|remove> \fIdevpath
|
||||
\fB[\fIdevpath \fB...]
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] [\-n|\-\-dry\-run] <add|remove|auto> \fB[\fIdevpath\fB...]
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] [\-n|\-\-dry\-run] auto
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] list
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] list \fB[\fIdevpath\fB...]
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] [\-k|\-\-key \fIkey\fB] dumpconfig
|
||||
|
||||
.B dahdi_span_assignments \-h|\-\-help
|
||||
|
||||
.SH DESCRIPTION
|
||||
Channels in DAHDI devices (such as DAHDI PCI cards) are groups to logical
|
||||
units called "spans" (for example: a port in a digital card is a span).
|
||||
When the kernel module parameter \fBdahdi.auto_assign_span\fR is unset,
|
||||
DAHDI devices (such as DAHDI PCI cards) that register with DAHDI don't
|
||||
register their spans (e.g.: each digital port is normally a span) with
|
||||
DAHDI. This allows user-space to order DAHDI to register them to specific
|
||||
span and channel numbers. This allows registering different spans out of
|
||||
order.
|
||||
DAHDI devices that register with DAHDI don't cause their spans to be
|
||||
automatically assigned.
|
||||
|
||||
This allows user-space to order DAHDI to assign them to specific span
|
||||
and channel numbers. That way, specific spans on specific DAHDI devices
|
||||
may be assigned with specific span and channel numbers \fBregardless\fR
|
||||
of the registration order of the hardware (or if all hardware is present
|
||||
at all).
|
||||
|
||||
.B dahdi_span_assignments
|
||||
is used to register those spans or to help creating the configuration
|
||||
file used in their registration:
|
||||
.B /etc/dahdi/assigned-spans.conf .
|
||||
is used to assign those spans or to help creating the configuration
|
||||
file used in their assignment:
|
||||
.B /etc/dahdi/assigned\-spans.conf .
|
||||
|
||||
.SH OPTIONS
|
||||
.SH SUB-COMMANDS
|
||||
|
||||
There are several sub-commands:
|
||||
There are several sub-commands.
|
||||
|
||||
.B add \fIdevpath \fB[\fIdevpath \fB...]
|
||||
All sub-commands take an optional list of paths to SysFS nodes of
|
||||
devices. If given, the command will only operate on those DAHDI
|
||||
devices. The default is to operate on all devices (which would normally
|
||||
be the sane case when running from the command-line).
|
||||
|
||||
.B add \fB[\fIdevpath \fB...]
|
||||
.RS
|
||||
Parameters are paths (in SysFS) to DAHDI devices with unregistered
|
||||
spans. The command will register with DAHDI according to according to
|
||||
configuration in \fBassigned-spans.conf\fR.
|
||||
Applies to all devices or to those listed on the command line.
|
||||
Parameters are paths (in SysFS) to DAHDI devices with unassigned
|
||||
spans.
|
||||
|
||||
The command will assign spans with DAHDI according to
|
||||
configuration in \fBassigned\-spans.conf\fR.
|
||||
|
||||
If no line matches the span, or if the assignment for it fails (it is
|
||||
not available) it will remain unassigned.
|
||||
|
||||
If any of the span settings fails (the span number or range of channels
|
||||
is already in use), the program will print a message, but continue
|
||||
applying the others. In such a case you should fix assigned\-spans.conf
|
||||
and re-run \fBadd\fR (or run \fBauto\fR to give those channels the
|
||||
first available range and regenerate the file with 'dahdi_genconf
|
||||
assignedspans').
|
||||
.RE
|
||||
|
||||
.B remove \fIdevpath \fB[\fIdevpath \fB...]
|
||||
.B remove \fB[\fIdevpath \fB...]
|
||||
.RS
|
||||
Parameters are paths (in SysFS) to DAHDI devices with registered
|
||||
spans. The command will unregister with DAHDI.
|
||||
Applies to all devices or to those listed on the command line.
|
||||
Parameters are paths (in SysFS) to DAHDI devices with assigned
|
||||
spans.
|
||||
|
||||
The command will un-assign them.
|
||||
.RE
|
||||
|
||||
.B auto
|
||||
.B auto \fB[\fIdevpath \fB...]
|
||||
.RS
|
||||
Register all non-registered spans. Each span registers to first
|
||||
available span number and channel numbers, as if
|
||||
\fBdahdi.auto_assign_span\fR was set.
|
||||
Applies to all devices or to those listed on the command line.
|
||||
Parameters are paths (in SysFS) to DAHDI devices with unassigned
|
||||
spans.
|
||||
|
||||
Each span is assigned to first available span number and channel
|
||||
numbers, as if \fBdahdi.auto_assign_span\fR was set. The configuration
|
||||
file doesn't affect these assignments.
|
||||
.RE
|
||||
|
||||
.B list
|
||||
@@ -59,14 +86,16 @@ List all spans in the system.
|
||||
|
||||
.B dumpconfig
|
||||
.RS
|
||||
List all registered spans in the system in a format fit to be used in
|
||||
\fBassigned-spans.conf\fR. Use this to generate a configuration file after
|
||||
you have (perhaps manually) registered all existing spans.
|
||||
List all assigned spans in the system in a format fit to be used in
|
||||
\fBassigned\-spans.conf\fR. Use this to generate a configuration file after
|
||||
you have (automatically or manually) assigned all existing spans.
|
||||
|
||||
.B dahdi_genconf assignedspans
|
||||
uses this command internally.
|
||||
.RE
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.B \-v \-\-verbose
|
||||
.RS
|
||||
Verbose output.
|
||||
@@ -74,7 +103,7 @@ Verbose output.
|
||||
|
||||
.B \-n \-\-dry\-run
|
||||
.RS
|
||||
Don't register / unregister spans. Only print commands used to do so.
|
||||
Don't assign / un-assign spans. Only print commands used to do so.
|
||||
.RE
|
||||
|
||||
.B \-k \fIkey
|
||||
@@ -101,9 +130,9 @@ Path in SysFS to the device node.
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.SH CONFIGURATOIN
|
||||
.B assigned-spans.conf
|
||||
is a file with lines specifying registration of spans.
|
||||
.SH CONFIGURATION
|
||||
.B /etc/dahdi/assigned\-spans.conf
|
||||
is a file with lines specifying assignment of spans.
|
||||
|
||||
Empty lines or lines beginning with '#' are ignored.
|
||||
|
||||
@@ -112,7 +141,7 @@ Each line is in the format of:
|
||||
.I ID spanspec ...
|
||||
|
||||
The \fIID\fR field specifies the DAHDI device and the \fIspanspecs\fR
|
||||
define how to register its spans. A line may have multiple
|
||||
define how to assign its spans. A line may have multiple
|
||||
\fIspanspecs\fR in a single line (though dumpconfig generates a
|
||||
configuration with one per line).
|
||||
|
||||
@@ -132,12 +161,12 @@ The value in this field is matched (when the commands \fBadd\fR and
|
||||
See above for their descriptions. The value may include shell wildcards:
|
||||
*, ? and [], which are used in the match. The values to be matched are
|
||||
first cleaned up: '!' is replaced with '/' and any character beyond
|
||||
"a-zA-Z0-9/:.-" is removed.
|
||||
"a\-zA\-Z0\-9/:.\-" is removed.
|
||||
|
||||
.SS Span Specification
|
||||
|
||||
Each line should have one or more span specifications: this is the value
|
||||
used to register a span with DAHDI in the SysFS interface. A
|
||||
used to assign a span with DAHDI in the SysFS interface. A
|
||||
specification has three colon-separated numbers:
|
||||
|
||||
.I rel_span_no:span_no:first_chan
|
||||
@@ -159,7 +188,7 @@ The desired DAHDI span number. Must be available.
|
||||
.B first_chan
|
||||
.RS
|
||||
The desired DAHDI channel number for the first DAHDI channel in the span.
|
||||
All channels of the span will be registered following it and hence that
|
||||
All channels of the span will be assigned following it and hence that
|
||||
space must be available.
|
||||
.RE
|
||||
|
||||
@@ -168,13 +197,13 @@ space must be available.
|
||||
|
||||
.B DAHDICONFDIR
|
||||
.RS
|
||||
The directory in which assigned-spans.conf resides. /etc/dahdi if not
|
||||
The directory in which assigned\-spans.conf resides. /etc/dahdi if not
|
||||
overridden from the environment.
|
||||
.RE
|
||||
|
||||
.B DAHDISASSIGNEDSPANSCONF
|
||||
.RS
|
||||
The path to assigned-spans.conf resides. /etc/dahdi/assigned-spans.conf if
|
||||
The path to assigned-spans.conf resides. /etc/dahdi/assigned\-spans.conf if
|
||||
not overridden from the environment.
|
||||
.RE
|
||||
|
||||
@@ -187,7 +216,7 @@ environment.
|
||||
|
||||
.SH FILES
|
||||
|
||||
.B /etc/dahdi/assigned-spans.conf
|
||||
.B /etc/dahdi/assigned\-spans.conf
|
||||
.RS
|
||||
The default location for the configuration file.
|
||||
.RE
|
||||
|
||||
@@ -1,44 +1,73 @@
|
||||
.TH "SPAN_TYPES" "8" "13 Oct 2013" "" ""
|
||||
.TH "DAHDI_SPAN_TYPES" "8" "23 Jan 2014" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_span_types \- set DAHDI spans properties before registration (E1/T1)
|
||||
dahdi_span_types \- set line modes of DAHDI spans before assignment
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_span_types <list|dumpconfig|set> [\fIdevpath \fB[\fIdevpath \fB...]]
|
||||
.B dahdi_span_types [\fIoptions\fB] <list|dumpconfig|set> \fB[\fIdevpath \fB...]
|
||||
|
||||
.SH DESCRIPTION
|
||||
The span type (E1/T1/J1) must be set to a span before registering it
|
||||
with DAHDI, as E1 spans use more channels. \fBdahdi_span_types\fR applies the
|
||||
span type configuration to an unregistered span.
|
||||
The span type (the line mode: E1/T1/J1) must be set to a span before
|
||||
DAHDI assigns it a span number, as E1 spans use more channels.
|
||||
\fBdahdi_span_types\fR applies the span type configuration to an
|
||||
un-assigned span.
|
||||
|
||||
Using it only makes sense when the kernel module parameter
|
||||
\fBdahdi.auto_assign_span\fR is unset, otherwise the DAHDI spans register
|
||||
automatically.
|
||||
\fBdahdi.auto_assign_span\fR is unset, otherwise DAHDI automatically
|
||||
assign span numbers during device registration.
|
||||
|
||||
.SH OPTIONS
|
||||
.B dahdi_span_types
|
||||
takes a command and an optional list of devices. If no device is given,
|
||||
the command is applied to all devices.
|
||||
|
||||
The device is marked as a path in the SysFS tree.
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.B \-h|\-\-help
|
||||
.RS
|
||||
Output usage message and exit
|
||||
.RE
|
||||
|
||||
.B \-n|\-\-dry\-run
|
||||
.RS
|
||||
During \fB"set"\fR operation, only show what would be done, without actually
|
||||
changing anything.
|
||||
.RE
|
||||
|
||||
.B \-v|\-\-verbose
|
||||
.RS
|
||||
During \fB"set"\fR operation, show the actions that are being performed.
|
||||
.RE
|
||||
|
||||
.BI \-\-line\-mode= <E1|T1|J1>
|
||||
.RS
|
||||
During \fB"dumpconfig"\fR operation, force special generation mode:
|
||||
.IP \(bu 3
|
||||
First, generates a "wildcard" entry with the fiven \fBline\-mode\fR.
|
||||
.IP \(bu 3
|
||||
Comment out all span entries. Each of them may be manually un-commented
|
||||
to override the "wildcard".
|
||||
.RE
|
||||
|
||||
.SH SUB-COMMANDS
|
||||
.B set
|
||||
.RS
|
||||
Reads settings from \fBspan-types.conf\fR and applies them to the
|
||||
Reads settings from \fBspan\-types.conf\fR and applies them to the
|
||||
device(s) specified in the command line (or all devices, if none
|
||||
specified).
|
||||
.RE
|
||||
|
||||
.B list
|
||||
.RS
|
||||
List types for all spans in the system which may be set with dahdi_span_types
|
||||
(E1/T1/J1 spans).
|
||||
List line modes for all spans in the system which may be set with
|
||||
dahdi_span_types (E1/T1/J1 spans).
|
||||
.RE
|
||||
|
||||
.B dumpconfig
|
||||
.RS
|
||||
List types for the spans in a format fit to be used in
|
||||
\fBspan-types.conf\fR. Use this to generate a configuration file after
|
||||
\fBspan\-types.conf\fR. Use this to generate a configuration file after
|
||||
you have (perhaps manually) set all existing spans.
|
||||
|
||||
.B dahdi_genconf spantypes
|
||||
@@ -46,8 +75,9 @@ uses this command internally.
|
||||
.RE
|
||||
|
||||
.SH CONFIGURATION
|
||||
.B span-types.conf
|
||||
is a file with lines specifying registration of spans.
|
||||
.SS General structure
|
||||
.B span\-types.conf
|
||||
is a file with lines specifying line modes of spans.
|
||||
|
||||
Empty lines or lines beginning with '#' are ignored.
|
||||
|
||||
@@ -56,7 +86,7 @@ Each line is in the format of:
|
||||
.I ID spanspec ...
|
||||
|
||||
The \fIID\fR field specifies the DAHDI device and the \fIspanspecs\fR
|
||||
define how to register its spans. A line may have multiple
|
||||
define the line modes of its spans. A line may have multiple
|
||||
\fIspanspecs\fR in a single line (though dumpconfig generates a
|
||||
configuration with one per line).
|
||||
|
||||
@@ -66,8 +96,8 @@ software readable serial number or whatever) or the location in which
|
||||
it is installed on the system. The former makes it simpler to change
|
||||
connector / slot whereas the latter makes it simpler to replace a unit.
|
||||
|
||||
The value in this field is matched (when the commands \fBadd\fR and
|
||||
\fBremove\fR) are used) to the following values:
|
||||
The value in this field is matched (when the command \fBset\fR is
|
||||
used) to the following values:
|
||||
|
||||
\fIhwid\fR
|
||||
\fB@\fIlocation\fR
|
||||
@@ -75,22 +105,28 @@ The value in this field is matched (when the commands \fBadd\fR and
|
||||
|
||||
See above for their descriptions. The value may include shell wildcards:
|
||||
*, ? and [], which are used in the match. The values to be matched are
|
||||
first cleaned up: '!' is replaced with '/' and any character beyond
|
||||
"a-zA-Z0-9/:.-" is removed.
|
||||
first cleaned up: '!' is replaced with '/' and any character not in
|
||||
"a\-zA\-Z0\-9/:.\-" is replaced by "_".
|
||||
|
||||
Note that while span\-types.conf allows an arbitrarily-complex
|
||||
combination of E1, J1 and T1 ports, it would normally have just a single
|
||||
wildcard line setting the line mode (the first line in the example below).
|
||||
|
||||
.SS Span Specification
|
||||
|
||||
Each line should have one or more span specifications: this is the value
|
||||
used to register a span with DAHDI in the SysFS interface. A
|
||||
specification has three colon-separated numbers:
|
||||
used to set span type with DAHDI in the SysFS interface. A
|
||||
specification has two colon-separated fields:
|
||||
|
||||
.I rel_span_no:span_type
|
||||
|
||||
for instance, the following are four span specifications specify ports 1 and 2 as E1 and ports 3 and 4 as T1: [12]:E1 [34]:T1 .
|
||||
for instance, the following are four span specifications specify ports 1
|
||||
and 2 as E1 and ports 3 and 4 as T1: [12]:E1 [34]:T1 .
|
||||
|
||||
.B rel_span_no
|
||||
.RS
|
||||
The relative number of the span in the device. E.g.: port number.
|
||||
This field may contain shell wildcards (*, ? and [])
|
||||
.RE
|
||||
|
||||
.B span_type
|
||||
@@ -98,25 +134,40 @@ The relative number of the span in the device. E.g.: port number.
|
||||
E1/T1/J1
|
||||
.RE
|
||||
|
||||
.SS Multiple matches
|
||||
During \fBset\fR operation, the \fBdahdi_span_types\fR applies all
|
||||
matching settings to a span. This is done in the order of lines in the
|
||||
configuration files.
|
||||
|
||||
Thus, if there are multiple matches to a span -- the last match
|
||||
will \fIwin\fR (all will be applied to the kernel in order. The last
|
||||
one in the file will be applied last).
|
||||
|
||||
Example:
|
||||
.EX
|
||||
* *:T1 # All spans on all devices will be T1
|
||||
usb:X1234567 [34]:E1 # Except spans 3,4 on the device which will be E1
|
||||
.EE
|
||||
|
||||
|
||||
.SH ENVIRONMENT
|
||||
|
||||
.B DAHDICONFDIR
|
||||
.RS
|
||||
The directory in which span-types.conf resides. /etc/dahdi if not
|
||||
The directory in which span\-types.conf resides. /etc/dahdi if not
|
||||
overridden from the environment.
|
||||
.RE
|
||||
|
||||
.B DAHDISPANTYPESCONF
|
||||
.RS
|
||||
The path to span-types.conf resides. /etc/dahdi/span-types.conf if
|
||||
The path to span\-types.conf resides. /etc/dahdi/span\-types.conf if
|
||||
not overridden from the environment.
|
||||
.RE
|
||||
|
||||
|
||||
.SH FILES
|
||||
|
||||
.B /etc/dahdi/span-types.conf
|
||||
.B /etc/dahdi/span\-types.conf
|
||||
.RS
|
||||
The default location for the configuration file.
|
||||
.RE
|
||||
@@ -129,8 +180,8 @@ files, among others:
|
||||
.B spantype
|
||||
.RS
|
||||
read/write file. Reading from it returns current configuration for spans
|
||||
of the device. Span-specifications can be written to it to change types
|
||||
(but only for a span that is not registered).
|
||||
of the device. Span-specifications can be written to it to change line
|
||||
modes (but only for a span that is not assigned yet).
|
||||
.RE
|
||||
|
||||
|
||||
|
||||
49
doc/dahdi_waitfor_span_assignments.8
Normal file
49
doc/dahdi_waitfor_span_assignments.8
Normal file
@@ -0,0 +1,49 @@
|
||||
.TH "DAHDI_WAITFOR_SPAN_ASSIGNMENTS" "8" "22 Jan 2014" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_waitfor_span_assignments \- wait for DAHDI spans to get (un)assigned
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_span_assignments assigned
|
||||
|
||||
.B dahdi_span_assignments unassigned
|
||||
|
||||
.SH DESCRIPTION
|
||||
DAHDI spans get assigned / unassigned asynchronously.
|
||||
|
||||
.B dahdi_span_assignments
|
||||
is a helper script that allows running commands after all the spans have
|
||||
been assigned or unassigned.
|
||||
|
||||
It takes a single command: \fBassigned\fR or \fBunassigned\fR and waits
|
||||
(up until a timeout of 5 seconds) for all the DAHDI spans in the system
|
||||
to do so.
|
||||
|
||||
Note that if the system has a span that will not get assigned
|
||||
automatically (e.g.: it's not in assigned\-spans.conf), this program
|
||||
does not know and will wait until a timeout.
|
||||
|
||||
.SH EXAMPLES
|
||||
|
||||
modprobe wctdm24xxp
|
||||
dahdi_waitfor_span_assignments assigned
|
||||
do_something
|
||||
|
||||
dahdi_span_assignments add
|
||||
dahdi_waitfor_span_assignments assigned
|
||||
do_something_else
|
||||
|
||||
dahdi_span_assignments remove
|
||||
dahdi_span_assignments unassigned
|
||||
do_something_completely_different
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_span_assignments(8)
|
||||
|
||||
.SH AUTHOR
|
||||
dahdi_waitfor_span_assignments was written by Oron Peled. This manual
|
||||
page was written by Tzafrir Cohen. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the GNU
|
||||
General Public License, Version 2 any later version published by the
|
||||
Free Software Foundation.
|
||||
|
||||
25
hotplug/dahdi_auto_assign_compat
Executable file
25
hotplug/dahdi_auto_assign_compat
Executable file
@@ -0,0 +1,25 @@
|
||||
#! /bin/sh
|
||||
|
||||
devdir='/sys/bus/dahdi_devices/devices'
|
||||
|
||||
# DAHDI is loaded?
|
||||
if [ ! -d "$devdir" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
devices_by_registration_time() {
|
||||
grep -H '' $devdir/*/registration_time 2>/dev/null | \
|
||||
sed 's,/registration_time:,\t,' | \
|
||||
sort -k 2,2
|
||||
}
|
||||
|
||||
# First assign non-Astribank devices
|
||||
devices_by_registration_time | \
|
||||
grep -v '/astribanks:' | \
|
||||
while read devpath time; do
|
||||
echo >&2 "D: auto '$devpath'"
|
||||
dahdi_span_assignments auto "$devpath"
|
||||
done
|
||||
|
||||
# Now handle Astribanks
|
||||
LC_ALL=C dahdi_registration -Rv on
|
||||
@@ -20,6 +20,7 @@ exec 2> /dev/null
|
||||
|
||||
# Our directory in the beginning, so we can use local lab setup
|
||||
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||
export PATH
|
||||
|
||||
set -e
|
||||
|
||||
@@ -35,44 +36,50 @@ if [ "$DAHDI_UDEV_DISABLE_DEVICES" = 'yes' ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check if we can safely do our job
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
echo "Old driver (no auto_assign_spans parameter). Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
if [ `cat /sys/module/dahdi/parameters/auto_assign_spans` -eq 1 ]; then
|
||||
echo "auto_assign_spans=1. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Can we pass a different value so we can use
|
||||
# alternate (testing) configuration?
|
||||
# Meanwhile, make it hard-coded.
|
||||
DAHDICONFDIR='/etc/dahdi'
|
||||
export DAHDICONFDIR
|
||||
|
||||
run_parts() {
|
||||
# Have our internal "run-parts" (adapted from Fedora),
|
||||
# as implementations differ
|
||||
for i in `LC_ALL=C; ls -d $dir/handle_device.d/*[!~,] 2>/dev/null` ; do
|
||||
[ -d "$i" ] && continue
|
||||
[ ! -x "$i" ] && continue
|
||||
# Don't run *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} files
|
||||
case "$i" in
|
||||
*.cfsaved|*.rpmsave|*.rpmorig|*.rpmnew|*.swp|*,v)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
echo "D: Running '$i'"
|
||||
"$i"
|
||||
done
|
||||
}
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
# Can have alternate dahdi configuration directory for debugging
|
||||
# export DAHDICONFDIR="/tmp/xortel/dahdi"
|
||||
|
||||
# Don't block udev for too long
|
||||
(
|
||||
if [ -r "$DAHDICONFDIR/span-types.conf" ]; then
|
||||
dahdi_span_types set "/sys$DEVPATH"
|
||||
fi
|
||||
if [ -r "$DAHDICONFDIR/assigned-spans.conf" ]; then
|
||||
dahdi_span_assignments add "/sys$DEVPATH"
|
||||
else
|
||||
# No configuration. No order guaranteed
|
||||
dahdi_span_assignments auto
|
||||
fi
|
||||
) 2>&1 < /dev/null | $LOGGER &
|
||||
# Check if we can safely do our job
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
echo "Old driver (no auto_assign_spans parameter). Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
if [ `cat /sys/module/dahdi/parameters/auto_assign_spans` -ne 0 ]; then
|
||||
echo "auto_assign_spans=1. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
remove)
|
||||
# Nothing to do yet...
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
*)
|
||||
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
|
||||
@@ -20,6 +20,7 @@ exec 2> /dev/null
|
||||
|
||||
# Our directory in the beginning, so we can use local lab setup
|
||||
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||
export PATH
|
||||
|
||||
set -e
|
||||
|
||||
@@ -41,52 +42,49 @@ fi
|
||||
DAHDICONFDIR='/etc/dahdi'
|
||||
export DAHDICONFDIR
|
||||
|
||||
run_dahdi_cfg() {
|
||||
echo "dahdi_cfg: span $spanno <$basechan-$endchan> ($DEVPATH)"
|
||||
dahdi_cfg -c "$cfg_file" -S "$spanno" -C "$basechan-$endchan"
|
||||
}
|
||||
|
||||
configure_span() {
|
||||
span_devpath="$1"
|
||||
# Sanity check
|
||||
checkit=`"dahdi_cfg" --help 2>&1 | grep -- '-S' | wc -l`
|
||||
if [ "$checkit" != 1 ]; then
|
||||
echo "Bad dahdi_cfg (no -S support). Skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set variables
|
||||
spanno=`echo "$span_devpath" | sed 's,.*/span-,,'`
|
||||
basechan=`cat "$span_devpath/basechan"`
|
||||
channels=`cat "$span_devpath/channels"`
|
||||
endchan=`expr "$basechan" + "$channels" - 1`
|
||||
|
||||
# Configure DAHDI
|
||||
cfg_file="$DAHDICONFDIR/system.conf"
|
||||
if [ -r "$cfg_file" ]; then
|
||||
run_dahdi_cfg
|
||||
else
|
||||
echo "Using auto-generated config for dahdi_cfg"
|
||||
cfg_file='-'
|
||||
DAHDI_CONF_FILE="$cfg_file" dahdi_genconf system | run_dahdi_cfg
|
||||
fi
|
||||
fxotune_cfg='/etc/fxotune.conf'
|
||||
if [ -r "$fxotune_cfg" ]; then
|
||||
echo "fxotune: span $spanno <$basechan-$endchan> ($DEVPATH)"
|
||||
fxotune -s -b "$basechan" -e "$endchan"
|
||||
fi
|
||||
|
||||
# Add to asterisk
|
||||
asterisk -rx "dahdi create channels $basechan $endchan"
|
||||
run_parts() {
|
||||
# Have our internal "run-parts" (adapted from Fedora),
|
||||
# as implementations differ
|
||||
for i in `LC_ALL=C; ls -d $dir/span_config.d/*[!~,] 2>/dev/null` ; do
|
||||
[ -d "$i" ] && continue
|
||||
[ ! -x "$i" ] && continue
|
||||
# Don't run *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} files
|
||||
case "$i" in
|
||||
*.cfsaved|*.rpmsave|*.rpmorig|*.rpmnew|*.swp|*,v)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
#echo "D: Running '$i'"
|
||||
"$i"
|
||||
done
|
||||
}
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
# Can have alternate dahdi configuration directory for debugging
|
||||
# export DAHDICONFDIR="/tmp/xortel/dahdi"
|
||||
|
||||
configure_span "/sys$DEVPATH" 2>&1 | $LOGGER
|
||||
# Old driver. These scripts probably won't work anyway.
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
if [ -f /sys/module/dahdi ]; then
|
||||
$LOGGER "Old driver (no auto_assign_spans parameter). Skip $DEVPATH"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $(cat /sys/module/dahdi/parameters/auto_assign_spans) -ne 0 ]; then
|
||||
$LOGGER "auto_assign_spans=1. Skip $DEVPATH"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set variables
|
||||
span_devpath="/sys$DEVPATH"
|
||||
SPANNO=`echo "$span_devpath" | sed 's,.*/span-,,'`
|
||||
BASECHAN=`cat "$span_devpath/basechan"`
|
||||
CHANNELS=`cat "$span_devpath/channels"`
|
||||
ENDCHAN=`expr "$BASECHAN" + "$CHANNELS" - 1`
|
||||
export SPANNO BASECHAN CHANNELS ENDCHAN
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
remove|online|offline)
|
||||
# Nothing to do yet...
|
||||
12
hotplug/handle_device.d/10-span-types
Executable file
12
hotplug/handle_device.d/10-span-types
Executable file
@@ -0,0 +1,12 @@
|
||||
#! /bin/sh
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
if [ -r "$DAHDICONFDIR/span-types.conf" ]; then
|
||||
dahdi_span_types set "/sys$DEVPATH"
|
||||
fi
|
||||
15
hotplug/handle_device.d/20-span-assignments
Executable file
15
hotplug/handle_device.d/20-span-assignments
Executable file
@@ -0,0 +1,15 @@
|
||||
#! /bin/sh
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
# For now, handle only spans in assigned-spans.conf
|
||||
# We leave other cases to /etc/init.d/dahdi, so
|
||||
# legacy ordering can be preserved.
|
||||
if [ -r "$DAHDICONFDIR/assigned-spans.conf" ]; then
|
||||
dahdi_span_assignments add "/sys$DEVPATH"
|
||||
fi
|
||||
28
hotplug/span_config.d/10-dahdi-cfg
Executable file
28
hotplug/span_config.d/10-dahdi-cfg
Executable file
@@ -0,0 +1,28 @@
|
||||
#! /bin/sh
|
||||
|
||||
if [ "$ACTION" != 'add' ]; then
|
||||
# Nothing to do here
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Sanity check
|
||||
checkit=`"dahdi_cfg" --help 2>&1 | grep -- '-S' | wc -l`
|
||||
if [ "$checkit" != 1 ]; then
|
||||
echo "Bad dahdi_cfg (no -S support). Skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
run_dahdi_cfg() {
|
||||
echo "dahdi_cfg: span $SPANNO <$BASECHAN-$ENDCHAN> ($DEVPATH)"
|
||||
dahdi_cfg -c "$cfg_file" -S "$SPANNO" -C "$BASECHAN-$ENDCHAN"
|
||||
}
|
||||
|
||||
# Configure DAHDI
|
||||
cfg_file="$DAHDICONFDIR/system.conf"
|
||||
if [ -r "$cfg_file" ]; then
|
||||
run_dahdi_cfg
|
||||
else
|
||||
echo "Using auto-generated config for dahdi_cfg"
|
||||
cfg_file='-'
|
||||
DAHDI_CONF_FILE="$cfg_file" dahdi_genconf system | run_dahdi_cfg
|
||||
fi
|
||||
12
hotplug/span_config.d/20-fxotune
Executable file
12
hotplug/span_config.d/20-fxotune
Executable file
@@ -0,0 +1,12 @@
|
||||
#! /bin/sh
|
||||
|
||||
if [ "$ACTION" != 'add' ]; then
|
||||
# Nothing to do here
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fxotune_cfg='/etc/fxotune.conf'
|
||||
if [ -r "$fxotune_cfg" ]; then
|
||||
echo "fxotune: span $SPANNO <$BASECHAN-$ENDCHAN> ($DEVPATH)"
|
||||
fxotune -s -b "$BASECHAN" -e "$ENDCHAN"
|
||||
fi
|
||||
14
hotplug/span_config.d/50-asterisk
Executable file
14
hotplug/span_config.d/50-asterisk
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /bin/sh
|
||||
|
||||
# This file, if installed under /usr/share/dahdi/span_config.d/ , will
|
||||
# attempt to add a newly-generated span to a running copy of Asterisk.
|
||||
# Asterisk has to be running (if not: it will pick the span on its
|
||||
# startup), and has to have the channels already configured.
|
||||
|
||||
if [ "$ACTION" != 'add' ]; then
|
||||
# Nothing to do here
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Add to asterisk
|
||||
asterisk -rx "dahdi create channels $BASECHAN $ENDCHAN"
|
||||
@@ -24,6 +24,8 @@ wcte12xp
|
||||
|
||||
# Digium TE131: PCI-Express single-port T1/E1/J1
|
||||
# Digium TE132: PCI single-port T1/E1/J1
|
||||
# Digium TE133: PCI-Express single-port T1/E1/J1 with hardware echocan
|
||||
# Digium TE134: PCI single-port T1/E1/J1 with hardware echocan
|
||||
wcte13xp
|
||||
|
||||
# Digium T100P: PCI single-port T1
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# This file is parsed by the DAHDI Configurator, dahdi_cfg
|
||||
#
|
||||
# Span Configuration
|
||||
# ^^^^^^^^^^^^^^^^^^
|
||||
# ++++++++++++++++++
|
||||
# First come the span definitions, in the format
|
||||
#
|
||||
# span=<span num>,<timing source>,<line build out (LBO)>,<framing>,<coding>[,yellow]
|
||||
@@ -69,7 +69,7 @@
|
||||
#span=3,0,0,ccs,hdb3,crc4
|
||||
#
|
||||
# Dynamic Spans
|
||||
# ^^^^^^^^^^^^^
|
||||
# +++++++++++++
|
||||
# Next come the dynamic span definitions, in the form:
|
||||
#
|
||||
# dynamic=<driver>,<address>,<numchans>,<timing>
|
||||
@@ -87,7 +87,7 @@
|
||||
# have the non-zero value.
|
||||
#
|
||||
# Channel Configuration
|
||||
# ^^^^^^^^^^^^^^^^^^^^^
|
||||
# +++++++++++++++++++++
|
||||
# Next come the definitions for using the channels. The format is:
|
||||
# <device>=<channel list>
|
||||
#
|
||||
@@ -204,7 +204,7 @@
|
||||
#dacsrbs=1-24:48
|
||||
#
|
||||
# Tone Zone Data
|
||||
# ^^^^^^^^^^^^^^
|
||||
# ++++++++++++++
|
||||
# Finally, you can preload some tone zones, to prevent them from getting
|
||||
# overwritten by other users (if you allow non-root users to open /dev/dahdi/*
|
||||
# interfaces anyway. Also this means they won't have to be loaded at runtime.
|
||||
@@ -232,7 +232,7 @@ loadzone = us
|
||||
defaultzone=us
|
||||
#
|
||||
# PCI Radio Interface
|
||||
# ^^^^^^^^^^^^^^^^^^^
|
||||
# +++++++++++++++++++
|
||||
# (see http://www.zapatatelephony.org/app_rpt.html)
|
||||
#
|
||||
# The PCI Radio Interface card interfaces up to 4 two-way radios (either
|
||||
@@ -298,7 +298,7 @@ defaultzone=us
|
||||
#channels=1-4
|
||||
#
|
||||
# Overiding PCM encoding
|
||||
# ^^^^^^^^^^^^^^^^^^^^^^
|
||||
# ++++++++++++++++++++++
|
||||
# Usually the channel driver sets the encoding of the PCM for the
|
||||
# channel (mulaw / alaw. That is: g711u or g711a). However there are
|
||||
# some cases where you would like to override that. 'mulaw' and 'alaw'
|
||||
@@ -313,7 +313,7 @@ defaultzone=us
|
||||
#deflaw=5
|
||||
#
|
||||
# Echo Cancellers
|
||||
# ^^^^^^^^^^^^^^^
|
||||
# +++++++++++++++
|
||||
# DAHDI uses modular echo cancellers that are configured per channel. The echo
|
||||
# cancellers are compiled and installed as part of the dahdi-linux package.
|
||||
# You can specify in this file the echo canceller to be used for each
|
||||
|
||||
@@ -11,17 +11,30 @@ use strict;
|
||||
use File::Basename;
|
||||
BEGIN { my $dir = dirname($0); unshift(@INC, "$dir", "$dir/perl_modules"); }
|
||||
|
||||
use Getopt::Std;
|
||||
use Getopt::Long;
|
||||
use Dahdi;
|
||||
use Dahdi::Xpp;
|
||||
use Dahdi::Config::Gen;
|
||||
use Dahdi::Config::Params;
|
||||
|
||||
Getopt::Long::Configure ("bundling");
|
||||
|
||||
my $version = '1'; # Functionality version (integer)
|
||||
my $revision = '$Revision$';
|
||||
|
||||
my %opts;
|
||||
|
||||
sub usage {
|
||||
warn "Usage: $0 [options] <generators>\n";
|
||||
warn " Options:\n";
|
||||
warn " --line-mode=<E1|T1|J1> - Also generate span-types.conf with default line mode\n";
|
||||
warn " -F|--freepbx - Modify configuration for Freepbx (skip FXS channels)\n";
|
||||
warn " -v|--verbose - Be versbose, show generated files\n";
|
||||
warn " -V|--version - Show version and exit\n";
|
||||
warn " -h|--help - Show this message\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
sub set_defaults {
|
||||
my $default_file = $ENV{GENCONF_PARAMETERS} || "/etc/dahdi/genconf_parameters";
|
||||
my $params = Dahdi::Config::Params->new($default_file);
|
||||
@@ -44,20 +57,33 @@ sub spans_prep($@) {
|
||||
}
|
||||
}
|
||||
|
||||
sub munge_spantypes {
|
||||
if ($opts{'line-mode'}) {
|
||||
print "Will generate span-types.conf with line-mode=$opts{'line-mode'}\n"
|
||||
if $opts{'verbose'};
|
||||
return "spantypes=line-mode=$opts{'line-mode'}";
|
||||
} else {
|
||||
print "Will generate span-types.conf\n" if $opts{'verbose'};
|
||||
return "spantypes";
|
||||
}
|
||||
}
|
||||
|
||||
sub generator_list($) {
|
||||
my $gconfig = shift || die;
|
||||
my @genlist;
|
||||
|
||||
if (@ARGV) {
|
||||
for my $gen (@ARGV) {
|
||||
$gen = munge_spantypes() if $gen eq 'spantypes';
|
||||
push @genlist, $gen;
|
||||
}
|
||||
} else {
|
||||
# No files given. Use the defaults.
|
||||
@genlist = ('spantypes', 'assignedspans', 'system', 'chandahdi');
|
||||
@genlist = ('assignedspans', 'system', 'chandahdi');
|
||||
if($gconfig->{'pri_connection_type'} eq 'R2') {
|
||||
push @genlist, 'unicall';
|
||||
}
|
||||
push(@genlist, munge_spantypes()) if $opts{'line-mode'};
|
||||
}
|
||||
return @genlist;
|
||||
}
|
||||
@@ -93,7 +119,16 @@ sub generate_files($@) {
|
||||
}
|
||||
}
|
||||
|
||||
getopts('vVF', \%opts) || die "$0: Bad option\n";
|
||||
GetOptions(\%opts,
|
||||
"line-mode=s",
|
||||
"h|help",
|
||||
"v|verbose",
|
||||
"V|version",
|
||||
"F|freepbx",
|
||||
) or usage;
|
||||
|
||||
usage if $opts{h};
|
||||
|
||||
if($opts{'V'}) {
|
||||
my $revstr = $revision;
|
||||
$revstr =~ s/[^$]*\$[^:]+:\s*//;
|
||||
@@ -141,7 +176,9 @@ as specified by the generator arguments. Each generator is a perl class
|
||||
in Dahdi::Config::Gen namespace. The generator names on the command line
|
||||
are the class names in lowercase.
|
||||
|
||||
The following generators are currently implemented: system, chandahdi, unicall, users.
|
||||
The following generators are currently implemented: system, modules, spantypes,
|
||||
assignedspans, chandahdi, unicall, users.
|
||||
|
||||
For further documentation on each, please user perldoc on the relevant
|
||||
class. E.g: C<perldoc Dahdi::Config::Gen::Chandahdi>
|
||||
|
||||
@@ -154,19 +191,27 @@ a comma separated list of options to the generator name. E.g:
|
||||
|
||||
=over 4
|
||||
|
||||
=item -V
|
||||
=item -V --version
|
||||
|
||||
Version -- print version string and exit.
|
||||
|
||||
=item -v
|
||||
=item -v --verbose
|
||||
|
||||
Verbose -- sets the C<'verbose'> option for all generators.
|
||||
|
||||
=item -F
|
||||
=item -F --freepbx
|
||||
|
||||
Freepbx -- sets the C<'freepbx'> option for all generators.
|
||||
Currently, chandahdi is affected.
|
||||
|
||||
=item --line-mode=I<mode>
|
||||
|
||||
I<mode> may be E1, J1 or T1.
|
||||
|
||||
Enables the generator B<spantypes> and the option B<line-mode> to it.
|
||||
(Equivalent to the option C<--line-mode> to C<dahdi_span_types>). This
|
||||
will generate a C<span-types.conf> file with a single wildcard line
|
||||
setting the line mode to I<mode>.
|
||||
|
||||
=back
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ my %opts;
|
||||
getopts('vRs:', \%opts) || usage;
|
||||
|
||||
my $dahdi_autoreg = check_param('/sys/module/xpp/parameters/dahdi_autoreg') eq 'Y';
|
||||
my $auto_assign_spans = check_param('/sys/module/dahdi/parameters/auto_assign_spans') eq '1';
|
||||
my $auto_assign_spans = check_param('/sys/module/dahdi/parameters/auto_assign_spans') ne '0';
|
||||
my $assigned_spans_config = $ENV{'ASSIGNED_SPANS_CONF_FILE'} || '/etc/dahdi/assigned-spans.conf';
|
||||
my $span_types_config = $ENV{'SPAN_TYPES_CONF_FILE'} || '/etc/dahdi/span-types.conf';
|
||||
my $have_assigned_spans_config = -f $assigned_spans_config || 0;
|
||||
|
||||
@@ -29,13 +29,17 @@ sub generate($$$) {
|
||||
system "which dahdi_span_types > /dev/null 2>&1";
|
||||
return if $?;
|
||||
|
||||
my $line_mode = $genopts->{'line-mode'};
|
||||
$line_mode = 'E1' unless defined $line_mode;
|
||||
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
|
||||
warn "Empty configuration -- no spans\n" unless @spans;
|
||||
rename "$file", "$file.bak"
|
||||
or $! == 2 # ENOENT (No dependency on Errno.pm)
|
||||
or die "Failed to backup old config: $!\n";
|
||||
#$gconfig->dump;
|
||||
print "Generating $file\n" if $genopts->{verbose};
|
||||
my $cmd = "dahdi_span_types dumpconfig > $file";
|
||||
printf("Generating $file (with default line-mode %s)\n", $line_mode)
|
||||
if $genopts->{verbose};
|
||||
my $cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file";
|
||||
system $cmd;
|
||||
die "Command failed (status=$?): '$cmd'" if $?;
|
||||
}
|
||||
@@ -61,3 +65,17 @@ Generate the F</etc/dahdi/span-types.conf>.
|
||||
This is the configuration for dahdi_span_types.
|
||||
|
||||
Its location may be overriden via the environment variable F<SPAN_TYPES_CONF_FILE>.
|
||||
|
||||
You would normally run:
|
||||
|
||||
dahdi_genconf --line-mode=<line_mode>
|
||||
|
||||
which is a short for:
|
||||
|
||||
dahdi_genconf spantypes=line-mode=<line_mode>
|
||||
|
||||
This is done by running:
|
||||
dahdi_span_types dumpconfig --line-mode=line_mode>
|
||||
|
||||
where I<line_mode> is the module parameter, and defaults to B<E1> if not
|
||||
given (running C<dahdi_genconf spantypes>).
|
||||
|
||||
@@ -94,8 +94,8 @@ my %pci_ids = (
|
||||
'd161:8001' => { DRIVER => 'wcte12xp', DESCRIPTION => 'Wildcard TE122' },
|
||||
|
||||
# from wcte13xp
|
||||
'd161:800a' => { DRIVER => 'wcte13xp', DESCRIPTION => 'Wildcard TE133' },
|
||||
'd161:800b' => { DRIVER => 'wcte13xp', DESCRIPTION => 'Wildcard TE134' },
|
||||
'd161:800a' => { DRIVER => 'wcte13xp', DESCRIPTION => 'Wildcard TE131/TE133' },
|
||||
'd161:800b' => { DRIVER => 'wcte13xp', DESCRIPTION => 'Wildcard TE132/TE134' },
|
||||
|
||||
# from wcaxx
|
||||
'd161:800c' => { DRIVER => 'wcaxx', DESCRIPTION => 'Digium A8A' },
|
||||
|
||||
@@ -144,9 +144,9 @@ my @pri_strings = (
|
||||
'Wildcard TE120P', # wcte12xp
|
||||
'Wildcard TE121', # wcte12xp
|
||||
'Wildcard TE122', # wcte12xp
|
||||
'Wildcard TE133', # wcte13xp
|
||||
'Wildcard TE134', # wcte13xp
|
||||
'T[248]XXP \(PCI\) Card ', # wct4xxp
|
||||
'Wildcard TE131/TE133', # wcte13xp
|
||||
'Wildcard TE132/TE134', # wcte13xp
|
||||
'T[248]XXP \(PCI\) Card ', # wct4xxp
|
||||
'WCTE43X \(PCI\) Card ', # wcte43xp
|
||||
'WCTE23X \(PCI\) Card ', # wcte43xp
|
||||
'R[24]T1 \(PCI\) Card', # rxt1
|
||||
|
||||
@@ -110,9 +110,7 @@ sub read_xpdnames($) {
|
||||
sub read_num($) {
|
||||
my $self = shift or die;
|
||||
my $xbus_dir = $self->sysfs_dir;
|
||||
my @xpdnames = read_xpdnames($xbus_dir);
|
||||
my $first = shift @xpdnames or die "No XPDs for '$xbus_dir'\n";
|
||||
$first =~ /^(\d+\d+).*/;
|
||||
$xbus_dir =~ /.*-(\d\d)$/;
|
||||
return $1;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,6 +72,10 @@ waitfor_ab_initialization() {
|
||||
fi
|
||||
test "$oldab" != "$ab"
|
||||
do
|
||||
if [ "$ab" = '' ]; then
|
||||
echo >&2 "Astribanks disappeared"
|
||||
break
|
||||
fi
|
||||
oldab="$ab"
|
||||
cat $ab
|
||||
#echo -n 1>&2 "_"
|
||||
|
||||
Reference in New Issue
Block a user