Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applied Patch: https://issues-archive.asterisk.org/DAHTOOL/00/DAHTOOL… #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions dahdi_span_assignments
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,23 @@ attr_clean() {
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
}

get_device_spannos() {
device=$1
sp_file="dahdi_spantype"
if [ ! -f "$device/$sp_file" ]; then
sp_file="spantype"
fi
cut -d: -f1 "$device/$sp_file"
}

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"`
for local_spanno in `get_device_spannos "$device"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
Expand Down Expand Up @@ -193,7 +202,7 @@ dump_config() {
id="$devpath"
fi
echo "# Device: [$hardware_id] @$location $devpath"
for local_spanno in `cut -d: -f1 "$device/spantype"`
for local_spanno in `get_device_spannos "$device"`
do
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
Expand Down Expand Up @@ -358,7 +367,7 @@ list_devices() {
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"`
for local_spanno in `get_device_spannos "$device"`
do
found=`dev_match_conf "$devpath" "$location" "$hardware_id" "$local_spanno"`
if [ "$wanted" = "unmatched" ]; then
Expand Down
23 changes: 18 additions & 5 deletions dahdi_span_types
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,24 @@ attr_clean() {
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
}

get_device_spantype_file() {
device=$1
sp_file="dahdi_spantype"
if [ ! -f "$device/$sp_file" ]; then
sp_file="spantype"
fi
echo "$device/$sp_file"
}

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
sp_file=`get_device_spantype_file "$device"`
cat "$sp_file" | while read st; do
case "$st" in
*:[ETJ]1)
printf "%-10s %-20s %-30s %s\n" \
Expand All @@ -192,7 +202,7 @@ show_spantypes() {
}

list_pri_spantypes() {
find $DEVICES -follow -maxdepth 1 -name spantype | \
find $DEVICES -follow -maxdepth 1 -name spantype -or -name dahdi_spantype | \
xargs cat | \
sed -n '/:[ETJ]1$/s/^.*://p' | \
sort -u | \
Expand Down Expand Up @@ -255,7 +265,8 @@ dump_config() {
id="$devpath"
fi
echo "# Device: [$hardware_id] @$location $devpath"
cat "$device/spantype" | while read st; do
sp_file=`get_device_spantype_file "$device"`
cat "$sp_file" | while read st; do
case "$st" in
*:[ETJ]1)
if [ "$num_spantypes" -eq 1 ]; then
Expand All @@ -281,7 +292,8 @@ filter_conf() {
handle_span() {
device="$1"
spantype="$2"
attr_file="$device/spantype"
sp_file=`get_device_spantype_file "$device"`
attr_file="$sp_file"
devpath=`cd "$device" && pwd -P`
devname=`echo "$device" | sed "s,$devbase/,,"`
location='@'`attr_clean "$device/location"`
Expand Down Expand Up @@ -351,7 +363,8 @@ set_all_devices() {
for device in $DEVICES
do
devname=`echo "$device" | sed "s,$devbase/,,"`
cat "$device/spantype" | while read spantype; do
sp_file=`get_device_spantype_file "$device"`
cat "$sp_file" | while read spantype; do
case "$spantype" in
*:[ETJ]1)
handle_span "$device" "$spantype"
Expand Down
6 changes: 5 additions & 1 deletion dahdi_waitfor_span_assignments
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ devbase='/sys/bus/dahdi_devices/devices'

spans_of() {
dev="$1"
wc -l < "$dev/spantype"
sp_file="dahdi_spantype"
if [ ! -f "$dev/$sp_file" ]; then
sp_file="spantype"
fi
wc -l < "$dev/$sp_file"
}

assigned_spans_of() {
Expand Down