Compare commits

...

177 Commits

Author SHA1 Message Date
Keith Morgan
31cca182bf Reported by Trent Creekmore
DAHTOOL-73
Changed the output to match the command needed for installing init scripts.
2018-09-20 17:54:03 +00:00
Tzafrir Cohen
75eedd6fa6 Ignore quilt .pc directory, used in deb packaging
Debian packaging uses quilt to manage patches. Book-keeping for them is
done using quilt (either directly, or in a compatible format), and
tracked in the directory .pc .

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2018-01-11 15:50:28 +02:00
Tzafrir Cohen
b54ec6efd3 xpp: dahdi_registration: wait at end of assignments
Wait for assindments to end only after calling all of them.
Otherwise we are likely to get a timeout with multiple Astribanks.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-12-24 18:02:29 +02:00
Oron Peled
754d981621 Avoid a race between /etc/init.d/dahdi and hotplug scripts:
* On some systems/configurations, dahdi init script may kick in
  during the time that hotplug scripts are configuring spans.

* It may lead to a race since the init script runs "dahdi_auto_assign_compat"
  which calls "dahdi_registration" and that tries to run
  "dahdi_span_assignments auto ..."

* Use the newly-added "dahdi_span_assignments" "unmatched" operation.

* Now the "dahdi_auto_assign_compat" script only runs "dahdi_registration"
  if there are no "unmatched" Astribanks.

* This prevents the race in fully configured systems.
  The race may still exist on partially-configured systems.
2017-08-31 19:00:02 +03:00
Oron Peled
dc95a1164f dahdi_span_assignments: matched and unmatched
Add two new subcommands to dahdi_span_assignments:
* matched: list all spans that are in devices that have been registered
  and are matched by span_assignments.conf lines.
* unmatched: list all such existing spans that have not been matched
  by span_assignments.conf lines.
2017-08-31 18:56:33 +03:00
Tzafrir Cohen
9631938e90 dahdi_span_types: compare
This adds an extra subcommand: compare: shows span that have been
configured (in /etc/dahdi/span_types.conf) to a different value than
the one currently active on the system.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-06-26 17:01:09 +03:00
Tzafrir Cohen
55679791b5 xpp_fxloader: Also look for udevadm in /bin
* udevadm is being moved to /bin. /sbin/udevadm will remain as a
  compatibility symlink.
* xpp_fxloader should also look for /bin/udevadm in addition to
  /sbin/udevadm and /sbin/udevsettle
* Reverse the order: look for newer ones first.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-06-26 17:01:01 +03:00
Tzafrir Cohen
ba09742a3f xpp: prevent dracut from loading Astribank drivers
Prevent an early load of the Astribank (xpp) drivers at initrd time, as
they require some files from the root filesystem.

This installs a file in the dracut configuration directory that will
take effect the next time dracut generates an initrd image.

This installs an configuration file for dracut which is ignored if
dracut is not installed and is a no-op if xpp_usb is not loaded on your
system.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-03-22 17:07:27 +02:00
Tzafrir Cohen
e4197cc499 xpp: README: libusb1
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-03-21 18:46:05 +02:00
Tzafrir Cohen
abd139ae91 xpp: README: hwid attribute of the xpd sysfs node
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-03-21 18:45:54 +02:00
Dima Stoliarov
6b2c6d72d8 xpp_fxloader: Also load PIC of FXS module type 6
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-03-21 13:42:35 +02:00
Tzafrir Cohen
f64500c986 xpp: run xpp_sync when an Astribank is connected
This was originally done in the init script after all Astribanks were
connected. But now there is no single point in the startup sequence
where we can guarantee all of them were loaded.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2017-03-02 11:11:54 +02:00
Tzafrir Cohen
424157834d Don't install xtalk_send
xtalk_send is a helper tool for xtalk, a low-level libary used by some
Xorcom DAHDI userspace tools. It is hardly needed by most people.
2016-11-15 15:39:28 +02:00
Tzafrir Cohen
95d03118cb Typos. Mostly by Lintian
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2016-06-26 22:54:58 +02:00
Oron Peled
99e3c572d1 build fix: external CFLAGS are ignored
* When passing CFLAGS to ./configure, they are ignored.
* The reason is that in Makefile.am CFLAGS are clobbered.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2016-03-13 14:05:46 +02:00
Tzafrir Cohen
6057ef25e9 xpp: perl man pages: Perl may be upper case
In file's output Perl scripts may be 'awk or perl script',
'/usr/bin/perl script' or 'Perl script' (with some minor variants). The
latter was not detected by current code and thus perld man pages were
not created.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2016-02-17 17:40:54 +02:00
Oron Peled
e1da7b5284 link libtonezone directly to libm
* Now we properly '-lm' to libtonezone itself.
  Tools that link with libtonezone get it automatically without having
  to individually link it.
  - dahdi_cfg historically needed -lm, but no longer does.

* Also use "autoscan" to refresh "configure.ac":
  - Added missing tests
  - Move AC_CHECK_HEADERS() to their correct location (before testing
    libraries).
* Fixes the following (on Ubuntu-14.04):
      CCLD     dahdi_cfg
    ./.libs/libtonezone.so: undefined reference to `sin'
    ./.libs/libtonezone.so: undefined reference to `cos'
    ./.libs/libtonezone.so: undefined reference to `pow'
    collect2: error: ld returned 1 exit status
    make[2]: *** [dahdi_cfg] Error 1

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2016-02-15 17:22:21 +02:00
Tzafrir Cohen
f105a09eda Remove rcsid: Unused since move to Git
* While technically Git can support $ID keywords, in practice they are not
  used.
* GCC now give a warning about ''rcsid' defined but not used' for some
  of those.

Let's just remove the unused rcsid.
2016-02-15 17:22:21 +02:00
Oron Peled
212b247e68 xpp: move tools man-pages into PBX_USB conditional
* Otherwise, they pull compilation of xpp tools via implicit rules.
* This breaks build without libusb/libusbx
* To test this scenario:
    ./configure .... --without-libusb --without-libusbx

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2015-12-22 11:24:52 -06:00
Oron Peled
f225a5692c configure.ac: remove unused PKG_CONFIG_LIBUSB
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2015-12-22 11:24:52 -06:00
Tzafrir Cohen
cffc5158cc dahdi_cfg: -S has assumtions on system.conf order
dahdi_cfg's -S (apply only to a specific span) uses the array chan2span
to map channel numbers to span numbers.

The problem is that it assumes that channels first appear in system.conf
immediately after the span line of a specific span. Thus the following
configuration breaks it:

span=1,...
span=2,...
clear=1-2,4-5
dchan=3,6

The best fix for that is to require -C to be used when -S is used (which
is already the case in our udev hooks).

Fixes DAHTOOL-69.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-16 15:54:23 +02:00
Oron Peled
42850dba35 xpp: refactor manual pages out of conditionals
* So they are always included in 'make dist' even if PBX_USB is false.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:06:25 +02:00
Oron Peled
06ae8473d7 xpp: Move astribank_license to libastribank
* So it's available to all utilities

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:06:06 +02:00
Oron Peled
dbb5ba6db6 xpp: allow XTALK_OPTIONS from a file
* The file is defined as XTALK_OPTIONS_FILE (/etc/dahdi/xpp.conf):
  - Lines beginning with '#' are skipped.
  - Line beginning with "XTALK_OPTIONS" are used.
  - Anything after whitespaces (with optional "=" characters) is part
    of the value.

* An environment variable named "XTALK_OPTIONS" may override file contents.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:05:44 +02:00
Oron Peled
2097f1adc5 configure.ac: xpp: now libusbx is the default
* Fallback to old libusb-0.1 if libusbx isn't found.
* Can force either: --{with,without}-{libusb,libusbx}

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:05:21 +02:00
Oron Peled
d02361e99f xpp: strict compilation flags in oct612x/
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:04:49 +02:00
Oron Peled
77a3d8b0a7 xpp: don't use USB "clear-halt" by default
* Problematic with USB3 controllers

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:04:41 +02:00
Oron Peled
bd49fc9d95 xpp: xtalk -- no private status range
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:04:13 +02:00
Oron Peled
0e6b068e89 xpp: migrate everything to libxtalk
* Build new libxtalk as local convenience library
 * Have new mpptalk.[ch] and astribank.[ch] wrap the new API
 * Modify all tools to use the new API

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:04:04 +02:00
Oron Peled
9c61e40187 xpp: add all base libxtalk files
* Do not remove yet the old ones.
* So new files are built, but not used yet.
* Build as a "noinst_" convenience library.
* Also, compile with '-Wno-unknown-pragmas' because we use some pragmas.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:03:43 +02:00
Oron Peled
5ee15a2337 configure.ac: add libusb/libusbx support (for xpp)
* Use pkg-config
* For tight control have: --with-libusbx, --with-libusb
  - For now, we choose libusb (AKA libusb-0.1)
  - After committing support for libusbx (AKA libusb-1.0)
    we'll change the default.

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:00:54 +02:00
Oron Peled
01faf597d6 xpp: automake: cleanup $man_MANS handling
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 18:00:14 +02:00
Tzafrir Cohen
48b25e849f xpp.rules: increase xpp_fxloader timeout to 180s
Allow firmware loading to take much longer (up to 180 seconds) before
it is killed. The default timeout is 30 seconds.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-05 17:59:42 +02:00
Tzafrir Cohen
d239b8dc4d ignore: dahdi_pcap and .version
.version is generated in the git tree.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2015-11-05 17:53:40 +02:00
Tzafrir Cohen
4676ad6671 make_version: cut off slashes in git
If we are based on a git tag with a name (such as 'upstream/2.10.2'),
remove everything up to the slash.

While we're at it, remove a leading '1%' that gets into the version
string as part of the version tag (a Debian version with an epoch: '1:'
is converted to '1%').

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2015-11-05 17:53:25 +02:00
Tzafrir Cohen
b471526700 Makefile: build asciidoc with TZ=UTC
In order to support a reproducable build, always run asciidoc with the
timezone UTC. This makes sure that the time shown in the file will be
the same, regardless of the location from which it is run.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-11-02 10:27:08 +02:00
Russ Meyerriecks
855772135c wcb4xxp: Adds support for b43x/b23x products
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2015-10-26 16:51:50 -05:00
Oron Peled
ec1ebffa89 xpp: bugfix: waitfor_xpds twinstar, auto_assign_spans
Exposed in twinstar setups where dahdi has auto_assign_spans=1:
* We start configuration with an empty /etc/dahdi/xpp_order
* If "XPP_HOTPLUG_DAHDI=yes", the astribank_hook removes
  the asterisk_is_starting semaphore too early.
* There's no point in waiting for non-existant or empty /etc/dahdi/xpp_order

Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-07-19 13:15:01 +03:00
Tzafrir Cohen
9afcde3f1e README: document the need for autoreconf
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-06-27 01:56:02 +03:00
Russ Meyerriecks
9a181ccfbc xpp: Fix a logical not being applied to the wrong operand
gcc 5 found this with the new -Werror=logical-not-parenthesis warning. Since we
have -Wall by default, it would also fail the compile.

Internal-Issue-ID: DAHLIN-347

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
2015-06-22 13:45:54 -05:00
Tzafrir Cohen
10c1cd196e Force-link libtonezone.so.2.0 on make install
Use ln -sf to create libtonezone.so.2.0 on the install target

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-06-14 16:29:30 +03:00
Tzafrir Cohen
65ba28fe4a A placeholder for the m4 directory
The m4/ directory needs to exist
2015-06-02 14:41:34 +03:00
Oron Peled
66e2c3ba11 autotools: now "make distcheck" also works.
* Fix distcheck by having all the targets installed under $prefix
* But by default (no prefix or prefix=/usr), revert to older pathes:
  - /etc/dahdi
  - udev rules in /etc/udev/rules.d
  - perl in perl sitelib
  - man pages in /usr/share/man
* Add configure options:
  --with-udevrules= (e.g.: /lib/udev/rules.d)
  --with-perllib= (e.g.: `perl -V:vendorlib)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-26 13:57:36 +03:00
Oron Peled
94ca4a1bb4 automake: remove unused stuff from Makefile.legacy
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-26 12:19:35 +03:00
Oron Peled
af920cd079 automake: bugfix: fix installation paths
* Install to $datadir/dahdi and not $datadir/dahdi-tools
* Install to $includedir/dahdi and not $includedir/dahdi-tools

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-26 12:18:30 +03:00
Tzafrir Cohen
b375bb80b8 Update README
Reflect recent changes as well as soem long-due fixes.
2015-05-19 20:58:50 +03:00
Oron Peled
0090086bce automake: handle "make dist"
* "make distcheck" still fails

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
f21b592f68 automake: migrate dahdi_pcap from Makefile.legacy
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
d63812bd73 automake: migrated "--enable-dev-mode"
* Fix small compile warnings (which are now errors):
  - hdlcgen.c
  - hdlcstress.c (remove return value which isn't checked)
  - patlooptest.c

* Also added dev-mode to xpp with relevant compile fixes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
bf9500ab32 automake: migrate tools from Makefile.legacy
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
703db3bcc3 automake: handle doc/ man-pages
* Install via doc/Makefile.am
* Remove relevant code from Makefile.legacy
* For now, leave the conversion to HTML in Makefile.legacy

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
b5b32a438f automake: xpp: remove xpp/Makefile.legacy
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
4cc7df1089 automake: xpp: handle /usr/share/dahdi
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
ac6f437317 automake: xpp: handle udev rules
* Set udev installation directory to $sysconfdir/udev/rules.d
* Add definitions to xpp/Makefile.am and remove them from xpp/Makefile.legacy
* TODO: add "--with-udev-rulesdir=" for packagers (/lib/udev/rules.d)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:54:11 +03:00
Oron Peled
b054abb7e9 automake: xpp: man-pages and perl-scripts
* Now man-pages and perl-script are handled by xpp/Makefile.am
* Removed from xpp/Makefile.legacy
* Detect perl and set perllibdir in configure.ac
* Handle modules in their own xpp/perl_modules/Makefile.am
* Enclose perl-related stuff in conditional
* Updates for "make dist"

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 19:52:15 +03:00
Oron Peled
ee83afa669 automake: handle xpp/ compilation via Makefile.am:
* Added xpp/oct612x/Makefile.am:
  - Compile octasic sources into a convenience library (static, not installed)
  - Set OCTASIC_CFLAGS in configure.ac, as they are used in two
    Makefile.am's
  - Added relevant Makefile.in and Makefile into build_tools/make_dist

* In xpp/Makefile.am:
  - Have USE_OCTASIC conditional (currently configure.ac always set it to true)

* Added PBX_USB automake conditional, so we only build our tools if
  configure'd for libusb.

* Create two convenience libraries (libastribank and libecholoader)
  Statically link them into our tools.

* Handle man-pages for the tools.

* Remove all new functionality from xpp/Makefile.legacy -- it now
  contains:
  - All perl related tools and man-pages
  - Other misc stuff (udev files, etc.)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 17:01:55 +03:00
Oron Peled
5ac7fef4b2 automake: full ppp/ support
* Remove ppp/Makefile.legacy
* The ppp/Makefile.am includes complete functionality

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 16:31:57 +03:00
Oron Peled
6df9a492a0 automake: add basic libtool support
* Also:
  - Add libtool-related files into "make dist"
  - Update .gitignore

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 16:27:34 +03:00
Oron Peled
fc620819b6 automake: add basic framwork
* Added needed boilerplate to configure.ac

* Wrap original Makefile's with automake:
  - Renamed all original Makefile -> Makefile.legacy
  - Force automake generated Makefile to call Makefile.legacy:
    Currently handle: all, install, clean, distclean, dist, docs, config
  - Note: our temporary 'dist' target conflicts with automake 'dist' target.

* Temporarily added extra dist files into build_tools/make_dist
  (until we move "make dist" functionality into automake)

* For now, we don't try to compile ppp/ as it wasn't compiled
  from the top-level Makefile before.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 16:22:10 +03:00
Oron Peled
723b3ce87f autoconf: rename "dahdi" to "dahdi-tools"
Autoconf use this name as the "PACKAGE_NAME":
 * Available as a macro to compiled code and Makefile's
 * With automake, this determines the name of the tarball
   produced in "make dist"

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 15:55:04 +03:00
Oron Peled
5fd1ce5ca0 build: remove unused "update" target from Makefile
The 'update' makefile target seems unused as it has not been
updated to use git.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 15:52:35 +03:00
Oron Peled
41532ca8a1 build: generate version.c during configure
The TOOLSVERSION was inconsistent in configure.ac and Makefile:
* Rename the second parameter to AC_INIT() into short_version
* Calculate TOOLSVERSION during configure and use it to
  generate version.c from version.c.in
* For now, leave duplicate TOOLSVERSION in Makefile (for make dist)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 14:32:44 +03:00
Oron Peled
fbb6c1a17e build: xpp -- remove legacy usb-hotplug
Hotplug is the system that predated udev. No longer supported anywhere
sane.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 14:29:20 +03:00
Oron Peled
131d694054 build: fix ppp/Makefile CFLAGS
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 14:26:53 +03:00
Oron Peled
010c4d836c build: remove unused xpp/oct612x/Makefile
* Octasic sources are built from xpp/Makefile

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 14:25:30 +03:00
Oron Peled
025b9a5593 build: remove unused build_tools/menuselect-deps.in
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 14:24:37 +03:00
Oron Peled
c863d1d2c2 build: remove autoconf generated files
* Remove autoconf related files
* Add needed ones to "dist"
* Ignore config.guess, config.sub (currently they aren't used)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-05-19 14:20:45 +03:00
Tzafrir Cohen
77730a9059 xpp_fxloader: handle empty span-type.conf
If we have /etc/dahdi/span-types.conf but it doesn't have any
line, we should avoid using the option -S to astribank_hexload.
Fix the test for this.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-03-31 22:37:10 +03:00
Tzafrir Cohen
3f55dd78de no astribank_is_starting with hotplug asterisk
Don't run the final astribank_is_starting if asterisk is hotpluggable.

Likewise, if there's no xpp_order file, waiting is pointless as the hook
can't count Astribanks.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2015-01-21 20:47:36 +02:00
Tzafrir Cohen
283f01bd67 astribank_hook: remove useless 'time'
* 'time' was added here for debugging and never actually needed.
* It actually causes a minor bashism issue.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-12-07 11:53:07 +02:00
Oron Peled
631d32680f xpp: waitfor_xpds: Always remove Astribank semaphore
If we waited -- no Astribanks are "in initialization"

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-11-06 13:29:19 +02:00
Oron Peled
44fe560f3b xpp/astribank_hook: remove Astribank initialization
If this is the last seen Astribank

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-11-06 13:29:19 +02:00
Oron Peled
1a78b71fac xpp: waitfor_xpds: documentation
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-11-06 13:29:19 +02:00
Oron Peled
f11b937659 xpp: can use modern Asterisk hotplug support
* New asynchronous behavior is used only when two conditions are met:
  - Finding new $ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes in /etc/dahdi/init.conf
    This should be set only when Asterisk support hotplug and configured
    to use it (no_failed_channels==1).
  - DAHDI auto_assign_spans==0

* Adapt /usr/share/dahdi/astribank_hook:
  - Refactor old twinstar behavior into functions
  - Add new behavior in a function (just enable the Asrribank watchdog)
  - Call the correct function.

* Adapt init script:
  If asynchronous behavior is on, don't wait for all Astribanks to
  finish initialization (it's enough that we saw all/some of them)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-11-06 13:29:19 +02:00
Oron Peled
cd6083b6ce xpp: waitfor_xpds: assume astribank_is_starting exists
It's in the same package (dahdi-tools) for a long time

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-11-06 13:29:19 +02:00
Oron Peled
0eb77e626e xpp: waitfor_xpds: expansion error with no ABs
Fix an exansion error in case there were no Astribanks on the system.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-11-06 13:29:19 +02:00
Oron Peled
2e1c15baa3 xpp: astribank_is_starting: improve '-v' output
Do print a message if no semaphore exists. It means that either there
are no Astribanks, or existing Astribanks were already initialized.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-11-06 13:29:19 +02:00
Russ Meyerriecks
094bb2c1e8 tonezone: Fix regression in Australian tone patch
Initialize db to 1.0 instead of doing it in a few, but not all, logic contexts.

Reported-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-09-16 19:07:17 -05:00
Oron Peled
9aee76a3a5 xpp: revert USB "clear_halt" change and better overrides.
Why:
 * Doing "clear_halt" is normally the right thing to do on startup.
 * The original observed problem is better fixed via USB bios settings.
 * Defaulting to no "clear_halt" cause more problems on other platform
   combinations (hardware/kernel).

The change:
 * We now reverted to do "clear_halt" by default.
 * The XTALK_OPTIONS may now contain either "use-clear-halt" (the default)
   or "no-use-clear-halt" to override for debugging/testing.

Original commit: ca7c04e9cb

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-08-18 15:15:06 +03:00
Tzafrir Cohen
d4537e46ce xpp: astribank_hexload: allow empty span specs
DAHDI 2.9.2 added support for -S (span specs). However if this option
was not specified, it fails to run.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-08-04 09:35:52 +03:00
Tzafrir Cohen
60401c5f49 xpp_fxloader: rename variable: default_law -> law
The variable 'default_law' was the result of a partial renaming of the
original variable 'law'. Let's keep all of them in sync.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-08-04 09:35:52 +03:00
Armen Karlozian
a109763160 tonezone: Fix congestion tone for Australia
The Congestion tone in Australia must be reduced by 10 to 15 dB
at every other cadence and the frequencies for both at cadences are 425 Hz.

From: Armen Karlozian <armeniki@hotmail.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-08-01 16:04:00 -05:00
Shaun Ruffell
6c40704fec zonedata: Ensure all zones have a default DAHDI_TONE_DIALRECALL.
The default 'us' tone is most likely better than silence when Asterisk tries to
generate the recall tone on a DAHDI channel.

Internal-Issue-ID: DAHTOOL-63
Reported-By: Igor Kravets
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-08-01 15:53:48 -05:00
Russ Meyerriecks
95e9dd71d8 dahdi_cfg: Reduce mass ioctls on non-existing channels
Logic was calling DAHDI_SPECIFY ioctl on all channels up to maximum channel
limit. Added a short circuit to prevent the ioctl on channels that aren't
configured.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
2014-07-23 16:53:38 -05:00
Russ Meyerriecks
df47721962 dahdi_cfg: minor: Rename fo_real to dry_run
Minor readability change

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
2014-07-23 16:52:59 -05:00
Russ Meyerriecks
4e14561508 wcte43xp: Teach tools about te436 and te236 products
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-07-18 10:41:54 -05:00
Shaun Ruffell
49361e5ce7 dahdi_cfg: Warn if idle bits are set on invalid channel type.
Hopefully will save a little time in the future if anyone ever types into
/etc/dahdi/system.conf:

  bchan=1-15,17-30:1101

when they meant:

  cas=1-15,17-30:1101

in the future.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-07-09 15:55:37 -05:00
Shaun Ruffell
8045f7f493 dahdi_cfg: Unlink semaphore on early exit.
If dahdi_cfg is terminated while holding the named semaphore, it is possible to
leave it behind and all subsequenct invocations of dahdi_cfg will block waiting
for it.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-07-07 17:06:16 -05:00
Tzafrir Cohen
64e7c688d3 Makefile: A typo in a comment
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-06-30 13:47:23 +03:00
Oron Peled
b28ec382bb added autoconfig.h to .gitignore
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-06-29 16:34:24 +03:00
Oron Peled
412c3f0fe3 xpp: support per-port E1/T1 EC
* Added optional '-S <span-spec>' argument to astribank_hexload:
  - Allow passing PRI span specification to EC firmware loader.
  - The span specifications is whitespace/comma separate list
    of items.
  - Each item is: <span>:<type> (Example: 3:T1)
  - The <span> may use shell-like globbing (e.g: *:E1 or [12]:T1)
  - Any span not matched in the span specification will be set
    as without the new '-S' option (i.e: depends on the '-A' option).

* Adapted xpp_fxloader:
  - Read specification for both device label and wildcard from
    /etc/dahdi/span-types.conf
  - If the result is non-empty, pass it as '-S <span-spec>' to
    the EC firmware loader.
2014-06-29 16:34:21 +03:00
Oron Peled
fc459c374c xpp: set EC firmware according to PRI settings:
* Read first from modern configuration files
  (/etc/dahdi/span-types.conf)
  - Support either exact label match or complete '*' match in the
    configuration file.

* Fallback to legacy /etc/dahdi/xpp.conf

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-06-29 16:34:17 +03:00
Oron Peled
ca09f327ed xpp: better dahdi_registration
Improvements to the xpp tool dahdi_registration:

* Use the new xpp driver with support for dahdi_registration sysfs
  attribute in each device.

* Wait for UDEV to finish handling span assignments (via
  dahdi_waitfor_span_assignments).

* Still supports legacy drivers without this, by falling back
  to old style iterative "registration" on each xpd.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-06-29 16:30:34 +03:00
Tzafrir Cohen
b1d55683ae xpp: Don't generate .depends if there's no libusb
Creating the The .depends file requires libusb support.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-06-10 12:41:43 +03:00
Oron Peled
9285e86492 xpp: better error checking (echo_loader)
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-11 19:07:40 +03:00
Oron Peled
ca7c04e9cb xpp: fix usb "clear_halt" problem
* Don't use "usb_clear_halt" by default anymore
   - It caused problems with specific devices in the past
   - Now it cause problems with specific servers as well (64 bits, USB3)

 * Add an "XTALK_OPTIONS" environment variable to pass options:
   - Use it to implement a "use-clear-halt" boolean option that
     restore original behavior.
   - Also use it for "no-lock" option which replace the legacy
     environment variable "XUSB_NOLOCK".
2014-05-11 18:03:11 +03:00
Oron Peled
ae02edacb4 xpp: safer compilation
* Compile with "-Wall -Werror"
* Better dependency calculation:
  - Explicit listing of sources, don't use wildcards.
  - Pass various CFLAGS to dependency calculation as well.
  - Make sure a failure is propagated

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-05-11 18:03:11 +03:00
Shaun Ruffell
2abfd165ae system.conf.sample: Remove reference to single frequency signalling.
Single frequency signalling has not been supported in dahdi_cfg since the switch
to DAHDI. Before DAHDI, in the Zaptel days, it was only suported in the
ztcfg_dude utility which wasn't mainlined. So this removes references to those
signalling modes unless support is added back into the driver.

Internal-Issue-ID: DAHLIN-335
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-05-05 09:45:02 -05:00
Oron Peled
1e6b2741db dahdi_genconf: remove hard-coded E1 default
* The "spantypes" generator had E1 default if no 'line-mode' parameter
  was passed.

* As a result the new logic in "dahdi_span_types dumpconfig" had no
  effect when called from dahdi_genconf, as it was always called
  with "--line-mode=" argument.

* Now "dahdi_genconf spantype" behaves just like
  "dahdi_span_types dumpconfig":
  - The "--line-mode=" forces generation of provided line-mode (E1/J1/T1)
  - Without this option, the generated config matches the current spans
    state according to new dahd_span_types default logic:
    - Wildcard rule if all spans have same line-mode.
    - Uncommented specific matches if spans have different line-modes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-04-30 22:51:58 +03:00
Oron Peled
794c8eb048 xpp: waitfor_xpds: handle missing serial numbers
Fixes a regression since 949ea4ca9f
(2.7.0) - allows using an Astribank with no serial.

* Some of the olderst Astribanks don't have a serial number burned in
  them. Thus there is no serial attribute for the sysfs USB device node.

* waitfor_xpds identifies the Astribanks by their serial numbers.

* An lone Astribank without serial number would thus block waitfor_xpds
  (until timeout).

* Now we warn about them.

* We also try to handle it gracefully. As long as there's only one
  of thease, it would be counted as "NO-SERIAL".

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-04-30 22:48:06 +03:00
Oron Peled
ffe36c63e0 xpp: dahdi_registration: force re-assignment
* The system state causing the bug:
  - DAHDI has auto_assign_spans==1
  - No /etc/dahdi/assigned-spans.conf

* The bug scenario:
  - During initial device detection, they are assigned by
    DAHDI driver.
  - Later we run "dahdi_span_assignment remove"
  - Then, a "dahdi_registration on" would not assign any span.

* The fix:
  - Using the '-R' option, force "dahdi_registration on" to also
    do "dahdi_span_assignment auto" on relevant devices.
  - This is the way it's called by /usr/share/dahdi/dahdi_auto_assign_compat

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
2014-04-30 22:46:41 +03:00
Oron Peled
f2628eeedd improved dahdi_span_types dumpconfig
* Better defaults:
  - A wildcard match:
    - If '--line-mode' option is given, generate a wildcard entry.
      (existing behavior).

    - Otherwise, if *all spans* are of the same type (E1/T1),
      generate a wildcard entry for this type.
      This is the most common use-case and now it work without
      any command line flags.

    - Otherwise (mixed E1/T1 spans), do not generate a wildcard entry.
      This isn't common case (except from our labs), but regardless
      without '--line-mode' any guess could be wrong.

  - Specific device matches:
    - If all spans are of the same type, generate commented out
      specific entries (for manual overrides).

    - If spans have mixed E1/T1 types, generate specific entries
      In this case, specific entries MUST NOT be commented out
      otherwise, the configuration file is wrong!

* Generated header with better organization:
  - Shows what is generated:
    - Generating wildcard / Not generating wildcard
    - Generating specific lines / Generating *commented-out* specific lines

  - For each decision, show *why* it was taken.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-04-01 21:23:28 +03:00
Oron Peled
1292ea9078 registration-order: Added dahdi_auto_assign_compat
Maintains the original registration order as was before span
assignments. Should allow seemless trannsition to
dahdi.auto_assign_spans=0

* The idea:
  - We stop handling in udev the case of missing
    /etc/dahdi/assigned-spans.conf
  - Instead we rely on "registration_time" dahdi_device attribute from
    DAHDI-linux
  - Then, we can sort the devices and assign their spans in
    /etc/init.d/dahdi
* Mechanics:
  - From /etc/init.d/dahdi, we run a new 'dahdi_auto_assign_compat'
    script (after "waitfor_xpds" etc.)
  - In this script we "auto" assign spans of non-Astribank devices
  - In the end of the script we run "dahdi_registration" which
    does the same for Astribank devices.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-03-25 14:51:29 +02:00
Oron Peled
cfee27106b hotplug: call handle_device.d/ actions for remove
* Original actions didn't care about remove (10-span-types, 20-span-assignments)
* But others need to know about removals too.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-03-25 14:48:09 +02:00
Shaun Ruffell
066fa2aff3 dahdi_cfg: error()->perror() when sem_open fails.
This fixes a confusing error message. When sem_open failed, the system.conf line
number was being printed and the system error code was not.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-02-12 11:56:00 -06:00
Aslan Laoz
bce5afacf1 waitfor_xpds: handle the case of a failing AB
If an Astribank failed initialization, don't keep waiting for it.
2014-02-07 14:23:19 +02:00
Tzafrir Cohen
dd752529f0 auto_assign_spans may be true even if not '1'
auto_assign_spans is an int and may have legal values other than 1. It
is legal (though pointless) to use: modprobe dahdi auto_assign_spans=3.
Any value != 0 is true.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-02-07 14:22:49 +02:00
Shaun Ruffell
27d07446ef hotplug: Check for auto_assign_spans only when ACTION is add.
Removes a potentially confusing error message. This is a reapplication of
(4f259cd569 "dahdi_handle_device, dahdi_span_config: Check for
auto_assign_spans only when ACTION is add.") which appears to have been
accidentally removed when moving the hotplug scripts into a subdirectory.

From the original commit:

When dahdi.ko is unloaded, it may be possible for the driver to be removed from
the kernel before the udev scripts are run.  When this happens, you'll see
messages like the following which are not accurate:

    'dahdi_handle_device'[24567]: Old driver (no auto_assign_spans parameter). Skip /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Now instead you will see:

    'dahdi_handle_device'[28008]: remove: /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Also, all the udev events will be logged in the system log even when they are
ignored because of legacy auto span assignment. This will help show what is
going on during the transition period to full udev configuration of spans.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2014-01-31 16:08:21 -06:00
Shaun Ruffell
8e2a5def27 hotplug: Do not run auto span configuration if spans are auto assigned.
This reapplies the change made in commit (6ed0adc08 "dahdi_span_config: Do not run auto
span configuration if spans are auto assigned.") which appears to have been
accidentally removed in (7f826a7d35 "hotplug modularization: split logic to
scriptlets").

To rationale from commit 6ed0adc08:

I have seen cases were users run:

  # modprobe <driver>; dahdi_cfg -c <custom config file>

and the spans end up misconfigured because dahdi_span_assignments ends up
running, via udev, after the user configured the span the way it wanted.

dahdi_span_assignments now looks at auto_assign_spans module parameter on
dahdi.ko, like dahdi_handle_device already does, to determine if legacy or udev
based configuration is being done.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2014-01-31 11:16:08 -06:00
Tzafrir Cohen
e553ffde2b README: udev hooks run scripts from directories
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-28 11:42:33 +02:00
Tzafrir Cohen
d1fb614ac8 hotplug: document asterisk scriptlet
A well-behaving distribution may choose not to install
span_config.d/50-asterisk as part of dahdi-tools, as it belongs in
asterisk. Still, it would be nice to be able to keep it as a documented
usage example. So just writ where this file needs to go and what it
does.

No other change: it is still installed by default.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-28 11:32:31 +02:00
Tzafrir Cohen
98ecc272d1 hyphen/minus fixes in man pages
in groff '-' creates a hyphen and for a minus (path, option, or similar)
you need '\-'.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-27 20:29:04 +02:00
Russ Meyerriecks
91768d360c dahdi.init: Don't exit on lack of /etc/dahdi/system.conf
auto_spans and dahdi_cfg -c are valid config methods which may not have a
/etc/dahdi/system.conf. We already check for the existance of the dahdi modules
before the case start, so I think it's safe to remove this section.

Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-23 16:25:56 -06:00
Tzafrir Cohen
63842cc4f3 bash_completion: fix dahdi_genconf
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-23 23:16:55 +02:00
Tzafrir Cohen
b8d1e467e4 dahdi_perl: fix regression with an AB with no modules
Fixes a regression introduced in
3572bb5a13 (before 2.7.0) - most of the
dahdi_perl tools will fail for an Astribank with no modules claiming
"No XPDs for '/sys/bus/astribanks/devices/xbus-00'"

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-23 22:32:45 +02:00
Tzafrir Cohen
de1ee8494a programmable bash completion for some commands
Programmable bash completion for dahdi_span_assignments,
dahdi_span_types and dahdi_genconf.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 22:30:47 +02:00
Tzafrir Cohen
d3feed5c4c dahdi_span_types: hush warning of missing attribute
Don't warn when a sysfs attribute does not exist.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 21:33:10 +02:00
Oron Peled
b621c02b7f Change span-type.conf generation policy
* Add '--line-mode=<E1|T1|J1>' option to dahdi_span_types:
  - Will first generate a wildcard entry (* *:<type>)
  - All later entries will be commented-out.
  - Manually uncommenting any of them will create an "override"
    (e.g: mixed system with all spans T1, but some E1)

* Now dahdi_genconf does not generate span-types.conf by default:
  - Added '--line-mode=<E1|T1|J1>' option to trigger generation
  - This parameter will be passed to "dahdi_span_types dumpconfig"
  - Also explicit specification of 'spantypes' as an argument will
    trigger a similar generation (with a default of 'E1').
  - The line-mode may also be passed to the generator directly
    with identical results. Example:
          dahdi_genconf spantypes=line-mode=T1

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 21:32:14 +02:00
Oron Peled
451a8b4d6f dahdi_span_types: allow defaults + overrides
* Allow wildcards for both device and span number (as before).
  Example:
     *        *:T1

* But now we are carefull to follow strict order in the configuration
  file. This means, if there are multiple matches -- last one wins.

* So we can use specialisation:
     *        *:T1	# Everything is T1
     FOO      [34]:T1	# Except spans 3,4 on the FOO device

* Added --dry-run and --verbose options.

* Updated the man-page:
  - Fixed "registered" => "assigned".
  - Use "line mode" for E1/J1/T1.
  - Document current changes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 21:28:59 +02:00
Tzafrir Cohen
09fd3f53b1 dahdi_span_assignments.8: s/register/assign/
* Use the term "assignment" instead of "registration" (for spans).
* Further fixes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-By: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 21:27:58 +02:00
Oron Peled
c3b020a155 new "dahdi_waitfor_span_assignments" tool
* Allows waiting until all spans are "assigned" or "unassigned"
* Current implementation use a polling loop with sleep
* Future implementation may block on sysfs attribute
  (like waitfor_xpds is blocking on sysfs Astribanks attribute)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 12:35:59 +02:00
Oron Peled
7f826a7d35 hotplug modularization: split logic to scriptlets
* Device related operations are ordered in /usr/share/dahdi/handle_device.d/
* Span related operations are ordered in /usr/share/dahdi/span_config.d/
* In the future, span_config.d/50-asterisk should be moved to Asterisk.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 12:35:59 +02:00
Oron Peled
cdedf024ae hotplug modularization: move sources to a subdir
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-23 12:35:59 +02:00
Russ Meyerriecks
a6203e151f wcte13xp: Teach tools about te131 te132 products
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 17:45:58 -06:00
Shaun Ruffell
69ce6f07e0 dahdi_cfg: Allow dynamic spans to handle udev based span assignment.
Prior to this commit, if auto_assign_spans was set to 0, it was possible to
get in an endless loop creating and destroying spans. The primary reason was
that all dynamic spans are destroyed and recreated each time dahdi_cfg runs, BUT
dahdi_cfg was run each time a new span showed up in udev when auto_assign_spans
was set to 0.

Now dahdi_cfg will only destroy and recreate dynamic spans if dahdi_cfg is run
without a specifc span number. Also, while creating dynamic spans, dahdi_cfg
will pause for up to one second for the span to be assigned in order to ensure
that the spans are numbered consistently when auto span assignment is
configured.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 12:58:57 -06:00
Shaun Ruffell
9989b8779c dahdi_cfg: Add semaphore to prevent parallel execution.
When dahdi is configured for fully dynamic configuration on a device and
span basis via sysfs and udev it is possible for multiple instances of
dahdi_cfg to be run in parallel on different spans. If this happens it
is possible to see errors on the console that tone zones are already
registered since the check for the existence of a tone zone and the
re-registering needs to be atomic.

dahdi_cfg will now prevent itself from running in parallel.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2014-01-22 12:58:57 -06:00
Shaun Ruffell
a4f79134c9 dahdi_handle_device: Auto assign only the device being added.
Eliminates trying to add spans multiple times as seen below:

    'dahdi_handle_device'[21993]: add: /devices/dynamic:loc:1
    'dahdi_handle_device'[21991]: add: /devices/dynamic:loc:0
    'dahdi_handle_device'[22001]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:0
    'dahdi_handle_device'[22001]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:1
    'dahdi_handle_device'[21999]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:0
    'dahdi_handle_device'[21999]: auto-assign /sys/bus/dahdi_devices/devices/dynamic:loc:1
    kernel: [ 3348.312534] dahdi_devices dynamic:loc:0: local span 1 is already assigned span 1
    kernel: [ 3348.312552] dahdi_devices dynamic:loc:1: local span 1 is already assigned span 2

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Shaun Ruffell
d8074f434f dahdi_span_types: Show location of configuration file in help message.
Makes similar in for the dahdi_span_assignments in that the location of the
default configuration file is shown in the help screen.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Shaun Ruffell
15875924f0 dahdi_genconf: Add 'modules', 'spantypes', and 'assignedspans' to list of available generators.
This is a documentation change, that hopefully will help until I can remember
the names of the new generators.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Tzafrir Cohen
a5bf1d3a2e dahdi_genconf: don't generate spantypes by default
A sane value for span-types.conf is either "all E1" or "all T1". Either
way it is not hardware-dependent, and hence no point in regenerating on
when the hardware changes.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:57 +02:00
Tzafrir Cohen
bf960799ea span_types/assignments: no * in device list
If there are no dahdi devices, $devbase/* expans to have a literal '*',
which leads to warnings such as:
/usr/sbin/dahdi_span_types: 1: cd: can't cd to /sys/bus/dahdi_devices/devices/*

Let's just avoid those.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2014-01-20 19:22:03 +02:00
Shaun Ruffell
4f259cd569 dahdi_handle_device, dahdi_span_config: Check for auto_assign_spans only when ACTION is add.
When dahdi.ko is unloaded, it may be possible for the driver to be removed from
the kernel before the udev scripts are run.  When this happens, you'll see
messages like the following which are not accurate:

    'dahdi_handle_device'[24567]: Old driver (no auto_assign_spans parameter). Skip /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Now instead you will see:

    'dahdi_handle_device'[28008]: remove: /devices/pci0000:00/0000:00:1e.0/0000:11:01.0/pci:0000:11:01.0

Also, all the udev events will be logged in the system log even when they are
ignored because of legacy auto span assignment. This will help show what is
going on during the transition period to full udev configuration of spans.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2014-01-08 17:56:52 -06:00
Tzafrir Cohen
4d5ca04ad6 README: Update the install targets
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-30 19:24:23 +02:00
Tzafrir Cohen
2d3580a3db README: document initialization
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-30 19:12:59 +02:00
Tzafrir Cohen
d96be70986 README: indentation level for config samples
Indent the configuration samples one level deeper

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-29 20:32:12 +02:00
Tzafrir Cohen
41a725adea .gitignore: more generated files
Ignore test binaries and files generated by 'make docs'

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-12-29 13:53:53 +02:00
Shaun Ruffell
6ed0adc086 dahdi_span_config: Do not run auto span configuration if spans are auto assigned.
I have seen cases were users run:

  # modprobe <driver>; dahdi_cfg -c <custom config file>

and the spans end up misconfigured because dahdi_span_assignments ends up
running, via udev, after the user configured the span the way it wanted.

dahdi_span_assignments now looks at auto_assign_spans module parameter on
dahdi.ko, like dahdi_handle_device already does, to determine if legacy or udev
based configuration is being done.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2013-12-21 00:02:22 -06:00
Tzafrir Cohen
5e75fa48f4 dahdi.rules: use += for RUN
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-12 23:47:50 +02:00
Tzafrir Cohen
4ab8e95d0b dahdi.rules: Replace SYSFS with ATTRS
SYSFS has been deprecated. Use ATTRS.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-12 23:47:50 +02:00
Shaun Ruffell
5ca600c7c7 dahdi_cfg: Wait for all spans to be assigned.
When auto span assignment is disabled, it's possible that simply running

  # /etc/init.d/dahdi restart

Will fail since dahdi_cfg can run in parallel with udev scripts that are
assigning spans, which results in /etc/dahdi/system.conf describing spans that
do not exist in the system.

This change sets up dahdi_cfg, when run without the -C or -S options, to look in
sysfs and make sure all spans for each device are assigned.  dahdi_cfg will wait
5 seconds for span assignment to happen before proceeding normally.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-12 09:08:51 -06:00
Oron Peled
98736e1add Makefile: do install all man-pages
Fixes a regression in 2.8 (ffced0ca) in the main Makefile:
MAN_PAGES gets assigned twice and thus most man pages will not get
installed.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-09 22:57:41 +02:00
Oron Peled
a9338d9b74 Makefile: new 'make-dist' target
Creates a tar.gz:
* Identical results to Digium's distributed tarballs
* Named "dahdi-tools-<version>.tar.gz"
* Only from committed files (uses git-archive)
* Adds a .version file

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-12-02 23:01:17 +02:00
Shaun Ruffell
c0e19d47e8 dahdi_span_assignments, dahdi_span_types: Allow conf file to be overridden.
The environment variables that specified the full path the the configuration
files for dahdi_span_types and dahdi_span_assignments was documented, but they
were not actually set from the environment.

Also, the case of the variable was changed to match the one for the directory
where the rest of the config files are located.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-26 13:50:02 -06:00
Shaun Ruffell
ffced0cad2 Add dahdi_ prefix to handle_device, span_types, span_assignments, and span_config.
All new dahdi tools and utilities will be prefixed with "dahdi_" in order to
avoid any future conflicts with other packages.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2013-11-26 13:50:02 -06:00
Shaun Ruffell
e298eb1237 span_types: Fix bug that would prevent matching on devpath.
If a configuration file was specified that used the devpath, like:

  # Device: [] @Board_ID_Switch_0 /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 1:E1
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 2:E1
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 3:E1
  /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0/0000:02:08.0/pci:0000:02:08.0 4:E1

Then the span_types script would silently fail to match the configuration lines
for the device and silently fail to change the linemodes.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Oron Peled <oron.peled@xorcom.com>
2013-11-25 16:11:37 -06:00
Tzafrir Cohen
a97d373d95 configure: regenerate for 6d10525
Regenerate configure script following changes in commit
6d10525863.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 18:11:04 +02:00
Shaun Ruffell
c27664dc1b dahdi.init: Remove spurious "Missing '/sys/bus/astribanks/drivers/xppdrv/sync'".
The xpp_sync will fail if there are not any Astribank devices loaded. Check for
existence of the tools before trying to sync.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 10:06:11 -06:00
Tzafrir Cohen
365a12f42a README: include pinned spans config files
Include pinned-spans.conf and span-types.conf in the generated
README.html. Reformat them to render properly.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-11-24 16:48:29 +02:00
Oron Peled
2a84216fe4 Terminology rename: "pinned" -> "assigned"
* File names fixed
* File contents fixed

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:42:15 +02:00
Oron Peled
791a596c07 dahdi.rules: add persistent channel names as well
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:39:33 +02:00
Oron Peled
d145364c00 dahdi.rules: don't process "add" events unless needed
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:38:43 +02:00
Oron Peled
0afba16b2e hotplug: run fxotune from span_config:
* Use fxotune -b/-e options to run on wanted channel range
2013-11-24 16:36:01 +02:00
Oron Peled
c163caca00 fxotune: Now options '-b/-e' also apply with '-s'
* Now we can limit fxotune "set" mode to specific channel range.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:35:10 +02:00
Oron Peled
c9e8ec7499 dahdi.rules: use tools_rootdir from driver
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:30:49 +02:00
Oron Peled
1356a55d77 span_types: fix for white-space in hardware_id
* Sanitize hardware_id/location attributes, just like span_assignments
* Allow control of keys via SPAN_ASSIGNMENTS_KEY or '-k <key>' option
* In general, import most features/options from span_assignments

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:22:58 +02:00
Oron Peled
10a6622774 udev scripts now read /etc/dahdi/init.conf
Added two override variables in init.conf:
* DAHDI_UDEV_DISABLE_DEVICES
* DAHDI_UDEV_DISABLE_SPANS

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:20:08 +02:00
Oron Peled
a4217f6977 sysfs: restored legacy names /etc/dahdi/<channo>:
Update dahdi.rules to create again the old fashioned device files
(/dev/dahdi/<channo>), but as symlinks to modern names.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:17:35 +02:00
Oron Peled
fb1a2b5572 added udev rules and their install target:
* Added missing Makefile install rule for dahdi.rules
* Pulled xpp.rules from dahdi-linux and added install rules for it

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:16:33 +02:00
Oron Peled
6d10525863 pinned-spans: remove '--enable-pinned' from configure
pinned-spans utilities are now essential:
* Called by udev rules
* Called by dahdi_genconf

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:13:51 +02:00
Oron Peled
a1d4355c20 pinned-spans: fix examples in configuration files
* Correctly use the new "location" attribute
* Document the possibility to match against sysfs devpath
  (used to be the "location")

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:08:31 +02:00
Oron Peled
b303802658 pinned-spans: fix configuration file names
* Install them as *.conf.sample -- that's what they are
* Correctly rename spantype.conf to span-types.conf (new name)

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
Acked-by: Russ Meyerriecks <rmeyerriecks@digium.com>
2013-11-24 16:05:11 +02:00
Shaun Ruffell
8d9a6bdd80 dahdi_genconf: Do not fail if pinned/assigned span utilities were not installed.
If you installed dahdi tools and did not specify DAHDI_PINNED=yes on the
makefile, when you run dahdi_genconf you would get an error like the following:

  # dahdi_genconf
  sh: span_types: command not found
  Command failed (status=32512): 'span_types dumpconfig > /etc/dahdi/span-types.conf' at ...

This change allows the generator for span-types.conf and span-assignements.conf
check for the existence of the utilities before attempting to call them.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-22 11:12:12 -06:00
Shaun Ruffell
bb19620c52 wcte43x: Teach tools about the wcte43x driver.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 15:40:11 -06:00
Shaun Ruffell
11310bde53 wcaxx: Teach tools about the wcaxx driver.
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
2013-11-11 15:39:51 -06:00
Tzafrir Cohen
b123bc87dd xpp_fxloader: support loading AB with ID > 201
Support loading firmware for Astribanks with bcdDevice > 2.01, as we'll
have 2.02 soon.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-21 16:55:18 +03:00
Oron Peled
299d9d9d9c fix typos in man-page
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-14 15:45:21 +03:00
Tzafrir Cohen
5e30a1401f Man pages for span_types and span_assignments
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 23:28:46 +03:00
Tzafrir Cohen
2f688f83c4 Remove dahdi_map, obsoleted by span_assignments
dahdi_map can be replaced by span_assignments list / dumpconfig

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 11:03:00 -04:00
Oron Peled
680f3e1d1d dahdi_registration: adapt to pinned-spans
* If xpp.dahdi_autoreg parameter is 'Y' -- Skip actuall registration.
* If dahdi.auto_assign_spans is '0' and there's no /etc/dahdi/pinned-spans.conf
  Than use 'span_assignments auto ...' to assign device spans.
* Since dahdi_registration iterate in correct xpp_order, the span
  assignment logic provides migration path for users who did not
  generate their pinned-spans.conf configuration yet.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 11:02:47 -04:00
Oron Peled
60fca920bc span_assignments: -k / --keys and more
* New functionality (documented in the script header):
  - Alternative "keys" for device matching
  - Added new command line options: --help, --dry-run, --verbose, --key

* Clean sysfs attribute contents from special characters in every use-case.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 11:01:56 -04:00
Tzafrir Cohen
c1e016fa33 Do the Right Thing when there's no config
Do the "right thing" (hopefully. At least for a system with a single
device) if there is are no configuration files:

* No span-types.conf: just ignore it as before. It is optional.
* No pinned-spans.conf: use span_assignments auto (same as having
  dahdi.auto_assign_spans=1).
* No system.conf: generate a temporary one with dahdi_genconf.

This will hopefully allow having a partially-working system, and help
making ut usable with 'span_assignments dumpconfig'. Or maybe just work
as-is.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-13 10:18:34 -04:00
Oron Peled
dc5c7de9fc dahdi_cfg: can optionally read config from stdin
Allow for the convention of '-' marking stdin:

  dahdi_cfg -c -

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-08 10:05:09 -04:00
Oron Peled
1e81ed14cf Augment dahdi_genconf default generators list
Run Add spantypes and pinnedspans generators by default.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-01 22:01:35 +03:00
Oron Peled
44a5285454 add new dahdi_genconf generators
* pinnedspas: For /etc/dahdi/pinned-spans.conf
* spantypes: For /etc/dahdi/span-types.conf

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-01 21:58:04 +03:00
Oron Peled
7a1e222309 remove unused dahdi_cfg_device_args
Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-01 21:57:42 +03:00
Tzafrir Cohen
52488d66fa handle_device: don't fail if no config files
Allow the udev rule to work well even if there's no span-types.conf

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-01 21:56:47 +03:00
Oron Peled
00af777a97 Newer version of DAHDI hotplug scripts
A newer version of the scripts fully adapted to pinned spans:
* handle_device does not run dahdi_cfg.
* A separate UDEV rule script for that: span_config. Should also work
  for the non-pinned case.
* span_assignments, span_types: add actions 'auto' (manually enable all)
  and 'dumpconfig' (dump current status in the format of configuration
  file).
* Fixed name of span_types and span_assignments (no '-').
* spantype.conf renamed span-types.conf: configuration files do have a
  dash.
* Those two are useful programs, insstalled to /usr/sbin.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
2013-10-01 21:51:46 +03:00
141 changed files with 9947 additions and 13991 deletions

47
.gitignore vendored
View File

@@ -1,23 +1,60 @@
*~
*.o
*.lo
*.a
*.so
*.la
.*.o.d
.*.lo.d
*.asciidoc
*.html
.deps
.libs
.dirstamp
.version
/.pc
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_pcap
dahdi_scan
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
@@ -33,4 +70,10 @@ xpp/test_parse
xpp/twinstar.8
xpp/xpp_blink.8
xpp/xpp_sync.8
xpp/xtalk/xlist_test
xpp/xtalk/xtalk_raw_test
xpp/xtalk/xtalk_send
xpp/xtalk/xtalk_test
xpp/xtalk/xusb_test
xpp/xtalk/xusb_test_bypath
zonedata.lo

370
Makefile
View File

@@ -1,370 +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
# 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
MAN_PAGES:=$(wildcard $(BINS:%=doc/%.8))
PINNED_DATA_SCRIPTS:=dahdi_cfg_device_args handle_device \
span_assignments span_types
PINNED_UTILS:=dahdi_map
PINNED_CONF:=pinned-spans.conf spantype.conf
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
$(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
ifeq ($(DAHDI_PINNED),yes)
install -d $(DESTDIR)$(DATA_DIR)
install $(PINNED_DATA_SCRIPTS) $(DESTDIR)$(DATA_DIR)/
install $(PINNED_UTILS) $(DESTDIR)/$(BIN_DIR)/
install -m 644 $(PINNED_CONF) $(DESTDIR)/$(CONFIG_DIR)/
endif
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
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
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
FORCE:
ifneq ($(wildcard .*.d),)
include .*.d
endif

197
Makefile.am Normal file
View File

@@ -0,0 +1,197 @@
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)"
libtonezone_la_LIBADD = -lm
if PBX_PCAP
noinst_PROGRAMS += dahdi_pcap
dahdi_pcap_LDADD = -lpcap
endif
patlooptest_LDADD = libtonezone.la
fxstest_LDADD = libtonezone.la
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 = -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
View 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
TZ=UTC $(ASCIIDOC) -n -a toc -a toclevels=4 $<
README.Astribank.html: xpp/README.Astribank
TZ=UTC $(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 install-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:

198
README
View File

@@ -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,25 +116,58 @@ 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[]
Tonezones
~~~~~~~~~
The file zonedata.c contains the information about the tone zones used
@@ -202,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[]

View File

@@ -1,5 +1,5 @@
#
# /etc/dahdi/pinned-spans.conf:
# /etc/dahdi/assigned-spans.conf:
#
# This file assigns span and channel numbers to dahdi devices
#
@@ -10,6 +10,7 @@
# * The <id> field may be either:
# hardware_id
# @location
# devpath (in sysfs)
# * Shell-style globbing is allowed for the <id> field
# * There may one or more of <spanspec>
# * Each <spanspec> is composed as:
@@ -44,13 +45,13 @@
# Astribank with 4*BRI without hardware_id :-(
# We use the location on the bus (ie: where it is physically
# located). Note the '@' prefix that indicate the location key.
#@pci0000:00/0000:00:03.3/usb1/1-6/xbus-01/astribanks:xbus-01 1:1:50
#@pci0000:00/0000:00:03.3/usb1/1-6/xbus-01/astribanks:xbus-01 2:2:100
#@pci0000:00/0000:00:03.3/usb1/1-6/xbus-01/astribanks:xbus-01 3:3:150
#@pci0000:00/0000:00:03.3/usb1/1-6/xbus-01/astribanks:xbus-01 4:4:200
#@usb-0000:00:1d.7-3 1:1:50
#@usb-0000:00:1d.7-3 2:2:100
#@usb-0000:00:1d.7-3 3:3:150
#@usb-0000:00:1d.7-3 4:4:200
# Same configuration with globbing:
#@*/usb1/1-6/* 1:1:50
#@*/usb1/1-6/* 2:2:100
#@*/usb1/1-6/* 3:3:150
#@*/usb1/1-6/* 4:4:200
#/sys/*/usb1/1-6/* 1:1:50
#/sys/*/usb1/1-6/* 2:2:100
#/sys/*/usb1/1-6/* 3:3:150
#/sys/*/usb1/1-6/* 4:4:200

View File

@@ -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

View File

@@ -12,6 +12,8 @@ blacklist wcfxo
blacklist wctdm
blacklist wctc4xxp
blacklist wcb4xxp
blacklist wcaxx
blacklist wcte43x
# Some mISDN drivers may try to attach to cards supported by DAHDI. If you
# have a card which is *not* supported by DAHDI but supported by one of the

View File

@@ -68,6 +68,8 @@ elif [ -d ${1}/.git ]; then
# options.
VERSION=GIT-`git rev-parse --short --verify HEAD`${MODIFIED}
fi
VERSION=${VERSION##*/} # Remove leading slashes: upsteram/2.10.2
VERSION=${VERSION#[1-9]%} # Remove 1% from tag (tag from Debian epoch)
echo ${VERSION}
else
PARTS=`LANG=C git log --pretty=full | grep -F "git-svn-id:" | head -1 | awk '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`

View File

@@ -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

File diff suppressed because it is too large Load Diff

1658
config.sub vendored

File diff suppressed because it is too large Load Diff

6476
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -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)
@@ -32,15 +68,18 @@ AC_CONFIG_HEADER(autoconfig.h)
# This needs to be before any macros that use the C compiler
AC_GNU_SOURCE
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 +109,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,15 +146,7 @@ AC_ARG_ENABLE(dev-mode,
*) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode) ;;
esac])
AC_SUBST(DAHDI_DEVMODE)
AC_ARG_ENABLE(pinned,
[ --enable-pinned Install pinned-spans support],
[case "${enableval}" in
y|ye|yes) DAHDI_PINNED=yes ;;
n|no) DAHDI_PINNED=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pinned) ;;
esac])
AC_SUBST(DAHDI_PINNED)
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
@@ -98,17 +158,104 @@ else
fi
AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
# Checks for header files.
AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
# Checks for libraries.
AC_CHECK_LIB([m], [cos])
AC_CHECK_LIB([pthread], [pthread_create])
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])
AC_CHECK_FUNCS([alarm bzero gettimeofday memset pow regcomp select socket strcasecmp strchr strdup strerror strrchr strstr strtol strtoul])
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
# What the user asked for? libusb/libusbx
AC_ARG_WITH([libusbx],
[AS_HELP_STRING([--without-libusbx], [Disable libusbx @<:@default=check@:>@])],
[],
[with_libusbx=check])
AC_ARG_WITH([libusb],
[AS_HELP_STRING([--without-libusb], [Disable libusb-0.1 @<:@default=check@:>@])],
[],
[with_libusb=check])
# LIBUSBX tests
have_libusbx=
AS_IF([test "$with_libusbx" != "no"],
[PKG_CHECK_MODULES([LIBUSBX], [libusb-1.0],
[AC_CHECK_LIB([usb-1.0], [libusb_error_name],
[
have_libusbx="yes"
AC_DEFINE([HAVE_LIBUSBX], [1], [Define to 1 if you have <libusb.h>.])
AC_SUBST([PBX_USB], [1])
], [
if test "$with_libusbx" != "yes"; then
AC_MSG_NOTICE([Ignoring old libusb-1.0, trying fallback to old libusb])
fi
])
], [:])
], [])
AS_IF([test "$with_libusbx" = "yes" -a "$have_libusbx" = ""],
[AC_MSG_ERROR([No libusbx found (--with-libusbx was given)])])
# LIBUSB tests
have_libusb=
AS_IF([test "$with_libusb" != "no"],
[AS_IF([test "$have_libusbx" != ""],
[
AS_IF([test "$with_libusbx" = "check"], [
AC_MSG_NOTICE([Skipping LIBUSB tests (have good LIBUSBX)])
])
], [
PKG_CHECK_MODULES([LIBUSB], [libusb],
[
have_libusb="yes"
AC_SUBST([PBX_USB], [1])
]
[AC_DEFINE([HAVE_LIBUSB], [1], [Define to 1 if you have <usb.h>.])],
[:]
)
])
], [])
AS_IF([test "$with_libusb" = "yes" -a "$have_libusb" = ""],
[AC_MSG_ERROR([No libusb found (--with-libusb was given)])])
AM_CONDITIONAL([LIBUSBX], [test "$have_libusbx" != ""])
AM_CONDITIONAL([LIBUSB], [test "$have_libusb" != ""])
AM_CONDITIONAL([PBX_USB], [test "$PBX_USB" = "1"])
PBX_HDLC=0
AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
@@ -147,6 +294,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],
@@ -202,6 +350,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. *** ])
@@ -220,7 +371,26 @@ fi
AC_SUBST(PPPD_VERSION)
AC_CONFIG_FILES([makeopts])
# 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/xtalk/Makefile
xpp/oct612x/Makefile
xpp/perl_modules/Makefile
])
AC_OUTPUT
AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)

133
dahdi-bash-completion Normal file
View 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 | compare)
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 compare' -- $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

View File

@@ -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"
@@ -286,8 +287,12 @@ case "$1" in
$FXOTUNE -s || :
fi
# Set the right Astribanks ticker:
LC_ALL=C xpp_sync "$XPP_SYNC"
# Do not try to call xpp_sync if there are no Astribank devices
# installed.
if test -e /sys/bus/astribanks; then
# Set the right Astribanks ticker:
LC_ALL=C xpp_sync "$XPP_SYNC"
fi
hpec_start
;;

View File

@@ -1,3 +1,18 @@
ACTION!="add", GOTO="dahdi_add_end"
# DAHDI devices with ownership/permissions for running as non-root
SUBSYSTEM=="dahdi", OWNER="asterisk", GROUP="asterisk", MODE="0660"
SUBSYSTEM=="dahdi_devices", RUN="/usr/share/dahdi/handle_device"
# Backward compat names: /dev/dahdi/<channo>
SUBSYSTEM=="dahdi_channels", SYMLINK+="dahdi/%m"
# Add persistant names as well
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"

View File

@@ -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"
@@ -85,11 +90,9 @@ static struct dahdi_lineconfig lc[DAHDI_MAX_SPANS];
static struct dahdi_chanconfig cc[DAHDI_MAX_CHANNELS];
static int current_span = 0;
static int only_span = 0;
static int restrict_channels = 0;
static int selected_channels[DAHDI_MAX_CHANNELS];
static int chan2span[DAHDI_MAX_CHANNELS];
static int declared_spans[DAHDI_MAX_SPANS];
static struct dahdi_attach_echocan ae[DAHDI_MAX_CHANNELS];
@@ -104,7 +107,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 +140,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) {
@@ -237,20 +331,9 @@ static char *trim(char *buf)
static int skip_channel(int x)
{
int spanno = chan2span[x];
if (restrict_channels) {
if (!selected_channels[x])
return 1;
/* sanity check */
if (only_span) {
if (spanno != 0 && only_span != spanno) {
fprintf(stderr,
"Only span %d. Skip selected channel %d from span %d\n",
only_span, x, spanno);
return 1;
}
}
} else {
if (only_span && !declared_spans[only_span]) {
fprintf(stderr,
@@ -258,8 +341,6 @@ static int skip_channel(int x)
only_span);
exit(1);
}
if (only_span && only_span != spanno)
return 1;
}
return 0;
}
@@ -346,7 +427,6 @@ int spanconfig(char *keyword, char *args)
error("Span number should be a valid span number, not '%s'\n", realargs[0]);
return -1;
}
current_span = span;
declared_spans[span] = 1;
res = sscanf(realargs[1], "%d", &timing);
if ((res != 1) || (timing < 0) || (timing > MAX_TIMING)) {
@@ -519,7 +599,6 @@ static int chanconfig(char *keyword, char *args)
int master=0;
int dacschan = 0;
char *idle;
int is_digital;
bzero(chans, sizeof(chans));
strtok(args, ":");
idle = strtok(NULL, ":");
@@ -531,7 +610,6 @@ static int chanconfig(char *keyword, char *args)
if (res <= 0)
return -1;
for (x=1;x<DAHDI_MAX_CHANNELS;x++) {
is_digital = 0;
if (chans[x]) {
if (slineno[x]) {
error("Channel %d already configured as '%s' at line %d\n", x, sig[x], slineno[x]);
@@ -577,7 +655,6 @@ static int chanconfig(char *keyword, char *args)
return -1;
cc[x].sigtype = DAHDI_SIG_CAS;
sig[x] = sigtype_to_str(cc[x].sigtype);
is_digital = 1;
} else if (!strcasecmp(keyword, "dacs")) {
/* Setup channel for monitor */
cc[x].idlebits = dacschan;
@@ -588,7 +665,6 @@ static int chanconfig(char *keyword, char *args)
cc[dacschan].sigtype = DAHDI_SIG_DACS;
sig[x] = sigtype_to_str(cc[dacschan].sigtype);
dacschan++;
is_digital = 1;
} else if (!strcasecmp(keyword, "dacsrbs")) {
/* Setup channel for monitor */
cc[x].idlebits = dacschan;
@@ -598,7 +674,6 @@ static int chanconfig(char *keyword, char *args)
cc[dacschan].idlebits = x;
cc[dacschan].sigtype = DAHDI_SIG_DACS_RBS;
sig[x] = sigtype_to_str(cc[dacschan].sigtype);
is_digital = 1;
dacschan++;
} else if (!strcasecmp(keyword, "unused")) {
cc[x].sigtype = 0;
@@ -606,7 +681,6 @@ static int chanconfig(char *keyword, char *args)
} else if (!strcasecmp(keyword, "indclear") || !strcasecmp(keyword, "bchan")) {
cc[x].sigtype = DAHDI_SIG_CLEAR;
sig[x] = sigtype_to_str(cc[x].sigtype);
is_digital = 1;
} else if (!strcasecmp(keyword, "clear")) {
sig[x] = sigtype_to_str(DAHDI_SIG_CLEAR);
if (master) {
@@ -616,7 +690,6 @@ static int chanconfig(char *keyword, char *args)
cc[x].sigtype = DAHDI_SIG_CLEAR;
master = x;
}
is_digital = 1;
} else if (!strcasecmp(keyword, "rawhdlc")) {
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCRAW);
if (master) {
@@ -626,7 +699,6 @@ static int chanconfig(char *keyword, char *args)
cc[x].sigtype = DAHDI_SIG_HDLCRAW;
master = x;
}
is_digital = 1;
} else if (!strcasecmp(keyword, "nethdlc")) {
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCNET);
memset(cc[x].netdev_name, 0, sizeof(cc[x].netdev_name));
@@ -640,7 +712,6 @@ static int chanconfig(char *keyword, char *args)
}
master = x;
}
is_digital = 1;
} else if (!strcasecmp(keyword, "fcshdlc")) {
sig[x] = sigtype_to_str(DAHDI_SIG_HDLCFCS);
if (master) {
@@ -650,26 +721,26 @@ static int chanconfig(char *keyword, char *args)
cc[x].sigtype = DAHDI_SIG_HDLCFCS;
master = x;
}
is_digital = 1;
} else if (!strcasecmp(keyword, "dchan")) {
sig[x] = "D-channel";
cc[x].sigtype = DAHDI_SIG_HDLCFCS;
is_digital = 1;
} else if (!strcasecmp(keyword, "hardhdlc")) {
sig[x] = "Hardware assisted D-channel";
cc[x].sigtype = DAHDI_SIG_HARDHDLC;
is_digital = 1;
} else if (!strcasecmp(keyword, "mtp2")) {
sig[x] = "MTP2";
cc[x].sigtype = DAHDI_SIG_MTP2;
is_digital = 1;
} else {
fprintf(stderr, "Huh? (%s)\n", keyword);
}
if (is_digital)
chan2span[x] = current_span;
else
current_span = 0;
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]);
}
}
}
}
return 0;
@@ -714,21 +785,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 +821,7 @@ static void apply_fiftysix(void)
}
close(chanfd);
}
return 0;
}
static int setechocan(char *keyword, char *args)
@@ -1444,12 +1517,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 +1557,7 @@ int main(int argc, char *argv[])
force++;
break;
case 't':
fo_real = 0;
dry_run = 1;
break;
case 's':
stopmode = 1;
@@ -1495,12 +1583,28 @@ int main(int argc, char *argv[])
fprintf(stderr, "%s\n", dahdi_tools_version);
}
if (!restrict_channels && only_span) {
error("-S requires -C\n");
goto finish;
}
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);
goto finish;
}
cf = fopen(filename, "r");
if (strcmp(filename, "-") == 0)
cf = fdopen(STDIN_FILENO, "r");
else
cf = fopen(filename, "r");
if (cf) {
while((buf = readline())) {
if (*buf == 10) /* skip new line */
@@ -1550,18 +1654,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)
@@ -1569,10 +1703,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)
@@ -1580,16 +1716,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;
@@ -1712,7 +1864,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;
@@ -1723,7 +1876,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) {
@@ -1750,7 +1904,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++) {
@@ -1759,9 +1914,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);
}

View File

@@ -1,32 +0,0 @@
#! /bin/sh
devbase='/sys/bus/dahdi_devices/devices'
# Use given devices or otherwise, all existing devices
if [ "$#" -gt 0 ]; then
DEVICES="$@"
else
DEVICES=`echo $devbase/*`
fi
run_action_spans() {
device="$1"
for span in $device/span-*
do
spanno=`echo "$span" | sed 's,.*/span-,,'`
spantype=`cat "$span/spantype"`
basechan=`cat "$span/basechan"`
channels=`cat "$span/channels"`
endchan=`expr "$basechan" + "$channels" - 1`
echo "-S $spanno -C $basechan-$endchan"
done
}
run_action() {
for device in $DEVICES
do
run_action_spans "$device"
done
}
run_action

View File

@@ -1,39 +0,0 @@
#! /bin/sh
#
# Show a map of dahdi devices with the following fields:
# - spanno (or '-' if not assigned yet)
# - (vendor assigned) name
# - local spanno
# - hardware_id (or empty if none)
# - location (prefixed by '@')
devbase="/sys/bus/dahdi_devices/devices"
[ -d "$devbase" ] || {
echo >&2 "$0: Missing '$devbase' (Old driver?)"
exit 1
}
fmt="%-4s %-17s %-3s %-12s %s\n"
printf "$fmt" 'SPAN' 'NAME' '#' 'HARDWARE_ID' 'LOCATION'
DEVICES=`echo $devbase/*`
for device in $DEVICES
do
hw_id=`cat "$device/hardware_id"`
location=`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
if [ "$span" != '' ]; then
spanno=`echo $span | sed 's/^.*-//'`
name=`cat 2>/dev/null "$device/$span/name"`
else
spanno='-'
fi
printf "$fmt" "$spanno" "$name" "($local_spanno)" "[$hw_id]" "@$location"
done | sort -n
done

399
dahdi_span_assignments Executable file
View File

@@ -0,0 +1,399 @@
#! /bin/sh
#
# /usr/sbin/dahdi_span_assignments:
#
# this script can be used both from udev and
# from the command line to assign/unassign and list
# current span assignments.
#
# It uses a configuration file: $DAHDICONFDIR/assigned-spans.conf
# (default DAHDICONFDIR=/etc/dahdi)
#
# The first argument is an action:
# "auto" - trigger driver auto_assign attribute for given devices
# (no configuration file is used)
# "add" - assign (spans which are not already assigned), according
# to /etc/dahdi/assigned-spans.conf configuration file
# "remove" - unassign spans which are not already unassigned
# "list" - human-readable list of all spans (with/without assignments)
# "dumpconfig" - dump current assignments in a /etc/dahdi/assigned-spans.conf
# compatible format
#
# Without further arguments, it operates on all existing spans
# With one or more sysfs dahdi_devices it is limited to those.
#
# We may use alternative "keys" for device matching:
# * Available keys:
# - "hwid" - Hardware id attribute from sysfs
# - "@location" - Location attribute from sysfs (embeded inside '<>')
# - "/devpath" - The sysfs absolute devpath
#
# * 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
# or the '{-k|--key} key' command line option.
#
# * During "add":
# - Any key match is valid (hwid/location/devpath)
# - Shell globs (wildcards: '*', '?', '[...]') may be optionally used.
#
# Command line options:
# - The '-h|--help' show a usage message.
# - The '-n|--dry-run' affects the "add" and "remove" operations.
# - The '-v|--verbose' currently shows device matches during "add" operation.
# - The '-k <key>|--key <key>' overrides the SPAN_ASSIGNMENTS_KEY environment
# variable.
#
# Examples:
# dahdi_span_assignments list
# dahdi_span_assignments add # all unassigned devices
# dahdi_span_assignments add /sys/bus/dahdi_devices/devices/astribanks:xbus-00
# dahdi_span_assignments remove # all assigned devices
# dahdi_span_assignments -k location dumpconfig
#
devbase='/sys/bus/dahdi_devices/devices'
DAHDICONFDIR="${DAHDICONFDIR:-/etc/dahdi}"
DAHDISASSIGNEDSPANSCONF="${DAHDIASSIGNEDSPANSCONF:-"${DAHDICONFDIR}/assigned-spans.conf"}"
SPAN_ASSIGNMENTS_KEY=${SPAN_ASSIGNMENTS_KEY:-hwid}
dry_run=
verbose=
usage() {
echo >&2 "Usage: $0 [options] action [devpath ...]"
echo >&2 " action:"
echo >&2 " auto - trigger driver auto_assign attribute for given devices"
echo >&2 " add - assign spans, according to /etc/dahdi/assigned-spans.conf"
echo >&2 " remove - unassign spans"
echo >&2 " list - human-readable list of all spans"
echo >&2 " matched - found spans matched in configuration"
echo >&2 " unmatched - found spans not matched in configuration"
echo >&2 " dumpconfig - dump current state as new configuration"
echo >&2 ""
echo >&2 " options:"
echo >&2 " -h|--help - Show this help"
echo >&2 " -n|--dry-run - For 'add/remove' actions"
echo >&2 " -v|--versbose - Show matches during 'add' action"
echo >&2 " -k|--key <k> - Override prefered key during dumpconfig action"
exit 1
}
# Parse command line options
TEMP=`getopt -o hnvk: --long help,dry-run,verbose,key: -n "$0" -- "$@"`
if [ $? != 0 ]; then
echo >&2 "Bad options"
usage
fi
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-h|--help)
usage
;;
-n|--dry-run)
dry_run='true'
shift
;;
-v|--verbose)
verbose='true'
shift
;;
-k|--key)
SPAN_ASSIGNMENTS_KEY="$2"
shift
shift
;;
--)
shift
break
;;
*)
echo >&2 "Internal error!"
exit 1
;;
esac
done
if [ "$#" -eq 0 ]; then
echo >&2 "Missing action argument"
usage
fi
action="$1"
shift
# Validate SPAN_ASSIGNMENTS_KEY
case "$SPAN_ASSIGNMENTS_KEY" in
hwid|location|devpath)
;;
*)
echo >&2 "Bad SPAN_ASSIGNMENTS_KEY='$SPAN_ASSIGNMENTS_KEY' (should be: hwid|location|devpath)"
usage
;;
esac
if [ ! -d "$devbase" ]; then
echo >&2 "$0: Missing '$devbase' (DAHDI driver unloaded?)"
exit 1
fi
# Use given devices or otherwise, all existing devices
if [ "$#" -gt 0 ]; then
DEVICES="$@"
else
DEVICES=`ls -d $devbase/* 2>/dev/null`
fi
# Beware of special characters in attributes
attr_clean() {
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
}
show_devices() {
for device in $DEVICES
do
devpath=`cd "$device" && pwd -P`
location='@'`attr_clean "$device/location"`
hardware_id=`attr_clean "$device/hardware_id"`
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
if [ "$span" != '' ]; then
spanno=`echo $span | sed 's/^.*-//'`
name=`cat 2>/dev/null "$device/$span/name"`
basechan=`cat 2>/dev/null "$device/$span/basechan"`
else
spanno='-'
basechan='-'
fi
printf "%-8s %-14s %s %s\n" "$local_spanno:$spanno:$basechan" "[$hardware_id]" "$location" "$devpath"
done | sort -n
done
}
dump_config() {
echo '#'
echo "# Autogenerated by $0 on `date`"
echo "# Map devices + local spans to span + base channel number"
echo ''
for device in $DEVICES
do
devpath=`cd "$device" && pwd -P`
location=`attr_clean "$device/location"`
hardware_id=`attr_clean "$device/hardware_id"`
if [ "$SPAN_ASSIGNMENTS_KEY" = 'hwid' -a "$hardware_id" != '' ]; then
id="$hardware_id"
elif [ "$SPAN_ASSIGNMENTS_KEY" = 'location' -a "$location" != '' ]; then
id="@$location"
else
id="$devpath"
fi
echo "# Device: [$hardware_id] @$location $devpath"
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
if [ "$span" != '' ]; then
spanno=`echo $span | sed 's/^.*-//'`
name=`cat 2>/dev/null "$device/$span/name"`
basechan=`cat 2>/dev/null "$device/$span/basechan"`
printf "%-30s %s\n" "$id" "$local_spanno:$spanno:$basechan"
else
echo "# Skipped unassigned local span $local_spanno"
fi
done | sort
echo ''
done
}
unassign_all_spans() {
for device in $DEVICES
do
find "$device" -follow -maxdepth 1 -name 'span-*' -type d | \
sort | while read spandir; do
local_spanno=`cat "$spandir/local_spanno"`
if [ "$dry_run" = true ]; then
echo >&2 "(dry-run) unassign $device $local_spanno"
continue
fi
echo >&2 "unassign $device $local_spanno"
if ! echo "$local_spanno" > "$device/unassign_span"; then
echo >&2 "$0: failed unassigning '$local_spanno' in '$device'"
fi
done
done
}
# Allow comments and empty lines in config file
filter_conf() {
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$DAHDISASSIGNEDSPANSCONF"
}
assign_device_spans() {
device="$1"
for s in $spanspecs
do
local_spanno=`echo "$s" | cut -d: -f1`
spanno=`echo "$s" | cut -d: -f2`
span="$device/span-$spanno"
if [ "$dry_run" = true ]; then
echo "(dry-run) assign $device: $s"
continue
fi
if [ -d "$span" ]; then
span_local_spanno=`cat "$span/local_spanno"`
if [ "$span_local_spanno" != "$local_spanno" ]; then
echo >&2 "WARNING: $span_local_spanno != $local_spanno"
fi
echo >&2 "$device [$local_spanno] already assigned to span $spanno. Skipping..."
continue
fi
echo >&2 "assign $device: $s"
if ! echo "$s" > "$device/assign_span"; then
echo >&2 "$0: failed assigning '$s' to '$device'"
fi
done
}
match_device() {
device="$1"
devpath=`cd "$device" && pwd -P`
location='@'`attr_clean "$device/location"`
hardware_id=`attr_clean "$device/hardware_id"`
filter_conf | while read id spanspecs
do
# We use case to enable shell-style globbing in configuration
case "$hardware_id" in
$id)
[ "$verbose" = true ] && echo >&2 "match by hwid ($id ~ $hardware_id): $spanspecs"
assign_device_spans "$device"
;;
esac
# We use case to enable shell-style globbing in configuration
case "$location" in
$id)
[ "$verbose" = true ] && echo >&2 "match by location ($id ~ $location): $spanspecs"
assign_device_spans "$device"
;;
esac
# We use case to enable shell-style globbing in configuration
case "$devpath" in
$id)
[ "$verbose" = true ] && echo >&2 "match by devpath ($id ~ $devpath): $spanspecs"
assign_device_spans "$device"
;;
esac
done
}
assign_devices() {
if [ ! -f "$DAHDISASSIGNEDSPANSCONF" ]; then
echo >&2 "$0: Missing '$DAHDISASSIGNEDSPANSCONF'"
exit 1
fi
echo >&2 "using '$DAHDISASSIGNEDSPANSCONF'"
for device in $DEVICES
do
match_device "$device"
done
}
auto_assign_devices() {
for device in $DEVICES
do
echo >&2 "auto-assign $device"
if [ "$dry_run" != true ]; then
echo 1 > "$device/auto_assign"
fi
done
}
dev_match_conf() {
local devpath="$1"
local location="$2"
local hardware_id="$3"
local local_spanno="$4"
filter_conf | while read id spanspecs
do
spanno=`echo "$spanspecs" | cut -d: -f1`
match_dev=no
# We use case to enable shell-style globbing in configuration
case "$hardware_id" in
$id)
match_dev=yes
;;
esac
# We use case to enable shell-style globbing in configuration
case "$location" in
$id)
match_dev=yes
;;
esac
# We use case to enable shell-style globbing in configuration
case "$devpath" in
$id)
match_dev=yes
;;
esac
if [ "$match_dev" = 'yes' -a "$local_spanno" = "$spanno" ]; then
#printf "%-8s (%s) %-14s %s %s\n" "$local_spanno" "$spanno" "[$hardware_id]" "$location" "$devpath"
echo "[$hardware_id]:$local_spanno"
fi
done
}
list_devices() {
wanted="$1"
if [ ! -f "$DAHDISASSIGNEDSPANSCONF" ]; then
echo >&2 "$0: Missing '$DAHDISASSIGNEDSPANSCONF'"
exit 1
fi
echo >&2 "using '$DAHDISASSIGNEDSPANSCONF'"
for device in $DEVICES
do
devpath=`cd "$device" && pwd -P`
location='@'`attr_clean "$device/location"`
hardware_id=`attr_clean "$device/hardware_id"`
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
found=`dev_match_conf "$devpath" "$location" "$hardware_id" "$local_spanno"`
if [ "$wanted" = "unmatched" ]; then
[ -z "$found" ] && echo "[$hardware_id]:$local_spanno"
else
[ -z "$found" ] || echo "[$hardware_id]:$local_spanno"
fi
done
done
}
case "$action" in
auto)
auto_assign_devices
;;
add)
assign_devices
;;
remove)
unassign_all_spans
;;
list)
show_devices
;;
dumpconfig)
dump_config
;;
matched)
list_devices "matched"
;;
unmatched)
list_devices "unmatched"
;;
*)
echo >&2 "Bad action='$action'"
usage
;;
esac

397
dahdi_span_types Executable file
View File

@@ -0,0 +1,397 @@
#! /bin/sh
#
# /usr/sbin/dahdi_span_types
#
# This script can be used both from udev and
# from the command line to manage PRI spans
# type (E1/T1/J1).
#
# Span types can be set only *BEFORE* span are assigned.
#
# It uses a configuration file: $DAHDICONFDIR/span-types.conf
# (default DAHDICONFDIR=/etc/dahdi)
# (the format is documented inside that file)
#
# The first argument is an action:
# "set" - actually write the setting to the driver
# "list" - human-readable list of E1/T1/J1 types
# "dumpconfig" - dump current assignments in a /etc/dahdi/span-types.conf
# compatible format
#
# Without further arguments, it operates on all existing spans
# With one or more sysfs dahdi_devices it is limited to those.
#
# We may use alternative "keys" for device matching:
# * Available keys:
# - "hwid" - Hardware id attribute from sysfs
# - "@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
# or the '{-k|--key} key' command line option.
#
# 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.
#
# Examples:
# dahdi_span_types list
# dahdi_span_types set # all devices
# dahdi_span_types set /sys/bus/dahdi_devices/devices/astribanks:xbus-00
# dahdi_span_types -k location dumpconfig
#
devbase='/sys/bus/dahdi_devices/devices'
DAHDICONFDIR="${DAHDICONFDIR:-/etc/dahdi}"
DAHDISPANTYPESCONF="${DAHDISPANTYPESCONF:-"${DAHDICONFDIR}/span-types.conf"}"
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 /etc/dahdi/span-types.conf"
echo >&2 " compare - show config values that differ from system"
echo >&2 " list - human-readable list of all spans"
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 hnvk: --long help,dry-run,verbose,key:,line-mode: -n "$0" -- "$@"`
if [ $? != 0 ]; then
echo >&2 "Bad options"
usage
fi
compare=false
# Note the quotes around `$TEMP': they are essential!
eval set -- "$TEMP"
while true ; do
case "$1" in
-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
;;
*)
echo "Internal error!"
exit 1
;;
esac
done
if [ "$#" -eq 0 ]; then
echo >&2 "Missing action argument"
usage
fi
action="$1"
shift
# Validate SPAN_ASSIGNMENTS_KEY
case "$SPAN_ASSIGNMENTS_KEY" in
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
if [ ! -d "$devbase" ]; then
echo >&2 "$0: Missing '$devbase' (DAHDI driver unloaded?)"
exit 1
fi
# Use given devices or otherwise, all existing devices
if [ "$#" -gt 0 ]; then
DEVICES="$@"
else
DEVICES=`ls -d $devbase/* 2>/dev/null`
fi
# Beware of special characters in attributes
attr_clean() {
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
}
show_spantypes() {
echo "# PRI span types (E1/T1/J1)"
for device in $DEVICES
do
devpath=`cd "$device" && pwd -P`
location='@'`attr_clean "$device/location"`
hardware_id=`attr_clean "$device/hardware_id"`
cat "$device/spantype" | while read st; do
case "$st" in
*:[ETJ]1)
printf "%-10s %-20s %-30s %s\n" \
"$st" "[$hardware_id]" "$location" \
"$devpath"
;;
esac
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"
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`
location=`attr_clean "$device/location"`
hardware_id=`attr_clean "$device/hardware_id"`
if [ "$SPAN_ASSIGNMENTS_KEY" = 'hwid' -a "$hardware_id" != '' ]; then
id="$hardware_id"
elif [ "$SPAN_ASSIGNMENTS_KEY" = 'location' -a "$location" != '' ]; then
id="@$location"
else
id="$devpath"
fi
echo "# Device: [$hardware_id] @$location $devpath"
cat "$device/spantype" | while read st; do
case "$st" in
*:[ETJ]1)
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 ''
done
}
# Allow comments and empty lines in config file
filter_conf() {
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$DAHDISPANTYPESCONF"
}
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): $span_spec"
found=yes
;;
esac
case "$hardware_id" in
$id)
#echo >&2 "match([$id]): $span_spec"
found=yes
;;
esac
case "$devpath" in
$id)
#echo >&2 "match([$id]): $span_spec"
found=yes
;;
esac
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
if [ "$compare" = 'true' ]; then
config="$spanno:$val"
system=`grep "$spanno:" "$attr_file"`
if [ "$config" != "$system" ]; then
active_val=`echo $system | cut -d: -f2`
echo "$devname $spanno $val $active_val" >>"$compare_results_file"
fi
else
echo "$spanno:$val" > "$attr_file"
fi
fi
fi
done
}
set_all_devices() {
span_differs='false'
SPANS_DIFFER='false'
if [ ! -f "$DAHDISPANTYPESCONF" ]; then
echo >&2 "$0: Missing configuration '$DAHDISPANTYPESCONF'"
exit 1
fi
for device in $DEVICES
do
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
if [ "$compare" = 'true' ]; then
if [ -s "$compare_results_file" ]; then
echo "# Device Unit Config Active"
cat "$compare_results_file"
rm -f "$compare_results_file"
exit 5
fi
rm -f "$compare_results_file"
exit 0
fi
}
case "$action" in
list)
show_spantypes
;;
dumpconfig)
dump_config
;;
set)
set_all_devices
;;
compare)
compare=true
compare_results_file=`mktemp`
set_all_devices
;;
*)
usage
;;
esac

View File

@@ -64,7 +64,7 @@ void hup_handler(int sig)
printf("\n--- Results after %d passes ---\n", pass);
printf("Best: %.3f%% -- Worst: %.3f%% -- Average: %f%%\n",
best, worst, pass ? total/pass : 100.00);
printf("Cummulative Accuracy (not per pass): %0.3f\n",
printf("Cumulative Accuracy (not per pass): %0.3f\n",
pass ? accuracy : 0.0);
exit(0);
}

73
dahdi_waitfor_span_assignments Executable file
View 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
View 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)

View File

@@ -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
@@ -24,6 +24,8 @@ the DAHDI init script.
.RS
Use an alternative configuration file instead of
.I /etc/dahdi/system.conf
If \fICFG_FILE\fR is '\fB\-\fR', it is read from stdin.
.RE
.B \-C \fICHANNELS
@@ -39,10 +41,8 @@ Only shutdown spans.
.B \-S \fISPAN
.RS
Only apply changes to span no. \fISPAN\fR. For a digital span (with
a 'span=' line in the configuration file) this will do. For an analog
span you'll have to explicitly tell dahdi_cfg the range of channels,
using \-C .
Only apply changes to span no. \fISPAN\fR. You also need to specify the
range of channels in the span explicitly with \-C.
.RE
.B \-f

View File

@@ -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

View File

@@ -1,48 +0,0 @@
.TH dahdi_test 8 "2013-05-24"
.SH "NAME"
dahdi_map \(em List hardware IDs and locations of DAHDI spans
.SH "SYNOPSIS"
.B dahdi_map
.SH DESCRIPTION
.B dahdi_map
prints a list of hardware IDs and locations of any DAHDI span on the system
(possibly not yet assigned).
It takes no extra options or parameters.
Example output:
.EX
SPAN NAME # HARDWARE_ID LOCATION
5 XBUS-00/XPD-00 (1) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
6 XBUS-00/XPD-01 (2) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
7 XBUS-00/XPD-02 (3) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
8 XBUS-00/XPD-03 (4) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
9 XBUS-00/XPD-04 (5) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
10 XBUS-00/XPD-05 (6) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
11 XBUS-00/XPD-06 (7) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
12 XBUS-00/XPD-07 (8) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
13 XBUS-00/XPD-10 (9) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
14 XBUS-00/XPD-20 (10) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
15 XBUS-00/XPD-30 (11) [usb:INT06380] @pci0000:00/0000:00:10.4/usb1/1-3/xbus-00/astribanks:xbus-00
16 XBUS-01/XPD-00 (1) [] @pci0000:00/0000:00:10.4/usb1/1-4/xbus-01/astribanks:xbus-01
1 XBUS-02/XPD-00 (1) [usb:XILINX_4] @pci0000:00/0000:00:10.4/usb1/1-1/xbus-02/astribanks:xbus-02
2 XBUS-02/XPD-10 (2) [usb:XILINX_4] @pci0000:00/0000:00:10.4/usb1/1-1/xbus-02/astribanks:xbus-02
3 XBUS-02/XPD-20 (3) [usb:XILINX_4] @pci0000:00/0000:00:10.4/usb1/1-1/xbus-02/astribanks:xbus-02
4 XBUS-02/XPD-30 (4) [usb:XILINX_4] @pci0000:00/0000:00:10.4/usb1/1-1/xbus-02/astribanks:xbus-02
.EE
.SH FILES
.B /sys/bus/dahdi_devices/devices
.RS
Information taken from that area in SysFS.
.RE
.SH SEE ALSO
dahdi_cfg(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
later version published by the Free Software Foundation.

View File

@@ -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

View File

@@ -0,0 +1,251 @@
.TH "DAHDI_SPAN_ASSIGNMENTS" "8" "23 Jan 2014" "" ""
.SH NAME
dahdi_span_assignments \- handle DAHDI spans assignments
.SH SYNOPSIS
.B dahdi_span_assignments [\-v|\-\-verbose] [\-n|\-\-dry\-run] <add|remove|auto> \fB[\fIdevpath\fB...]
.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 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 assign those spans or to help creating the configuration
file used in their assignment:
.B /etc/dahdi/assigned\-spans.conf .
.SH SUB-COMMANDS
There are several sub-commands.
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
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 \fB[\fIdevpath \fB...]
.RS
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 \fB[\fIdevpath \fB...]
.RS
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
.RS
List all spans in the system.
.RE
.B dumpconfig
.RS
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.
.RE
.B \-n \-\-dry\-run
.RS
Don't assign / un-assign spans. Only print commands used to do so.
.RE
.B \-k \fIkey
.RS
For \fBdumpconfig\fR \- The key by which to identify the hardware in the
generated configuration. Legal values:
.B hwid
.RS
Hardware identifier (e.g.: software-readable serial number). This is the
default. If the device has no hwid, devpath is used.
.RE
.B location
.RS
The location field (file) in the SysFS device node (directory) for the
DAHDI device. If not available (typically: DAHDI version <= 2.7.x),
devpath is used.
.RE
.B devpath
.RS
Path in SysFS to the device node.
.RE
.RE
.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.
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 assign its spans. A line may have multiple
\fIspanspecs\fR in a single line (though dumpconfig generates a
configuration with one per line).
.SS Span Identifier
A DAHDI device may be specified either by a hardware identifier (a
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:
\fIhwid\fR
\fB@\fIlocation\fR
\fIdevpath\fR
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.
.SS Span Specification
Each line should have one or more span specifications: this is the value
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
for instance, the following are four span specifications for a quad-E1
device: 1:6:53 2:7:84 3:8:115 4:9:146 occupying spans 6-9 and channels
53-176.
.B rel_span_no
.RS
The relative number of the span in the device. E.g.: port number.
.RE
.B span_no
.RS
The desired DAHDI span number. Must be available.
.RE
.B first_chan
.RS
The desired DAHDI channel number for the first DAHDI channel in the span.
All channels of the span will be assigned following it and hence that
space must be available.
.RE
.SH ENVIRONMENT
.B DAHDICONFDIR
.RS
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
not overridden from the environment.
.RE
.B SPAN_ASSIGNMENTS_KEY
.RS
The default value for \-k . Defaults to "hwid" if not overridden from the
environment.
.RE
.SH FILES
.B /etc/dahdi/assigned\-spans.conf
.RS
The default location for the configuration file.
.RE
.B /sys/bus/dahdi_devices/devices/\fIdevice\fR
.RS
SysFS node for the device. In this directory reside the following
files, among others:
.B location
.RS
The value of the device's location field.
.RE
.B assign_span, unassign_span, auto_assign
.RS
Write only files for the operations. Used by \fBadd\fR, \fBremove\fR and
\fBauto\fR, respectively.
.RE
.RE
.SH SEE ALSO
dahdi_span_types(8), dahdi_genconf(8), dahdi_cfg(8)
.SH AUTHOR
dahdi_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.

207
doc/dahdi_span_types.8 Normal file
View File

@@ -0,0 +1,207 @@
.TH "DAHDI_SPAN_TYPES" "8" "23 Jan 2014" "" ""
.SH NAME
dahdi_span_types \- set line modes of DAHDI spans before assignment
.SH SYNOPSIS
.B dahdi_span_types [\fIoptions\fB] <list|dumpconfig|compare|set> \fB[\fIdevpath \fB...]
.SH DESCRIPTION
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 DAHDI automatically
assign span numbers during device registration.
.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
device(s) specified in the command line (or all devices, if none
specified).
.RE
.B compare
.RS
Compare the settings on the system to those in the configuration file.
For each line that applies to a device on the system, print it if the
value to be set and the active value on the system differ.
The exit status is 0 if there is no difference and non-zero if a
difference was detected.
.RE
.B list
.RS
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
you have (perhaps manually) set all existing spans.
.B dahdi_genconf spantypes
uses this command internally.
.RE
.SH CONFIGURATION
.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.
Each line is in the format of:
.I ID spanspec ...
The \fIID\fR field specifies the DAHDI device and the \fIspanspecs\fR
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).
.SS Span Identifier
A DAHDI device may be specified either by a hardware identifier (a
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 command \fBset\fR is
used) to the following values:
\fIhwid\fR
\fB@\fIlocation\fR
\fIdevpath\fR
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 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 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 .
.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
.RS
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
overridden from the environment.
.RE
.B DAHDISPANTYPESCONF
.RS
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
.RS
The default location for the configuration file.
.RE
.B /sys/bus/dahdi_devices/devices/\fIdevice\fR
.RS
SysFS node for the device. In this directory reside the following
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 line
modes (but only for a span that is not assigned yet).
.RE
.SH SEE ALSO
dahdi_span_assignments(8), dahdi_genconf(8), dahdi_cfg(8)
.SH AUTHOR
dahdi_span_types 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.

View File

@@ -7,7 +7,7 @@ dahdi_tool \- Shows status of DAHDI interfaces
.B dahdi_tool
.SH DESCRIPTION
dahdi_tool shows the current status the DAHDI inteface cards plugged
dahdi_tool shows the current status the DAHDI interface cards plugged
to the computer.
It displays values like Current Alarms, SyncSource, Tx/Rx

View 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.

View File

@@ -11,6 +11,7 @@ fxotune \- automatically tune DAHDI FXO channels
\- dump mode
.B fxotune \-s
.I [ options ]
\- Startup mode
.SH
.SH DESCRIPTION
@@ -32,7 +33,7 @@ is generated in the current directory.
fxotune just reads the settings from fxotune.conf into the FXO modules.
You are advised to run fxotune on all FXO ports you have that support
it and that are connected. Note that the tunning is affected by e.g.
it and that are connected. Note that the tuning is affected by e.g.
the physical parameters of the connection, and thus if it has been
radically changed, you may need to re-run fxotune.
@@ -43,7 +44,7 @@ cards and clones) do not have the hardware to support such tuning.
The tuning process needs a clear line to do the tuning. In order to do
that, it runs in cycles of the following: sets the line off-hook, dials
a dial string (which should set the PSTN provider waiting for the next
digit), and then starts tuning. It has a limited ammount of time for
digit), and then starts tuning. It has a limited amount of time for
tuning before the PSTN gives up and gives a busy tone. So after a while
it hangs up and starts a new cycle.
@@ -179,7 +180,7 @@ so if you stop it half-way, you may get a half-configured system. If you
have already tuned your FXO channels and wish to test-run fxotune again,
you are advised to backup /etc/fxotune.conf .
The default for \-m is 18 seconds. This asusmes that you get a clear line
The default for \-m is 18 seconds. This assumes that you get a clear line
for at least 18 seconds. It is advised that you test that timeout earlier
by connecting a phone to the FXO line, dialing 4 (or whatever dial string
you put with \-n) and see how much time of silence you have.

View File

@@ -980,7 +980,7 @@ static int channel_open(int channo)
*
* @return 0 if successful, !0 otherwise
*/
static int do_set(char *configfilename)
static int do_set(char *configfilename, int dev_range, int startdev, int stopdev)
{
FILE *fp = NULL;
int res = 0;
@@ -1007,6 +1007,8 @@ static int do_set(char *configfilename)
if (res == EOF) {
break;
}
if (dev_range && (mydahdi < startdev || mydahdi > stopdev))
continue;
/* Check to be sure conversion is done correctly */
if (OUT_OF_BOUNDS(myacim) || OUT_OF_BOUNDS(mycoef1)||
@@ -1028,6 +1030,8 @@ static int do_set(char *configfilename)
mycoefs.coef7 = mycoef7;
mycoefs.coef8 = mycoef8;
if (debug >= 2)
printf("fxotune: set channel %d\n", mydahdi);
fd = channel_open(mydahdi);
if (fd < 0) {
return -1;
@@ -1187,6 +1191,7 @@ int main(int argc , char **argv)
{
int startdev = 1; /* -b */
int stopdev = 252; /* -e */
int dev_range = 0; /* false */
int calibtype = 2; /* -t */
int waveformtype = -1; /* -w multi-tone by default. If > 0, single tone of specified frequency */
int delaytosilence = 0; /* -l */
@@ -1228,9 +1233,11 @@ int main(int argc , char **argv)
continue;
case 'b':
startdev = moreargs ? atoi(argv[++i]) : startdev;
dev_range = 1;
break;
case 'e':
stopdev = moreargs ? atoi(argv[++i]) : stopdev;
dev_range = 1;
break;
case 't':
calibtype = moreargs ? atoi(argv[++i]) : calibtype;
@@ -1300,13 +1307,13 @@ int main(int argc , char **argv)
if (docalibrate){
res = do_calibrate(startdev, stopdev, calibtype, configfile, dialstr, delaytosilence, silencegoodfor);
if (!res)
return do_set(configfile);
return do_set(configfile, dev_range, startdev, stopdev);
else
return -1;
}
if (doset)
return do_set(configfile);
return do_set(configfile, dev_range, startdev, stopdev);
if (dodump){
res = do_dump(startdev, dialstr, delaytosilence, silencegoodfor, waveformtype);

View File

@@ -1,50 +0,0 @@
#! /bin/sh
#
# /usr/share/dahdi/handle_device
#
# Called by UDEV when a span goes online/offline to assign spans
me=`basename $0`
dir=`dirname $0`
LOGGER="logger -i -t '$me'"
NAME=`basename "$DEVPATH" | tr -c 'A-Za-z0-9-' '_'`
# Always redirect stderr somewhere, otherwise the shell script will die
# when it tries to do I/O related stuff on closed file descriptor.
# Our default is to throw it down the bit-bucket.
exec 2> /dev/null
# If you wish to trace this script:
#exec 2> "/tmp/${me}.$NAME" 1>&2
#exec 2> /dev/console
# Our directory in the beginning, so we can use local lab setup
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
set -e
run_dahdi_cfg() {
args="-c $DAHDICONFDIR/system.conf $@"
echo "Running dahdi_cfg $args"
dahdi_cfg $args
}
echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
case "$ACTION" in
add)
echo "$ACTION: $DEVPATH" | $LOGGER
# FIXME: need a way to add custom environment here:
#export DAHDICONFDIR="/tmp/xortel/dahdi"
span_types set "/sys/$DEVPATH" 2>&1 | $LOGGER
span_assignments add "/sys/$DEVPATH" 2>&1 | $LOGGER
dahdi_cfg_device_args | while read args; do
run_dahdi_cfg $args 2>&1 | $LOGGER
done
;;
remove)
echo "$ACTION: $DEVPATH" | $LOGGER
;;
*)
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
;;
esac

View File

@@ -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;

View File

@@ -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
View 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 \
#

View File

@@ -0,0 +1,30 @@
#! /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
unmatched="`dahdi_span_assignments unmatched`"
if [ -n "$unmatched" ]; then
# Only if astribanks are not matched in span-assignments.conf
# TODO: have dahdi_registration run only on "$unmatched"
LC_ALL=C dahdi_registration -Rv on
fi

87
hotplug/dahdi_handle_device Executable file
View File

@@ -0,0 +1,87 @@
#! /bin/sh
#
# /usr/share/dahdi/dahdi_handle_device
#
# Called by UDEV when a dahdi device is added/removed
#
me=`basename $0`
dir=`dirname $0`
LOGGER="logger -i -t '$me'"
NAME=`basename "$DEVPATH" | tr -c 'A-Za-z0-9-' '_'`
# Always redirect stderr somewhere, otherwise the shell script will die
# when it tries to do I/O related stuff on closed file descriptor.
# Our default is to throw it down the bit-bucket.
exec 2> /dev/null
# If you wish to trace this script:
#exec 2> "/tmp/${me}.$NAME" 1>&2
#exec 2> /dev/console
# Our directory in the beginning, so we can use local lab setup
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
export PATH
set -e
#echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
# Do we have a configuration?
if [ -f /etc/dahdi/init.conf ]; then
. /etc/dahdi/init.conf
fi
if [ "$DAHDI_UDEV_DISABLE_DEVICES" = 'yes' ]; then
echo "DAHDI_UDEV_DISABLE_DEVICES=yes. 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
# 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)
echo "$ACTION: $DEVPATH" | $LOGGER
# Background run -- don't block udev
run_parts 2>&1 < /dev/null | $LOGGER &
;;
*)
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
;;
esac

97
hotplug/dahdi_span_config Executable file
View File

@@ -0,0 +1,97 @@
#! /bin/sh
#
# /usr/share/dahdi/dahdi_span_config
#
# Called by UDEV when a dahdi span is added/removed
#
me=`basename $0`
dir=`dirname $0`
LOGGER="logger -i -t '$me'"
NAME=`basename "$DEVPATH" | tr -c 'A-Za-z0-9-' '_'`
exec 2> /dev/null
# Always redirect stderr somewhere, otherwise the shell script will die
# when it tries to do I/O related stuff on closed file descriptor.
# Our default is to throw it down the bit-bucket.
#exec 2> /dev/console
## If you wish to trace this script:
#exec 2> "/tmp/${me}.$NAME" 1>&2
# Our directory in the beginning, so we can use local lab setup
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
export PATH
set -e
#echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
# Do we have a configuration?
if [ -f /etc/dahdi/init.conf ]; then
. /etc/dahdi/init.conf
fi
if [ "$DAHDI_UDEV_DISABLE_SPANS" = 'yes' ]; then
echo "DAHDI_UDEV_DISABLE_SPANS=yes. 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/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
# 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...
echo "$ACTION: $DEVPATH" | $LOGGER
;;
*)
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
;;
esac

View 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

View 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

View File

@@ -0,0 +1,18 @@
#! /bin/sh
# Run xpp_sync whenever an Astribank is connected.
# May be set in /etc/dahdi/init.conf
XPP_SYNC=${XPP_SYNC:-auto}
case "$ACTION" in
add) ;;
*) exit 0 ;;
esac
case "${DEVPATH##*/}" in
astribanks:*) ;;
*) exit 0 ;;
esac
xpp_sync "$XPP_SYNC"

View 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

View 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

View 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"

View File

@@ -17,3 +17,8 @@
#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
#DAHDI_UDEV_DISABLE_SPANS=yes

View File

@@ -30,8 +30,6 @@ DOWNLOAD=@DOWNLOAD@
DAHDI_DEVMODE=@DAHDI_DEVMODE@
DAHDI_DECLARATION_AFTER_STATEMENT=@DAHDI_DECLARATION_AFTER_STATEMENT@
DAHDI_PINNED=@DAHDI_PINNED@
PBX_NEWT=@PBX_NEWT@
NEWT_LIB=@NEWT_LIB@
NEWT_INCLUDE=@NEWT_INCLUDE@

View File

@@ -13,6 +13,12 @@
# Digium TE420: PCI-Express quad-port T1/E1/J1
wct4xxp
# Digium TE435
# Digium TE235
# Digium TE436
# Digium TE236
wcte43x
# Digium TE120P: PCI single-port T1/E1/J1
# Digium TE121: PCI-Express single-port T1/E1/J1
# Digium TE122: PCI single-port T1/E1/J1
@@ -20,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
@@ -34,6 +42,9 @@ wcte11xp
# Digium TDM410P/AEX410: up to 4 analog ports
wctdm24xxp
# Digium A4A/A4B/A8A/A8B
wcaxx
# X100P - Single port FXO interface
# X101P - Single port FXO interface
wcfxo
@@ -42,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

View File

@@ -45,7 +45,6 @@
#define BLOCK_SIZE 2041
#define DEVICE "/dev/dahdi/channel"
static const char rcsid[] = "$Id$";
char *prog_name;
static void usage(void)
@@ -53,7 +52,6 @@ static void usage(void)
fprintf(stderr, "Usage: %s <dahdi_chan>\n", prog_name);
fprintf(stderr, " e.g.: %s /dev/dahdi/55\n", prog_name);
fprintf(stderr, " %s 455\n", prog_name);
fprintf(stderr, "%s version %s\n", prog_name, rcsid);
exit(1);
}

View File

@@ -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)

View File

@@ -44,7 +44,6 @@
#define BLOCK_SIZE 2039
#define DEVICE "/dev/dahdi/channel"
static const char rcsid[] = "$Id$";
char *prog_name;
static void usage(void)
@@ -52,7 +51,6 @@ static void usage(void)
fprintf(stderr, "Usage: %s <dahdi_chan>\n", prog_name);
fprintf(stderr, " e.g.: %s /dev/dahdi/55\n", prog_name);
fprintf(stderr, " %s 455\n", prog_name);
fprintf(stderr, "%s version %s\n", prog_name, rcsid);
exit(1);
}

View File

@@ -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
View 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

View File

@@ -8,6 +8,7 @@
# * The <id> field may be either:
# hardware_id
# @location
# devpath (in sysfs)
# * The <local_spanno> is the relative span number
# in the device (starting from 1)
# In this filed globbing rules apply. E.g:
@@ -24,4 +25,4 @@
# Set the first two spans of an Astribank to T1. The
# Astribanks is specified by its location instead of hardware_id
#@pci0000:00/0000:00:03.3/usb1/1-5/xbus-01/astribanks:xbus-01 [12]:T1
#@usb-0000:00:1d.7-3 [12]:T1

View File

@@ -1,193 +0,0 @@
#! /bin/sh
#
# /usr/share/dahdi/span_assignments:
#
# this script can be used both from udev and
# from the command line to assign/unassign and list
# current assignments.
#
# The first argument is an action:
# "add" to assign (spans which are not already assigned)
# "remove" to unassign (spans which are not already unassigned)
# "list" to show all spans (with/without assignments)
#
# Without further arguments, it operates on all existing spans
# With one or more sysfs dahdi_devices it is limited to those.
#
# Examples:
# span_assignments list
# span_assignments add # all
# span_assignments add /sys/bus/dahdi_devices/devices/astribanks:xbus-00
# span_assignments remove # all
#
devbase='/sys/bus/dahdi_devices/devices'
DAHDICONFDIR="${DAHDICONFDIR:-/etc/dahdi}"
pinned_spans_conf="$DAHDICONFDIR/pinned-spans.conf"
usage() {
echo >&2 "Usage: $0 {add|remove|list} [devpath ...]"
exit 1
}
if [ "$#" -eq 0 ]; then
usage
fi
action="$1"
shift
if [ ! -d "$devbase" ]; then
echo >&2 "$0: Missing '$devbase' (DAHDI driver unloaded?)"
exit 1
fi
# Use given devices or otherwise, all existing devices
if [ "$#" -gt 0 ]; then
DEVICES="$@"
else
DEVICES=`echo $devbase/*`
fi
show_devices() {
for device in $DEVICES
do
hw_id=`cat "$device/hardware_id"`
location=`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
if [ "$span" != '' ]; then
spanno=`echo $span | sed 's/^.*-//'`
name=`cat 2>/dev/null "$device/$span/name"`
basechan=`cat 2>/dev/null "$device/$span/basechan"`
else
spanno='-'
basechan='-'
fi
printf "%-4s %-12s %s\n" "$local_spanno:$spanno:$basechan" "[$hw_id]" "@$location"
done | sort -n
done
}
dump_config() {
for device in $DEVICES
do
hw_id=`cat "$device/hardware_id"`
location=`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
if [ "$hw_id" != '' ]; then
id="$hw_id"
else
id="@$location"
fi
for local_spanno in `cut -d: -f1 "$device/spantype"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
if [ "$span" != '' ]; then
spanno=`echo $span | sed 's/^.*-//'`
name=`cat 2>/dev/null "$device/$span/name"`
basechan=`cat 2>/dev/null "$device/$span/basechan"`
else
spanno='-'
fi
printf "%-30s %s\n" "$id" "$local_spanno:$spanno:$basechan"
done | sort -n
done
}
unassign_all_spans() {
for device in $DEVICES
do
find "$device" -follow -maxdepth 1 -name 'span-*' -type d | \
sort | while read spandir; do
local_spanno=`cat "$spandir/local_spanno"`
echo "unassign $device $local_spanno"
if ! echo "$local_spanno" > "$device/unassign_span"; then
echo >&2 "$0: failed unassigning '$local_spanno' in '$device'"
fi
done
done
}
# Allow comments and empty lines in config file
filter_conf() {
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$pinned_spans_conf"
}
# Beware of special characters in attributes
attr_clean() {
cat "$1" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
}
assign_device_spans() {
device="$1"
for s in $spanspecs
do
local_spanno=`echo "$s" | cut -d: -f1`
spanno=`echo "$s" | cut -d: -f2`
span="$device/span-$spanno"
if [ -d "$span" ]; then
span_local_spanno=`cat "$span/local_spanno"`
if [ "$span_local_spanno" != "$local_spanno" ]; then
echo "WARNING: $span_local_spanno != $local_spanno"
fi
echo "$device [$local_spanno] already assigned to $spanno. Skipping..."
continue
fi
echo "assign $device: $s"
if ! echo "$s" > "$device/assign_span"; then
echo >&2 "$0: failed assigning '$s' to '$device'"
fi
done
}
match_device() {
device="$1"
location='@'`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
hardware_id=`attr_clean "$device/hardware_id"`
filter_conf | while read id spanspecs
do
# We use case to enable shell-style globbing in configuration
case "$location" in
$id)
#echo "match location($id ~ $location): $spanspecs"
assign_device_spans "$device"
;;
esac
# We use case to enable shell-style globbing in configuration
case "$hardware_id" in
$id)
#echo "match hardware_id([$id] ~ $hardware_id): $spanspecs"
assign_device_spans "$device"
;;
esac
done
}
assign_devices() {
for device in $DEVICES
do
match_device "$device"
done
}
case "$action" in
list)
show_devices
;;
dump)
dump_config
;;
add)
assign_devices
;;
remove)
unassign_all_spans
;;
*)
usage
;;
esac

View File

@@ -1,160 +0,0 @@
#! /bin/sh
#
# /usr/share/dahdi/span_types:
#
# this script can be used both from udev and
# from the command line for spantype management.
#
# It use a configuration file /etc/dahdi/spantype.conf
# (the format is documented inside this file)
#
# The first argument is an action:
# "list" to show existing E1/T1/J1 types
# "dump" the same, but in a format (almost) suitable for
# the configuration file
# FIXME: we currently don't have the base channo in sysfs.
# "set" actually write the setting to the driver
#
# Examples:
# span_types list
# span_types dump
# span_types set # all
# span_types set /sys/bus/dahdi_devices/devices/astribanks:xbus-00
#
devbase='/sys/bus/dahdi_devices/devices'
DAHDICONFDIR="${DAHDICONFDIR:-/etc/dahdi}"
spantype_conf="$DAHDICONFDIR/spantype.conf"
usage() {
echo >&2 "Usage: $0 {list|dump|set} [devpath ...]"
exit 1
}
if [ "$#" -eq 0 ]; then
usage
fi
action="$1"
shift
# Use given devices or otherwise, all existing devices
if [ "$#" -gt 0 ]; then
DEVICES="$@"
else
DEVICES=`echo $devbase/*`
fi
show_spantypes() {
for device in $DEVICES
do
hw_id=`cat "$device/hardware_id"`
location='@'`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
cat "$device/spantype" | while read st; do
printf "%-10s %-20s %s\n" "$st" "[$hw_id]" "$location"
done | sort -n
done
}
dump_config() {
fmt="%-65s %s\n"
echo "# Map of dahdi_devices to span types for E1/T1/J1"
printf "$fmt" '# @location/hardware_id' 'span_type'
for device in $DEVICES
do
hw_id=`cat "$device/hardware_id"`
location='@'`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
if [ -n "$hw_id" ]; then
id="$hw_id"
else
id="$location"
fi
cat "$device/spantype" | while read st; do
case "$st" in
*:[ETJ]1)
printf "$fmt" "$id" "$st"
;;
esac
done | sort -n
done
}
# Allow comments and empty lines in config file
filter_conf() {
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$spantype_conf"
}
conf_spans() {
hw_id="$1"
location="$2"
filter_conf | (
# Collect device spans
# in a subshell, so $SPANS is not lost
SPANS=''
while read id spans; do
# GLOBBING
case "$location" in
$id)
#echo >&2 "match($id): $spans"
SPANS="$SPANS $spans"
;;
esac
case "$hw_id" in
$id)
#echo >&2 "match([$id]): $spans"
SPANS="$SPANS $spans"
;;
esac
done
echo "$SPANS"
)
}
# Beware of special characters in attributes
attr_clean() {
cat "$1" | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
}
device_set_spantype() {
device="$1"
attr_file="$device/spantype"
hw_id=`attr_clean "$device/hardware_id"`
location='@'`cd "$device" && pwd -P | sed 's,/sys/devices/,,'`
spanspecs=`conf_spans "$hw_id" "$location"`
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
done
}
set_spantypes() {
for device in $DEVICES
do
device_set_spantype "$device"
done
}
case "$action" in
list)
show_spantypes
;;
dump)
dump_config
;;
set)
set_spantypes
;;
*)
usage
;;
esac

View File

@@ -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

View File

@@ -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
View File

@@ -0,0 +1,6 @@
/*
* version.c.in
*/
const char dahdi_tools_version[] = "DAHDI Tools Version - @TOOLSVERSION@";

5
xpp/50-dahdi.conf Normal file
View File

@@ -0,0 +1,5 @@
# A dracut.conf(5) snippet
# Disable loading the Astribank (xpp_usb) drivers. This is because
# it relies on files in the root filesystem:
# See https://issues.asterisk.org/jira/browse/DAHLIN-352
omit_drivers+=" xpp_usb "

View File

@@ -1,173 +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
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)$(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

170
xpp/Makefile.am Normal file
View File

@@ -0,0 +1,170 @@
all-local: $(perl_checks)
SUBDIRS =
man_MANS =
# FIXME: try to improve code, so we can use $(PEDANTIC)
#PEDANTIC = -ansi -pedantic -std=c99
GLOBAL_CFLAGS = -I$(srcdir) -I$(srcdir)/xtalk/include $(PEDANTIC) -Wall
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 -iw 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)
dracutconfdir = @prefix@/lib/dracut/dracut.conf.d
dracutconf_DATA = 50-dahdi.conf
if PBX_USB
SUBDIRS += oct612x xtalk
if LIBUSBX
USB_CFLAGS = $(LIBUSBX_CFLAGS)
USB_LIBS = $(LIBUSBX_LIBS)
USB_NAME = libusbx
else
if LIBUSB
USB_CFLAGS = $(LIBUSB_CFLAGS)
USB_LIBS = $(LIBUSB_LIBS)
USB_NAME = libusb
endif
endif
noinst_LTLIBRARIES = libastribank.la libecholoader.la libhexfile.la
libastribank_la_SOURCES = \
astribank.c \
astribank.h \
mpptalk.c \
mpptalk.h \
astribank_license.c \
astribank_license.h \
#
libastribank_la_CFLAGS = $(GLOBAL_CFLAGS)
libastribank_la_LIBADD = xtalk/libxtalk.la
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_LIBS)
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_LIBS)
astribank_hexload_LDADD = \
libhexfile.la \
libastribank.la \
libecholoader.la \
oct612x/liboctasic.la \
#
astribank_allow_CFLAGS = $(GLOBAL_CFLAGS)
astribank_allow_LDFLAGS = $(USB_LIBS)
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 \
#

View File

@@ -47,9 +47,9 @@ Apart from the standard DAHDI build requirements, you also need:
* *libusb development headers* to build the Astribank firmware tools
(astribank_tool, astribank_hexload, astribank_allow).
This is typically the package libusb-dev on Debian (and derivatives
like Ubuntu) or libusb-devel on RedHat (and derivatives like
CentOS/Trixbox).
This is typically the package libusb-1.0-0-dev on Debian (and
derivatives such as Ubuntu) or libusbx-devel on RedHat (and derivatives
such as CentOS).
* *Echo Canceller Module firmware*: If you have an Astribank with an
echo canceller module, see the following section.
@@ -1257,8 +1257,8 @@ Astribanks Synchronization Source
If there is more than one Astribank on the system, all the Astribanks
keep their clock in sync. Optionally the Astribanks can synchronize
their clock to the master DAHDI device (in case it is a different DAHDI
device). Normally you just use the default init.d script or run
explicitly:
device). Normally it would be run automatically from the udev hooks
run on device plug (handle_device), but you can also run it explicitly:
xpp_sync auto
@@ -1488,6 +1488,9 @@ other side.
current. That is: which ones are connected to an active FXS on the
other side.
===== /sys/bus/astribanks/devices/xbus-NN/NN:M:P/hwid
Prints <module type>.<module subtype>. Both are small numbers.
===== /sys/bus/astribanks/devices/xbus-NN/NN:M:P/offhook
Shows ports that are (1) or are not (0) off-hook. When a channel is
not off-hook. For BRI and E1/T1 the value is 1 if the span is in use.

177
xpp/astribank.c Normal file
View File

@@ -0,0 +1,177 @@
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <xtalk/debug.h>
#include <xtalk/xusb.h>
#include "mpptalk.h"
#include "astribank.h"
#define DBG_MASK 0x08
struct astribank {
struct xusb_device *xusb_device;
struct xusb_iface *xpp_iface;
struct xusb_iface *mpp_iface;
struct mpp_device *mpp;
char *path;
};
struct astribank *astribank_new(const char *path)
{
struct astribank *ab;
ab = calloc(sizeof(*ab), 1);
if (!ab) {
ERR("%s: Failed allocating Astribank device\n", path);
goto err;
}
ab->xusb_device = xusb_find_bypath(path);
if (!ab->xusb_device) {
ERR("%s: Cannot find Astribank\n", path);
goto err;
}
ab->path = strdup(path);
if (!ab->path) {
ERR("%s: Failed allocating Astribank path\n", path);
goto err;
}
return ab;
err:
astribank_destroy(ab);
return NULL;
}
void astribank_destroy(struct astribank *ab)
{
if (ab) {
if (ab->path)
free(ab->path);
if (ab->xpp_iface)
xusb_release(ab->xpp_iface);
if (ab->mpp) {
mpp_delete(ab->mpp); /* this also closes the underlying xusb */
ab->mpp = NULL;
}
if (ab->xusb_device) {
xusb_destroy(ab->xusb_device);
ab->xusb_device = NULL;
}
free(ab);
ab = NULL;
}
}
struct xusb_iface *astribank_xpp_open(struct astribank *ab)
{
int ret;
ret = xusb_claim(ab->xusb_device, 0, &ab->xpp_iface);
if (ret < 0) {
ERR("%s: Cannot claim XPP interface\n", ab->path);
goto err;
}
DBG("%s: Claimed Astribank XPP interface\n", ab->path);
return ab->xpp_iface;
err:
if (ab->xpp_iface)
xusb_release(ab->xpp_iface);
return NULL;
}
struct mpp_device *astribank_mpp_open(struct astribank *ab)
{
int ret;
ret = xusb_claim(ab->xusb_device, 1, &ab->mpp_iface);
if (ret < 0) {
ERR("%s: Cannot claim MPP interface\n", ab->path);
goto err;
}
DBG("%s: Claimed Astribank MPP interface\n", ab->path);
ab->mpp = mpp_new(ab->mpp_iface);
if (!ab->mpp) {
ERR("Failed initializing MPP protocol\n");
goto err;
}
ret = mpp_status_query(ab->mpp);
if (ret < 0) {
ERR("status query failed (ret=%d)\n", ret);
goto err;
}
return ab->mpp;
err:
if (ab->mpp) {
mpp_delete(ab->mpp); /* this also closes the underlying xusb */
ab->mpp = NULL;
}
return NULL;
}
struct xusb_device *xusb_dev_of_astribank(const struct astribank *ab)
{
assert(ab->xusb_device);
return ab->xusb_device;
}
const char *astribank_devpath(const struct astribank *ab)
{
return xusb_devpath(ab->xusb_device);
}
const char *astribank_serial(const struct astribank *ab)
{
return xusb_serial(ab->xusb_device);
}
void show_astribank_info(const struct astribank *ab)
{
struct xusb_device *xusb_device;
assert(ab != NULL);
xusb_device = ab->xusb_device;
assert(xusb_device != NULL);
if(verbose <= LOG_INFO) {
xusb_showinfo(xusb_device);
} else {
const struct xusb_spec *spec;
spec = xusb_spec(xusb_device);
printf("USB Bus/Device: [%s]\n", xusb_devpath(xusb_device));
printf("USB Firmware Type: [%s]\n", spec->name);
printf("USB iSerialNumber: [%s]\n", xusb_serial(xusb_device));
printf("USB iManufacturer: [%s]\n", xusb_manufacturer(xusb_device));
printf("USB iProduct: [%s]\n", xusb_product(xusb_device));
}
}
int astribank_send(struct astribank *ab, int interface_num, const char *buf, int len, int timeout)
{
struct xusb_iface *iface;
if (interface_num == 0)
iface = ab->xpp_iface;
else if (interface_num == 1)
iface = ab->mpp_iface;
else {
ERR("Unknown interface number (%d)\n", interface_num);
return -EINVAL;
}
return xusb_send(iface, buf, len, timeout);
}
int astribank_recv(struct astribank *ab, int interface_num, char *buf, size_t len, int timeout)
{
struct xusb_iface *iface;
if (interface_num == 0)
iface = ab->xpp_iface;
else if (interface_num == 1)
iface = ab->mpp_iface;
else {
ERR("Unknown interface number (%d)\n", interface_num);
return -EINVAL;
}
return xusb_recv(iface, buf, len, timeout);
}

33
xpp/astribank.h Normal file
View File

@@ -0,0 +1,33 @@
#ifndef ASTRIBANK_H
#define ASTRIBANK_H
#include <mpptalk.h>
struct astribank *astribank_new(const char *path);
void astribank_destroy(struct astribank *ab);
void show_astribank_info(const struct astribank *ab);
struct xusb_iface *astribank_xpp_open(struct astribank *ab);
struct mpp_device *astribank_mpp_open(struct astribank *ab);
struct xusb_device *xusb_dev_of_astribank(const struct astribank *ab);
const char *astribank_devpath(const struct astribank *ab);
const char *astribank_serial(const struct astribank *ab);
int astribank_send(struct astribank *ab, int interface_num, const char *buf, int len, int timeout);
int astribank_recv(struct astribank *ab, int interface_num, char *buf, size_t len, int timeout);
#define AB_REPORT(report_type, astribank, fmt, ...) \
report_type("%s [%s]: " fmt, \
astribank_devpath(astribank), \
astribank_serial(astribank), \
## __VA_ARGS__)
#define AB_INFO(astribank, fmt, ...) \
AB_REPORT(INFO, astribank, fmt, ## __VA_ARGS__)
#define AB_ERR(astribank, fmt, ...) \
AB_REPORT(ERR, astribank, fmt, ## __VA_ARGS__)
#endif /* ASTRIBANK_H */

View File

@@ -31,13 +31,11 @@
#include <sys/types.h>
#include <arpa/inet.h>
#include <ctype.h>
#include "mpp.h"
#include <xtalk/debug.h>
#include "mpptalk.h"
#include <debug.h>
#include "astribank.h"
#include "astribank_license.h"
static const char rcsid[] = "$Id$";
#define DBG_MASK 0x80
static char *progname;
@@ -55,28 +53,11 @@ static void usage()
exit(1);
}
static int capabilities_burn(
struct astribank_device *astribank,
struct eeprom_table *eeprom_table,
struct capabilities *capabilities,
struct capkey *key)
{
int ret;
INFO("Burning capabilities\n");
ret = mpp_caps_set(astribank, eeprom_table, capabilities, key);
if(ret < 0) {
ERR("Capabilities burning failed: %d\n", ret);
return ret;
}
INFO("Done\n");
return 0;
}
int main(int argc, char *argv[])
{
char *devpath = NULL;
struct astribank_device *astribank;
struct astribank *astribank;
struct mpp_device *mpp;
struct eeprom_table eeprom_table;
struct capabilities caps;
struct capkey key;
@@ -127,16 +108,19 @@ int main(int argc, char *argv[])
usage();
}
DBG("Startup %s\n", devpath);
if((astribank = mpp_init(devpath, 1)) == NULL) {
ERR("Failed initializing MPP\n");
astribank = astribank_new(devpath);
if(!astribank) {
ERR("Failed initializing Astribank\n");
return 1;
}
if(astribank->eeprom_type != EEPROM_TYPE_LARGE) {
mpp = astribank_mpp_open(astribank);
ret = mpp_eeprom_type(mpp);
if(ret != EEPROM_TYPE_LARGE) {
ERR("Cannot use this program with astribank EEPROM type %d (need %d)\n",
astribank->eeprom_type, EEPROM_TYPE_LARGE);
ret, EEPROM_TYPE_LARGE);
return 1;
}
ret = mpp_caps_get(astribank, &eeprom_table, &caps, &key);
ret = mpp_caps_get(mpp, &eeprom_table, &caps, &key);
if(ret < 0) {
ERR("Failed to get original capabilities: %d\n", ret);
return 1;
@@ -158,8 +142,13 @@ int main(int argc, char *argv[])
return 1;
}
show_capabilities(&caps, stderr);
if (capabilities_burn(astribank, &eeprom_table, &caps, &key) < 0)
INFO("Burning capabilities\n");
ret = mpp_caps_set(mpp, &eeprom_table, &caps, &key);
if(ret < 0) {
ERR("Capabilities burning failed: %d\n", ret);
return 1;
}
INFO("Done\n");
if (file != stdin)
fclose(file);
} else {
@@ -180,6 +169,6 @@ int main(int argc, char *argv[])
if (file != stdout)
fclose(file);
}
mpp_exit(astribank);
astribank_destroy(astribank);
return 0;
}

View File

@@ -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 existence 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

View File

@@ -28,17 +28,19 @@
#include <errno.h>
#include <assert.h>
#include <arpa/inet.h>
#include <debug.h>
#include <autoconfig.h>
#include <xtalk/debug.h>
#include <xtalk/xusb.h>
#include "hexfile.h"
#include "mpptalk.h"
#include "astribank.h"
#include "pic_loader.h"
#include "echo_loader.h"
#include "astribank_usb.h"
#include "../autoconfig.h"
#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 +52,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");
@@ -59,7 +62,7 @@ static void usage()
exit(1);
}
int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
int handle_hexline(struct mpp_device *mpp, struct hexline *hexline)
{
uint16_t len;
uint16_t offset_dummy;
@@ -67,7 +70,7 @@ int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
int ret;
assert(hexline);
assert(astribank);
assert(mpp);
if(hexline->d.content.header.tt != TT_DATA) {
DBG("Non data record type = %d\n", hexline->d.content.header.tt);
return 0;
@@ -75,14 +78,19 @@ int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
len = hexline->d.content.header.ll;
offset_dummy = hexline->d.content.header.offset;
data = hexline->d.content.tt_data.data;
if((ret = mpp_send_seg(astribank, data, offset_dummy, len)) < 0) {
if((ret = mpp_send_seg(mpp, data, offset_dummy, len)) < 0) {
ERR("Failed hexfile send line: %d\n", ret);
return -EINVAL;
}
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;
@@ -93,7 +101,7 @@ void print_parse_errors(int level, const char *msg, ...)
}
}
static int load_hexfile(struct astribank_device *astribank, const char *hexfile, enum dev_dest dest)
static int load_hexfile(struct mpp_device *mpp, const char *hexfile, enum dev_dest dest)
{
struct hexdata *hexdata = NULL;
int finished = 0;
@@ -101,19 +109,24 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile,
unsigned i;
char star[] = "+\\+|+/+-";
const char *devstr;
struct xusb_device *xusb_device;
struct xusb_iface *xusb_iface;
parse_hexfile_set_reporting(print_parse_errors);
if((hexdata = parse_hexfile(hexfile, MAX_HEX_LINES)) == NULL) {
perror(hexfile);
return -errno;
}
devstr = xusb_devpath(astribank->xusb);
xusb_iface = xubs_iface_of_mpp(mpp);
xusb_device = xusb_deviceof(xusb_iface);
devstr = xusb_devpath(xusb_device);
INFO("%s [%s]: Loading %s Firmware: %s (version %s)\n",
devstr,
xusb_serial(astribank->xusb),
xusb_serial(xusb_device),
dev_dest2str(dest),
hexdata->fname, hexdata->version_info);
if((ret = mpp_send_start(astribank, dest, hexdata->version_info)) < 0) {
if((ret = mpp_send_start(mpp, dest, hexdata->version_info)) < 0) {
ERR("%s: Failed hexfile send start: %d\n", devstr, ret);
return ret;
}
@@ -135,7 +148,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile,
finished = 1;
continue;
}
if((ret = handle_hexline(astribank, hexline)) < 0) {
if((ret = handle_hexline(mpp, hexline)) < 0) {
ERR("%s: Failed hexfile sending in lineno %d (ret=%d)\n", devstr, i, ret);;
return ret;
}
@@ -144,7 +157,7 @@ static int load_hexfile(struct astribank_device *astribank, const char *hexfile,
putchar('\n');
fflush(stdout);
}
if((ret = mpp_send_end(astribank)) < 0) {
if((ret = mpp_send_end(mpp)) < 0) {
ERR("%s: Failed hexfile send end: %d\n", devstr, ret);
return ret;
}
@@ -164,12 +177,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";
int iface_num;
const char options[] = "vd:D:EFOopAS:";
int ret;
progname = argv[0];
@@ -210,6 +224,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;
@@ -235,7 +252,6 @@ int main(int argc, char *argv[])
" and -p options are mutually exclusive, if neither is used then -o should present\n");
usage();
}
iface_num = (opt_dest) ? 1 : 0;
if(!opt_pic && !opt_ecver) {
if(optind != argc - 1) {
ERR("Got %d hexfile names (Need exactly one hexfile)\n",
@@ -247,33 +263,54 @@ 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
*/
struct astribank_device *astribank;
struct astribank *astribank;
struct mpp_device *mpp;
if((astribank = mpp_init(devpath, iface_num)) == NULL) {
astribank = astribank_new(devpath);
if(!astribank) {
ERR("%s: Opening astribank failed\n", devpath);
return 1;
}
//show_astribank_info(astribank);
if(load_hexfile(astribank, argv[optind], dest) < 0) {
mpp = astribank_mpp_open(astribank);
if(!mpp) {
ERR("%s: Opening astribank XPP interface failed\n", devpath);
return 1;
}
show_astribank_info(astribank);
if(load_hexfile(mpp, argv[optind], dest) < 0) {
ERR("%s: Loading firmware to %s failed\n", devpath, dev_dest2str(dest));
return 1;
}
astribank_close(astribank, 0);
astribank_destroy(astribank);
} else if(opt_pic || opt_echo || opt_ecver) {
/*
* XPP Interface
*/
struct astribank_device *astribank;
struct astribank *astribank;
struct xusb_iface *xpp_iface;
if((astribank = astribank_open(devpath, iface_num)) == NULL) {
astribank = astribank_new(devpath);
if (!astribank) {
ERR("%s: Opening astribank failed\n", devpath);
return 1;
}
//show_astribank_info(astribank);
xpp_iface = astribank_xpp_open(astribank);
if(!xpp_iface) {
ERR("%s: Opening astribank XPP interface failed\n", devpath);
return 1;
}
show_astribank_info(astribank);
#if HAVE_OCTASIC
if (opt_ecver) {
if((ret = echo_ver(astribank)) < 0) {
@@ -290,13 +327,13 @@ 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;
}
#endif
}
astribank_close(astribank, 0);
astribank_destroy(astribank);
}
return 0;
}

View File

@@ -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.
@@ -75,22 +94,27 @@ wait_for_udev() {
UDEV_SETTLE_MAX_TIME=10
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"
udevsettle_cmd=
if [ -x /bin/udevadm ]; then
udevsettle_cmd="/bin/udevadm settle"
elif [ -x /sbin/udevadm ]; then
# Assume modern system, udevadm has settle parameter
if ! time /sbin/udevadm settle --timeout="$UDEV_SETTLE_MAX_TIME"
then
echo "udevadm failed ($?)."
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
sleep "$UDEV_SETTLE_MAX_TIME"
fi
udevsettle_cmd="/sbin/udevadm settle"
elif [ -x /sbin/udevsettle ]; then
udevsettle_cmd="/sbin/udevsettle"
else
echo "No udevsettle/udevadm."
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
sleep "$UDEV_SETTLE_MAX_TIME"
return
fi
if ! $udevsettle_cmd --timeout="$UDEV_SETTLE_MAX_TIME"
then
echo "udevadm failed ($?)."
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
sleep "$UDEV_SETTLE_MAX_TIME"
fi
sleep 1 # Wait a bit more (races)
}
@@ -110,13 +134,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 +162,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 +175,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

View File

@@ -83,7 +83,7 @@ Q: Why do you use a semaphore?
A: because, unlike the filesystem, it is writable at any given time.
.SH BUGS
Option ordering matter. The \fB\-v\fR and \fB\-d\fR options should preceed
Option ordering matter. The \fB\-v\fR and \fB\-d\fR options should precede
the actions (\fB\-a\fR, \fB\-r\fR and \fB\-w\fR).
The \fB\-t\fItimeout\fR option should preceed the \fB\-w\fR option.

View File

@@ -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)

View File

@@ -24,7 +24,7 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <debug.h>
#include <xtalk/debug.h>
#include "astribank_license.h"
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))

View File

@@ -1,7 +1,7 @@
#ifndef ASTRIBANK_ALLOW_H
#define ASTRIBANK_ALLOW_H
#include "mpp.h"
#include "mpptalk.h"
enum license_markers {
LICENSE_MARKER_NONE = 0,

View File

@@ -28,10 +28,10 @@
#include <getopt.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include "astribank_usb.h"
#include <xtalk/debug.h>
#include <xtalk/xusb.h>
#include "mpptalk.h"
#include <debug.h>
#include <xusb.h>
#include "astribank.h"
#define DBG_MASK 0x80
/* if enabled, adds support for resetting pre-MPP USB firmware - if we
@@ -72,94 +72,15 @@ static int reset_kind(const char *arg)
if(strcasecmp(reset_kinds[i].name, arg) == 0)
return reset_kinds[i].type_code;
}
ERR("Uknown reset kind '%s'\n", arg);
ERR("Unknown reset kind '%s'\n", arg);
return -1;
}
static int show_hardware(struct astribank_device *astribank)
{
int ret;
struct eeprom_table eeprom_table;
struct capabilities capabilities;
struct extrainfo extrainfo;
ret = mpp_caps_get(astribank, &eeprom_table, &capabilities, NULL);
if(ret < 0)
return ret;
show_eeprom(&eeprom_table, stdout);
show_astribank_status(astribank, stdout);
if(astribank->eeprom_type == EEPROM_TYPE_LARGE) {
show_capabilities(&capabilities, stdout);
if(STATUS_FPGA_LOADED(astribank->status)) {
uint8_t unit;
uint8_t card_status;
uint8_t card_type;
uint8_t fpga_configuration;
uint8_t status;
for(unit = 0; unit < 5; unit++) {
ret = mpps_card_info(astribank, unit, &card_type, &card_status);
if(ret < 0)
return ret;
printf("CARD %d: type=%x.%x %s\n", unit,
((card_type >> 4) & 0xF), (card_type & 0xF),
((card_status & 0x1) ? "PIC" : "NOPIC"));
}
ret = mpps_stat(astribank, unit, &fpga_configuration, &status);
if (ret < 0)
return ret;
printf("FPGA: %-17s: %d\n", "Configuration num", fpga_configuration);
printf("FPGA: %-17s: %s\n", "Watchdog Timer",
(SER_STAT_WATCHDOG_READY(status)) ? "ready" : "expired");
printf("FPGA: %-17s: %s\n", "XPD Alive",
(SER_STAT_XPD_ALIVE(status)) ? "yes" : "no");
}
ret = mpp_extrainfo_get(astribank, &extrainfo);
if(ret < 0)
return ret;
show_extrainfo(&extrainfo, stdout);
if(CAP_EXTRA_TWINSTAR(&capabilities)) {
twinstar_show(astribank, stdout);
}
}
return 0;
}
#ifdef SUPPORT_OLD_RESET
/* Try to reset a device using USB_FW.hex, up to Xorcom rev. 6885 */
int old_reset(const char* devpath)
{
struct astribank_device *astribank;
int ret;
struct {
uint8_t op;
} PACKED header = {0x20}; /* PT_RESET */
char *buf = (char*) &header;
/* Note that the function re-opens the connection to the Astribank
* as any reference to the previous connection was lost when mpp_open
* returned NULL as the astribank reference. */
astribank = astribank_open(devpath, 1);
if (!astribank) {
DBG("Failed re-opening astribank device for old_reset\n");
return -ENODEV;
}
ret = xusb_send(astribank->xusb, buf, 1, 5000);
/* If we just had a reenumeration, we may get -ENODEV */
if(ret < 0 && ret != -ENODEV)
return ret;
/* We don't astribank_close(), as it has likely been
* reenumerated by now. */
return 0;
}
#endif /* SUPPORT_OLD_RESET */
int main(int argc, char *argv[])
{
char *devpath = NULL;
struct astribank_device *astribank;
struct astribank *astribank;
struct mpp_device *mpp;
const char options[] = "vd:D:nr:p:w:Q";
int opt_renumerate = 0;
char *opt_port = NULL;
@@ -218,20 +139,12 @@ int main(int argc, char *argv[])
usage();
}
DBG("Startup %s\n", devpath);
if((astribank = mpp_init(devpath, 1)) == NULL) {
ERR("Failed initializing MPP\n");
#ifdef SUPPORT_OLD_RESET
DBG("opt_reset = %s\n", opt_reset);
if (opt_reset) {
DBG("Trying old reset method\n");
if ((ret = old_reset(devpath)) != 0) {
ERR("Old reset method failed as well: %d\n", ret);
}
}
#endif /* SUPPORT_OLD_RESET */
astribank = astribank_new(devpath);
if(!astribank) {
ERR("Failed initializing Astribank\n");
return 1;
}
mpp = astribank_mpp_open(astribank);
/*
* First process reset options. We want to be able
* to reset minimal USB firmwares even if they don't
@@ -244,19 +157,19 @@ int main(int argc, char *argv[])
ERR("Bad reset kind '%s'\n", opt_reset);
return 1;
}
DBG("Reseting (%s)\n", opt_reset);
if((ret = mpp_reset(astribank, full_reset)) < 0) {
ERR("%s Reseting astribank failed: %d\n",
DBG("Resetting (%s)\n", opt_reset);
if((ret = mpp_reset(mpp, full_reset)) < 0) {
ERR("%s Resetting astribank failed: %d\n",
(full_reset) ? "Full" : "Half", ret);
}
goto out;
}
show_astribank_info(astribank);
if(opt_query) {
show_hardware(astribank);
show_hardware(mpp);
} else if(opt_renumerate) {
DBG("Renumerate\n");
if((ret = mpp_renumerate(astribank)) < 0) {
if((ret = mpp_renumerate(mpp)) < 0) {
ERR("Renumerating astribank failed: %d\n", ret);
}
} else if(opt_watchdog) {
@@ -264,24 +177,24 @@ int main(int argc, char *argv[])
DBG("TWINSTAR: Setting watchdog %s-guard\n",
(watchdogstate) ? "on" : "off");
if((ret = mpp_tws_setwatchdog(astribank, watchdogstate)) < 0) {
if((ret = mpp_tws_setwatchdog(mpp, watchdogstate)) < 0) {
ERR("Failed to set watchdog to %d\n", watchdogstate);
return 1;
}
} else if(opt_port) {
int new_portnum = strtoul(opt_port, NULL, 0);
int tws_portnum = mpp_tws_portnum(astribank);
int tws_portnum = mpp_tws_portnum(mpp);
char *msg = (new_portnum == tws_portnum)
? " Same same, never mind..."
: "";
DBG("TWINSTAR: Setting portnum to %d.%s\n", new_portnum, msg);
if((ret = mpp_tws_setportnum(astribank, new_portnum)) < 0) {
if((ret = mpp_tws_setportnum(mpp, new_portnum)) < 0) {
ERR("Failed to set USB portnum to %d\n", new_portnum);
return 1;
}
}
out:
mpp_exit(astribank);
astribank_destroy(astribank);
return 0;
}

View File

@@ -1,276 +0,0 @@
/*
* Written by Oron Peled <oron@actcom.co.il>
* Copyright (C) 2008, 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 _GNU_SOURCE /* for memrchr() */
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <syslog.h>
#include <arpa/inet.h>
#include <xusb.h>
#include "astribank_usb.h"
#include <debug.h>
static const char rcsid[] = "$Id$";
#define DBG_MASK 0x01
#define TIMEOUT 500
#define TYPE_ENTRY(t,p,ni,n,ne,out,in,...) \
{ \
.my_vendor_id = 0xe4e4, \
.my_product_id = (p), \
.name = #t, \
.num_interfaces = (ni), \
.my_interface_num = (n), \
.num_endpoints = (ne), \
.my_ep_in = (in), \
.my_ep_out = (out), \
}
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
static const struct xusb_spec astribank_specs[] = {
/* OLD Firmwares */
TYPE_ENTRY("USB-OLDFXS", 0x1131, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("FPGA-OLDFXS", 0x1132, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("USB-BRI", 0x1141, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("FPGA-BRI", 0x1142, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("USB-OLD", 0x1151, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("FPGA-OLD", 0x1152, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("USB-MULTI", 0x1161, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("FPGA-MULTI", 0x1162, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("BURNED-MULTI", 0x1164, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
TYPE_ENTRY("USB-BURN", 0x1112, 2, 1, 2, MP_EP_OUT, MP_EP_IN),
};
static const struct xusb_spec astribank_pic_specs[] = {
TYPE_ENTRY("USB_PIC", 0x1161, 2, 0, 2, XPP_EP_OUT, XPP_EP_IN),
};
#undef TYPE_ENTRY
//static int verbose = LOG_DEBUG;
/*
* USB handling
*/
struct astribank_device *astribank_open(const char devpath[], int iface_num)
{
struct astribank_device *astribank = NULL;
struct xusb *xusb;
DBG("devpath='%s' iface_num=%d\n", devpath, iface_num);
if((astribank = malloc(sizeof(struct astribank_device))) == NULL) {
ERR("Out of memory\n");
goto fail;
}
memset(astribank, 0, sizeof(*astribank));
if (iface_num) {
xusb = xusb_find_bypath(astribank_specs, ARRAY_SIZE(astribank_specs), devpath);
} else {
xusb = xusb_find_bypath(astribank_pic_specs, ARRAY_SIZE(astribank_pic_specs), devpath);
}
if (!xusb) {
ERR("%s: No device found\n", __func__);
goto fail;
}
astribank->xusb = xusb;
astribank->is_usb2 = (xusb_packet_size(xusb) == 512);
astribank->my_interface_num = iface_num;
if (xusb_claim_interface(astribank->xusb) < 0) {
ERR("xusb_claim_interface failed\n");
goto fail;
}
astribank->tx_sequenceno = 1;
return astribank;
fail:
if (astribank) {
free(astribank);
astribank = NULL;
}
return NULL;
}
/*
* MP device handling
*/
void show_astribank_info(const struct astribank_device *astribank)
{
struct xusb *xusb;
assert(astribank != NULL);
xusb = astribank->xusb;
assert(xusb != NULL);
if(verbose <= LOG_INFO) {
xusb_showinfo(xusb);
} else {
const struct xusb_spec *spec;
spec = xusb_spec(xusb);
printf("USB Bus/Device: [%s]\n", xusb_devpath(xusb));
printf("USB Firmware Type: [%s]\n", spec->name);
printf("USB iSerialNumber: [%s]\n", xusb_serial(xusb));
printf("USB iManufacturer: [%s]\n", xusb_manufacturer(xusb));
printf("USB iProduct: [%s]\n", xusb_product(xusb));
}
}
void astribank_close(struct astribank_device *astribank, int disconnected)
{
assert(astribank != NULL);
if (astribank->xusb) {
xusb_close(astribank->xusb);
astribank->xusb = NULL;
}
astribank->tx_sequenceno = 0;
}
#if 0
int flush_read(struct astribank_device *astribank)
{
char tmpbuf[BUFSIZ];
int ret;
DBG("starting...\n");
memset(tmpbuf, 0, BUFSIZ);
ret = recv_usb(astribank, tmpbuf, BUFSIZ, 1);
if(ret < 0 && ret != -ETIMEDOUT) {
ERR("ret=%d\n", ret);
return ret;
} else if(ret > 0) {
DBG("Got %d bytes:\n", ret);
dump_packet(LOG_DEBUG, DBG_MASK, __FUNCTION__, tmpbuf, ret);
}
return 0;
}
#endif
int release_isvalid(uint16_t release)
{
uint8_t rmajor = (release >> 8) & 0xFF;
uint8_t rminor = release & 0xFF;
return (rmajor > 0) &&
(rmajor < 10) &&
(rminor > 0) &&
(rminor < 10);
}
int label_isvalid(const char *label)
{
int len;
int goodlen;
const char GOOD_CHARS[] =
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789"
"-_.";
len = strlen(label);
goodlen = strspn(label, GOOD_CHARS);
if(len > LABEL_SIZE) {
ERR("Label too long (%d > %d)\n", len, LABEL_SIZE);
return 0;
}
if(goodlen != len) {
ERR("Bad character in label (pos=%d)\n", goodlen);
return 0;
}
return 1;
}
int eeprom_fill(struct eeprom_table *eprm,
const char *vendor,
const char *product,
const char *release,
const char *label)
{
uint16_t val;
eprm->source = 0xC0;
eprm->config_byte = 0;
if(vendor) {
val = strtoul(vendor, NULL, 0);
if(!val) {
ERR("Invalid vendor '%s'\n",
vendor);
return -EINVAL;
}
eprm->vendor = val;
}
if(product) {
val = strtoul(product, NULL, 0);
if(!val) {
ERR("Invalid product '%s'\n",
product);
return -EINVAL;
}
eprm->product = val;
}
if(release) {
int release_major = 0;
int release_minor = 0;
uint16_t value;
if(sscanf(release, "%d.%d", &release_major, &release_minor) != 2) {
ERR("Failed to parse release number '%s'\n", release);
return -EINVAL;
}
value = (release_major << 8) | release_minor;
DBG("Parsed release(%d): major=%d, minor=%d\n",
value, release_major, release_minor);
if(!release_isvalid(value)) {
ERR("Invalid release number 0x%X\n", value);
return -EINVAL;
}
eprm->release = value;
}
if(label) {
/* padding */
if(!label_isvalid(label)) {
ERR("Invalid label '%s'\n", label);
return -EINVAL;
}
memset(eprm->label, 0, LABEL_SIZE);
memcpy(eprm->label, label, strlen(label));
}
return 0;
}
int astribank_has_twinstar(struct astribank_device *astribank)
{
uint16_t product_series;
assert(astribank != NULL);
product_series = xusb_product_id(astribank->xusb);
product_series &= 0xFFF0;
if(product_series == 0x1160) /* New boards */
return 1;
return 0;
}

View File

@@ -1,113 +0,0 @@
#ifndef ASTRIBANK_USB_H
#define ASTRIBANK_USB_H
/*
* Written by Oron Peled <oron@actcom.co.il>
* Copyright (C) 2008, 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 <xusb.h>
#include <xtalk.h>
#include "mpp.h"
/*
* Astribank handling
*/
#define PACKET_SIZE 512
/* USB Endpoints */
#define MP_EP_OUT 0x04 /* Managment processor */
#define MP_EP_IN 0x88 /* Managment processor */
#define XPP_EP_OUT 0x02 /* XPP */
#define XPP_EP_IN 0x86 /* XPP */
/* USB firmware types */
#define USB_11xx 0
#define USB_FIRMWARE_II 1
#define USB_PIC 2
struct interface_type {
int type_code;
int num_interfaces;
int my_interface_num;
int num_endpoints;
int my_ep_out;
int my_ep_in;
char *name;
int endpoints[4]; /* for matching */
};
enum eeprom_burn_state {
BURN_STATE_NONE = 0,
BURN_STATE_STARTED = 1,
BURN_STATE_ENDED = 2,
BURN_STATE_FAILED = 3,
};
struct astribank_device {
struct xusb *xusb;
struct xtalk_device *xtalk_dev;
usb_dev_handle *handle;
int my_interface_num;
int my_ep_out;
int my_ep_in;
char iInterface[BUFSIZ];
int is_usb2;
enum eeprom_type eeprom_type;
enum eeprom_burn_state burn_state;
uint8_t status;
uint8_t mpp_proto_version;
struct eeprom_table *eeprom;
struct firmware_versions fw_versions;
uint16_t tx_sequenceno;
};
/*
* Prototypes
*/
struct astribank_device *astribank_open(const char devpath[], int iface_num);
void astribank_close(struct astribank_device *astribank, int disconnected);
void show_astribank_info(const struct astribank_device *astribank);
int send_usb(struct astribank_device *astribank, char *buf, int len, int timeout);
int recv_usb(struct astribank_device *astribank, char *buf, size_t len, int timeout);
int flush_read(struct astribank_device *astribank);
int eeprom_fill(struct eeprom_table *eprm,
const char *vendor,
const char *product,
const char *release,
const char *label);
int astribank_has_twinstar(struct astribank_device *astribank);
int label_isvalid(const char *label);
#define AB_REPORT(report_type, astribank, fmt, ...) \
report_type("%s [%s]: " fmt, \
xusb_devpath((astribank)->xusb), \
xusb_serial((astribank)->xusb), \
## __VA_ARGS__)
#define AB_INFO(astribank, fmt, ...) \
AB_REPORT(INFO, astribank, fmt, ## __VA_ARGS__)
#define AB_ERR(astribank, fmt, ...) \
AB_REPORT(ERR, astribank, fmt, ## __VA_ARGS__)
#endif /* ASTRIBANK_USB_H */

View File

@@ -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 = ('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

View File

@@ -19,11 +19,32 @@ use Dahdi::Xpp::Xpd;
use Getopt::Std;
sub usage {
die "Usage: $0 [-s sort_order] [on|off|1|0]\n";
die "Usage: $0 [-v] [-R] [-s sort_order] [on|off|1|0]\n";
}
sub check_param {
my $param = shift || die;
open(F, $param) || return '';
my $val = <F>;
close F;
chomp $val;
return $val;
}
my %opts;
getopts('s:', \%opts) || usage;
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') 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'};
@@ -41,9 +62,11 @@ if(defined $sort_order) {
@ARGV == 0 or @ARGV == 1 or usage;
my $on = shift;
my $verbose = 0;
my $verbose = $opts{'v'};
my $should_output = 1;
#print "dahdi_autoreg=$dahdi_autoreg auto_assign_spans=$auto_assign_spans have_assigned_spans_config='$have_assigned_spans_config' have_span_types_config='$have_span_types_config'\n";
if(defined($on)) { # Translate to booleans
$on = uc($on);
$on =~ /^(ON|OFF|1|0)$/ or usage;
@@ -59,26 +82,47 @@ 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;
my $prev = $xbus->dahdi_registration($on);
if(!defined($prev)) { # Failure
printf STDERR "%s: Failed %s\n", $xbus->name, $!;
next;
}
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 $?;
}
}
}
if (defined($on) && $on) {
if ($opts{'R'} || ! $default_auto_assign) {
# wait for UDEV to do its stuff
system "dahdi_waitfor_span_assignments assigned";
}
}
foreach my $xbus (Dahdi::Xpp::xbuses($sorter)) {
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;
}
my $spanno = $xpd->xpd_getattr('span');
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 $spanstr = ($spanno) ? ("Span " . $spanno) : "unassigned";
myprintf "%s\n", $spanstr ;
}
}
myprintf "# Sorted: $sort_order\n" if defined $sort_order;
@@ -91,7 +135,7 @@ dahdi_registration - Handle registration of Xorcom XPD modules in dahdi.
=head1 SYNOPSIS
dahdi_registration [-s sortorder] [on|off]
dahdi_registration [-v] [-s sortorder] [-R] [on|off]
=head1 DESCRIPTION
@@ -105,6 +149,13 @@ Span registration should generally always succeed. Span unregistration may
fail if channels from the span are in use by e.g. asterisk. In such a case
you'll also see those channels as '(In use)' in the output of lsdahdi(8).
dahdi_registration is intended to be used when the kernel module parameter
B<xpp.dahdi_autoreg> is false (and implicitly: when the module parameter
B<dahdi.auto_assign_span> is true). See also the NOTES section regarding
C<dahdi_span_assignments>.
If dahdi_autoreg is true, the program will normally do nothing.
=head2 Parameters
off -- deregisters all XPD's from dahdi.
@@ -115,6 +166,15 @@ on -- registers all XPD's to dahdi.
=over
=item -v
verbose output.
=item -R
Force operations (on/off) even if the module parameter B<dahdi_autoreg>
for xpp is enabled (which makes this program unneeded).
=item -s I<sort_order>
The sort order to use.
@@ -165,3 +225,30 @@ This should allow you to register / unregister a specific XPD rather
than all of them.
=back
=head1 NOTES
dahdi_registration is intended to be used when the kernel module
parameter B<xpp.dahdi_autoreg> is false (and implicitly: when the module
parameter B<dahdi.auto_assign_span> is true), that is, Astribank devices
as detected by XPP (xbus / xpd) do not register automatically with the
DAHDI core. This tool is used to register tem in an explicit order. It
works well, but only if you can arange for all of the Astribanks of the
system to be available (and not already registered) at a specific point
in time.
Newer versions of DAHDI added support for registering a span to a
specific span/channelss numbers specification. This allows registering
them out of order. To use this capability, the module parameter
B<dahdi.auto_assign_span> should be unset (set to 0) and thus spans of
detected DAHDI devices could be registered using C<dahdi_span_assignments>
(which may also be run automatically from a udev hook).
In this case there is no point in delaying XPP device registration with
dahdi and the parameter B<xpp.dahdi_autoreg> should be set.
dahdi_registration will simply become a no-op.
=head1 SEE ALSO
B<dahdi_cfg>(8), B<dahdi_span_assignments>(8).

View File

@@ -28,11 +28,21 @@
#include <limits.h>
#include <regex.h>
#include <sys/time.h>
#include "echo_loader.h"
#include "debug.h"
#include <unistd.h>
#include <oct6100api/oct6100_api.h>
#include <xtalk/debug.h>
#include <xtalk/xusb.h>
#include <astribank.h>
#include "echo_loader.h"
#include "parse_span_specs.h"
#define DBG_MASK 0x03
#ifdef __GNUC__
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif
#define DBG_MASK 0x10
#define TIMEOUT 1000
#define ECHO_MAX_CHANS 128
#define ECHO_RIN_STREAM 0
@@ -52,7 +62,7 @@ static float oct_fw_load_timeout = 2.0;
struct echo_mod {
tPOCT6100_INSTANCE_API pApiInstance;
UINT32 ulEchoChanHndl[256];
struct astribank_device *astribank;
struct astribank *astribank;
int maxchans;
};
@@ -99,9 +109,9 @@ static struct usb_buffer {
} usb_buffer;
static void usb_buffer_init(struct astribank_device *astribank, struct usb_buffer *ub)
static void usb_buffer_init(struct astribank *astribank, struct usb_buffer *ub)
{
ub->max_len = xusb_packet_size(astribank->xusb);
ub->max_len = xusb_packet_size(xusb_dev_of_astribank(astribank));
ub->curr = 0;
ub->min_send = INT_MAX;
ub->max_send = 0;
@@ -119,7 +129,7 @@ static long usb_buffer_usec(struct usb_buffer *ub)
(now.tv_usec - ub->start.tv_usec);
}
static void usb_buffer_showstatistics(struct astribank_device *astribank, struct usb_buffer *ub)
static void usb_buffer_showstatistics(struct astribank *astribank, struct usb_buffer *ub)
{
long usec;
@@ -132,7 +142,7 @@ static void usb_buffer_showstatistics(struct astribank_device *astribank, struct
usec / 1000, usec / ub->num_sends);
}
static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffer *ub)
static int usb_buffer_flush(struct astribank *astribank, struct usb_buffer *ub)
{
int ret;
long t;
@@ -141,7 +151,7 @@ static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffe
if (ub->curr == 0)
return 0;
ret = xusb_send(astribank->xusb, ub->data, ub->curr, TIMEOUT);
ret = astribank_send(astribank, 0, ub->data, ub->curr, TIMEOUT);
if (ret < 0) {
AB_ERR(astribank, "xusb_send failed: %d\n", ret);
return ret;
@@ -174,7 +184,7 @@ static int usb_buffer_flush(struct astribank_device *astribank, struct usb_buffe
return ret;
}
static int usb_buffer_append(struct astribank_device *astribank, struct usb_buffer *ub,
static int usb_buffer_append(struct astribank *astribank, struct usb_buffer *ub,
char *buf, int len)
{
if (ub->curr + len >= ub->max_len) {
@@ -187,7 +197,7 @@ static int usb_buffer_append(struct astribank_device *astribank, struct usb_buff
return len;
}
static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer *ub,
static int usb_buffer_send(struct astribank *astribank, struct usb_buffer *ub,
char *buf, int len, int timeout, int recv_answer)
{
int ret = 0;
@@ -208,7 +218,7 @@ static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer
ret = usb_buffer_flush(astribank, ub);
if (ret < 0)
return ret;
ret = xusb_recv(astribank->xusb, buf, PACKET_SIZE, TIMEOUT);
ret = astribank_recv(astribank, 0, buf, PACKET_SIZE, TIMEOUT);
if (ret <= 0) {
AB_ERR(astribank, "No USB packs to read: %s\n", strerror(-ret));
return -EINVAL;
@@ -238,7 +248,7 @@ static int usb_buffer_send(struct astribank_device *astribank, struct usb_buffer
return ret;
}
int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver)
int spi_send(struct astribank *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver)
{
int ret;
char buf[PACKET_SIZE];
@@ -271,7 +281,7 @@ int spi_send(struct astribank_device *astribank, uint16_t addr, uint16_t data, i
return ret;
}
int test_send(struct astribank_device *astribank)
int test_send(struct astribank *astribank)
{
int ret;
char buf[PACKET_SIZE];
@@ -299,7 +309,7 @@ int test_send(struct astribank_device *astribank)
return ret;
}
int echo_send_data(struct astribank_device *astribank, const unsigned int addr, const unsigned int data)
int echo_send_data(struct astribank *astribank, const unsigned int addr, const unsigned int data)
{
int ret;
/* DBG("SEND: %04X -> [%04X]\n", data, addr);
@@ -329,7 +339,7 @@ failed:
return ret;
}
int echo_recv_data(struct astribank_device *astribank, const unsigned int addr)
int echo_recv_data(struct astribank *astribank, const unsigned int addr)
{
unsigned int data = 0x00;
int ret;
@@ -362,7 +372,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 +388,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",
@@ -447,7 +461,7 @@ UINT32 Oct6100UserDriverWriteApi(tPOCT6100_WRITE_PARAMS f_pWriteParams)
const unsigned int addr = f_pWriteParams->ulWriteAddress;
const unsigned int data = f_pWriteParams->usWriteData;
const struct echo_mod *echo_mod = (struct echo_mod *)(f_pWriteParams->pProcessContext);
struct astribank_device *astribank = echo_mod->astribank;
struct astribank *astribank = echo_mod->astribank;
int ret;
ret = echo_send_data(astribank, addr, data);
@@ -464,7 +478,7 @@ UINT32 Oct6100UserDriverWriteSmearApi(tPOCT6100_WRITE_SMEAR_PARAMS f_pSmearParam
unsigned int data;
unsigned int len;
const struct echo_mod *echo_mod;
struct astribank_device *astribank;
struct astribank *astribank;
unsigned int i;
len = f_pSmearParams->ulWriteLength;
@@ -490,7 +504,7 @@ UINT32 Oct6100UserDriverWriteBurstApi(tPOCT6100_WRITE_BURST_PARAMS f_pBurstParam
unsigned int data;
unsigned int len = f_pBurstParams->ulWriteLength;
const struct echo_mod *echo_mod = (struct echo_mod *)f_pBurstParams->pProcessContext;
struct astribank_device *astribank = echo_mod->astribank;
struct astribank *astribank = echo_mod->astribank;
unsigned int i;
for (i = 0; i < len; i++) {
@@ -511,7 +525,7 @@ UINT32 Oct6100UserDriverReadApi(tPOCT6100_READ_PARAMS f_pReadParams)
{
const unsigned int addr = f_pReadParams->ulReadAddress;
const struct echo_mod *echo_mod;
struct astribank_device *astribank;
struct astribank *astribank;
int ret;
echo_mod = (struct echo_mod *)f_pReadParams->pProcessContext;
@@ -530,7 +544,7 @@ UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
unsigned int addr;
unsigned int len;
const struct echo_mod *echo_mod;
struct astribank_device *astribank;
struct astribank *astribank;
unsigned int i;
len = f_pBurstParams->ulReadLength;
@@ -550,13 +564,13 @@ UINT32 Oct6100UserDriverReadBurstApi(tPOCT6100_READ_BURST_PARAMS f_pBurstParams)
return cOCT6100_ERR_OK;
}
inline int get_ver(struct astribank_device *astribank)
inline int get_ver(struct astribank *astribank)
{
return spi_send(astribank, 0, 0, 1, 1);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
UINT32 init_octasic(char *filename, struct astribank_device *astribank, int is_alaw)
UINT32 init_octasic(char *filename, struct astribank *astribank, struct span_specs *span_specs)
{
int cpld_ver;
struct echo_mod *echo_mod;
@@ -576,6 +590,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 +741,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 +847,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 *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);
@@ -844,7 +877,7 @@ int load_echo(struct astribank_device *astribank, char *filename, int is_alaw)
return 0;
}
int echo_ver(struct astribank_device *astribank)
int echo_ver(struct astribank *astribank)
{
usb_buffer_init(astribank, &usb_buffer);
return get_ver(astribank);

View File

@@ -23,10 +23,10 @@
*/
#include <stdint.h>
#include "astribank_usb.h"
#include "astribank.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 echo_ver(struct astribank_device *astribank);
int spi_send(struct astribank *astribank, uint16_t addr, uint16_t data, int recv_answer, int ver);
int load_echo(struct astribank *astribank, char *filename, int is_alaw, const char *span_spec);
int echo_ver(struct astribank *astribank);
#endif /* ECHO_LOADER_H */

View File

@@ -28,8 +28,6 @@
#include <ctype.h>
#include "hexfile.h"
static const char rcsid[] = "$Id$";
static parse_hexfile_report_func_t report_func = NULL;
parse_hexfile_report_func_t parse_hexfile_set_reporting(parse_hexfile_report_func_t rf)

View File

@@ -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);

202
xpp/mpp.h
View File

@@ -1,202 +0,0 @@
#ifndef MPP_H
#define MPP_H
/*
* Written by Oron Peled <oron@actcom.co.il>
* Copyright (C) 2008, 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.
*
*/
/*
* MPP - Managment Processor Protocol definitions
*/
#include <mpptalk_defs.h>
#include <stdint.h>
#include <xtalk.h>
#ifdef __GNUC__
#define PACKED __attribute__((packed))
#else
#error "We do not know how your compiler packs structures"
#endif
#define MK_PROTO_VERSION(major, minor) (((major) << 4) | (0x0F & (minor)))
#define MPP_PROTOCOL_VERSION MK_PROTO_VERSION(1,4)
#define MPP_SUPPORTED_VERSION(x) ((x) == MK_PROTO_VERSION(1,3) || (x) == MK_PROTO_VERSION(1,4))
/*
* The eeprom_table is common to all eeprom types.
*/
#define LABEL_SIZE 8
struct eeprom_table {
uint8_t source; /* C0 - small eeprom, C2 - large eeprom */
uint16_t vendor;
uint16_t product;
uint16_t release; /* BCD encoded release */
uint8_t config_byte; /* Must be 0 */
uint8_t label[LABEL_SIZE];
} PACKED;
#define VERSION_LEN 6
struct firmware_versions {
char usb[VERSION_LEN];
char fpga[VERSION_LEN];
char eeprom[VERSION_LEN];
} PACKED;
struct capabilities {
uint8_t ports_fxs;
uint8_t ports_fxo;
uint8_t ports_bri;
uint8_t ports_pri;
uint8_t extra_features; /* BIT(0) - TwinStar */
uint8_t ports_echo;
uint8_t reserved[2];
uint32_t timestamp;
} PACKED;
#define CAP_EXTRA_TWINSTAR(c) ((c)->extra_features & 0x01)
#define CAP_EXTRA_TWINSTAR_SET(c) do {(c)->extra_features |= 0x01;} while (0)
#define CAP_EXTRA_TWINSTAR_CLR(c) do {(c)->extra_features &= ~0x01;} while (0)
#define KEYSIZE 16
struct capkey {
uint8_t k[KEYSIZE];
} PACKED;
struct extrainfo {
char text[EXTRAINFO_SIZE];
} PACKED;
struct mpp_header {
uint16_t len;
uint16_t seq;
uint8_t op; /* MSB: 0 - to device, 1 - from device */
} PACKED;
enum mpp_ser_op {
SER_CARD_INFO_GET = 0x1,
SER_STAT_GET = 0x3,
/* Status bits */
#define SER_STAT_WATCHDOG_READY(s) ((s) & 0x01)
#define SER_STAT_XPD_ALIVE(s) ((s) & 0x02)
};
/* Individual commands structure */
CMD_DEF(MPP, STATUS_GET);
CMD_DEF(MPP, STATUS_GET_REPLY,
uint8_t i2cs_data;
#define STATUS_FPGA_LOADED(x) ((x) & 0x01)
uint8_t status; /* BIT(0) - FPGA is loaded */
struct firmware_versions fw_versions;
);
CMD_DEF(MPP, EEPROM_SET,
struct eeprom_table data;
);
CMD_DEF(MPP, CAPS_GET);
CMD_DEF(MPP, CAPS_GET_REPLY,
struct eeprom_table data;
struct capabilities capabilities;
struct capkey key;
);
CMD_DEF(MPP, CAPS_SET,
struct eeprom_table data;
struct capabilities capabilities;
struct capkey key;
);
CMD_DEF(MPP, EXTRAINFO_GET);
CMD_DEF(MPP, EXTRAINFO_GET_REPLY,
struct extrainfo info;
);
CMD_DEF(MPP, EXTRAINFO_SET,
struct extrainfo info;
);
CMD_DEF(MPP, RENUM);
CMD_DEF(MPP, EEPROM_BLK_RD,
uint16_t offset;
uint16_t len;
);
CMD_DEF(MPP, EEPROM_BLK_RD_REPLY,
uint16_t offset;
uint8_t data[0];
);
CMD_DEF(MPP, DEV_SEND_START,
uint8_t dest;
char ihex_version[VERSION_LEN];
);
CMD_DEF(MPP, DEV_SEND_END);
CMD_DEF(MPP, DEV_SEND_SEG,
uint16_t offset;
uint8_t data[0];
);
CMD_DEF(MPP, RESET);
CMD_DEF(MPP, HALF_RESET);
CMD_DEF(MPP, SER_SEND,
uint8_t data[0];
);
CMD_DEF(MPP, SER_RECV,
uint8_t data[0];
);
CMD_DEF(MPP, TWS_WD_MODE_SET,
uint8_t wd_active;
);
CMD_DEF(MPP, TWS_WD_MODE_GET);
CMD_DEF(MPP, TWS_WD_MODE_GET_REPLY,
uint8_t wd_active;
);
CMD_DEF(MPP, TWS_PORT_SET,
uint8_t portnum;
);
CMD_DEF(MPP, TWS_PORT_GET);
CMD_DEF(MPP, TWS_PORT_GET_REPLY,
uint8_t portnum;
);
CMD_DEF(MPP, TWS_PWR_GET);
CMD_DEF(MPP, TWS_PWR_GET_REPLY,
uint8_t power;
);
#endif /* MPP_H */

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
#ifndef MPP_FUNCS_H
#define MPP_FUNCS_H
#ifndef MPPTALK_H
#define MPPTALK_H
/*
* Written by Oron Peled <oron@actcom.co.il>
* Copyright (C) 2008, Xorcom
@@ -22,64 +22,152 @@
*
*/
#include <stdint.h>
#include <stdio.h>
#include "mpp.h"
#include "astribank_usb.h"
struct astribank_device;
struct eeprom_table;
struct extrainfo;
struct capabilities;
struct capkey;
#define TIMEOUT 6000
/* high-level */
struct astribank_device *mpp_init(const char devpath[], int iface_num);
void mpp_exit(struct astribank_device *astribank);
int mpp_proto_query(struct astribank_device *astribank);
int mpp_status_query(struct astribank_device *astribank);
int mpp_eeprom_set(struct astribank_device *astribank, const struct eeprom_table *et);
int mpp_renumerate(struct astribank_device *astribank);
int mpp_caps_get(struct astribank_device *astribank,
struct eeprom_table *et,
struct capabilities *cap,
struct capkey *key);
int mpp_caps_set(struct astribank_device *astribank,
const struct eeprom_table *eeprom_table,
const struct capabilities *capabilities,
const struct capkey *key);
int mpp_extrainfo_get(struct astribank_device *astribank, struct extrainfo *info);
int mpp_extrainfo_set(struct astribank_device *astribank, const struct extrainfo *info);
int mpp_eeprom_blk_rd(struct astribank_device *astribank, uint8_t *buf, uint16_t offset, uint16_t len);
int mpp_send_start(struct astribank_device *astribank, int dest, const char *ihex_version);
int mpp_send_end(struct astribank_device *astribank);
int mpp_send_seg(struct astribank_device *astribank, const uint8_t *data, uint16_t offset, uint16_t len);
int mpp_reset(struct astribank_device *astribank, int full_reset);
int mpp_serial_cmd(struct astribank_device *astribank, const uint8_t *in, uint8_t *out, uint16_t len);
void show_eeprom(const struct eeprom_table *eprm, FILE *fp);
void show_capabilities(const struct capabilities *capabilities, FILE *fp);
void show_astribank_status(struct astribank_device *astribank, FILE *fp);
void show_extrainfo(const struct extrainfo *extrainfo, FILE *fp);
int twinstar_show(struct astribank_device *astribank, FILE *fp);
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
/*
* Serial commands to FPGA
* MPPTALK - Example XTALK dialect
*/
int mpps_card_info(struct astribank_device *astribank, int unit, uint8_t *card_type, uint8_t *card_status);
int mpps_stat(struct astribank_device *astribank, int unit, uint8_t *maincard_version, uint8_t *status);
#include <xtalk/proto.h>
#include <xtalk/proto_sync.h>
#ifdef __GNUC__
#define PACKED __attribute__((packed))
#else
#define PACKED
#endif
/*---------------- Common types --------------------*/
/*
* The eeprom_table is common to all eeprom types.
*/
#define LABEL_SIZE 8
struct eeprom_table {
uint8_t source; /* C0 - small eeprom, C2 - large eeprom */
uint16_t vendor;
uint16_t product;
uint16_t release; /* BCD encoded release */
uint8_t config_byte; /* Must be 0 */
uint8_t label[LABEL_SIZE];
} PACKED;
#define VERSION_LEN 6
struct firmware_versions {
char usb[VERSION_LEN];
char fpga[VERSION_LEN];
char eeprom[VERSION_LEN];
} PACKED;
struct capabilities {
uint8_t ports_fxs;
uint8_t ports_fxo;
uint8_t ports_bri;
uint8_t ports_pri;
uint8_t extra_features; /* BIT(0) - TwinStar */
uint8_t ports_echo;
uint8_t reserved[2];
uint32_t timestamp;
} PACKED;
#define CAP_EXTRA_TWINSTAR(c) ((c)->extra_features & 0x01)
#define CAP_EXTRA_TWINSTAR_SET(c) do {(c)->extra_features |= 0x01;} while (0)
#define CAP_EXTRA_TWINSTAR_CLR(c) do {(c)->extra_features &= ~0x01;} while (0)
#define KEYSIZE 16
struct capkey {
uint8_t k[KEYSIZE];
} PACKED;
#define EXTRAINFO_SIZE 24
struct extrainfo {
char text[EXTRAINFO_SIZE];
} PACKED;
struct mpp_header {
uint16_t len;
uint16_t seq;
uint8_t op; /* MSB: 0 - to device, 1 - from device */
} PACKED;
enum mpp_ser_op {
SER_CARD_INFO_GET = 0x1,
SER_STAT_GET = 0x3,
/* Status bits */
#define SER_STAT_WATCHDOG_READY(s) ((s) & 0x01)
#define SER_STAT_XPD_ALIVE(s) ((s) & 0x02)
};
/* EEPROM_QUERY: i2cs(ID1, ID0) */
enum eeprom_type {
EEPROM_TYPE_NONE = 0,
EEPROM_TYPE_SMALL = 1,
EEPROM_TYPE_LARGE = 2,
EEPROM_TYPE_UNUSED = 3,
};
enum dev_dest {
DEST_NONE = 0x00,
DEST_FPGA = 0x01,
DEST_EEPROM = 0x02,
};
/*---------------- PROTOCOL ------------------------*/
/* API */
struct mpp_device;
struct mpp_device *mpp_new(struct xusb_iface *iface);
void mpp_delete(struct mpp_device *dev);
struct xusb_iface *xubs_iface_of_mpp(struct mpp_device *mpp);
int mpp_status_query(struct mpp_device *mpp_dev);
enum eeprom_type mpp_eeprom_type(struct mpp_device *mpp_dev);
void show_eeprom(const struct eeprom_table *eprm, FILE *fp);
void show_capabilities(const struct capabilities *capabilities, FILE *fp);
void show_astribank_status(struct mpp_device *mpp_dev, FILE *fp);
void show_extrainfo(const struct extrainfo *extrainfo, FILE *fp);
int twinstar_show(struct mpp_device *mpp, FILE *fp);
int show_hardware(struct mpp_device *mpp_dev);
int mpp_renumerate(struct mpp_device *mpp_dev);
int mpp_send_start(struct mpp_device *mpp_dev, int dest, const char *ihex_version);
int mpp_send_end(struct mpp_device *mpp_dev);
int mpp_send_seg(struct mpp_device *mpp_dev, const uint8_t *data, uint16_t offset, uint16_t len);
int mpp_reset(struct mpp_device *mpp_dev, int full_reset);
int mpp_caps_get(struct mpp_device *mpp_dev,
struct eeprom_table *eeprom_table,
struct capabilities *capabilities,
struct capkey *key);
int mpp_caps_set(struct mpp_device *mpp_dev,
const struct eeprom_table *eeprom_table,
const struct capabilities *capabilities,
const struct capkey *key);
/*
* serial sub-protocol to FPGA
*/
int mpps_card_info(struct mpp_device *mpp, int unit, uint8_t *card_type, uint8_t *card_status);
int mpps_stat(struct mpp_device *mpp, int unit, uint8_t *maincard_version, uint8_t *status);
/*
* Twinstar
*/
int mpp_tws_watchdog(struct astribank_device *astribank);
int mpp_tws_setwatchdog(struct astribank_device *astribank, int yes);
int mpp_tws_powerstate(struct astribank_device *astribank);
int mpp_tws_portnum(struct astribank_device *astribank);
int mpp_tws_setportnum(struct astribank_device *astribank, uint8_t portnum);
int mpp_tws_watchdog(struct mpp_device *mpp);
int mpp_tws_setwatchdog(struct mpp_device *mpp, int yes);
int mpp_tws_powerstate(struct mpp_device *mpp);
int mpp_tws_portnum(struct mpp_device *mpp);
int mpp_tws_setportnum(struct mpp_device *mpp, uint8_t portnum);
const char *dev_dest2str(int dest);
#endif /* MPP_FUNCS_H */
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* MPPTALK_H */

View File

@@ -1,113 +0,0 @@
#ifndef MPPTALK_DEFS_H
#define MPPTALK_DEFS_H
/*
* Written by Oron Peled <oron@actcom.co.il>
* Copyright (C) 2008,2009,2010 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 <xtalk_defs.h>
/*
* MPP - Managment Processor Protocol definitions
*/
/*
* OP Codes:
* MSB of op signifies a reply from device
*/
#define MPP_RENUM 0x0B /* Trigger USB renumeration */
#define MPP_EEPROM_SET 0x0D
/* AB capabilities */
#define MPP_CAPS_GET 0x0E
#define MPP_CAPS_GET_REPLY 0x8E
#define MPP_CAPS_SET 0x0F
#define MPP_DEV_SEND_START 0x05
#define MPP_DEV_SEND_SEG 0x07
#define MPP_DEV_SEND_END 0x09
/* Astribank Status */
#define MPP_STATUS_GET 0x11
#define MPP_STATUS_GET_REPLY 0x91
#define MPP_STATUS_GET_REPLY_V13 0x91 /* backward compat */
/* Get extra vendor information */
#define MPP_EXTRAINFO_GET 0x13
#define MPP_EXTRAINFO_GET_REPLY 0x93
#define MPP_EXTRAINFO_SET 0x15 /* Set extra vendor information */
#define MPP_EEPROM_BLK_RD 0x27
#define MPP_EEPROM_BLK_RD_REPLY 0xA7
#define MPP_SER_SEND 0x37
#define MPP_SER_RECV 0xB7
#define MPP_RESET 0x45 /* Reset both FPGA and USB firmwares */
#define MPP_HALF_RESET 0x47 /* Reset only FPGA firmware */
/* Twinstar */
#define MPP_TWS_WD_MODE_SET 0x31 /* Set watchdog off/on guard */
#define MPP_TWS_WD_MODE_GET 0x32 /* Current watchdog mode */
#define MPP_TWS_WD_MODE_GET_REPLY 0xB2 /* Current watchdog mode */
#define MPP_TWS_PORT_SET 0x34 /* USB-[0/1] */
#define MPP_TWS_PORT_GET 0x35 /* USB-[0/1] */
#define MPP_TWS_PORT_GET_REPLY 0xB5 /* USB-[0/1] */
#define MPP_TWS_PWR_GET 0x36 /* Power: bits -> USB ports */
#define MPP_TWS_PWR_GET_REPLY 0xB6 /* Power: bits -> USB ports */
/*
* Statuses
*/
#define STAT_OK 0x00 /* acknowledges previous command */
#define STAT_FAIL 0x01 /* Last command failed */
#define STAT_RESET_FAIL 0x02 /* reset failed */
#define STAT_NODEST 0x03 /* No destination is selected */
#define STAT_MISMATCH 0x04 /* Data mismatch */
#define STAT_NOACCESS 0x05 /* No access */
#define STAT_BAD_CMD 0x06 /* Bad command */
#define STAT_TOO_SHORT 0x07 /* Packet is too short */
#define STAT_ERROFFS 0x08 /* Offset error */
#define STAT_NOCODE 0x09 /* Source was not burned before */
#define STAT_NO_LEEPROM 0x0A /* Large EEPROM was not found */
#define STAT_NO_EEPROM 0x0B /* No EEPROM was found */
#define STAT_WRITE_FAIL 0x0C /* Writing to device failed */
#define STAT_FPGA_ERR 0x0D /* FPGA error */
#define STAT_KEY_ERR 0x0E /* Bad Capabilities Key */
#define STAT_NOCAPS_ERR 0x0F /* No matching capability */
#define STAT_NOPWR_ERR 0x10 /* No power on USB connector */
#define STAT_CAPS_FPGA_ERR 0x11 /* Setting of the capabilities while FPGA is loaded */
/* EEPROM_QUERY: i2cs(ID1, ID0) */
enum eeprom_type {
EEPROM_TYPE_NONE = 0,
EEPROM_TYPE_SMALL = 1,
EEPROM_TYPE_LARGE = 2,
EEPROM_TYPE_UNUSED = 3,
};
enum dev_dest {
DEST_NONE = 0x00,
DEST_FPGA = 0x01,
DEST_EEPROM = 0x02,
};
#define EXTRAINFO_SIZE 24
#endif /* MPPTALK_DEFS_H */

View File

@@ -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)

119
xpp/oct612x/Makefile.am Normal file
View File

@@ -0,0 +1,119 @@
GLOBAL_CFLAGS = -Wall -Werror
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 = \
$(GLOBAL_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
View 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
View 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 */

View File

@@ -143,7 +143,7 @@ sub new($$$$$$) {
$type = "FXO"; # likely Rhino
} elsif ($fqn =~ m{---/.*}) {
$type = "EMPTY"; # likely Rhino, empty slot.
} elsif ($fqn =~ m{\b(TE[24]|WCT1|WCT13x|Tor2|TorISA|WP[TE]1|cwain[12]|R[124]T1|AP40[124]|APE40[124])/.*}) {
} elsif ($fqn =~ m{\b(WCTE|TE[24]|WCT1|WCT13x|Tor2|TorISA|WP[TE]1|cwain[12]|R[124]T1|AP40[124]|APE40[124])/.*}) {
# TE[24]: Digium wct4xxp
# WCT1: Digium single span card drivers?
# Tor2: Tor PCI cards

View File

@@ -0,0 +1,63 @@
package Dahdi::Config::Gen::Assignedspans;
use strict;
use Dahdi::Config::Gen qw(is_true);
sub new($$$) {
my $pack = shift || die;
my $gconfig = shift || die;
my $genopts = shift || die;
my $file = $ENV{ASSIGNED_SPANS_CONF_FILE} || "/etc/dahdi/assigned-spans.conf";
my $self = {
FILE => $file,
GCONFIG => $gconfig,
GENOPTS => $genopts,
};
bless $self, $pack;
return $self;
}
sub generate($$$) {
my $self = shift || die;
my $file = $self->{FILE};
my $gconfig = $self->{GCONFIG};
my $genopts = $self->{GENOPTS};
my @spans = @_;
# If the span_types utilities were not installed we do not want to run
# this generator or report any errors.
system "which dahdi_span_assignments > /dev/null 2>&1";
return if $?;
warn "Empty configuration -- no spans\n" unless @spans;
rename "$file", "$file.bak"
or $! == 2 # ENOENT (No dependency on Errno.pm)
or die "Failed to backup old config: $!\n";
#$gconfig->dump;
print "Generating $file\n" if $genopts->{verbose};
my $cmd = "dahdi_span_assignments dumpconfig > $file";
system $cmd;
die "Command failed (status=$?): '$cmd'" if $?;
}
1;
__END__
=head1 NAME
dahdi - Generate configuration for dahdi drivers.
=head1 SYNOPSIS
use Dahdi::Config::Gen::Dahdi;
my $cfg = new Dahdi::Config::Gen::Dahdi(\%global_config, \%genopts);
$cfg->generate(@span_list);
=head1 DESCRIPTION
Generate the F</etc/dahdi/assigned-spans.conf>.
This is the configuration for dahdi_span_assignments.
Its location may be overriden via the environment variable F<ASSIGNED_SPANS_CONF_FILE>.

View File

@@ -0,0 +1,86 @@
package Dahdi::Config::Gen::Spantypes;
use strict;
use Dahdi::Config::Gen qw(is_true);
sub new($$$) {
my $pack = shift || die;
my $gconfig = shift || die;
my $genopts = shift || die;
my $file = $ENV{SPAN_TYPES_CONF_FILE} || "/etc/dahdi/span-types.conf";
my $self = {
FILE => $file,
GCONFIG => $gconfig,
GENOPTS => $genopts,
};
bless $self, $pack;
return $self;
}
sub generate($$$) {
my $self = shift || die;
my $file = $self->{FILE};
my $gconfig = $self->{GCONFIG};
my $genopts = $self->{GENOPTS};
my @spans = @_;
# If the dahdi_span_types utilities were not installed we do not want to run
# this generator or report any errors.
system "which dahdi_span_types > /dev/null 2>&1";
return if $?;
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;
system $cmd;
die "Command failed (status=$?): '$cmd'" if $?;
}
1;
__END__
=head1 NAME
dahdi - Generate configuration for dahdi drivers.
=head1 SYNOPSIS
use Dahdi::Config::Gen::Dahdi;
my $cfg = new Dahdi::Config::Gen::Dahdi(\%global_config, \%genopts);
$cfg->generate(@span_list);
=head1 DESCRIPTION
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>).

View File

@@ -94,11 +94,25 @@ 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' },
'd161:800d' => { DRIVER => 'wcaxx', DESCRIPTION => 'Digium A8B' },
'd161:800f' => { DRIVER => 'wcaxx', DESCRIPTION => 'Digium A4A' },
'd161:8010' => { DRIVER => 'wcaxx', DESCRIPTION => 'Digium A4B' },
# 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' },

View File

@@ -144,9 +144,11 @@ 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
'Rhino R1T1 (E1)/PRA Card', # r1t1
'Rhino R1T1 (T1)/PRI Card', # r1t1

View File

@@ -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();

Some files were not shown because too many files have changed in this diff Show More