Commit Graph

15 Commits

Author SHA1 Message Date
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:


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 <>
2015-11-16 15:54:23 +02: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

Signed-off-by: Russ Meyerriecks <>
Acked-by: Shaun Ruffell <>
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 <>
Acked-by: Shaun Ruffell <>
2014-07-23 16:52:59 -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


when they meant:


in the future.

Signed-off-by: Shaun Ruffell <>
Signed-off-by: Russ Meyerriecks <>
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 <>
Signed-off-by: Russ Meyerriecks <>
2014-07-07 17:06:16 -05: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 <>
2014-02-12 11:56:00 -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

Signed-off-by: Shaun Ruffell <>
Signed-off-by: Russ Meyerriecks <>
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 <>
Signed-off-by: Russ Meyerriecks <>
2014-01-22 12:58:57 -06: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 <>
Acked-by: Tzafrir Cohen <>
Acked-by: Russ Meyerriecks <>
2013-12-12 09:08:51 -06: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 <>
2013-10-08 10:05:09 -04:00
Shaun Ruffell 2889d6afee dahdi_cfg: Make -S option based on spannumber instead of order in config file.
If the config file has two spans defined:


And you only want to configure span-2, you would need to pass -S 1 to
dahdi_cfg. Now make the -S option take the span number as assigned in the
config file.

Signed-off-by: Shaun Ruffell <>
Signed-off-by: Russ Meyerriecks <>
2013-05-28 12:34:03 -05:00
Tzafrir Cohen b093554f54 Fix GCC 4.6 "set but not used" warnings
Signed-off-by: Tzafrir Cohen <>

git-svn-id: 17933a7a-c749-41c5-a318-cba88f637d49
2011-11-02 21:57:25 +00:00
Oron Peled ba070152fc dahdi_cfg: add '-S <spanno>' and '-C <chan-ranges>'
* dahdi_cfg -S <num>: only apply changes to span <num>.
* If span is analog (no 'span=<num>,<channels>,...' statement in
  system.conf), we need to set range: -C <channels>
* With the <basechan> and <channels> attributes in sysfs
  we easily configure each device on the fly.
  Simply run: dahdi_cfg -S <spanno> -C <basechan>+<channels>-1
  from udev script

Signed-off-by: Oron Peled <>
Acked-by: Tzafrir Cohen <>

git-svn-id: 17933a7a-c749-41c5-a318-cba88f637d49
2011-11-02 20:10:06 +00:00
Shaun Ruffell e878bc06dc dahdi_cfg: DAHDI_INDIRECT -> DAHDI_SPECIFY when configuring pciradio channels.
While slightly less efficient, this is only used when configuring the
channels initially (not the hot path) and allows dahdi-base.c to assume
that the open "file" pointer always refers to the channel on which to
perform the operation.

Signed-off-by: Shaun Ruffell <>

git-svn-id: 17933a7a-c749-41c5-a318-cba88f637d49
2010-09-20 20:30:49 +00:00
Asterisk Development Team 466357f5c2 Import DAHDI-Tools r9159
This revision of DAHDI-Tools is the base revision for the switch to

2010-08-18 13:49:24 +00:00