Compare commits
105 Commits
v2.8.0
...
v2.11.0-rc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
855772135c | ||
|
|
ec1ebffa89 | ||
|
|
9afcde3f1e | ||
|
|
9a181ccfbc | ||
|
|
10c1cd196e | ||
|
|
65ba28fe4a | ||
|
|
66e2c3ba11 | ||
|
|
94ca4a1bb4 | ||
|
|
af920cd079 | ||
|
|
b375bb80b8 | ||
|
|
0090086bce | ||
|
|
f21b592f68 | ||
|
|
d63812bd73 | ||
|
|
bf9500ab32 | ||
|
|
703db3bcc3 | ||
|
|
b5b32a438f | ||
|
|
4cc7df1089 | ||
|
|
ac6f437317 | ||
|
|
b054abb7e9 | ||
|
|
ee83afa669 | ||
|
|
5ac7fef4b2 | ||
|
|
6df9a492a0 | ||
|
|
fc620819b6 | ||
|
|
723b3ce87f | ||
|
|
5fd1ce5ca0 | ||
|
|
41532ca8a1 | ||
|
|
fbb6c1a17e | ||
|
|
131d694054 | ||
|
|
010c4d836c | ||
|
|
025b9a5593 | ||
|
|
c863d1d2c2 | ||
|
|
77730a9059 | ||
|
|
3f55dd78de | ||
|
|
283f01bd67 | ||
|
|
631d32680f | ||
|
|
44fe560f3b | ||
|
|
1a78b71fac | ||
|
|
f11b937659 | ||
|
|
cd6083b6ce | ||
|
|
0eb77e626e | ||
|
|
2e1c15baa3 | ||
|
|
094bb2c1e8 | ||
|
|
9aee76a3a5 | ||
|
|
d4537e46ce | ||
|
|
60401c5f49 | ||
|
|
a109763160 | ||
|
|
6c40704fec | ||
|
|
95e9dd71d8 | ||
|
|
df47721962 | ||
|
|
4e14561508 | ||
|
|
49361e5ce7 | ||
|
|
8045f7f493 | ||
|
|
64e7c688d3 | ||
|
|
b28ec382bb | ||
|
|
412c3f0fe3 | ||
|
|
fc459c374c | ||
|
|
ca09f327ed | ||
|
|
b1d55683ae | ||
|
|
9285e86492 | ||
|
|
ca7c04e9cb | ||
|
|
ae02edacb4 | ||
|
|
2abfd165ae | ||
|
|
1e6b2741db | ||
|
|
794c8eb048 | ||
|
|
ffe36c63e0 | ||
|
|
f2628eeedd | ||
|
|
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 |
38
.gitignore
vendored
38
.gitignore
vendored
@@ -1,10 +1,31 @@
|
||||
*~
|
||||
*.o
|
||||
*.lo
|
||||
*.a
|
||||
*.so
|
||||
*.la
|
||||
.*.o.d
|
||||
.*.lo.d
|
||||
*.asciidoc
|
||||
*.html
|
||||
.deps
|
||||
.libs
|
||||
.dirstamp
|
||||
Makefile
|
||||
Makefile.in
|
||||
auxdir/
|
||||
build_tools/menuselect-deps
|
||||
aclocal.m4
|
||||
autom4te.cache/
|
||||
autoconfig.h
|
||||
autoconfig.h.in
|
||||
config.log
|
||||
config.status
|
||||
config.guess
|
||||
config.ignore
|
||||
configure
|
||||
dahdi_cfg
|
||||
dahdi_diag
|
||||
dahdi_maint
|
||||
dahdi_monitor
|
||||
dahdi_scan
|
||||
@@ -12,12 +33,25 @@ dahdi_speed
|
||||
dahdi_test
|
||||
dahdi_tool
|
||||
fxotune
|
||||
libtonezone.a
|
||||
libtonezone.so
|
||||
fxstest
|
||||
genconf_parameters.sample
|
||||
hdlcgen
|
||||
hdlcstress
|
||||
hdlctest
|
||||
hdlcverify
|
||||
libtool
|
||||
m4/
|
||||
makeopts
|
||||
patgen
|
||||
patlooptest
|
||||
pattest
|
||||
sethdlc
|
||||
stamp-h1
|
||||
timertest
|
||||
tonezone.lo
|
||||
tonezones.txt
|
||||
version.c
|
||||
xpp/*.check
|
||||
xpp/.depend
|
||||
xpp/.octasic.depend
|
||||
xpp/.perlcheck
|
||||
|
||||
375
Makefile
375
Makefile
@@ -1,375 +0,0 @@
|
||||
#
|
||||
# Makefile for DAHDI tools
|
||||
#
|
||||
# Copyright (C) 2001-2010 Digium, Inc.
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
|
||||
ifneq ($(wildcard makeopts),)
|
||||
include makeopts
|
||||
endif
|
||||
endif
|
||||
|
||||
SUBDIRS_UTILS_ALL:= ppp
|
||||
SUBDIRS_UTILS := xpp
|
||||
|
||||
OPTFLAGS=-O2
|
||||
CFLAGS+=-I. $(OPTFLAGS) -g -fPIC -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
|
||||
ifneq (,$(findstring ppc,$(UNAME_M)))
|
||||
CFLAGS+=-fsigned-char
|
||||
endif
|
||||
ifneq (,$(findstring x86_64,$(UNAME_M)))
|
||||
CFLAGS+=-m64
|
||||
endif
|
||||
|
||||
ifeq ($(DAHDI_DEVMODE),yes)
|
||||
CFLAGS+=-Werror -Wunused -Wundef $(DAHDI_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
|
||||
endif
|
||||
|
||||
ROOT_PREFIX=
|
||||
|
||||
# extra cflags to build dependencies. Recursively expanded.
|
||||
MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
|
||||
|
||||
CFLAGS+=$(DAHDI_INCLUDE)
|
||||
|
||||
CHKCONFIG := $(wildcard /sbin/chkconfig)
|
||||
UPDATE_RCD := $(wildcard /usr/sbin/update-rc.d)
|
||||
ifeq (,$(DESTDIR))
|
||||
ifneq (,$(CHKCONFIG))
|
||||
ADD_INITD := $(CHKCONFIG) --add dahdi
|
||||
else
|
||||
ifneq (,$(UPDATE_RCD))
|
||||
ADD_INITD := $(UPDATE_RCD) dahdi defaults 15 30
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
INITRD_DIR := $(firstword $(wildcard $(DESTDIR)/etc/rc.d/init.d $(DESTDIR)/etc/init.d))
|
||||
ifneq (,$(INITRD_DIR))
|
||||
INIT_TARGET := $(INITRD_DIR)/dahdi
|
||||
COPY_INITD := install -D dahdi.init $(INIT_TARGET)
|
||||
endif
|
||||
|
||||
RCCONF_FILE = /etc/dahdi/init.conf
|
||||
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
|
||||
|
||||
NETSCR_DIR := $(firstword $(wildcard $(DESTDIR)/etc/sysconfig/network-scripts ))
|
||||
ifneq (,$(NETSCR_DIR))
|
||||
NETSCR_TARGET := $(NETSCR_DIR)/ifup-hdlc
|
||||
COPY_NETSCR := install -D ifup-hdlc $(NETSCR_TARGET)
|
||||
endif
|
||||
|
||||
TOOLSVERSION=$(shell build_tools/make_version . dahdi/tools)
|
||||
|
||||
LTZ_A:=libtonezone.a
|
||||
LTZ_A_OBJS:=zonedata.o tonezone.o version.o
|
||||
LTZ_SO:=libtonezone.so
|
||||
LTZ_SO_OBJS:=zonedata.lo tonezone.lo version.o
|
||||
LTZ_SO_MAJOR_VER:=2
|
||||
LTZ_SO_MINOR_VER:=0
|
||||
|
||||
# sbindir, libdir, includedir and mandir are defined in makeopts
|
||||
# (from configure).
|
||||
BIN_DIR:=$(sbindir)
|
||||
LIB_DIR:=$(libdir)
|
||||
INC_DIR:=$(includedir)/dahdi
|
||||
MAN_DIR:=$(mandir)/man8
|
||||
DATA_DIR:=${datadir}/dahdi
|
||||
CONFIG_DIR:=$(sysconfdir)/dahdi
|
||||
CONFIG_FILE:=$(CONFIG_DIR)/system.conf
|
||||
UDEVRULES_DIR:=$(sysconfdir)/udev/rules.d
|
||||
|
||||
# Utilities we build with a standard build procedure:
|
||||
UTILS = dahdi_tool dahdi_test dahdi_monitor dahdi_speed sethdlc dahdi_cfg \
|
||||
fxstest fxotune dahdi_diag dahdi_scan
|
||||
|
||||
# some tests:
|
||||
UTILS += patgen pattest patlooptest hdlcstress hdlctest hdlcgen \
|
||||
hdlcverify timertest dahdi_maint
|
||||
|
||||
|
||||
BINS:=fxotune dahdi_cfg dahdi_monitor dahdi_speed dahdi_test dahdi_scan dahdi_maint
|
||||
ifeq (1,$(PBX_NEWT))
|
||||
BINS += dahdi_tool
|
||||
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_CONF:=assigned-spans.conf.sample span-types.conf.sample
|
||||
|
||||
MAN_PAGES:=$(wildcard $(BINS:%=doc/%.8))
|
||||
MAN_PAGES:=$(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:
|
||||
GROFF_PAGES := $(wildcard doc/*.8 xpp/*.8)
|
||||
GROFF_HTML := $(GROFF_PAGES:%=%.html)
|
||||
|
||||
GENERATED_DOCS := $(GROFF_HTML) README.html README.Astribank.html
|
||||
|
||||
all: prereq programs
|
||||
|
||||
libs: $(LTZ_SO) $(LTZ_A)
|
||||
|
||||
utils-subdirs:
|
||||
@for dir in $(SUBDIRS_UTILS); do \
|
||||
$(MAKE) -C $$dir; \
|
||||
done
|
||||
|
||||
programs: libs utils
|
||||
|
||||
utils: $(BINS) utils-subdirs
|
||||
|
||||
version.c: FORCE
|
||||
@TOOLSVERSION="${TOOLSVERSION}" build_tools/make_version_c > $@.tmp
|
||||
@if cmp -s $@.tmp $@ ; then :; else \
|
||||
mv $@.tmp $@ ; \
|
||||
fi
|
||||
@rm -f $@.tmp
|
||||
|
||||
tests: $(TEST_BINS)
|
||||
|
||||
$(UTILS): %: %.o
|
||||
|
||||
$(UTILS): version.o
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
|
||||
|
||||
%.lo: %.c
|
||||
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
|
||||
|
||||
%: %.o
|
||||
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
prereq: config.status
|
||||
|
||||
dahdi_tool: CFLAGS+=$(NEWT_INCLUDE)
|
||||
dahdi_tool: LIBS+=$(NEWT_LIB)
|
||||
|
||||
dahdi_speed: CFLAGS+=-O0
|
||||
|
||||
$(LTZ_A): $(LTZ_A_OBJS)
|
||||
ar rcs $@ $^
|
||||
ranlib $@
|
||||
|
||||
$(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_pcap:
|
||||
$(CC) $(CFLAGS) dahdi_pcap.c -lpcap -o $@ $<
|
||||
|
||||
|
||||
fxstest: $(LTZ_SO)
|
||||
fxstest: LIBS+=-lm
|
||||
fxotune: LIBS+=-lm
|
||||
|
||||
tonezones.txt: zonedata.c
|
||||
perl -ne 'next unless (/\.(country|description) = *"([^"]*)/); \
|
||||
print (($$1 eq "country")? "* $$2\t":"$$2\n");' $< \
|
||||
>$@
|
||||
|
||||
%.asciidoc: %.sample
|
||||
perl -n -e \
|
||||
'if (/^#($$|\s)(.*)/){ if (!$$in_doc){print "\n"}; $$in_doc=1; print "$$2\n" } else { if ($$in_doc){print "\n"}; $$in_doc=0; print " $$_" }' \
|
||||
$< \
|
||||
| perl -p -e 'if (/^ #?(\w+)=/ && ! exists $$cfgs{$$1}){my $$cfg = $$1; $$cfgs{$$cfg} = 1; s/^/\n[[cfg_$$cfg]]\n/}' >$@
|
||||
|
||||
docs: $(GENERATED_DOCS)
|
||||
|
||||
genconf_parameters.sample: xpp/genconf_parameters
|
||||
cp $< $@
|
||||
|
||||
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 $<
|
||||
|
||||
README.Astribank.html: xpp/README.Astribank
|
||||
$(ASCIIDOC) -o $@ -n -a toc -a toclevels=4 $<
|
||||
|
||||
# on Debian: this requires the full groof, not just groff-base.
|
||||
%.8.html: %.8
|
||||
man -Thtml $^ >$@
|
||||
|
||||
htmlman: $(GROFF_HTML)
|
||||
|
||||
install: all install-programs
|
||||
@echo "###################################################"
|
||||
@echo "###"
|
||||
@echo "### DAHDI tools installed successfully."
|
||||
@echo "### If you have not done so before, install init scripts with:"
|
||||
@echo "###"
|
||||
@echo "### make config"
|
||||
@echo "###"
|
||||
@echo "###################################################"
|
||||
|
||||
install-programs: install-utils install-libs
|
||||
|
||||
install-utils: utils install-utils-subdirs
|
||||
ifneq (,$(BINS))
|
||||
install -d $(DESTDIR)$(BIN_DIR)
|
||||
install $(BINS) $(DESTDIR)$(BIN_DIR)/
|
||||
install -d $(DESTDIR)$(MAN_DIR)
|
||||
install -m 644 $(MAN_PAGES) $(DESTDIR)$(MAN_DIR)/
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(CONFIG_FILE)))
|
||||
$(INSTALL) -d $(DESTDIR)$(CONFIG_DIR)
|
||||
$(INSTALL) -m 644 system.conf.sample $(DESTDIR)$(CONFIG_FILE)
|
||||
endif
|
||||
install -d $(DESTDIR)$(DATA_DIR)
|
||||
install $(ASSIGNED_DATA_SCRIPTS) $(DESTDIR)$(DATA_DIR)/
|
||||
install $(ASSIGNED_UTILS) $(DESTDIR)/$(BIN_DIR)/
|
||||
install -m 644 $(ASSIGNED_CONF) $(DESTDIR)/$(CONFIG_DIR)/
|
||||
|
||||
install-libs: libs
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 755 $(LTZ_A) $(DESTDIR)$(LIB_DIR)/
|
||||
$(INSTALL) -m 755 $(LTZ_SO) $(DESTDIR)$(LIB_DIR)/$(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER)
|
||||
ifeq (,$(DESTDIR))
|
||||
if [ `id -u` = 0 ]; then \
|
||||
/sbin/ldconfig || : ;\
|
||||
fi
|
||||
endif
|
||||
rm -f $(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO).$(LTZ_SO_MAJOR_VER)
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
# Overwrite the 1.0 links out there. dahdi-tools 2.0.0 installed
|
||||
# 1.0 links but dahdi-tools changed them to 2.0 in order to explicitly
|
||||
# break applications linked with zaptel. But, this also meant that
|
||||
# applications linked with libtonezone.so.1.0 broke when dahdi-tools
|
||||
# 2.1.0 was installed.
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO).1.0
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO).1
|
||||
ifneq (no,$(USE_SELINUX))
|
||||
ifeq (,$(DESTDIR))
|
||||
/sbin/restorecon -v $(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
endif
|
||||
endif
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)/$(INC_DIR)
|
||||
$(INSTALL) -m 644 tonezone.h $(DESTDIR)$(INC_DIR)/
|
||||
|
||||
install-utils-subdirs:
|
||||
@for dir in $(SUBDIRS_UTILS); do \
|
||||
$(MAKE) -C $$dir install; \
|
||||
done
|
||||
|
||||
install-tests: tests
|
||||
ifneq (,$(TEST_BINS))
|
||||
install -d $(DESTDIR)$(BIN_DIR)
|
||||
install $(TEST_BINS) $(DESTDIR)$(BIN_DIR)/
|
||||
endif
|
||||
|
||||
config:
|
||||
ifneq (,$(COPY_INITD))
|
||||
$(COPY_INITD)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(RCCONF_FILE)))
|
||||
$(INSTALL) -D -m 644 init.conf.sample $(DESTDIR)$(RCCONF_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(MODULES_FILE)))
|
||||
$(INSTALL) -D -m 644 modules.sample $(DESTDIR)$(MODULES_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(GENCONF_FILE)))
|
||||
$(INSTALL) -D -m 644 xpp/genconf_parameters $(DESTDIR)$(GENCONF_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(MODPROBE_FILE)))
|
||||
$(INSTALL) -D -m 644 modprobe.conf.sample $(DESTDIR)$(MODPROBE_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(BLACKLIST_FILE)))
|
||||
$(INSTALL) -D -m 644 blacklist.sample $(DESTDIR)$(BLACKLIST_FILE)
|
||||
endif
|
||||
$(INSTALL) -d $(DESTDIR)$(UDEVRULES_DIR)
|
||||
$(INSTALL) -D -m 644 dahdi.rules $(DESTDIR)$(UDEVRULES_DIR)/
|
||||
ifneq (,$(COPY_NETSCR))
|
||||
$(COPY_NETSCR)
|
||||
endif
|
||||
ifneq (,$(ADD_INITD))
|
||||
$(ADD_INITD)
|
||||
endif
|
||||
@echo "DAHDI has been configured."
|
||||
@echo ""
|
||||
@echo "List of detected DAHDI devices:"
|
||||
@echo ""
|
||||
@if [ `xpp/dahdi_hardware | tee /dev/stderr | wc -l` -eq 0 ]; then \
|
||||
echo "No hardware found"; \
|
||||
else \
|
||||
echo ""; \
|
||||
echo "run 'dahdi_genconf modules' to load support for only " ;\
|
||||
echo "the DAHDI hardware installed in this system. By "; \
|
||||
echo "default support for all DAHDI hardware is loaded at "; \
|
||||
echo "DAHDI start. "; \
|
||||
fi
|
||||
|
||||
update:
|
||||
@if [ -d .svn ]; then \
|
||||
echo "Updating from Subversion..." ; \
|
||||
svn update | tee update.out; \
|
||||
rm -f .version; \
|
||||
if [ `grep -c ^C update.out` -gt 0 ]; then \
|
||||
echo ; echo "The following files have conflicts:" ; \
|
||||
grep ^C update.out | cut -b4- ; \
|
||||
fi ; \
|
||||
rm -f update.out; \
|
||||
else \
|
||||
echo "Not under version control"; \
|
||||
fi
|
||||
|
||||
dist:
|
||||
@./build_tools/make_dist "dahdi-tools" "$(TOOLSVERSION)"
|
||||
|
||||
clean:
|
||||
rm -f $(BINS) $(TEST_BINS)
|
||||
rm -f *.o dahdi_cfg tzdriver sethdlc
|
||||
rm -f $(LTZ_SO) $(LTZ_A) *.lo
|
||||
@for dir in $(SUBDIRS_UTILS_ALL); do \
|
||||
$(MAKE) -C $$dir clean; \
|
||||
done
|
||||
@for dir in $(SUBDIRS_UTILS); do \
|
||||
$(MAKE) -C $$dir clean; \
|
||||
done
|
||||
rm -f libtonezone*
|
||||
rm -f fxotune
|
||||
rm -f core
|
||||
rm -f dahdi_cfg-shared fxstest
|
||||
rm -rf $(GENERATED_DOCS) *.asciidoc tonezones.txt
|
||||
rm -f dahdi_pcap
|
||||
|
||||
distclean: dist-clean
|
||||
|
||||
dist-clean: clean
|
||||
rm -f makeopts
|
||||
rm -f config.log config.status
|
||||
rm -f .*.d
|
||||
|
||||
config.status: configure
|
||||
@CFLAGS="" ./configure
|
||||
@echo "****"
|
||||
@echo "**** The configure script was just executed, so 'make' needs to be"
|
||||
@echo "**** restarted."
|
||||
@echo "****"
|
||||
@exit 1
|
||||
|
||||
.PHONY: distclean dist-clean clean all install programs tests devel data config update install-programs install-libs install-utils-subdirs utils-subdirs prereq dist
|
||||
|
||||
FORCE:
|
||||
|
||||
ifneq ($(wildcard .*.d),)
|
||||
include .*.d
|
||||
endif
|
||||
196
Makefile.am
Normal file
196
Makefile.am
Normal file
@@ -0,0 +1,196 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
LEGACY_MAKE = \
|
||||
$(MAKE) -f $(srcdir)/Makefile.legacy \
|
||||
top_srcdir=$(top_srcdir) \
|
||||
srcdir=$(srcdir)
|
||||
|
||||
CFLAGS = -g -Wall -O2 $(DAHDI_INCLUDE)
|
||||
if DAHDI_DEVMODE
|
||||
CFLAGS += \
|
||||
-Werror \
|
||||
-Wunused \
|
||||
-Wundef \
|
||||
$(DAHDI_DECLARATION_AFTER_STATEMENT) \
|
||||
-Wmissing-format-attribute \
|
||||
-Wformat-security \
|
||||
#-Wformat=2
|
||||
endif
|
||||
|
||||
SUBDIRS = xpp doc hotplug
|
||||
|
||||
if PPPD
|
||||
SUBDIRS += ppp
|
||||
endif
|
||||
|
||||
noinst_HEADERS = \
|
||||
bittest.h \
|
||||
dahdi_tools_version.h \
|
||||
fxotune.h \
|
||||
wavformat.h \
|
||||
#
|
||||
|
||||
sbin_PROGRAMS = \
|
||||
dahdi_test \
|
||||
dahdi_maint \
|
||||
dahdi_monitor \
|
||||
dahdi_cfg \
|
||||
dahdi_speed \
|
||||
dahdi_scan \
|
||||
fxotune
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
fxstest \
|
||||
patgen \
|
||||
pattest \
|
||||
patlooptest \
|
||||
dahdi_diag \
|
||||
timertest
|
||||
|
||||
dist_sbin_SCRIPTS = \
|
||||
dahdi_span_assignments \
|
||||
dahdi_waitfor_span_assignments \
|
||||
dahdi_span_types
|
||||
|
||||
if PBX_HDLC
|
||||
sbin_PROGRAMS += sethdlc
|
||||
noinst_PROGRAMS += hdlcstress hdlctest hdlcgen hdlcverify
|
||||
endif
|
||||
|
||||
# Libtool versioning for libtonezone:
|
||||
# Bump when interface changes
|
||||
LTZ_CURRENT = 2
|
||||
# Bump if interface change is backward compatible
|
||||
LTZ_AGE = 0
|
||||
# Bump if only implementation change
|
||||
LTZ_REVISION = 0
|
||||
|
||||
lib_LTLIBRARIES = libtonezone.la
|
||||
|
||||
libtonezone_la_SOURCES = \
|
||||
zonedata.c \
|
||||
tonezone.c \
|
||||
version.c
|
||||
dahdiinclude_HEADERS = tonezone.h
|
||||
libtonezone_la_CFLAGS = $(CFLAGS) -I$(srcdir) -DBUILDING_TONEZONE
|
||||
libtonezone_la_LDFLAGS = -version-info "$(LTZ_CURRENT):$(LTZ_REVISION):$(LTZ_AGE)"
|
||||
|
||||
if PBX_PCAP
|
||||
noinst_PROGRAMS += dahdi_pcap
|
||||
dahdi_pcap_LDADD = -lpcap
|
||||
endif
|
||||
|
||||
patlooptest_LDADD = libtonezone.la -lm
|
||||
fxstest_LDADD = libtonezone.la -lm
|
||||
fxotune_LDADD = -lm
|
||||
dahdi_speed_CFLAGS = -O2
|
||||
|
||||
dahdi_maint_SOURCES = dahdi_maint.c version.c
|
||||
|
||||
if PBX_NEWT
|
||||
sbin_PROGRAMS += dahdi_tool
|
||||
dahdi_tool_CFLAGS = $(CFLAGS) $(NEWT_INCLUDE)
|
||||
dahdi_tool_LDADD = $(NEWT_LIB)
|
||||
endif
|
||||
|
||||
dahdi_cfg_LDFLAGS = -lm -lpthread
|
||||
dahdi_cfg_LDADD = libtonezone.la
|
||||
|
||||
udevrulesdir = @udevrulesdir@
|
||||
udevrules_DATA = dahdi.rules
|
||||
|
||||
all-local:
|
||||
$(LEGACY_MAKE) all
|
||||
|
||||
clean-local:
|
||||
$(LEGACY_MAKE) clean
|
||||
|
||||
install-exec-hook:
|
||||
$(LEGACY_MAKE) install
|
||||
@echo "Compatibility symlinks (should be removed in the future)"
|
||||
ln -sf libtonezone.so.2.0.0 $(DESTDIR)$(libdir)/libtonezone.so.2.0
|
||||
|
||||
bashcompdir = $(sysconfdir)/bash_completion.d
|
||||
|
||||
install-data-hook:
|
||||
mkdir -p $(DESTDIR)$(bashcompdir)
|
||||
install -m 644 $(srcdir)/dahdi-bash-completion $(DESTDIR)$(bashcompdir)/dahdi
|
||||
|
||||
# Handle these files specially -- install them only with 'install-config'
|
||||
special_config_files = \
|
||||
init.conf.sample \
|
||||
blacklist.sample \
|
||||
modprobe.conf.sample \
|
||||
#
|
||||
|
||||
install-config:
|
||||
mkdir -p $(DESTDIR)$(dahdiconfdir)
|
||||
mkdir -p $(DESTDIR)$(sysconfdir)/modprobe.d
|
||||
install -m644 xpp/genconf_parameters $(DESTDIR)$(dahdiconfdir)/genconf_parameters
|
||||
install -m644 init.conf.sample $(DESTDIR)$(dahdiconfdir)/init.conf
|
||||
install -m644 blacklist.sample $(DESTDIR)$(sysconfdir)/modprobe.d/dahdi-blacklist.conf
|
||||
install -m644 modprobe.conf.sample $(DESTDIR)$(sysconfdir)/modprobe.d/dahdi.conf
|
||||
$(LEGACY_MAKE) config
|
||||
|
||||
dahdiconfdir = @sysconfdir@/dahdi
|
||||
dahdiconf_DATA = \
|
||||
system.conf.sample \
|
||||
assigned-spans.conf.sample \
|
||||
span-types.conf.sample \
|
||||
modules.sample \
|
||||
#
|
||||
|
||||
build_scripts = \
|
||||
build_tools/dahdi_svn_tarball \
|
||||
build_tools/dahdi_sysfs_copy \
|
||||
build_tools/dump_sys_state \
|
||||
build_tools/make_firmware_object.in \
|
||||
build_tools/make_tree \
|
||||
build_tools/make_version \
|
||||
build_tools/test_kernel_git \
|
||||
build_tools/uninstall-modules \
|
||||
#
|
||||
|
||||
.version:
|
||||
if ./build_tools/make_version . dahdi/tools > $@.tmp; then \
|
||||
mv "$@.tmp" "$@"; \
|
||||
fi
|
||||
|
||||
uninstall-hook:
|
||||
$(RM) $(DESTDIR)$(sysconfdir)/dahdi/span-types.conf.sample
|
||||
$(RM) $(DESTDIR)$(sysconfdir)/dahdi/assigned-spans.conf.sample
|
||||
$(RM) $(DESTDIR)$(sysconfdir)/dahdi/system.conf
|
||||
$(RM) $(DESTDIR)$(bashcompdir)/dahdi
|
||||
|
||||
docs:
|
||||
$(LEGACY_MAKE) $@
|
||||
|
||||
DISTCLEANFILES = makeopts config.log config.status .*.d
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
m4/libtool.m4 \
|
||||
m4/ltoptions.m4 \
|
||||
m4/ltsugar.m4 \
|
||||
m4/ltversion.m4 \
|
||||
m4/lt~obsolete.m4 \
|
||||
#
|
||||
|
||||
EXTRA_DIST = \
|
||||
.version \
|
||||
LICENSE \
|
||||
LICENSE.LGPL \
|
||||
UPGRADE.txt \
|
||||
bootstrap.sh \
|
||||
Makefile.legacy \
|
||||
dahdi.init \
|
||||
dahdi.xml \
|
||||
dahdi_pcap.c \
|
||||
ifup-hdlc \
|
||||
dahdi-bash-completion \
|
||||
$(special_config_files) \
|
||||
$(dahdiconf_DATA) \
|
||||
$(udevrules_DATA) \
|
||||
$(build_scripts) \
|
||||
#
|
||||
|
||||
.PHONY: docs config
|
||||
133
Makefile.legacy
Normal file
133
Makefile.legacy
Normal file
@@ -0,0 +1,133 @@
|
||||
#
|
||||
# Makefile for DAHDI tools
|
||||
#
|
||||
# Copyright (C) 2001-2010 Digium, Inc.
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(strip $(foreach var,clean,$(findstring $(var),$(MAKECMDGOALS)))),)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(foreach var,clean,$(findstring $(var),$(MAKECMDGOALS)))),)
|
||||
ifneq ($(wildcard makeopts),)
|
||||
include makeopts
|
||||
endif
|
||||
endif
|
||||
|
||||
CHKCONFIG := $(wildcard /sbin/chkconfig)
|
||||
UPDATE_RCD := $(wildcard /usr/sbin/update-rc.d)
|
||||
ifeq (,$(DESTDIR))
|
||||
ifneq (,$(CHKCONFIG))
|
||||
ADD_INITD := $(CHKCONFIG) --add dahdi
|
||||
else
|
||||
ifneq (,$(UPDATE_RCD))
|
||||
ADD_INITD := $(UPDATE_RCD) dahdi defaults 15 30
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
INITRD_DIR := $(firstword $(wildcard $(DESTDIR)/etc/rc.d/init.d $(DESTDIR)/etc/init.d))
|
||||
ifneq (,$(INITRD_DIR))
|
||||
INIT_TARGET := $(INITRD_DIR)/dahdi
|
||||
COPY_INITD := install -D dahdi.init $(INIT_TARGET)
|
||||
endif
|
||||
|
||||
NETSCR_DIR := $(firstword $(wildcard $(DESTDIR)/etc/sysconfig/network-scripts ))
|
||||
ifneq (,$(NETSCR_DIR))
|
||||
NETSCR_TARGET := $(NETSCR_DIR)/ifup-hdlc
|
||||
COPY_NETSCR := install -D ifup-hdlc $(NETSCR_TARGET)
|
||||
endif
|
||||
|
||||
# sbindir, libdir, includedir and mandir are defined in makeopts
|
||||
# (from configure).
|
||||
LIB_DIR:=$(libdir)
|
||||
|
||||
# All the man pages. Not just installed ones:
|
||||
GROFF_PAGES := $(wildcard doc/*.8 xpp/*.8)
|
||||
GROFF_HTML := $(GROFF_PAGES:%=%.html)
|
||||
|
||||
GENERATED_DOCS := $(GROFF_HTML) README.html README.Astribank.html
|
||||
|
||||
all:
|
||||
|
||||
tonezones.txt: zonedata.c
|
||||
perl -ne 'next unless (/\.(country|description) = *"([^"]*)/); \
|
||||
print (($$1 eq "country")? "* $$2\t":"$$2\n");' $< \
|
||||
>$@
|
||||
|
||||
%.asciidoc: %.sample
|
||||
perl -n -e \
|
||||
'if (/^#($$|\s)(.*)/){ if (!$$in_doc){print "\n"}; $$in_doc=1; print "$$2\n" } else { if ($$in_doc){print "\n"}; $$in_doc=0; print " $$_" }' \
|
||||
$< \
|
||||
| perl -p -e 'if (/^ #?(\w+)=/ && ! exists $$cfgs{$$1}){my $$cfg = $$1; $$cfgs{$$cfg} = 1; s/^/\n[[cfg_$$cfg]]\n/}' >$@
|
||||
|
||||
docs: $(GENERATED_DOCS)
|
||||
|
||||
genconf_parameters.sample: xpp/genconf_parameters
|
||||
cp $< $@
|
||||
|
||||
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=4 $<
|
||||
|
||||
README.Astribank.html: xpp/README.Astribank
|
||||
$(ASCIIDOC) -o $@ -n -a toc -a toclevels=4 $<
|
||||
|
||||
# on Debian: this requires the full groff, not just groff-base.
|
||||
%.8.html: %.8
|
||||
man -Thtml $^ >$@
|
||||
|
||||
htmlman: $(GROFF_HTML)
|
||||
|
||||
install: all install-programs
|
||||
@echo "###################################################"
|
||||
@echo "###"
|
||||
@echo "### DAHDI tools installed successfully."
|
||||
@echo "### If you have not done so before, install init scripts with:"
|
||||
@echo "###"
|
||||
@echo "### make config"
|
||||
@echo "###"
|
||||
@echo "###################################################"
|
||||
|
||||
install-programs: install-libs
|
||||
|
||||
install-libs:
|
||||
ifneq (no,$(USE_SELINUX))
|
||||
ifeq (,$(DESTDIR))
|
||||
/sbin/restorecon -v $(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
endif
|
||||
endif
|
||||
|
||||
config:
|
||||
ifneq (,$(COPY_INITD))
|
||||
$(COPY_INITD)
|
||||
endif
|
||||
ifneq (,$(COPY_NETSCR))
|
||||
$(COPY_NETSCR)
|
||||
endif
|
||||
ifneq (,$(ADD_INITD))
|
||||
$(ADD_INITD)
|
||||
endif
|
||||
@echo "DAHDI has been configured."
|
||||
@echo ""
|
||||
@echo "List of detected DAHDI devices:"
|
||||
@echo ""
|
||||
@if [ `xpp/dahdi_hardware | tee /dev/stderr | wc -l` -eq 0 ]; then \
|
||||
echo "No hardware found"; \
|
||||
else \
|
||||
echo ""; \
|
||||
echo "run 'dahdi_genconf modules' to load support for only " ;\
|
||||
echo "the DAHDI hardware installed in this system. By "; \
|
||||
echo "default support for all DAHDI hardware is loaded at "; \
|
||||
echo "DAHDI start. "; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
rm -f *.o tzdriver
|
||||
rm -f core
|
||||
rm -rf $(GENERATED_DOCS) *.asciidoc tonezones.txt
|
||||
|
||||
.PHONY: clean all install devel data config install-programs install-libs
|
||||
|
||||
FORCE:
|
||||
192
README
192
README
@@ -15,8 +15,9 @@ dahdi-linux before building dahdi-tools.
|
||||
Build System
|
||||
~~~~~~~~~~~~
|
||||
GCC and friends. Generally you will need to install the package gcc.
|
||||
There may be cases where you will need a specific version of gcc to build
|
||||
kernel modules.
|
||||
|
||||
Autotools (autoconf, automake and libtool) are needed if you clone from
|
||||
Git.
|
||||
|
||||
|
||||
Extra Libraries
|
||||
@@ -24,20 +25,25 @@ Extra Libraries
|
||||
Some libraries are needed for extra utilities that are provided with
|
||||
DAHDI.
|
||||
|
||||
- libusb is needed for building fpga_load, needed for firmware loading of
|
||||
the Xorcom Astribank.
|
||||
- libusb is needed for building astribank_hexload, needed for firmware
|
||||
loading of the Xorcom Astribank.
|
||||
- libnewt is needed to build the optional but useful utility dahdi_tool.
|
||||
- libpcap is needed for building dahdi_pcap.
|
||||
- pppd is needed to build the dahdi pppd plugin.
|
||||
|
||||
|
||||
Installation
|
||||
~~~~~~~~~~~~
|
||||
Note: If using `sudo` to build/install, you may need to add /sbin to your PATH.
|
||||
----------------------------------
|
||||
# Only if you cloned from git:
|
||||
autoreconf -i
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
# To install init scripts and config files:
|
||||
#make config
|
||||
# To install some extra configuration files:
|
||||
#make install-config
|
||||
----------------------------------
|
||||
|
||||
|
||||
@@ -49,15 +55,11 @@ 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
|
||||
targets of it:
|
||||
* make 'utilname': builds 'utilname' alone (e.g: `make dahdi_diag`)
|
||||
* make utils: Build libtonezone.
|
||||
* make libs: Build libtonezone.
|
||||
- make: Build DAHDI user-space programs and libraries.
|
||||
- make docs: Generate some extra documentation files.
|
||||
. 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
|
||||
- make install-config: install configuration files
|
||||
|
||||
|
||||
Installation to a Subtree
|
||||
@@ -73,8 +75,8 @@ This can be useful for any partial install target from the list above.
|
||||
|
||||
Options For ./configure
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
The configure script executes various tests and based on them generates
|
||||
makeopts. You can pass it --with options and variable settings, for
|
||||
The configure script executes various tests and the build will depend on
|
||||
their result. You can pass it --with options and variable settings, for
|
||||
instance:
|
||||
|
||||
./configure --without-ncurses CC="gcc-4.10"
|
||||
@@ -114,32 +116,55 @@ The configuration file of the dahdi init.d script is
|
||||
/etc/dahdi/init.conf . That file is used to override defaults that are
|
||||
set at the beginning of the init.d script.
|
||||
|
||||
/etc/dahdi/assigned-spans.conf
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Assigns span number and initial channel number for spans in each device.
|
||||
Just like system.conf it may be generated with dahdi_genconf:
|
||||
|
||||
dahdi_span_assignments auto
|
||||
dahdi_genconf
|
||||
|
||||
It may also be edited manually to allow reserving span and channel
|
||||
numbers for specific devices.
|
||||
|
||||
/etc/dahdi/span-types.conf
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Theoretically, this file is similar to assigned-spans.conf. It allows
|
||||
setting the type (E1/T1) of a "PRI" span. This cannot be configured
|
||||
anywhere else: it needs to be done before the span is assigned as it
|
||||
changes the number of channels the span has.
|
||||
|
||||
In practice most systems don't mix E1 and T1 and thus this file will
|
||||
typically have at most a single wild-card line setting all cards to be
|
||||
either E1 or T1.
|
||||
|
||||
|
||||
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 +237,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[]
|
||||
|
||||
|
||||
|
||||
114
autoconfig.h.in
114
autoconfig.h.in
@@ -1,114 +0,0 @@
|
||||
/* autoconfig.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if your system has the DAHDI headers. */
|
||||
#undef HAVE_DAHDI
|
||||
|
||||
/* Define if your system has the DAHDI23 headers. */
|
||||
#undef HAVE_DAHDI23
|
||||
|
||||
/* Define DAHDI23 headers version */
|
||||
#undef HAVE_DAHDI23_VERSION
|
||||
|
||||
/* Define DAHDI headers version */
|
||||
#undef HAVE_DAHDI_VERSION
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <linux/soundcard.h> header file. */
|
||||
#undef HAVE_LINUX_SOUNDCARD_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define this to indicate the ${NEWT_DESCRIP} library */
|
||||
#undef HAVE_NEWT
|
||||
|
||||
/* Define to indicate the ${NEWT_DESCRIP} library version */
|
||||
#undef HAVE_NEWT_VERSION
|
||||
|
||||
/* Define to 1 if you have the `semtimedop' function. */
|
||||
#undef HAVE_SEMTIMEDOP
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/soundcard.h> header file. */
|
||||
#undef HAVE_SYS_SOUNDCARD_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define this to indicate the ${USB_DESCRIP} library */
|
||||
#undef HAVE_USB
|
||||
|
||||
/* Define to indicate the ${USB_DESCRIP} library version */
|
||||
#undef HAVE_USB_VERSION
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
|
||||
|
||||
/* Define to 1 if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
@@ -1,26 +0,0 @@
|
||||
#! /bin/sh
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo >&2 "Usage: $0 <package> <version>"
|
||||
exit 1
|
||||
fi
|
||||
package="$1"
|
||||
version="$2"
|
||||
tarball_prefix="$package-$version"
|
||||
echo "I: Making dist tarball for $tarball_prefix"
|
||||
tarball_name="$tarball_prefix.tar.gz"
|
||||
|
||||
tmp_work_dir=".tmp"
|
||||
tmp_version_dir="$tmp_work_dir/$tarball_prefix"
|
||||
|
||||
if [ "$DESTDIR" != '' ]; then
|
||||
destdir="$DESTDIR/"
|
||||
fi
|
||||
output="$destdir$tarball_name"
|
||||
|
||||
mkdir -p "$tmp_version_dir"
|
||||
git archive --format tar HEAD | tar xf - -C "$tmp_version_dir"
|
||||
echo "$version" > "$tmp_version_dir/.version"
|
||||
tar czf "$output" -C "$tmp_work_dir" "$tarball_prefix"
|
||||
rm -rf "$tmp_work_dir"
|
||||
echo "I: tarball is ready: '$output'"
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
cat << END
|
||||
/*
|
||||
* version.c
|
||||
* Automatically generated
|
||||
*/
|
||||
|
||||
const char dahdi_tools_version[] = "DAHDI Tools Version - ${TOOLSVERSION}";
|
||||
|
||||
END
|
||||
1526
config.guess
vendored
1526
config.guess
vendored
File diff suppressed because it is too large
Load Diff
1658
config.sub
vendored
1658
config.sub
vendored
File diff suppressed because it is too large
Load Diff
129
configure.ac
129
configure.ac
@@ -2,29 +2,65 @@
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
m4_define([TOOLSVERSION],
|
||||
m4_define([short_version],
|
||||
m4_bpatsubst(m4_esyscmd([build_tools/make_version . dahdi/tools]),
|
||||
[\([0-9.]*\)\(\w\|\W\)*],
|
||||
[\1]))
|
||||
AC_INIT(dahdi, TOOLSVERSION, www.asterisk.org)
|
||||
AC_INIT([dahdi-tools], short_version, [www.asterisk.org])
|
||||
|
||||
# check existence of the package
|
||||
AC_CONFIG_SRCDIR([dahdi_cfg.c])
|
||||
AC_CONFIG_AUX_DIR([auxdir])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects])
|
||||
|
||||
build_version=`build_tools/make_version . dahdi/tools`
|
||||
AC_SUBST([BUILD_VERSION], "$build_version")
|
||||
|
||||
# enable nice build output on automake1.11
|
||||
m4_pattern_allow([AM_DEFAULT_VERBOSITY])
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],[AM_DEFAULT_VERBOSITY=1])
|
||||
AM_CONDITIONAL([SILENT_RULES], [test "$AM_DEFAULT_VERBOSITY" = '0'])
|
||||
|
||||
AC_COPYRIGHT("dahdi-tools")
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
ac_default_prefix=/usr
|
||||
if test ${sysconfdir} = '${prefix}/etc'; then
|
||||
sysconfdir=/etc
|
||||
fi
|
||||
if test ${mandir} = '${prefix}/man'; then
|
||||
mandir=/usr/share/man
|
||||
fi
|
||||
# Preserve old defaults if called without --prefix or --prefix=/usr
|
||||
# prefix=/usr
|
||||
# sysconfdir=/etc
|
||||
|
||||
if test ${localstatedir} = '${prefix}/var'; then
|
||||
localstatedir=/var
|
||||
ac_default_prefix=/usr
|
||||
if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
|
||||
if test ${sysconfdir} = '${prefix}/etc'; then
|
||||
sysconfdir=/etc
|
||||
fi
|
||||
if test ${mandir} = '${prefix}/man'; then
|
||||
mandir=/usr/share/man
|
||||
fi
|
||||
|
||||
if test ${localstatedir} = '${prefix}/var'; then
|
||||
localstatedir=/var
|
||||
fi
|
||||
fi
|
||||
AC_SUBST([dahditoolsdir], ['${datadir}/dahdi'])
|
||||
AC_SUBST([dahdiincludedir], ['${includedir}/dahdi'])
|
||||
|
||||
# Where to install udev rules?
|
||||
# * Our default is $sysconfdir/udev/rules.d:
|
||||
# - This preserve legacy location.
|
||||
# - It doesn't write into modern vendor supplied location (/lib/udev/rules.d)
|
||||
# - It doesn't break "make distcheck" (where everything should be relative
|
||||
# to prefix.
|
||||
# * Packagers are encouraged to use --udevrules=/lib/udev/rules.d
|
||||
#
|
||||
m4_define([_UDEV_RULES_DIR_DEFAULT], [${sysconfdir}/udev/rules.d])dnl
|
||||
AC_ARG_WITH(udevrules,
|
||||
[AS_HELP_STRING([--with-udevrules=PATH],
|
||||
[Location of UDEV rules @<:@default=]_UDEV_RULES_DIR_DEFAULT[@:>@])],
|
||||
[udevrulesdir=$withval],
|
||||
[udevrulesdir=]'_UDEV_RULES_DIR_DEFAULT'
|
||||
)
|
||||
AC_SUBST([udevrulesdir], "$udevrulesdir")
|
||||
|
||||
# specify output header file
|
||||
AC_CONFIG_HEADER(autoconfig.h)
|
||||
@@ -37,10 +73,15 @@ AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
|
||||
AC_CHECK_TOOL([LD], [ld])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_AWK
|
||||
AC_PROG_LIBTOOL
|
||||
AST_CHECK_GNU_MAKE
|
||||
|
||||
test_obj=conftest.o
|
||||
@@ -70,6 +111,35 @@ AC_SUBST(DOWNLOAD)
|
||||
|
||||
AC_LANG(C)
|
||||
|
||||
AC_PATH_PROG([PERL], [perl])
|
||||
if test "$PERL" = ''; then
|
||||
AC_MSG_ERROR(perl is mandatory)
|
||||
fi
|
||||
# Where to install perl modules?
|
||||
# * Packagers are encouraged to use the result of "perl -V:vendorlib"
|
||||
# * Our default is:
|
||||
# - The result of "perl -V:sitelib" for our default prefix (/usr)
|
||||
# - The "$datadir/perl5" directory otherwise (e.g: during "make distcheck")
|
||||
#
|
||||
AC_MSG_CHECKING(for perl libdir)
|
||||
m4_define([_PERL_LIBDIR_DEFAULT], [${datadir}/perl5])dnl
|
||||
AC_ARG_WITH(perllib,
|
||||
[AS_HELP_STRING([--with-perllib=PATH],
|
||||
[Location of perl modules @<:@default=]_PERL_LIBDIR_DEFAULT[, or perl -V:sitelib@:>@])],
|
||||
[perllibdir=$withval],
|
||||
[
|
||||
if test "$prefix" = 'NONE' -o "$prefix" = '/usr'; then
|
||||
eval `"$PERL" -V:sitelib`
|
||||
perllibdir="$sitelib"
|
||||
else
|
||||
perllibdir='_PERL_LIBDIR_DEFAULT'
|
||||
fi
|
||||
]
|
||||
)
|
||||
AC_SUBST([perllibdir], "$perllibdir")
|
||||
AC_MSG_RESULT([$perllibdir])
|
||||
AM_CONDITIONAL([PERL], [test "$perllibdir" != ''])
|
||||
|
||||
AC_ARG_ENABLE(dev-mode,
|
||||
[ --enable-dev-mode Turn on developer mode],
|
||||
[case "${enableval}" in
|
||||
@@ -78,6 +148,7 @@ AC_ARG_ENABLE(dev-mode,
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode) ;;
|
||||
esac])
|
||||
AC_SUBST(DAHDI_DEVMODE)
|
||||
AM_CONDITIONAL([DAHDI_DEVMODE], [test "$DAHDI_DEVMODE" = 'yes'])
|
||||
|
||||
AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
|
||||
if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
|
||||
@@ -92,12 +163,22 @@ AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
|
||||
AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
|
||||
AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
|
||||
AST_EXT_LIB_SETUP([USB], [usb], [usb])
|
||||
AST_EXT_LIB_SETUP([PCAP], [pcap], [pcap])
|
||||
|
||||
AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
|
||||
DAHDI23_DIR="${DAHDI_DIR}"
|
||||
AST_C_DEFINE_CHECK([DAHDI23], [DAHDI_CONFIG_NTTE], [dahdi/user.h])
|
||||
AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
|
||||
AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h])
|
||||
AST_EXT_LIB_CHECK([PCAP], [pcap], [pcap_compile], [pcap.h])
|
||||
|
||||
saved_CPPFLAGS="$CPPFLAGS"
|
||||
CPPFLAGS="$CPPFLAGS $DAHDI_INCLUDE"
|
||||
AC_CHECK_DECL([DAHDI_TXMIRROR], [DAHDI_TXMIRROR=1], [DAHDI_TXMIRROR=0], [#include <dahdi/user.h>])
|
||||
CPPFLAGS="$saved_CPPFLAGS"
|
||||
|
||||
AM_CONDITIONAL([PBX_NEWT], [test "$PBX_NEWT" = "1"])
|
||||
AM_CONDITIONAL([PBX_PCAP], [test "$PBX_PCAP" = "1" -a "$DAHDI_TXMIRROR" = "1"])
|
||||
|
||||
AC_CHECK_FUNCS([semtimedop])
|
||||
|
||||
@@ -138,6 +219,7 @@ if test "x${PBX_HDLC}" != "x1"; then
|
||||
fi
|
||||
|
||||
AC_SUBST(PBX_HDLC)
|
||||
AM_CONDITIONAL([PBX_HDLC], [test "$PBX_HDLC" = "1"])
|
||||
|
||||
AC_ARG_WITH(selinux,
|
||||
[AS_HELP_STRING([--with-selinux],
|
||||
@@ -193,6 +275,9 @@ case "$with_ppp" in
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_SUBST(PPPD_VERSION)
|
||||
AM_CONDITIONAL([PPPD], [test "$PPPD_VERSION" != ''])
|
||||
|
||||
if test "x${PBX_DAHDI}" != "x1"; then
|
||||
AC_MSG_NOTICE([***])
|
||||
AC_MSG_NOTICE([*** Building this package requires DAHDI support. *** ])
|
||||
@@ -211,7 +296,27 @@ fi
|
||||
|
||||
AC_SUBST(PPPD_VERSION)
|
||||
|
||||
AC_CONFIG_FILES([makeopts])
|
||||
AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
|
||||
|
||||
# Taken from octasic-helper
|
||||
AC_SUBST([USE_OCTASIC], [yes])
|
||||
AM_CONDITIONAL([USE_OCTASIC], [test "$USE_OCTASIC" = 'yes'])
|
||||
octasic_dir='$(top_srcdir)/xpp/oct612x'
|
||||
AC_SUBST([OCTASIC_CFLAGS], ["-I$octasic_dir/include -I$octasic_dir/octdeviceapi -I$octasic_dir/octdeviceapi/oct6100api"])
|
||||
|
||||
AC_SUBST([TOOLSVERSION], m4_esyscmd([build_tools/make_version . dahdi/tools]))
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
makeopts
|
||||
version.c
|
||||
Makefile
|
||||
doc/Makefile
|
||||
hotplug/Makefile
|
||||
ppp/Makefile
|
||||
xpp/Makefile
|
||||
xpp/oct612x/Makefile
|
||||
xpp/perl_modules/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)
|
||||
|
||||
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
|
||||
21
dahdi.init
21
dahdi.init
@@ -144,15 +144,18 @@ hotplug_exit_after_load() {
|
||||
|
||||
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
|
||||
xpp_startup() {
|
||||
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
|
||||
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
|
||||
aas=`cat "$aas_param" 2>/dev/null`
|
||||
if [ "$aas" = 0 ]; then
|
||||
echo 1>&2 "Don't wait for Astribanks (use Asterisk hotplug-support)"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
# do nothing if there are no astribank devices:
|
||||
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 +240,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 +266,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"
|
||||
|
||||
241
dahdi_cfg.c
241
dahdi_cfg.c
@@ -29,13 +29,18 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#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"
|
||||
@@ -104,7 +109,7 @@ static int fiftysixkhdlc[DAHDI_MAX_CHANNELS];
|
||||
|
||||
static int spans=0;
|
||||
|
||||
static int fo_real = 1;
|
||||
static int dry_run = 0;
|
||||
|
||||
static int verbose = 0;
|
||||
|
||||
@@ -137,6 +142,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) {
|
||||
@@ -666,7 +762,16 @@ static int chanconfig(char *keyword, char *args)
|
||||
} else {
|
||||
fprintf(stderr, "Huh? (%s)\n", keyword);
|
||||
}
|
||||
if (is_digital)
|
||||
|
||||
if (cc[x].sigtype != DAHDI_SIG_CAS &&
|
||||
cc[x].sigtype != DAHDI_SIG_DACS &&
|
||||
cc[x].sigtype != DAHDI_SIG_DACS_RBS) {
|
||||
if (NULL != idle) {
|
||||
fprintf(stderr, "WARNING: idlebits are not valid on %s channels.\n", sig[x]);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_digital)
|
||||
chan2span[x] = current_span;
|
||||
else
|
||||
current_span = 0;
|
||||
@@ -714,21 +819,22 @@ static int setfiftysixkhdlc(char *keyword, char *args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void apply_fiftysix(void)
|
||||
static int apply_fiftysix(void)
|
||||
{
|
||||
int x;
|
||||
int rate;
|
||||
int chanfd;
|
||||
|
||||
for (x = 1; x < DAHDI_MAX_CHANNELS; x++) {
|
||||
if (skip_channel(x))
|
||||
if (skip_channel(x) || !cc[x].sigtype)
|
||||
continue;
|
||||
|
||||
chanfd = open("/dev/dahdi/channel", O_RDWR);
|
||||
if (chanfd == -1) {
|
||||
fprintf(stderr,
|
||||
"Couldn't open /dev/dahdi/channel: %s\n",
|
||||
strerror(errno));
|
||||
exit(-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(chanfd, DAHDI_SPECIFY, &x)) {
|
||||
@@ -749,6 +855,7 @@ static void apply_fiftysix(void)
|
||||
}
|
||||
close(chanfd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int setechocan(char *keyword, char *args)
|
||||
@@ -1444,12 +1551,27 @@ static int span_restrict(char *str)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const char *SEM_NAME = "dahdi_cfg";
|
||||
static sem_t *lock = SEM_FAILED;
|
||||
|
||||
static void signal_handler(int signal)
|
||||
{
|
||||
if (SEM_FAILED != lock) {
|
||||
sem_unlink(SEM_NAME);
|
||||
}
|
||||
/* The default handler should have been restored before this handler was
|
||||
* called, so we can let the "normal" processing finish the cleanup. */
|
||||
raise(signal);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
char *buf;
|
||||
char *key, *value;
|
||||
int x,found;
|
||||
int exit_code = 0;
|
||||
struct sigaction act;
|
||||
|
||||
while((c = getopt(argc, argv, "fthc:vsd::C:S:")) != -1) {
|
||||
switch(c) {
|
||||
@@ -1469,7 +1591,7 @@ int main(int argc, char *argv[])
|
||||
force++;
|
||||
break;
|
||||
case 't':
|
||||
fo_real = 0;
|
||||
dry_run = 1;
|
||||
break;
|
||||
case 's':
|
||||
stopmode = 1;
|
||||
@@ -1495,6 +1617,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);
|
||||
@@ -1553,18 +1684,48 @@ finish:
|
||||
if (verbose) {
|
||||
printconfig(fd);
|
||||
}
|
||||
if (!fo_real)
|
||||
exit(0);
|
||||
|
||||
if (dry_run)
|
||||
exit(0);
|
||||
|
||||
if (debug & DEBUG_APPLY) {
|
||||
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]);
|
||||
|
||||
sigemptyset(&act.sa_mask);
|
||||
act.sa_handler = signal_handler;
|
||||
act.sa_flags = SA_RESETHAND;
|
||||
|
||||
if (sigaction(SIGTERM, &act, NULL) == -1) {
|
||||
perror("Failed to install SIGTERM handler.");
|
||||
exit(1);
|
||||
}
|
||||
if (sigaction(SIGINT, &act, NULL) == -1) {
|
||||
perror("Failed to install SIGINT handler.");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
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 +1733,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 +1746,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 +1894,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 +1906,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 +1934,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 +1944,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
|
||||
|
||||
210
dahdi_span_types
210
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,21 +179,66 @@ 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
|
||||
}
|
||||
|
||||
list_pri_spantypes() {
|
||||
find $DEVICES -follow -maxdepth 1 -name spantype | \
|
||||
xargs cat | \
|
||||
sed -n '/:[ETJ]1$/s/^.*://p' | \
|
||||
sort -u | \
|
||||
tr '\n' ' ' | \
|
||||
sed -e 's/^ *//' -e 's/ *$//'
|
||||
}
|
||||
|
||||
dump_config() {
|
||||
pri_spantypes=`list_pri_spantypes`
|
||||
num_spantypes=`echo "$pri_spantypes" | wc -w`
|
||||
gen_default=''
|
||||
echo '#'
|
||||
echo "# Autogenerated by $0 on `date`"
|
||||
echo "# Map PRI DAHDI devices to span types for E1/T1/J1"
|
||||
echo "#"
|
||||
|
||||
echo "# Summary:"
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
gen_default="$DEFAULT_LINE_MODE"
|
||||
echo "# * Generating wildcard match of $gen_default."
|
||||
echo "# - Was run with '--line-mode=$DEFAULT_LINE_MODE'"
|
||||
elif [ "$num_spantypes" -eq 1 ]; then
|
||||
gen_default="$pri_spantypes"
|
||||
echo "# * Generating wildcard match of $gen_default."
|
||||
echo "# - Spans were $pri_spantypes"
|
||||
else
|
||||
echo "# * Not generating wildcard match."
|
||||
echo "# - Was run without '--line-mode' option and span were of mixed types [$pri_spantypes]"
|
||||
fi
|
||||
echo "#"
|
||||
if [ "$num_spantypes" -eq 1 ]; then
|
||||
echo "# * Generating a list of commented out configurations for spans."
|
||||
echo "# - Spans were $pri_spantypes"
|
||||
echo "# - Uncomment for specific overrides"
|
||||
else
|
||||
echo "# * Generating a list of specific span configurations."
|
||||
echo "# - Spans were of mixed types: $pri_spantypes"
|
||||
fi
|
||||
echo "#"
|
||||
echo ''
|
||||
fmt="%-65s %s\n"
|
||||
printf "$fmt" '# @location/hardware_id' 'span_type'
|
||||
|
||||
fmt="%-65s %s"
|
||||
printf "$fmt\n" '# @location/hardware_id' 'span_type'
|
||||
|
||||
if [ "$gen_default" != '' ]; then
|
||||
printf "$fmt\t\t# Wildcard line-mode" "*" "*:$gen_default"
|
||||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
@@ -169,14 +255,18 @@ dump_config() {
|
||||
cat "$device/spantype" | while read st; do
|
||||
case "$st" in
|
||||
*:[ETJ]1)
|
||||
printf "$fmt" "$id" "$st"
|
||||
if [ "$num_spantypes" -eq 1 ]; then
|
||||
printf "#$fmt\n" "$id" "$st"
|
||||
else
|
||||
printf "$fmt\n" "$id" "$st"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
#echo "# Skipped local span `echo $st | sed 's/:/ -- /'`"
|
||||
;;
|
||||
esac
|
||||
done | sort -n
|
||||
#echo ''
|
||||
echo ''
|
||||
done
|
||||
}
|
||||
|
||||
@@ -185,70 +275,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 +358,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"
|
||||
19
doc/Makefile.am
Normal file
19
doc/Makefile.am
Normal file
@@ -0,0 +1,19 @@
|
||||
man_MANS = \
|
||||
dahdi_cfg.8 \
|
||||
dahdi_maint.8 \
|
||||
dahdi_monitor.8 \
|
||||
dahdi_scan.8 \
|
||||
dahdi_span_assignments.8 \
|
||||
dahdi_span_types.8 \
|
||||
dahdi_test.8 \
|
||||
dahdi_tool.8 \
|
||||
dahdi_waitfor_span_assignments.8 \
|
||||
fxotune.8
|
||||
|
||||
noinst_MANS = \
|
||||
dahdi_diag.8 \
|
||||
fxstest.8 \
|
||||
patgen.8 \
|
||||
pattest.8
|
||||
|
||||
EXTRA_DIST = $(man_MANS) $(noinst_MANS)
|
||||
@@ -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.
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#define RANDOM "/dev/urandom" /* Not genuinely random */
|
||||
/* #define RANDOM "/dev/random" */ /* Quite genuinely random */
|
||||
|
||||
int myread(int fd, char *buf, int len)
|
||||
int myread(int fd, unsigned char *buf, int len)
|
||||
{
|
||||
int sofar;
|
||||
int res;
|
||||
|
||||
@@ -107,13 +107,12 @@ static struct fasthdlc_state fs;
|
||||
|
||||
void send_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int res;
|
||||
int x;
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
int pos=0;
|
||||
unsigned int fcs = PPP_INITFCS;
|
||||
if (hdlcmode)
|
||||
res = write(fd, buf, len + 2);
|
||||
write(fd, buf, len + 2);
|
||||
else {
|
||||
for (x=0;x<len;x++) {
|
||||
if (fasthdlc_tx_load(&fs, buf[x]))
|
||||
|
||||
11
hotplug/Makefile.am
Normal file
11
hotplug/Makefile.am
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
nobase_dist_dahditools_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 \
|
||||
#
|
||||
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"
|
||||
@@ -17,6 +17,7 @@
|
||||
#XPP_FIRMWARE_DIR=/usr/share/dahdi
|
||||
#XPP_HOTPLUG_DISABLED=yes
|
||||
#XPP_HOTPLUG_DAHDI=yes
|
||||
#ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes
|
||||
|
||||
# Disable udev handling:
|
||||
#DAHDI_UDEV_DISABLE_DEVICES=yes
|
||||
|
||||
@@ -15,6 +15,8 @@ wct4xxp
|
||||
|
||||
# Digium TE435
|
||||
# Digium TE235
|
||||
# Digium TE436
|
||||
# Digium TE236
|
||||
wcte43x
|
||||
|
||||
# Digium TE120P: PCI single-port T1/E1/J1
|
||||
@@ -24,6 +26,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
|
||||
@@ -49,6 +53,10 @@ wcfxo
|
||||
wctdm
|
||||
|
||||
# Digium B410P: 4 NT/TE BRI ports
|
||||
# Digium B433P: 4 NT/TE BRI ports pci-e
|
||||
# Digium B434P: 4 NT/TE BRI ports
|
||||
# Digium B233P: 2 NT/TE BRI ports pci-e
|
||||
# Digium B234P: 2 NT/TE BRI ports
|
||||
wcb4xxp
|
||||
|
||||
# Digium TC400B: G729 / G723 Transcoding Engine
|
||||
|
||||
@@ -168,6 +168,7 @@ int main(int argc, char *argv[])
|
||||
int opt;
|
||||
int oldstyle_cmdline = 1;
|
||||
unsigned int event_count = 0;
|
||||
time_t start_time = 0;
|
||||
|
||||
/* Parse the command line arguments */
|
||||
while((opt = getopt(argc, argv, "b:s:t:r:v?h")) != -1) {
|
||||
@@ -218,8 +219,6 @@ int main(int argc, char *argv[])
|
||||
if (oldstyle_cmdline && argc > optind +1) {
|
||||
timeout = strtoul(argv[optind+1], NULL, 10);
|
||||
}
|
||||
|
||||
time_t start_time = 0;
|
||||
|
||||
fd = channel_open(device, &bs);
|
||||
if (fd < 0)
|
||||
|
||||
29
ppp/Makefile
29
ppp/Makefile
@@ -1,29 +0,0 @@
|
||||
#COPTS = -O2 -g
|
||||
|
||||
-include ../makeopts
|
||||
|
||||
CFLAGS += $(COPTS) -fPIC
|
||||
LDFLAGS += -shared
|
||||
|
||||
INCLUDE_DIR = $(includedir)/pppd
|
||||
|
||||
LIBDIR = $(libdir)/pppd/$(PPPD_VERSION)
|
||||
|
||||
PLUGINS := dahdi.so
|
||||
|
||||
all: $(PLUGINS)
|
||||
|
||||
%.so: %.c
|
||||
ifeq (,$(PPPD_VERSION))
|
||||
@echo "pppd version not found (in patchlevel.h)."
|
||||
@echo "Install ppp source/headers and/or ./configure --with-ppp=PATH."
|
||||
exit 1
|
||||
endif
|
||||
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS)
|
||||
|
||||
install: $(PLUGINS)
|
||||
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m 0644 $? $(DESTDIR)$(LIBDIR)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.a
|
||||
7
ppp/Makefile.am
Normal file
7
ppp/Makefile.am
Normal file
@@ -0,0 +1,7 @@
|
||||
plugindir = $(libdir)/pppd/$(PPPD_VERSION)
|
||||
plugin_LTLIBRARIES = dahdi.la
|
||||
|
||||
dahdi_la_CFLAGS = $(DAHDI_INCLUDE)
|
||||
dahdi_la_LDFLAGS = -module -avoid-version
|
||||
|
||||
CLEANFILES = dahdi.so
|
||||
@@ -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>
|
||||
#
|
||||
@@ -111,17 +111,6 @@
|
||||
# Channel(s) are signalled using FXO Groundstart protocol.
|
||||
# fxoks::
|
||||
# Channel(s) are signalled using FXO Koolstart protocol.
|
||||
# sf::
|
||||
# Channel(s) are signalled using in-band single freq tone.
|
||||
# Syntax as follows:
|
||||
#
|
||||
# channel# => sf:<rxfreq>,<rxbw>,<rxflag>,<txfreq>,<txlevel>,<txflag>
|
||||
#
|
||||
# rxfreq is rx tone freq in Hz, rxbw is rx notch (and decode)
|
||||
# bandwith in hz (typically 10.0), rxflag is either 'normal' or
|
||||
# 'inverted', txfreq is tx tone freq in hz, txlevel is tx tone
|
||||
# level in dbm, txflag is either 'normal' or 'inverted'. Set
|
||||
# rxfreq or txfreq to 0.0 if that tone is not desired.
|
||||
#
|
||||
# unused::
|
||||
# No signalling is performed, each channel in the list remains idle
|
||||
@@ -204,7 +193,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 +221,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 +287,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 +302,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
|
||||
|
||||
17
tonezone.c
17
tonezone.c
@@ -89,18 +89,20 @@ static int build_tone(void *data, size_t size, struct tone_zone_sound *t, int *c
|
||||
int firstnobang = -1;
|
||||
int freq1, freq2, time;
|
||||
int modulate = 0;
|
||||
float db = 1.0;
|
||||
float gain;
|
||||
int used = 0;
|
||||
dup = strdup(t->data);
|
||||
s = strtok(dup, ",");
|
||||
while(s && strlen(s)) {
|
||||
/* Handle optional ! which signifies don't start here*/
|
||||
if (s[0] == '!')
|
||||
if (s[0] == '!') {
|
||||
s++;
|
||||
else if (firstnobang < 0) {
|
||||
} else if (firstnobang < 0) {
|
||||
PRINT_DEBUG("First no bang: %s\n", s);
|
||||
firstnobang = *count;
|
||||
}
|
||||
|
||||
if (sscanf(s, "%d+%d/%d", &freq1, &freq2, &time) == 3) {
|
||||
/* f1+f2/time format */
|
||||
PRINT_DEBUG("f1+f2/time format: %d, %d, %d\n", freq1, freq2, time);
|
||||
@@ -118,6 +120,15 @@ static int build_tone(void *data, size_t size, struct tone_zone_sound *t, int *c
|
||||
} else if (sscanf(s, "%d/%d", &freq1, &time) == 2) {
|
||||
PRINT_DEBUG("f1/time format: %d, %d\n", freq1, time);
|
||||
freq2 = 0;
|
||||
} else if (sscanf(s, "%d@/%d", &freq1, &time) == 2) {
|
||||
/* The "@" character has been added to enable an
|
||||
* approximately -20db tone generation of any frequency This has been done
|
||||
* primarily to generate the Australian congestion tone.
|
||||
* Example: "425/375,0/375,425@/375,0/375"
|
||||
*/
|
||||
PRINT_DEBUG("f1 reduced amplitude/time format: %d, %d\n", freq1,time);
|
||||
db = 0.3;
|
||||
freq2 = 0;
|
||||
} else if (sscanf(s, "%d", &freq1) == 1) {
|
||||
PRINT_DEBUG("f1 format: %d\n", freq1);
|
||||
firstnobang = *count;
|
||||
@@ -137,7 +148,7 @@ static int build_tone(void *data, size_t size, struct tone_zone_sound *t, int *c
|
||||
td = data;
|
||||
|
||||
/* Bring it down -8 dbm */
|
||||
gain = pow(10.0, (LEVEL - 3.14) / 20.0) * 65536.0 / 2.0;
|
||||
gain = db*(pow(10.0, (LEVEL - 3.14) / 20.0) * 65536.0 / 2.0);
|
||||
|
||||
td->fac1 = 2.0 * cos(2.0 * M_PI * (freq1 / 8000.0)) * 32768.0;
|
||||
td->init_v2_1 = sin(-4.0 * M_PI * (freq1 / 8000.0)) * gain;
|
||||
|
||||
6
version.c.in
Normal file
6
version.c.in
Normal file
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* version.c.in
|
||||
*/
|
||||
|
||||
const char dahdi_tools_version[] = "DAHDI Tools Version - @TOOLSVERSION@";
|
||||
|
||||
177
xpp/Makefile
177
xpp/Makefile
@@ -1,177 +0,0 @@
|
||||
PEDANTIC = -ansi -pedantic -std=c99
|
||||
|
||||
INSTALL = install
|
||||
INSTALL_DATA = install -m 644
|
||||
|
||||
#
|
||||
# Ugly hack to find kernel directories before/after the split
|
||||
# to kernel/user-space.
|
||||
#
|
||||
# These variables should be passed to us. But until then...
|
||||
#
|
||||
DAHDI_TOOLSDIR ?= ..
|
||||
DAHDI_KERNELDIR =
|
||||
|
||||
-include $(DAHDI_TOOLSDIR)/makeopts
|
||||
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# In 1.4 those are provided by autoconf through makeopts
|
||||
prefix ?= /usr
|
||||
datadir ?= $(prefix)/share
|
||||
mandir ?= $(datadir)/man
|
||||
sysconfdir ?= $(prefix)/etc
|
||||
udevrulesdir ?= $(sysconfdir)/udev/rules.d
|
||||
INSTALL ?= install
|
||||
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
SBINDIR = $(prefix)/sbin
|
||||
DATADIR = $(datadir)/dahdi
|
||||
MANDIR = $(mandir)/man8
|
||||
HOTPLUG_USB_DIR = $(sysconfdir)/hotplug/usb
|
||||
PERLLIBDIR := $(shell eval `perl -V:sitelib`; echo "$$sitelib")
|
||||
PERL_DIRS := $(shell cd perl_modules; find * -name '[A-Z]*' -type d| xargs)
|
||||
PERL_MODS_PAT := *.pm $(PERL_DIRS:%=%/*.pm)
|
||||
PERL_MODS := $(shell cd perl_modules; echo $(PERL_MODS_PAT))
|
||||
|
||||
# Variables that should be defined above, but need sane defaults:
|
||||
# FIXME: Are those values really sane?
|
||||
HOSTCC ?= $(CC)
|
||||
|
||||
USE_OCTASIC := yes
|
||||
OCTASIC_DIR := oct612x
|
||||
|
||||
ifneq (no,$(USE_OCTASIC))
|
||||
|
||||
OCT_OBJS = $(shell $(OCTASIC_DIR)/octasic-helper objects $(OCTASIC_DIR))
|
||||
OCT_SRCS = $(shell echo $(OCT_OBJS) | tr -s ' ' '\n' | sed 's/\.o$$/.c/g')
|
||||
OCT_HERE_OBJS = $(shell echo $(OCT_OBJS) | tr -s ' ' '\n' | sed 's,^.*/,,')
|
||||
OCT_CFLAGS = $(shell $(OCTASIC_DIR)/octasic-helper cflags $(OCTASIC_DIR))
|
||||
OCT_DEFINES = \
|
||||
-DPTR_TYPE=uint32_t \
|
||||
-DcOCT6100_INTERNAL_SUPER_ARRAY_SIZE=1024 \
|
||||
-DcOCT6100_MAX_ECHO_CHANNELS=672 \
|
||||
-DcOCT6100_MAX_MIXER_EVENTS=1344
|
||||
|
||||
ECHO_LOADER = echo_loader.o
|
||||
endif
|
||||
|
||||
%.8: %
|
||||
pod2man --section 8 $^ > $@ || $(RM) $@
|
||||
PERL_SCRIPTS = \
|
||||
dahdi_registration \
|
||||
xpp_sync \
|
||||
lsdahdi \
|
||||
xpp_blink \
|
||||
dahdi_genconf \
|
||||
dahdi_hardware \
|
||||
twinstar \
|
||||
#
|
||||
|
||||
PERL_MANS = $(PERL_SCRIPTS:%=%.8)
|
||||
|
||||
XTALK_OBJS = xtalk/xtalk.o xtalk/xusb.o xtalk/xlist.o xtalk/debug.o
|
||||
ASTRIBANK_OBJS = astribank_usb.o mpptalk.o $(XTALK_OBJS)
|
||||
|
||||
ABHEXLOAD_OBJS = astribank_hexload.o hexfile.o pic_loader.o $(ECHO_LOADER) $(ASTRIBANK_OBJS) $(OCT_HERE_OBJS)
|
||||
ABTOOL_OBJS = astribank_tool.o $(ASTRIBANK_OBJS)
|
||||
ABALLOW_OBJS = astribank_allow.o astribank_license.o $(ASTRIBANK_OBJS)
|
||||
|
||||
TARGETS = .perlcheck astribank_is_starting
|
||||
PROG_INSTALL = astribank_is_starting
|
||||
MAN_INSTALL = $(PROG_INSTALL:%=%.8)
|
||||
ifeq (1,$(PBX_USB))
|
||||
TARGETS += \
|
||||
astribank_tool \
|
||||
astribank_hexload \
|
||||
astribank_allow \
|
||||
test_parse
|
||||
PROG_INSTALL += astribank_tool astribank_hexload astribank_allow
|
||||
endif
|
||||
ifneq (,$(PERLLIBDIR))
|
||||
PROG_INSTALL += $(PERL_SCRIPTS)
|
||||
TARGETS += $(PERL_MANS)
|
||||
endif
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
docs: $(PERL_MANS)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d $(DESTDIR)$(SBINDIR)
|
||||
$(INSTALL) $(PROG_INSTALL) $(DESTDIR)$(SBINDIR)/
|
||||
$(INSTALL) -d $(DESTDIR)$(DATADIR)
|
||||
$(INSTALL) xpp_fxloader astribank_hook $(DESTDIR)$(DATADIR)/
|
||||
$(INSTALL) waitfor_xpds $(DESTDIR)$(DATADIR)/
|
||||
$(INSTALL) -d $(DESTDIR)$(udevrulesdir)
|
||||
$(INSTALL_DATA) xpp.rules $(DESTDIR)$(udevrulesdir)/
|
||||
$(INSTALL) -d $(DESTDIR)$(MANDIR)
|
||||
$(INSTALL_DATA) $(MAN_INSTALL) $(DESTDIR)$(MANDIR)/
|
||||
$(INSTALL) -d $(DESTDIR)$(HOTPLUG_USB_DIR)
|
||||
$(INSTALL_DATA) xpp_fxloader.usermap $(DESTDIR)$(HOTPLUG_USB_DIR)/
|
||||
# for backward compatibility and for hotplug users:
|
||||
ln -sf $(DATADIR)/xpp_fxloader $(DESTDIR)$(HOTPLUG_USB_DIR)/
|
||||
ifneq (,$(PERLLIBDIR))
|
||||
$(INSTALL) -d $(DESTDIR)$(PERLLIBDIR)
|
||||
for i in $(PERL_DIRS); \
|
||||
do \
|
||||
$(INSTALL) -d "$(DESTDIR)$(PERLLIBDIR)/$$i"; \
|
||||
done
|
||||
for i in $(PERL_MODS); \
|
||||
do \
|
||||
$(INSTALL_DATA) "perl_modules/$$i" "$(DESTDIR)$(PERLLIBDIR)/$$i"; \
|
||||
done
|
||||
endif
|
||||
|
||||
CFLAGS += -I. -Ixtalk
|
||||
|
||||
astribank_hexload: $(ABHEXLOAD_OBJS)
|
||||
astribank_hexload: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
astribank_hexload: CFLAGS+=$(OCT_CFLAGS)
|
||||
|
||||
astribank_tool: $(ABTOOL_OBJS)
|
||||
astribank_tool: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
|
||||
astribank_allow: $(ABALLOW_OBJS)
|
||||
astribank_allow: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
|
||||
astribank_is_starting: astribank_is_starting.o
|
||||
astribank_is_starting: LIBS+=$(EXTRA_LIBS)
|
||||
|
||||
hex2iic: hex2iic.o iic.o hexfile.o
|
||||
|
||||
test_parse: test_parse.o hexfile.o
|
||||
test_parse: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
|
||||
ifneq (no,$(USE_OCTASIC))
|
||||
.octasic.depend: $(OCTASIC_DIR)/octasic-helper Makefile ../config.status
|
||||
$(CC) -MM $(OCT_CFLAGS) \
|
||||
`$(OCTASIC_DIR)/octasic-helper objects | \
|
||||
tr -s ' ' '\n' | \
|
||||
sed -e 's,.*,$(OCTASIC_DIR)/&,' -e 's/\.o$$/.c/'` > $@
|
||||
|
||||
-include .octasic.depend
|
||||
|
||||
$(OCT_HERE_OBJS): Makefile
|
||||
$(CC) -c $(CFLAGS) $(OCT_CFLAGS) $(OCT_DEFINES) $(OCT_SRCS)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
%: %.o
|
||||
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
.perlcheck: $(PERL_SCRIPTS)
|
||||
for i in $^; do perl -I./perl_modules -c $$i || exit 1; done
|
||||
touch $@
|
||||
|
||||
clean:
|
||||
$(RM) .depend .octasic.depend *.o xtalk/*.o $(OCT_HERE_OBJS) $(TARGETS)
|
||||
|
||||
.PHONY: depend
|
||||
depend: .depend
|
||||
.depend: *.c *.h xtalk/*.c xtalk/*.h
|
||||
@$(CC) $(CFLAGS) -MM *.c xtalk/*.c > $@ || rm -f $@
|
||||
|
||||
include .depend
|
||||
166
xpp/Makefile.am
Normal file
166
xpp/Makefile.am
Normal file
@@ -0,0 +1,166 @@
|
||||
|
||||
all-local: $(perl_checks)
|
||||
|
||||
SUBDIRS =
|
||||
|
||||
|
||||
# FIXME: try to improve code, so we can use $(PEDANTIC)
|
||||
#PEDANTIC = -ansi -pedantic -std=c99
|
||||
GLOBAL_CFLAGS = -I$(srcdir) -I$(srcdir)/xtalk $(PEDANTIC)
|
||||
|
||||
if DAHDI_DEVMODE
|
||||
GLOBAL_CFLAGS += \
|
||||
-Werror \
|
||||
-Wunused \
|
||||
-Wundef \
|
||||
-Wmissing-format-attribute \
|
||||
-Wformat-security \
|
||||
-Wformat=2
|
||||
endif
|
||||
|
||||
if PERL
|
||||
SUBDIRS += perl_modules
|
||||
|
||||
%.8: %
|
||||
@if file "$^" | cut -d: -f2 | grep -q perl; then \
|
||||
if pod2man --section 8 $^ > $@; then \
|
||||
echo " GEN $@"; \
|
||||
else \
|
||||
rm -f "$@"; \
|
||||
fi \
|
||||
fi
|
||||
|
||||
%.check: %
|
||||
@echo " CHECK $^"; \
|
||||
if ! perl -I./perl_modules -c $^ 2>/dev/null; then \
|
||||
perl -I./perl_modules -c $^; \
|
||||
fi
|
||||
@touch $@
|
||||
|
||||
perl_scripts = \
|
||||
dahdi_registration \
|
||||
xpp_sync \
|
||||
lsdahdi \
|
||||
xpp_blink \
|
||||
dahdi_genconf \
|
||||
dahdi_hardware \
|
||||
twinstar \
|
||||
#
|
||||
|
||||
perl_checks = $(perl_scripts:%=%.check)
|
||||
perl_mans = $(perl_scripts:%=%.8)
|
||||
|
||||
endif
|
||||
|
||||
dist_dahditools_SCRIPTS = xpp_fxloader astribank_hook waitfor_xpds
|
||||
udevrulesdir = @udevrulesdir@
|
||||
udevrules_DATA = xpp.rules
|
||||
|
||||
dist_sbin_SCRIPTS = $(perl_scripts)
|
||||
man_MANS = $(perl_mans)
|
||||
CLEANFILES = $(perl_checks) $(perl_mans)
|
||||
|
||||
if PBX_USB
|
||||
|
||||
SUBDIRS += oct612x
|
||||
|
||||
noinst_LTLIBRARIES = libastribank.la libecholoader.la libhexfile.la
|
||||
|
||||
libastribank_la_SOURCES = \
|
||||
astribank_usb.c \
|
||||
astribank_usb.h \
|
||||
mpptalk.c \
|
||||
mpptalk.h \
|
||||
mpp.h \
|
||||
mpptalk_defs.h \
|
||||
xtalk/debug.c \
|
||||
xtalk/debug.h \
|
||||
xtalk/xlist.c \
|
||||
xtalk/xlist.h \
|
||||
xtalk/xtalk.c \
|
||||
xtalk/xtalk.h \
|
||||
xtalk/xtalk_defs.h \
|
||||
xtalk/xusb.c \
|
||||
xtalk/xusb.h \
|
||||
#
|
||||
|
||||
libastribank_la_CFLAGS = $(GLOBAL_CFLAGS)
|
||||
|
||||
if USE_OCTASIC
|
||||
libecholoader_la_SOURCES = \
|
||||
parse_span_specs.c \
|
||||
parse_span_specs.h \
|
||||
echo_loader.c \
|
||||
echo_loader.h \
|
||||
#
|
||||
|
||||
libecholoader_la_CFLAGS = $(GLOBAL_CFLAGS) $(OCTASIC_CFLAGS)
|
||||
endif
|
||||
|
||||
libhexfile_la_SOURCES = \
|
||||
hexfile.c \
|
||||
hexfile.h \
|
||||
#
|
||||
|
||||
sbin_PROGRAMS = \
|
||||
astribank_tool \
|
||||
astribank_hexload \
|
||||
astribank_allow \
|
||||
astribank_is_starting
|
||||
|
||||
check_PROGRAMS = test_parse
|
||||
test_parse_LDADD = libhexfile.la
|
||||
|
||||
astribank_tool_SOURCES = astribank_tool.c
|
||||
astribank_tool_CFLAGS = $(GLOBAL_CFLAGS)
|
||||
astribank_tool_LDFLAGS = $(USB_LIB)
|
||||
astribank_tool_LDADD = libastribank.la
|
||||
|
||||
astribank_hexload_SOURCES = \
|
||||
astribank_hexload.c \
|
||||
pic_loader.c \
|
||||
pic_loader.h \
|
||||
#
|
||||
|
||||
astribank_hexload_CFLAGS = $(GLOBAL_CFLAGS) $(OCTASIC_CFLAGS)
|
||||
astribank_hexload_LDFLAGS = $(USB_LIB)
|
||||
astribank_hexload_LDADD = \
|
||||
libhexfile.la \
|
||||
libastribank.la \
|
||||
libecholoader.la \
|
||||
oct612x/liboctasic.la \
|
||||
#
|
||||
|
||||
astribank_allow_SOURCES = \
|
||||
astribank_allow.c \
|
||||
astribank_license.c \
|
||||
astribank_license.h \
|
||||
#
|
||||
|
||||
astribank_allow_CFLAGS = $(GLOBAL_CFLAGS)
|
||||
astribank_allow_LDFLAGS = $(USB_LIB)
|
||||
astribank_allow_LDADD = libastribank.la
|
||||
|
||||
man_pages = \
|
||||
astribank_tool.8 \
|
||||
astribank_hexload.8 \
|
||||
astribank_allow.8 \
|
||||
astribank_is_starting.8
|
||||
|
||||
man_MANS += $(man_pages)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(man_pages) \
|
||||
$(udevrules_DATA) \
|
||||
README.Astribank \
|
||||
astribank_upgrade \
|
||||
dahdi.cgi \
|
||||
dahdi_drivers \
|
||||
genconf_parameters \
|
||||
twinstar_hook \
|
||||
twinstar_setup \
|
||||
xpp_modprobe \
|
||||
xpp_timing \
|
||||
#
|
||||
|
||||
@@ -7,7 +7,7 @@ astribank_hexload \- Xorcom Astribank (xpp) firmware loader
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-p [\fIoptions\fR] \fIhexfile1 .. hexfile4\fR
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-O [-A] [\fIoptions\fR] \fIimagefile\fR
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-O [-A] [-S \fIspan-specs\fR] [\fIoptions\fR] \fIimagefile\fR
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-o [\fIoptions\fR]
|
||||
|
||||
@@ -29,7 +29,7 @@ It can be used to load either an FPGA firmware or a PIC
|
||||
firmware. It is normally run by the script xpp_fxloader.
|
||||
|
||||
.SH OPTIONS
|
||||
.B \-D
|
||||
.B \-D
|
||||
.I device-path
|
||||
.RS
|
||||
Required. The device to read from/write to. This is
|
||||
@@ -95,13 +95,38 @@ use for BRI and E1. If not set, the default mu-Law (G.711u), which is
|
||||
what you'd normally use for FXS, FXO and T1.
|
||||
.RE
|
||||
|
||||
.B \-S \fIspan-specs\fR
|
||||
.RS
|
||||
This option should only be used when loading Octasic echo canceller firmware
|
||||
and only if the first Astribank module is PRI.
|
||||
|
||||
Its goal is to allow specifying different \fIline-mode\fR (E1/T1/J1) in different
|
||||
ports of the PRI module. \fBastribank_hexload\fR use the \fIspan-specs\fR argument
|
||||
to select aLaw/uLaw for each of the PRI ports in the module.
|
||||
|
||||
The \fIspan-specs\fR is a list of items separated by whitespace or commas.
|
||||
Each item is composed of a port selector, colon and a \fIline-mode\fR specifier.
|
||||
This syntax follows the syntax of specifiers in \fB/etc/dahdi/span-types.conf\fR.
|
||||
|
||||
Examples:
|
||||
.RS
|
||||
3:E1 \- The 3'rd port is E1.
|
||||
|
||||
*:T1 \- Any unspecified port is T1 (wildcard match).
|
||||
|
||||
1:T1,2:T1,*:E1 \- First and second ports are T1, the rest are E1.
|
||||
.RE
|
||||
|
||||
If the \fB\-S\fR is not given, the PRI default is determined by the existance of the \fB\-A-fR option.
|
||||
.RE
|
||||
|
||||
.SH SEE ALSO
|
||||
fxload(8), lsusb(8), astribank_tool(8)
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> .
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#define DBG_MASK 0x80
|
||||
#define MAX_HEX_LINES 64000
|
||||
#define HAVE_OCTASIC 1
|
||||
#define DEF_SPAN_SPEC_FORMAT "*:%c1" /* %c: 'E' or 'T' */
|
||||
|
||||
static char *progname;
|
||||
|
||||
@@ -50,6 +51,7 @@ static void usage()
|
||||
#if HAVE_OCTASIC
|
||||
fprintf(stderr, "\t\t[-O] # Load Octasic firmware\n");
|
||||
fprintf(stderr, "\t\t[-o] # Show Octasic version\n");
|
||||
fprintf(stderr, "\t\t[-S <pri-spec>] # Set PRI type specification string\n");
|
||||
#endif
|
||||
fprintf(stderr, "\t\t[-F] # Load FPGA firmware\n");
|
||||
fprintf(stderr, "\t\t[-p] # Load PIC firmware\n");
|
||||
@@ -82,7 +84,12 @@ int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_parse_errors(int level, const char *msg, ...)
|
||||
|
||||
#ifdef __GNUC__
|
||||
static void print_parse_errors(int level, const char *msg, ...) __attribute__((format(printf,2,3)));
|
||||
#endif
|
||||
|
||||
static void print_parse_errors(int level, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@@ -164,11 +171,13 @@ int main(int argc, char *argv[])
|
||||
int opt_ecver = 0;
|
||||
#if HAVE_OCTASIC
|
||||
int opt_alaw = 0;
|
||||
const char *span_spec = NULL;
|
||||
char def_span_spec[sizeof(DEF_SPAN_SPEC_FORMAT)];
|
||||
#endif
|
||||
int opt_dest = 0;
|
||||
int opt_sum = 0;
|
||||
enum dev_dest dest = DEST_NONE;
|
||||
const char options[] = "vd:D:EFOopA";
|
||||
const char options[] = "vd:D:EFOopAS:";
|
||||
int iface_num;
|
||||
int ret;
|
||||
|
||||
@@ -210,6 +219,9 @@ int main(int argc, char *argv[])
|
||||
case 'A':
|
||||
opt_alaw = 1;
|
||||
break;
|
||||
case 'S':
|
||||
span_spec = optarg;
|
||||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
opt_pic = 1;
|
||||
@@ -247,6 +259,13 @@ int main(int argc, char *argv[])
|
||||
ERR("Missing device path.\n");
|
||||
usage();
|
||||
}
|
||||
# ifdef HAVE_OCTASIC
|
||||
if (!span_spec) {
|
||||
snprintf(def_span_spec, sizeof(def_span_spec),
|
||||
DEF_SPAN_SPEC_FORMAT, opt_alaw? 'E' : 'T');
|
||||
span_spec = def_span_spec;
|
||||
}
|
||||
#endif
|
||||
if(opt_dest) {
|
||||
/*
|
||||
* MPP Interface
|
||||
@@ -290,7 +309,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#if HAVE_OCTASIC
|
||||
} else if (opt_echo) {
|
||||
if((ret = load_echo(astribank, argv[optind], opt_alaw)) < 0) {
|
||||
if((ret = load_echo(astribank, argv[optind], opt_alaw, span_spec)) < 0) {
|
||||
ERR("%s: Loading ECHO's failed\n", devpath);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||
|
||||
set -e
|
||||
|
||||
LOCK="/var/lock/twinstar_startup"
|
||||
|
||||
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
|
||||
|
||||
# For lab testing
|
||||
@@ -32,17 +34,38 @@ if [ "$XPP_HOTPLUG_DAHDI" != yes ]; then
|
||||
fi
|
||||
|
||||
export XPPORDER_CONF="$dahdi_conf/xpp_order"
|
||||
if [ ! -r "$XPPORDER_CONF" ]; then
|
||||
(
|
||||
echo "Skip($ACTION): No '$XPPORDER_CONF'"
|
||||
echo "Removing uneeded startup semaphore"
|
||||
astribank_is_starting -v -r 2>&1
|
||||
) 2>&1 | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
export DAHDI_CFG_CMD="dahdi_cfg -c $dahdi_conf/system.conf"
|
||||
export CALLED_FROM_ATRIBANK_HOOK=yes
|
||||
|
||||
can_full_async() {
|
||||
# Can we work aynchronously:
|
||||
# - Need modern Asterisk that accept hotplug DAHDI devices.
|
||||
# - Need DAHDI with "auto_assign_spans" == 0
|
||||
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
|
||||
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
|
||||
aas=`cat "$aas_param" 2>/dev/null`
|
||||
if [ "$aas" = 0 ]; then
|
||||
return 0
|
||||
else
|
||||
$LOGGER "No async operation ($aas_param != 0)"
|
||||
fi
|
||||
else
|
||||
$LOGGER "No async operation (ASTERISK_SUPPORTS_DAHDI_HOTPLUG!=yes)"
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_xpporder_conf() {
|
||||
if [ ! -r "$XPPORDER_CONF" ]; then
|
||||
(
|
||||
echo "Skip($ACTION): No '$XPPORDER_CONF'"
|
||||
echo "Removing uneeded startup semaphore"
|
||||
astribank_is_starting -v -r 2>&1
|
||||
) 2>&1 | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
clean_lines() {
|
||||
sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' -e '$s/$/\n/' "$XPPORDER_CONF"
|
||||
}
|
||||
@@ -64,10 +87,6 @@ matched_devices() {
|
||||
done
|
||||
}
|
||||
|
||||
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||
NUM_GOOD=`matched_devices | wc -l`
|
||||
LOCK="/var/lock/twinstar_startup"
|
||||
|
||||
# Wait until udev finished processing our requests
|
||||
# so we know the device files were actually created
|
||||
# before trying dahdi_cfg et-al.
|
||||
@@ -77,10 +96,10 @@ wait_for_udev() {
|
||||
echo "Waiting for udev to settle down..."
|
||||
if [ -x /sbin/udevsettle ]; then
|
||||
# Old system, stand-alone udevsettle command
|
||||
time /sbin/udevsettle --timeout="$UDEV_SETTLE_MAX_TIME"
|
||||
/sbin/udevsettle --timeout="$UDEV_SETTLE_MAX_TIME"
|
||||
elif [ -x /sbin/udevadm ]; then
|
||||
# Assume modern system, udevadm has settle parameter
|
||||
if ! time /sbin/udevadm settle --timeout="$UDEV_SETTLE_MAX_TIME"
|
||||
if ! /sbin/udevadm settle --timeout="$UDEV_SETTLE_MAX_TIME"
|
||||
then
|
||||
echo "udevadm failed ($?)."
|
||||
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
|
||||
@@ -110,13 +129,9 @@ start_dahdi() {
|
||||
rm -f "$LOCK"
|
||||
}
|
||||
|
||||
#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
remove)
|
||||
;;
|
||||
online)
|
||||
old_synchronous_start() {
|
||||
NUM_GOOD=`matched_devices | wc -l`
|
||||
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
||||
if [ "$NUM_GOOD" -eq "$NUM_WANTED" ]; then
|
||||
(
|
||||
@@ -142,8 +157,11 @@ online)
|
||||
fi
|
||||
) < /dev/null 2>&1 | $LOGGER &
|
||||
fi
|
||||
;;
|
||||
offline)
|
||||
}
|
||||
|
||||
old_synchronous_stop() {
|
||||
NUM_GOOD=`matched_devices | wc -l`
|
||||
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
||||
if [ "$NUM_GOOD" -eq 0 ]; then
|
||||
echo "All Astribanks offline" | $LOGGER
|
||||
@@ -152,6 +170,59 @@ offline)
|
||||
fi
|
||||
rm -f "$LOCK"
|
||||
fi
|
||||
}
|
||||
|
||||
ab_list() {
|
||||
find /sys/devices -name idVendor 2>/dev/null | \
|
||||
xargs grep -H 'e4e4' 2>/dev/null | \
|
||||
sed -e 's/idVendor.*/idProduct/' | xargs grep -H '11[3456]' | \
|
||||
sed 's,/[^/]*$,,' || :
|
||||
}
|
||||
|
||||
tws_watchdog_enable() {
|
||||
devdir="/sys$DEVPATH"
|
||||
label=`cat "$devdir/label"`
|
||||
connector=`cat "$devdir/connector"`
|
||||
xbus=`echo "$devdir" | sed 's,.*/,,'`
|
||||
prefix="${xbus}: [${label}] @${connector}"
|
||||
TWS_NOAUTOJUMPFILE="$TWS_DIR/twinstar_no_autojump"
|
||||
if [ -e "$TWS_NOAUTOJUMPFILE" ]; then
|
||||
$LOGGER "$prefix: ignore wd (found $TWS_NOAUTOJUMPFILE)"
|
||||
else
|
||||
# Re-arm Astribank watchdog
|
||||
transportdir="$devdir/transport"
|
||||
busnum=`cat "$transportdir/busnum" 2>/dev/null || :`
|
||||
devnum=`cat "$transportdir/devnum" 2>/dev/null || :`
|
||||
devaddr=`printf "%03d/%03d" "$busnum" "$devnum"`
|
||||
$LOGGER "$prefix: enabling twinstar watchdog"
|
||||
astribank_tool -D "$devaddr" -w 1 2>&1 | $LOGGER
|
||||
fi
|
||||
}
|
||||
|
||||
#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
remove)
|
||||
ab=`ab_list | wc -l`
|
||||
if [ "$ab" -eq 0 ]; then
|
||||
$LOGGER "$prefix: No more Astribanks -- remove astribank_is_starting semaphore"
|
||||
astribank_is_starting -v -r 2>&1 | $LOGGER
|
||||
fi
|
||||
;;
|
||||
online)
|
||||
if can_full_async; then
|
||||
tws_watchdog_enable
|
||||
else
|
||||
old_synchronous_start
|
||||
fi
|
||||
;;
|
||||
offline)
|
||||
if can_full_async; then
|
||||
: # Nothing to do
|
||||
else
|
||||
old_synchronous_stop
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "$0: Unknown ACTION='$ACTION'" | $LOGGER
|
||||
|
||||
@@ -125,6 +125,8 @@ static int absem_detected(void)
|
||||
if((absem = absem_get(0)) < 0) {
|
||||
if(debug)
|
||||
fprintf(stderr, "%s: absem does not exist\n", progname);
|
||||
if(verbose)
|
||||
printf("No Astribanks are initializing\n");
|
||||
return absem;
|
||||
}
|
||||
if(debug)
|
||||
|
||||
@@ -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,12 +35,17 @@ 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;
|
||||
my $have_span_types_config = -f $span_types_config || 0;
|
||||
|
||||
# Spans will be auto-assigned by default if either:
|
||||
# - Driver $auto_assign_spans them or
|
||||
# - Udev script see that we $have_span_types_config and it "add" them
|
||||
my $default_auto_assign = $auto_assign_spans || $have_assigned_spans_config;
|
||||
|
||||
my $sorter;
|
||||
my $sort_order = $opts{'s'};
|
||||
if(defined $sort_order) {
|
||||
@@ -69,8 +74,6 @@ if(defined($on)) { # Translate to booleans
|
||||
$should_output = 0 unless $verbose;
|
||||
}
|
||||
|
||||
undef $on if $dahdi_autoreg and not $opts{'R'};
|
||||
|
||||
sub state2str($) {
|
||||
return (shift)?"on":"off";
|
||||
}
|
||||
@@ -79,35 +82,41 @@ sub myprintf {
|
||||
printf @_ if $should_output;
|
||||
}
|
||||
|
||||
my @spans = Dahdi::spans;
|
||||
|
||||
foreach my $xbus (Dahdi::Xpp::xbuses($sorter)) {
|
||||
myprintf "%-10s\t%3s-%s\t%s\n",
|
||||
$xbus->name, $xbus->xpporder, $xbus->label, $xbus->connector;
|
||||
next unless $xbus->status eq 'CONNECTED';
|
||||
foreach my $xpd (Dahdi::Xpp::Xpd::telephony_devs($xbus->xpds())) {
|
||||
my $prev = $xpd->dahdi_registration($on);
|
||||
if(!defined($prev)) { # Failure
|
||||
printf "%s: Failed %s\n", $xpd->fqn, $!;
|
||||
next;
|
||||
}
|
||||
myprintf "\t%-10s: ", $xpd->fqn;
|
||||
if(!defined($on)) { # Query only
|
||||
my ($span) = grep { $_->name eq $xpd->fqn } @spans;
|
||||
my $spanstr = ($span) ? ("Span " . $span->num) : "";
|
||||
myprintf "%s %s\n", state2str($prev), $spanstr ;
|
||||
next;
|
||||
}
|
||||
myprintf "%3s ==> %3s\n", state2str($prev), state2str($on);
|
||||
my $prev = $xbus->dahdi_registration($on);
|
||||
if(!defined($prev)) { # Failure
|
||||
printf STDERR "%s: Failed %s\n", $xbus->name, $!;
|
||||
next;
|
||||
}
|
||||
if (defined($on) && $on && ! $have_assigned_spans_config && ! $auto_assign_spans) {
|
||||
# Emulate /etc/dahdi/assigned-spans.conf:
|
||||
# - We iterate over $xbus according to /etc/dahdi/xpp_order
|
||||
# - We "auto" assign all spans of current $xbus
|
||||
my $devpath = sprintf "/sys/bus/dahdi_devices/devices/astribanks:xbus-%02d", $xbus->num;
|
||||
my @cmd = ('dahdi_span_assignments', 'auto', $devpath);
|
||||
system @cmd;
|
||||
warn "Failed '@cmd' (status=$?)\n" if $?;
|
||||
my $reg_str;
|
||||
if (defined $on) {
|
||||
$reg_str = ($on) ? "registering" : "unregistering";
|
||||
} else {
|
||||
$reg_str = ($prev) ? "registered" : "unregistered";
|
||||
}
|
||||
myprintf "%-10s\t%3s-%s\t%s (%s)\n",
|
||||
$xbus->name, $xbus->xpporder, $xbus->label, $xbus->connector,
|
||||
$reg_str;
|
||||
next unless $xbus->status eq 'CONNECTED';
|
||||
# Only assign if no default assignment, or forced by '-R' option
|
||||
if (defined($on) && $on) {
|
||||
if ($opts{'R'} || ! $default_auto_assign) {
|
||||
# Emulate /etc/dahdi/assigned-spans.conf:
|
||||
# - We iterate over $xbus according to /etc/dahdi/xpp_order
|
||||
# - We "auto" assign all spans of current $xbus
|
||||
my $devpath = sprintf "/sys/bus/dahdi_devices/devices/astribanks:xbus-%02d", $xbus->num;
|
||||
my @cmd = ('dahdi_span_assignments', 'auto', $devpath);
|
||||
system @cmd;
|
||||
warn "Failed '@cmd' (status=$?)\n" if $?;
|
||||
}
|
||||
# wait for UDEV to do its stuff
|
||||
system "dahdi_waitfor_span_assignments assigned";
|
||||
}
|
||||
foreach my $xpd (Dahdi::Xpp::Xpd::telephony_devs($xbus->xpds())) {
|
||||
my $spanno = $xpd->xpd_getattr('span');
|
||||
myprintf "\t%-10s: ", $xpd->fqn;
|
||||
my $spanstr = ($spanno) ? ("Span " . $spanno) : "unassigned";
|
||||
myprintf "%s\n", $spanstr ;
|
||||
}
|
||||
}
|
||||
myprintf "# Sorted: $sort_order\n" if defined $sort_order;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "echo_loader.h"
|
||||
#include "debug.h"
|
||||
#include <oct6100api/oct6100_api.h>
|
||||
#include "parse_span_specs.h"
|
||||
|
||||
#define DBG_MASK 0x03
|
||||
#define TIMEOUT 1000
|
||||
@@ -362,7 +363,7 @@ int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
|
||||
DBG("Loading %s file...\n", filename);
|
||||
pFile = fopen(filename, "rb");
|
||||
if (pFile == NULL) {
|
||||
ERR("fopen\n");
|
||||
ERR("fopen: %s\n", strerror(errno));
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -378,7 +379,11 @@ int load_file(char *filename, unsigned char **ppBuf, UINT32 *pLen)
|
||||
} else {
|
||||
DBG("allocated mem for pbyFileData\n");
|
||||
}
|
||||
fread(pbyFileData, 1, *pLen, pFile);
|
||||
if (fread(pbyFileData, 1, *pLen, pFile) != *pLen) {
|
||||
fclose(pFile);
|
||||
ERR("fread: %s\n", strerror(errno));
|
||||
return -ENODEV;
|
||||
}
|
||||
fclose(pFile);
|
||||
DBG("Successful loading %s file into memory "
|
||||
"(size = %d, DUMP: first = %02X %02X, last = %02X %02X)\n",
|
||||
@@ -556,7 +561,7 @@ inline int get_ver(struct astribank_device *astribank)
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_alaw)
|
||||
UINT32 init_octasic(char *filename, struct astribank_device *astribank, struct span_specs *span_specs)
|
||||
{
|
||||
int cpld_ver;
|
||||
struct echo_mod *echo_mod;
|
||||
@@ -576,6 +581,8 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
|
||||
/* Channel resources.*/
|
||||
tOCT6100_CHANNEL_OPEN ChannelOpen;
|
||||
UINT32 ulChanHndl;
|
||||
enum tdm_codec tdm_codec;
|
||||
int spanno;
|
||||
|
||||
if (test_send(astribank) < 0)
|
||||
return cOCT6100_ERR_FATAL;
|
||||
@@ -725,7 +732,17 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
|
||||
/* Set the channel to work at the echo cancellation mode.*/
|
||||
ChannelOpen.ulEchoOperationMode = cOCT6100_ECHO_OP_MODE_NORMAL;
|
||||
|
||||
pcmLaw = (is_alaw ? cOCT6100_PCM_A_LAW: cOCT6100_PCM_U_LAW);
|
||||
spanno = nChan % 4;
|
||||
assert(spanno >= 0 && spanno < MAX_SPANNO);
|
||||
tdm_codec = span_specs->span_is_alaw[spanno];
|
||||
if (tdm_codec == TDM_CODEC_UNKNOWN) {
|
||||
AB_ERR(astribank, "Calculated bad alaw/ulaw on channel %d\n", nChan);
|
||||
return cOCT6100_ERR_FATAL;
|
||||
}
|
||||
if (nChan < 4)
|
||||
AB_INFO(astribank, "ECHO PRI port %d = %s\n", spanno+1, (tdm_codec == TDM_CODEC_ALAW) ? "alaw" : "ulaw");
|
||||
|
||||
pcmLaw = ((tdm_codec == TDM_CODEC_ALAW) ? cOCT6100_PCM_A_LAW: cOCT6100_PCM_U_LAW);
|
||||
|
||||
/* Configure the TDM interface.*/
|
||||
ChannelOpen.TdmConfig.ulRinPcmLaw = pcmLaw;
|
||||
@@ -821,15 +838,22 @@ UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_a
|
||||
}
|
||||
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
int load_echo(struct astribank_device *astribank, char *filename, int is_alaw)
|
||||
int load_echo(struct astribank_device *astribank, char *filename, int default_is_alaw, const char *span_spec)
|
||||
{
|
||||
int ret;
|
||||
UINT32 octasic_status;
|
||||
struct span_specs *span_specs;
|
||||
|
||||
AB_INFO(astribank, "Loading ECHOCAN Firmware: %s (%s)\n",
|
||||
filename, (is_alaw) ? "alaw" : "ulaw");
|
||||
span_specs = parse_span_specifications(span_spec, default_is_alaw);
|
||||
if (!span_specs) {
|
||||
AB_ERR(astribank, "ECHO parsing span specs failed\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
AB_INFO(astribank, "Loading ECHOCAN Firmware: %s (default %s)\n",
|
||||
filename, (default_is_alaw) ? "alaw" : "ulaw");
|
||||
usb_buffer_init(astribank, &usb_buffer);
|
||||
octasic_status = init_octasic(filename, astribank, is_alaw);
|
||||
octasic_status = init_octasic(filename, astribank, span_specs);
|
||||
free_span_specifications(span_specs);
|
||||
if (octasic_status != cOCT6100_ERR_OK) {
|
||||
AB_ERR(astribank, "ECHO %s burning failed (%08X)\n",
|
||||
filename, octasic_status);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "astribank_usb.h"
|
||||
|
||||
int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver);
|
||||
int load_echo(struct astribank_device *astribank, char *filename, int is_alaw);
|
||||
int load_echo(struct astribank_device *astribank, char *filename, int is_alaw, const char *span_spec);
|
||||
int echo_ver(struct astribank_device *astribank);
|
||||
|
||||
#endif /* ECHO_LOADER_H */
|
||||
|
||||
@@ -72,7 +72,11 @@ struct hexdata {
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef void (*parse_hexfile_report_func_t)(int level, const char *msg, ...);
|
||||
typedef void (*parse_hexfile_report_func_t)(int level, const char *msg, ...)
|
||||
#ifdef __GNUC__
|
||||
__attribute__((format(printf,2,3)));
|
||||
#endif
|
||||
;
|
||||
|
||||
parse_hexfile_report_func_t parse_hexfile_set_reporting(parse_hexfile_report_func_t rf);
|
||||
void free_hexdata(struct hexdata *hexdata);
|
||||
|
||||
@@ -512,7 +512,7 @@ int mpp_send_seg(struct astribank_device *astribank, const uint8_t *data, uint16
|
||||
|
||||
assert(astribank != NULL);
|
||||
xtalk_dev = astribank->xtalk_dev;
|
||||
if(!astribank->burn_state == BURN_STATE_STARTED) {
|
||||
if(astribank->burn_state != BURN_STATE_STARTED) {
|
||||
ERR("Tried to send a segment while burn_state=%d\n",
|
||||
astribank->burn_state);
|
||||
return -EINVAL;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
CFLAGS=-V3.4 -ffunction-sections -I/lib/modules/$(shell uname -r)/build/include -Iinclude -Ioctdeviceapi -Ioctdeviceapi/oct6100api -DGFP_ATOMIC=0 -Dkmalloc=calloc -Dkfree=free
|
||||
LDFLAGS=-V3.4 -Wl,-Map -Wl,test.map -Wl,--gc-sections
|
||||
|
||||
APIDIR=octdeviceapi/oct6100api/oct6100_api
|
||||
|
||||
OCTASIC_OBJS=$(APIDIR)/oct6100_adpcm_chan.o \
|
||||
$(APIDIR)/oct6100_channel.o \
|
||||
$(APIDIR)/oct6100_chip_open.o \
|
||||
$(APIDIR)/oct6100_chip_stats.o \
|
||||
$(APIDIR)/oct6100_conf_bridge.o \
|
||||
$(APIDIR)/oct6100_debug.o \
|
||||
$(APIDIR)/oct6100_events.o \
|
||||
$(APIDIR)/oct6100_interrupts.o \
|
||||
$(APIDIR)/oct6100_memory.o \
|
||||
$(APIDIR)/oct6100_miscellaneous.o \
|
||||
$(APIDIR)/oct6100_mixer.o \
|
||||
$(APIDIR)/oct6100_phasing_tsst.o \
|
||||
$(APIDIR)/oct6100_playout_buf.o \
|
||||
$(APIDIR)/oct6100_remote_debug.o \
|
||||
$(APIDIR)/oct6100_tlv.o \
|
||||
$(APIDIR)/oct6100_tone_detection.o \
|
||||
$(APIDIR)/oct6100_tsi_cnct.o \
|
||||
$(APIDIR)/oct6100_tsst.o \
|
||||
$(APIDIR)/oct6100_user.o \
|
||||
apilib/bt/octapi_bt0.o \
|
||||
apilib/largmath/octapi_largmath.o \
|
||||
apilib/llman/octapi_llman.o
|
||||
|
||||
|
||||
all: test
|
||||
|
||||
test.o: test.c
|
||||
|
||||
test: test.o $(OCTASIC_OBJS)
|
||||
|
||||
clean:
|
||||
rm -rf test test.o
|
||||
rm -rf $(OCTASIC_OBJS)
|
||||
116
xpp/oct612x/Makefile.am
Normal file
116
xpp/oct612x/Makefile.am
Normal file
@@ -0,0 +1,116 @@
|
||||
OCTASIC_DEFINES = \
|
||||
-DPTR_TYPE=uint32_t \
|
||||
-DcOCT6100_INTERNAL_SUPER_ARRAY_SIZE=1024 \
|
||||
-DcOCT6100_MAX_ECHO_CHANNELS=672 \
|
||||
-DcOCT6100_MAX_MIXER_EVENTS=1344
|
||||
|
||||
noinst_LTLIBRARIES = liboctasic.la
|
||||
|
||||
# Taken from octasic-helper
|
||||
liboctasic_la_SOURCES = \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_adpcm_chan.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_channel.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_chip_open.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_chip_stats.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_conf_bridge.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_debug.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_events.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_interrupts.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_memory.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_miscellaneous.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_mixer.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_phasing_tsst.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_playout_buf.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_remote_debug.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_tlv.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_tone_detection.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_tsi_cnct.c \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_tsst.c \
|
||||
apilib/bt/octapi_bt0.c \
|
||||
apilib/largmath/octapi_largmath.c \
|
||||
apilib/llman/octapi_llman.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
apilib/bt/octapi_bt0_private.h \
|
||||
apilib/llman/octapi_llman_private.h \
|
||||
include/apilib/octapi_bt0.h \
|
||||
include/apilib/octapi_largmath.h \
|
||||
include/apilib/octapi_llman.h \
|
||||
include/digium_unused.h \
|
||||
include/oct6100api/oct6100_adpcm_chan_inst.h \
|
||||
include/oct6100api/oct6100_adpcm_chan_pub.h \
|
||||
include/oct6100api/oct6100_api.h \
|
||||
include/oct6100api/oct6100_api_inst.h \
|
||||
include/oct6100api/oct6100_apimi.h \
|
||||
include/oct6100api/oct6100_apiud.h \
|
||||
include/oct6100api/oct6100_channel_inst.h \
|
||||
include/oct6100api/oct6100_channel_pub.h \
|
||||
include/oct6100api/oct6100_chip_open_inst.h \
|
||||
include/oct6100api/oct6100_chip_open_pub.h \
|
||||
include/oct6100api/oct6100_chip_stats_inst.h \
|
||||
include/oct6100api/oct6100_chip_stats_pub.h \
|
||||
include/oct6100api/oct6100_conf_bridge_inst.h \
|
||||
include/oct6100api/oct6100_conf_bridge_pub.h \
|
||||
include/oct6100api/oct6100_debug_inst.h \
|
||||
include/oct6100api/oct6100_debug_pub.h \
|
||||
include/oct6100api/oct6100_defines.h \
|
||||
include/oct6100api/oct6100_errors.h \
|
||||
include/oct6100api/oct6100_events_inst.h \
|
||||
include/oct6100api/oct6100_events_pub.h \
|
||||
include/oct6100api/oct6100_interrupts_inst.h \
|
||||
include/oct6100api/oct6100_interrupts_pub.h \
|
||||
include/oct6100api/oct6100_mixer_inst.h \
|
||||
include/oct6100api/oct6100_mixer_pub.h \
|
||||
include/oct6100api/oct6100_phasing_tsst_inst.h \
|
||||
include/oct6100api/oct6100_phasing_tsst_pub.h \
|
||||
include/oct6100api/oct6100_playout_buf_inst.h \
|
||||
include/oct6100api/oct6100_playout_buf_pub.h \
|
||||
include/oct6100api/oct6100_remote_debug_inst.h \
|
||||
include/oct6100api/oct6100_remote_debug_pub.h \
|
||||
include/oct6100api/oct6100_tlv_inst.h \
|
||||
include/oct6100api/oct6100_tone_detection_inst.h \
|
||||
include/oct6100api/oct6100_tone_detection_pub.h \
|
||||
include/oct6100api/oct6100_tsi_cnct_inst.h \
|
||||
include/oct6100api/oct6100_tsi_cnct_pub.h \
|
||||
include/oct6100api/oct6100_tsst_inst.h \
|
||||
include/octdef.h \
|
||||
include/octmac.h \
|
||||
include/octosdependant.h \
|
||||
include/octrpc/oct6100_rpc_protocol.h \
|
||||
include/octrpc/rpc_protocol.h \
|
||||
include/octtype.h \
|
||||
include/octtypevx.h \
|
||||
include/octtypewin.h \
|
||||
#
|
||||
|
||||
liboctasic_la_CFLAGS = \
|
||||
$(OCTASIC_DEFINES) \
|
||||
$(OCTASIC_CFLAGS)
|
||||
|
||||
|
||||
EXTRA_DIST = \
|
||||
get_discards \
|
||||
octasic-helper \
|
||||
octdeviceapi/oct6100api/oct6100_adpcm_chan_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_api/oct6100_user.c \
|
||||
octdeviceapi/oct6100api/oct6100_apimi/oct6100_mask_interrupts.c \
|
||||
octdeviceapi/oct6100api/oct6100_channel_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_chip_open_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_chip_stats_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_conf_bridge_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_debug_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_events_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_interrupts_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_memory_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_miscellaneous_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_mixer_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_phasing_tsst_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_playout_buf_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_remote_debug_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_tlv_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_tone_detection_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_tsi_cnct_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_tsst_priv.h \
|
||||
octdeviceapi/oct6100api/oct6100_version.h \
|
||||
test.c \
|
||||
#
|
||||
152
xpp/parse_span_specs.c
Normal file
152
xpp/parse_span_specs.c
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Written by Oron Peled <oron@actcom.co.il>
|
||||
* Copyright (C) 2014, Xorcom
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <regex.h>
|
||||
#include <fnmatch.h>
|
||||
#include <sys/time.h>
|
||||
#include "parse_span_specs.h"
|
||||
|
||||
void free_span_specifications(struct span_specs *span_specs)
|
||||
{
|
||||
if (span_specs) {
|
||||
if (span_specs->buf)
|
||||
free(span_specs->buf);
|
||||
free(span_specs);
|
||||
}
|
||||
}
|
||||
|
||||
static enum tdm_codec is_alaw_span_type(const char *span_type)
|
||||
{
|
||||
assert(span_type);
|
||||
if (strcmp(span_type, "E1") == 0)
|
||||
return TDM_CODEC_ALAW;
|
||||
else if (strcmp(span_type, "T1") == 0)
|
||||
return TDM_CODEC_ULAW;
|
||||
return TDM_CODEC_UNKNOWN;
|
||||
}
|
||||
|
||||
struct span_specs *parse_span_specifications(const char *spec_string, int default_is_alaw)
|
||||
{
|
||||
struct span_specs *span_specs;
|
||||
char *p;
|
||||
int spanno;
|
||||
int i;
|
||||
|
||||
if (!spec_string)
|
||||
return NULL;
|
||||
/* Allocate and Initialize */
|
||||
span_specs = calloc(sizeof(char *), MAX_SPANNO);
|
||||
if (!span_specs)
|
||||
goto err;
|
||||
for (spanno = 0; spanno < MAX_SPANNO; spanno++)
|
||||
span_specs->span_is_alaw[spanno] = TDM_CODEC_UNKNOWN;
|
||||
span_specs->buf = strdup(spec_string);
|
||||
if (!span_specs->buf)
|
||||
goto err;
|
||||
for (i = 0;; i++) {
|
||||
char *curr_item;
|
||||
char *tokenize_key;
|
||||
char *key;
|
||||
char *value;
|
||||
enum tdm_codec is_alaw;
|
||||
int matched;
|
||||
|
||||
/* Split to items */
|
||||
p = (i == 0) ? span_specs->buf : NULL;
|
||||
p = strtok_r(p, " \t,", &curr_item);
|
||||
if (!p)
|
||||
break;
|
||||
|
||||
/* Split to <span>:<type> */
|
||||
key = strtok_r(p, ":", &tokenize_key);
|
||||
if (!key) {
|
||||
fprintf(stderr,
|
||||
"Missing ':' (item #%d inside '%s')\n",
|
||||
i+1, spec_string);
|
||||
goto err;
|
||||
}
|
||||
value = strtok_r(NULL, ":", &tokenize_key);
|
||||
if (!value) {
|
||||
fprintf(stderr,
|
||||
"Missing value after ':' (item #%d inside '%s')\n",
|
||||
i+1, spec_string);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Match span specification and set alaw/ulaw */
|
||||
is_alaw = is_alaw_span_type(value);
|
||||
if (is_alaw == TDM_CODEC_UNKNOWN) {
|
||||
fprintf(stderr,
|
||||
"Illegal span type '%s' (item #%d inside '%s')\n",
|
||||
value, i+1, spec_string);
|
||||
goto err;
|
||||
}
|
||||
matched = 0;
|
||||
for (spanno = 0; spanno < MAX_SPANNO; spanno++) {
|
||||
char tmpbuf[BUFSIZ];
|
||||
|
||||
snprintf(tmpbuf, sizeof(tmpbuf), "%d", spanno + 1);
|
||||
if (fnmatch(p, tmpbuf, 0) == 0) {
|
||||
matched++;
|
||||
span_specs->span_is_alaw[spanno] = is_alaw;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
fprintf(stderr,
|
||||
"Span specification '%s' does not match any span (item #%d inside '%s')\n",
|
||||
key, i+1, spec_string);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set defaults */
|
||||
for (spanno = 0; spanno < MAX_SPANNO; spanno++) {
|
||||
if (span_specs->span_is_alaw[spanno] == TDM_CODEC_UNKNOWN) {
|
||||
span_specs->span_is_alaw[spanno] = default_is_alaw;
|
||||
}
|
||||
}
|
||||
return span_specs;
|
||||
err:
|
||||
free_span_specifications(span_specs);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void print_span_specifications(struct span_specs *span_specs, FILE *output)
|
||||
{
|
||||
int spanno;
|
||||
|
||||
if (!span_specs)
|
||||
return;
|
||||
for (spanno = 0; spanno < MAX_SPANNO; spanno++) {
|
||||
enum tdm_codec is_alaw;
|
||||
|
||||
is_alaw = span_specs->span_is_alaw[spanno];
|
||||
fprintf(output, "%d %s\n",
|
||||
spanno+1, (is_alaw == TDM_CODEC_ALAW) ? "alaw" : "ulaw");
|
||||
}
|
||||
}
|
||||
43
xpp/parse_span_specs.h
Normal file
43
xpp/parse_span_specs.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef PARSE_SPAN_SPECS_H
|
||||
#define PARSE_SPAN_SPECS_H
|
||||
|
||||
/*
|
||||
* Written by Oron Peled <oron@actcom.co.il>
|
||||
* Copyright (C) 2014, Xorcom
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#define MAX_SPANNO 4 /* E1/T1 spans -- always in first unit. 1-based */
|
||||
|
||||
enum tdm_codec {
|
||||
TDM_CODEC_UNKNOWN,
|
||||
TDM_CODEC_ULAW,
|
||||
TDM_CODEC_ALAW,
|
||||
};
|
||||
|
||||
struct span_specs {
|
||||
char *buf;
|
||||
enum tdm_codec span_is_alaw[MAX_SPANNO];
|
||||
};
|
||||
|
||||
struct span_specs *parse_span_specifications(const char *spec_string, int default_is_alaw);
|
||||
void free_span_specifications(struct span_specs *span_specs);
|
||||
void print_span_specifications(struct span_specs *span_specs, FILE *output);
|
||||
|
||||
#endif /* PARSE_SPAN_SPECS_H */
|
||||
@@ -29,13 +29,22 @@ sub generate($$$) {
|
||||
system "which dahdi_span_types > /dev/null 2>&1";
|
||||
return if $?;
|
||||
|
||||
warn "Empty configuration -- no spans\n" unless @spans;
|
||||
my $line_mode = $genopts->{'line-mode'};
|
||||
my $cmd;
|
||||
if (defined $line_mode) {
|
||||
$line_mode =~ /^[ETJ]1$/ or die "Bad line-mode='$line_mode'\n";
|
||||
$cmd = "dahdi_span_types --line-mode=$line_mode dumpconfig > $file";
|
||||
printf("Generating $file (with default line-mode %s)\n", $line_mode)
|
||||
if $genopts->{verbose};
|
||||
} else {
|
||||
$cmd = "dahdi_span_types dumpconfig > $file";
|
||||
printf("Generating $file (no --line-mode override)\n")
|
||||
if $genopts->{verbose};
|
||||
}
|
||||
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";
|
||||
system $cmd;
|
||||
die "Command failed (status=$?): '$cmd'" if $?;
|
||||
}
|
||||
@@ -61,3 +70,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' },
|
||||
@@ -105,9 +105,14 @@ my %pci_ids = (
|
||||
|
||||
# from wcte435/235
|
||||
'd161:800e' => { DRIVER => 'wcte43x', DESCRIPTION => 'Wildcard TE435/235' },
|
||||
'd161:8013' => { DRIVER => 'wcte43x', DESCRIPTION => 'Wildcard TE436/236' },
|
||||
|
||||
# from wcb4xxp
|
||||
'd161:b410' => { DRIVER => 'wcb4xxp', DESCRIPTION => 'Digium Wildcard B410P' },
|
||||
'd161:8014' => { DRIVER => 'wcb4xxp', DESCRIPTION => 'Digium Wildcard B433' },
|
||||
'd161:8015' => { DRIVER => 'wcb4xxp', DESCRIPTION => 'Digium Wildcard B434' },
|
||||
'd161:8016' => { DRIVER => 'wcb4xxp', DESCRIPTION => 'Digium Wildcard B233' },
|
||||
'd161:8017' => { DRIVER => 'wcb4xxp', DESCRIPTION => 'Digium Wildcard B234' },
|
||||
|
||||
# from tor2
|
||||
'10b5:9030' => { DRIVER => 'tor2', DESCRIPTION => 'PLX 9030' },
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -148,6 +146,40 @@ sub new($$) {
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub dahdi_registration($$) {
|
||||
my $xbus = shift;
|
||||
my $on = shift;
|
||||
my $result;
|
||||
my $file = sprintf("%s/dahdi_registration", $xbus->sysfs_dir);
|
||||
# Handle old drivers without dahdi_registration xbus attribute
|
||||
if (! -f $file) {
|
||||
warn "Old xpp driver without dahdi_registration support. Emulating it using xpd/span support\n";
|
||||
my @xpds = sort { $a->id <=> $b->id } $xbus->xpds();
|
||||
my $prev;
|
||||
foreach my $xpd (@xpds) {
|
||||
$prev = $xpd->dahdi_registration($on);
|
||||
}
|
||||
return $prev;
|
||||
}
|
||||
# First query
|
||||
open(F, "$file") or die "Failed to open $file for reading: $!";
|
||||
$result = <F>;
|
||||
chomp $result;
|
||||
close F;
|
||||
if(defined($on) and $on ne $result) { # Now change
|
||||
open(F, ">$file") or die "Failed to open $file for writing: $!";
|
||||
print F ($on)?"1":"0";
|
||||
if(!close(F)) {
|
||||
if($! == 17) { # EEXISTS
|
||||
# good
|
||||
} else {
|
||||
undef $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub pretty_xpds($) {
|
||||
my $xbus = shift;
|
||||
my @xpds = sort { $a->id <=> $b->id } $xbus->xpds();
|
||||
|
||||
27
xpp/perl_modules/Makefile.am
Normal file
27
xpp/perl_modules/Makefile.am
Normal file
@@ -0,0 +1,27 @@
|
||||
perllibdir = @perllibdir@
|
||||
nobase_perllib_DATA = \
|
||||
Dahdi.pm \
|
||||
Dahdi/Hardware.pm \
|
||||
Dahdi/Xpp/Line.pm \
|
||||
Dahdi/Xpp/Xbus.pm \
|
||||
Dahdi/Xpp/Xpd.pm \
|
||||
Dahdi/Xpp/Mpp.pm \
|
||||
Dahdi/Span.pm \
|
||||
Dahdi/Utils.pm \
|
||||
Dahdi/Chans.pm \
|
||||
Dahdi/Xpp.pm \
|
||||
Dahdi/Config/Params.pm \
|
||||
Dahdi/Config/Gen/Xpporder.pm \
|
||||
Dahdi/Config/Gen/Spantypes.pm \
|
||||
Dahdi/Config/Gen/Modules.pm \
|
||||
Dahdi/Config/Gen/Users.pm \
|
||||
Dahdi/Config/Gen/Freepbxdb.pm \
|
||||
Dahdi/Config/Gen/Unicall.pm \
|
||||
Dahdi/Config/Gen/Chandahdi.pm \
|
||||
Dahdi/Config/Gen/Assignedspans.pm \
|
||||
Dahdi/Config/Gen/System.pm \
|
||||
Dahdi/Config/Gen.pm \
|
||||
Dahdi/Hardware/USB.pm \
|
||||
Dahdi/Hardware/PCI.pm
|
||||
|
||||
EXTRA_DIST = $(nobase_perllib_DATA)
|
||||
@@ -41,18 +41,25 @@ ab_list() {
|
||||
}
|
||||
|
||||
ab_serial_nums() {
|
||||
ab_list | \
|
||||
sed 's,$,/serial,' | \
|
||||
xargs grep -H '' 2>/dev/null | \
|
||||
sed 's,.*/serial:,,' | \
|
||||
sed 's/^$/NO-SERIAL/' | \
|
||||
sort -u
|
||||
for i in `ab_list`; do
|
||||
s=`cat "$i/serial" 2>/dev/null` || :
|
||||
if [ "$s" = '' ]; then
|
||||
echo "NO-SERIAL"
|
||||
else
|
||||
echo "$s"
|
||||
fi
|
||||
done | sort -u || :
|
||||
}
|
||||
|
||||
detected_serial_nums() {
|
||||
cat /sys/bus/astribanks/devices/*/transport/serial 2> /dev/null | \
|
||||
sed 's/^$/NO-SERIAL/' | \
|
||||
sort -u || :
|
||||
for i in `ls -1d /sys/bus/astribanks/devices/*/transport 2>/dev/null`; do
|
||||
s=`cat "$i/serial" 2>/dev/null` || :
|
||||
if [ "$s" = '' ]; then
|
||||
echo "NO-SERIAL"
|
||||
else
|
||||
echo "$s"
|
||||
fi
|
||||
done | sort -u || :
|
||||
}
|
||||
|
||||
calc_union() {
|
||||
@@ -72,28 +79,43 @@ 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 "_"
|
||||
done
|
||||
}
|
||||
|
||||
clean_lines() {
|
||||
sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' -e '$s/$/\n/' "$1"
|
||||
}
|
||||
|
||||
# Any hardware?
|
||||
if ! dahdi_hardware="`which dahdi_hardware 2>/dev/null`"; then
|
||||
echo >&2 "$0: Missing dahdi_hardware"
|
||||
exit 0
|
||||
fi
|
||||
if ! astribank_is_starting="`which astribank_is_starting 2>/dev/null`"; then
|
||||
echo >&2 "$0: Missing astribank_is_starting"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Just make sure
|
||||
if [ "`$dahdi_hardware | grep xpp_usb`" != "" ]; then
|
||||
astribank_is_starting -v -a
|
||||
fi
|
||||
if ! astribank_is_starting; then
|
||||
# No Astribanks ever seen -- nothing to do
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Sanity check
|
||||
for i in `ab_list`; do
|
||||
s=`cat "$i/serial" 2>/dev/null` || :
|
||||
if [ "$s" = '' ]; then
|
||||
echo >&2 "WARNING! Astribank without serial number: $i"
|
||||
fi
|
||||
done
|
||||
|
||||
serial_nums=`ab_serial_nums`
|
||||
|
||||
# Loop until detected (hopefully) all astribanks and they are initialized
|
||||
@@ -130,13 +152,22 @@ cat /sys/bus/astribanks/devices/*/waitfor_xpds 2> /dev/null || :
|
||||
|
||||
# Wait for device to stabilize and XPD's to finish initalizations
|
||||
echo 1>&2 "Astribanks initializing spans"
|
||||
if [ "$XPP_HOTPLUG_DAHDI" = yes ]; then
|
||||
if [ "$CALLED_FROM_ATRIBANK_HOOK" = '' ]; then
|
||||
# Now we can wait until the hotplug run would remove the semaphore
|
||||
echo -n 1>&2 "Other DAHDI initializations... "
|
||||
astribank_is_starting -v -w 1>&2
|
||||
if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" = '' -a \
|
||||
"$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" != 'yes' ]; then
|
||||
if [ ! -f /etc/dahdi/xpp_order ]; then
|
||||
echo 1>&2 "WARNING: No ASTERISK_SUPPORTS_DAHDI_HOTPLUG" \
|
||||
" and no /etc/dahdi/xpp_order"
|
||||
else
|
||||
count=`clean_lines /etc/dahdi/xpp_order | wc -l`
|
||||
if [ "$count" -le 0 ]; then
|
||||
echo 1>&2 "WARNING: No ASTERISK_SUPPORTS_DAHDI_HOTPLUG" \
|
||||
" and empty /etc/dahdi/xpp_order"
|
||||
else
|
||||
# Now we can wait until the hotplug run would remove the semaphore
|
||||
echo -n 1>&2 "Other DAHDI initializations... "
|
||||
astribank_is_starting -v -w 1>&2
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# Non-hotplug -- Sequential initialization, remove semaphore
|
||||
astribank_is_starting -v -r 1>&2
|
||||
fi
|
||||
# All Astribanks initialized -- remove semaphore
|
||||
astribank_is_starting -v -r 1>&2
|
||||
|
||||
@@ -68,6 +68,7 @@ FIRMWARE_DIR="${FIRMWARE_DIR:-/usr/share/dahdi}"
|
||||
ASTRIBANK_HEXLOAD=${ASTRIBANK_HEXLOAD:-/usr/sbin/astribank_hexload}
|
||||
ASTRIBANK_TOOL=${ASTRIBANK_TOOL:-/usr/sbin/astribank_tool}
|
||||
XPP_CONFIG="${XPP_CONFIG:-/etc/dahdi/xpp.conf}"
|
||||
SPAN_TYPES_CONFIG="${SPAN_TYPES_CONFIG:-/etc/dahdi/span-types.conf}"
|
||||
XPP_UDEV_SLEEP_TIME="${XPP_UDEV_SLEEP_TIME:-15}"
|
||||
|
||||
USB_RECOV="${USB_RECOV:-USB_RECOV.hex}"
|
||||
@@ -270,6 +271,15 @@ usb_firmware_all_devices() {
|
||||
wait_renumeration $numdevs 'e4e4/11[3456]1/*' "usb_firmware_all_devices"
|
||||
}
|
||||
|
||||
filter_span_types() {
|
||||
l="$1"
|
||||
sed < "$SPAN_TYPES_CONFIG" 2>/dev/null \
|
||||
-e 's/#.*//' \
|
||||
-e 's/[ \t]*$//' \
|
||||
-e 's/^[ \t]*//' \
|
||||
-e '/^$/d' | awk -vlabel="$l" '$1 == label { print $2 }' | tr -s ', \t\n' ','
|
||||
}
|
||||
|
||||
load_fw_device() {
|
||||
dev="$1"
|
||||
fw="$2"
|
||||
@@ -279,33 +289,62 @@ load_fw_device() {
|
||||
FPGA_1161*.hex)
|
||||
echo_file="$FIRMWARE_DIR/OCT6104E-256D.ima"
|
||||
law=''
|
||||
law_str='uLaw'
|
||||
dev_short=`echo "$dev" | sed -e 's,.*/usb/*,,'`
|
||||
abtool_output=`$ASTRIBANK_TOOL -D "$dev" -Q 2>&1`
|
||||
ec_card_type=`echo "$abtool_output" | grep 'CARD 4' | sed -e 's/.*type=//' -e 's/\..*//'`
|
||||
caps_num=`echo "$abtool_output" | grep 'ECHO ports' | sed -e 's/.*: *//'`
|
||||
if [ "$ec_card_type" = '5' ]; then
|
||||
debug "ECHO burning into $dev: $echo_file"
|
||||
debug "ECHO($dev_short): Firmware $echo_file"
|
||||
card_type=`echo "$abtool_output" | grep 'CARD 0' | sed -e 's/.*type=//' -e 's/\..*//'`
|
||||
case "$card_type" in
|
||||
3) law="-A";;
|
||||
4)
|
||||
pri_protocol=''
|
||||
if [ -r "$XPP_CONFIG" ]; then
|
||||
pri_protocol=`awk '/^pri_protocol/ {print $2}' $XPP_CONFIG`
|
||||
dev_lsusb=`echo "$dev_short" | tr '/' ':'`
|
||||
# Try modern configuration
|
||||
if [ -r "$SPAN_TYPES_CONFIG" ]; then
|
||||
# Try exact match by label
|
||||
label=`lsusb -s "$dev_lsusb" -v 2>/dev/null | awk '$1 == "iSerial" && $2 == 3 { print $3 }'`
|
||||
if [ "$label" != '' ]; then
|
||||
label="usb:$label"
|
||||
debug "ECHO($dev_short): Search span-types.conf for [$label]"
|
||||
pri_spec=`filter_span_types "${label}"`
|
||||
if [ "$pri_spec" != '' ]; then
|
||||
debug "ECHO($dev_short): Found definitions for [$label] -- '$pri_spec'"
|
||||
fi
|
||||
else
|
||||
debug "ECHO($dev_short): Device without a label"
|
||||
fi
|
||||
# Check wildcard match
|
||||
pri_spec_wildcard=`filter_span_types '*'`
|
||||
if [ "$pri_spec_wildcard" != '' ]; then
|
||||
debug "ECHO($dev_short): Found definitions for wildcard -- $pri_spec_wildcard"
|
||||
fi
|
||||
pri_spec_params=""
|
||||
if [ "$pri_spec$pri_spec_wildcard" != '' ]; then
|
||||
pri_spec=`echo "$pri_spec_wildcard $pri_spec" | tr -s ' \t\n' ','`
|
||||
pri_spec_params="-S $pri_spec"
|
||||
debug "ECHO($dev_short): pri_spec_params='$pri_spec_params'"
|
||||
fi
|
||||
fi
|
||||
# "E1" or empty (implied E1) means aLaw
|
||||
if [ "$pri_protocol" != 'T1' ]; then
|
||||
law='-A'
|
||||
# Fallback to legacy xpp.conf
|
||||
default_pri_protocol=''
|
||||
law=''
|
||||
if [ -r "$XPP_CONFIG" ]; then
|
||||
default_pri_protocol=`awk '/^pri_protocol/ {print $2}' $XPP_CONFIG`
|
||||
if [ "$default_pri_protocol" != '' ]; then
|
||||
debug "ECHO($dev_short): Found legacy xpp.conf setting -- $default_pri_protocol"
|
||||
# "E1" or empty (implied E1) means aLaw
|
||||
if [ "$default_pri_protocol" != 'T1' ]; then
|
||||
law='-A'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ "$law" = '-A' ]; then
|
||||
law_str="aLaw"
|
||||
fi
|
||||
caps_num=`echo "$abtool_output" | grep 'ECHO ports' | sed -e 's/.*: *//'`
|
||||
debug "ECHO: 1st module is $law_str, $caps_num channels allowed."
|
||||
debug "ECHO($dev_short): $caps_num channels allowed."
|
||||
if [ "$caps_num" != '0' ]; then
|
||||
run_astribank_hexload -D "$dev" -O $law "$echo_file"
|
||||
run_astribank_hexload -D "$dev" -O $law $pri_spec_params "$echo_file"
|
||||
else
|
||||
echo "WARNING: ECHO burning was skipped (no capabilities)"
|
||||
fi
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
# module match_flags idVendor idProduct bcdDevice_lo bcdDevice_hi bDeviceClass bDeviceSubClass bDeviceProtocol bInterfaceClass bInterfaceSubClass bInterfaceProtocol driver_info
|
||||
xpp_fxloader 0x0003 0x04b4 0x8613 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1130 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1131 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1140 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1141 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1150 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1151 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1160 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
xpp_fxloader 0x0003 0xe4e4 0x1161 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x0
|
||||
@@ -61,6 +61,23 @@ struct xusb {
|
||||
|
||||
static void xusb_init();
|
||||
|
||||
/*
|
||||
* XTALK_OPTIONS:
|
||||
* A white-space separated list of options, read from the environment
|
||||
* variable of that name. Existing options:
|
||||
*
|
||||
* - "use-clear-halt" -- force USB "clear_halt" operation during
|
||||
* device initialization (this is the default)
|
||||
* - "no-use-clear-halt" -- force no USB "clear_halt" operation during
|
||||
* device initialization
|
||||
* - "no-lock" -- prevent using global sempahore to serialize libusb
|
||||
* initialization. Previously done via "XUSB_NOLOCK"
|
||||
* environment variable.
|
||||
*/
|
||||
int xtalk_parse_options(void);
|
||||
int xtalk_option_use_clear_halt(void);
|
||||
int xtalk_option_no_lock(void);
|
||||
|
||||
void xusb_init_spec(struct xusb_spec *spec, char *name,
|
||||
uint16_t vendor_id, uint16_t product_id,
|
||||
int nifaces, int iface, int nep, int ep_out, int ep_in)
|
||||
@@ -257,13 +274,16 @@ int xusb_claim_interface(struct xusb *xusb)
|
||||
xusb->iProduct,
|
||||
xusb->iSerialNumber,
|
||||
xusb->iInterface);
|
||||
if (usb_clear_halt(xusb->handle, EP_OUT(xusb)) != 0) {
|
||||
ERR("Clearing output endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
if (usb_clear_halt(xusb->handle, EP_IN(xusb)) != 0) {
|
||||
ERR("Clearing input endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
if (xtalk_option_use_clear_halt()) {
|
||||
DBG("Using clear_halt()\n");
|
||||
if (usb_clear_halt(xusb->handle, EP_OUT(xusb)) != 0) {
|
||||
ERR("Clearing output endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
if (usb_clear_halt(xusb->handle, EP_IN(xusb)) != 0) {
|
||||
ERR("Clearing input endpoint: %s\n", usb_strerror());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
ret = xusb_flushread(xusb);
|
||||
if (ret < 0) {
|
||||
@@ -857,13 +877,67 @@ static int initizalized;
|
||||
static void xusb_init()
|
||||
{
|
||||
if (!initizalized) {
|
||||
if (!getenv("XUSB_NOLOCK"))
|
||||
xtalk_parse_options();
|
||||
if (!xtalk_option_no_lock())
|
||||
xusb_lock_usb();
|
||||
usb_init();
|
||||
usb_find_busses();
|
||||
usb_find_devices();
|
||||
initizalized = 1;
|
||||
if (!getenv("XUSB_NOLOCK"))
|
||||
if (!xtalk_option_no_lock())
|
||||
xusb_unlock_usb();
|
||||
}
|
||||
}
|
||||
|
||||
/* XTALK option handling */
|
||||
static int use_clear_halt = 1;
|
||||
static int libusb_no_lock = 0;
|
||||
|
||||
static int xtalk_one_option(const char *option_string)
|
||||
{
|
||||
if (strcmp(option_string, "use-clear-halt") == 0) {
|
||||
use_clear_halt = 1;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(option_string, "no-use-clear-halt") == 0) {
|
||||
use_clear_halt = 0;
|
||||
return 0;
|
||||
}
|
||||
if (strcmp(option_string, "no-lock") == 0) {
|
||||
libusb_no_lock = 1;
|
||||
return 0;
|
||||
}
|
||||
ERR("Unknown XTALK_OPTIONS content: '%s'\n", option_string);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int xtalk_option_use_clear_halt(void)
|
||||
{
|
||||
return use_clear_halt;
|
||||
}
|
||||
|
||||
int xtalk_option_no_lock(void)
|
||||
{
|
||||
return libusb_no_lock;
|
||||
}
|
||||
|
||||
int xtalk_parse_options(void)
|
||||
{
|
||||
char *xtalk_options;
|
||||
char *saveptr;
|
||||
char *token;
|
||||
int ret;
|
||||
|
||||
xtalk_options = getenv("XTALK_OPTIONS");
|
||||
if (!xtalk_options)
|
||||
return 0;
|
||||
token = strtok_r(xtalk_options, " \t", &saveptr);
|
||||
while (token) {
|
||||
ret = xtalk_one_option(token);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
token = strtok_r(NULL, " \t", &saveptr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
21
zonedata.c
21
zonedata.c
@@ -59,11 +59,18 @@ struct tone_zone builtin_zones[] =
|
||||
.description = "Australia",
|
||||
.ringcadence = { 400, 200, 400, 2000 },
|
||||
.tones = {
|
||||
{ DAHDI_TONE_DIALTONE, "413+438" },
|
||||
|
||||
{ DAHDI_TONE_DIALTONE, "415+440" },
|
||||
{ DAHDI_TONE_BUSY, "425/375,0/375" },
|
||||
{ DAHDI_TONE_RINGTONE, "413+438/400,0/200,413+438/400,0/2000" },
|
||||
/* XXX Congestion: Should reduce by 10 db every other cadence XXX */
|
||||
{ DAHDI_TONE_CONGESTION, "425/375,0/375,420/375,0/375" },
|
||||
/* The Australian congestion tone is 425Hz, 375ms On, 375ms Off, with the
|
||||
* second cadence being half the amplitude of the first; so the first cadence
|
||||
* is approximately -10dB with the second one being -20dB. Using the update
|
||||
* ToneZone.c file, this can be accomplished by adding the "@" symbol in front
|
||||
* of the frequency to reduce amplification, as in the following entry for
|
||||
* Congestion:
|
||||
*/
|
||||
{ DAHDI_TONE_CONGESTION, "425/375,0/375,425@/375,0/375" },
|
||||
{ DAHDI_TONE_CALLWAIT, "425/100,0/200,425/200,0/4400" },
|
||||
{ DAHDI_TONE_DIALRECALL, "413+428" },
|
||||
{ DAHDI_TONE_RECORDTONE, "!425/1000,!0/15000,425/360,0/15000" },
|
||||
@@ -928,6 +935,8 @@ struct tone_zone builtin_zones[] =
|
||||
{ DAHDI_TONE_RECORDTONE, "1400/400,0/15000" },
|
||||
{ DAHDI_TONE_INFO, "950/330,1440/330,1800/330,0/1000" },
|
||||
{ DAHDI_TONE_STUTTER, "!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425" },
|
||||
/* DIALRECALL - not specified */
|
||||
{ DAHDI_TONE_DIALRECALL, "!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440" },
|
||||
},
|
||||
.dtmf_high_level = -10,
|
||||
.dtmf_low_level = -10,
|
||||
@@ -948,6 +957,8 @@ struct tone_zone builtin_zones[] =
|
||||
/* This should actually be 950+1400+1800, but we only support 2 tones at a time */
|
||||
{ DAHDI_TONE_INFO, "!950+1400/300,!0/1000,!950+1400/300,!0/1000,!950+1400/1000,0" },
|
||||
{ DAHDI_TONE_STUTTER, "!450/100,!0/100,!450/100,!0/100,!450/100,!0/100,!450/100,!0/100,!450/100,!0/100,!450/100,!0/100,450" },
|
||||
/* DIALRECALL - not specified */
|
||||
{ DAHDI_TONE_DIALRECALL, "!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440" },
|
||||
},
|
||||
.dtmf_high_level = -10,
|
||||
.dtmf_low_level = -10,
|
||||
@@ -996,6 +1007,8 @@ struct tone_zone builtin_zones[] =
|
||||
{ DAHDI_TONE_INFO, "950/333,1400/333,1800/333,0/1000" },
|
||||
/* STUTTER TONE - not specified */
|
||||
{ DAHDI_TONE_STUTTER, "!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425" },
|
||||
/* DIALRECALL - not specified */
|
||||
{ DAHDI_TONE_DIALRECALL, "!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440" },
|
||||
},
|
||||
.dtmf_high_level = -10,
|
||||
.dtmf_low_level = -10,
|
||||
@@ -1044,6 +1057,8 @@ struct tone_zone builtin_zones[] =
|
||||
{ DAHDI_TONE_INFO, "950/330,1450/330,1850/330,0/1000" },
|
||||
/* STUTTER TONE */
|
||||
{ DAHDI_TONE_STUTTER, "380+420" },
|
||||
/* DIALRECALL - not specified */
|
||||
{ DAHDI_TONE_DIALRECALL, "!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440" },
|
||||
},
|
||||
.dtmf_high_level = -10,
|
||||
.dtmf_low_level = -10,
|
||||
|
||||
Reference in New Issue
Block a user