2e0b641e23
Submitted by: Vincent Jardin <vjardin@free.fr>
156 lines
3.0 KiB
Bash
156 lines
3.0 KiB
Bash
#!/bin/sh
|
|
#
|
|
# $FreeBSD$
|
|
#
|
|
err() {
|
|
echo "$*" >&2
|
|
}
|
|
usage() {
|
|
err "Usage: `basename $0` atmindex loc_ip udp_port rem_ip udp_port [pref_iface]"
|
|
err " or: `basename $0` flush"
|
|
exit $1
|
|
}
|
|
|
|
args=`getopt ed $*`
|
|
if [ $? != 0 ] ; then
|
|
usage 2
|
|
fi
|
|
set -- $args
|
|
|
|
debug_enable=0
|
|
|
|
for i
|
|
do
|
|
case "$i"
|
|
in
|
|
-e)
|
|
debug_enable=1
|
|
shift;;
|
|
-d)
|
|
debug_enable=-1
|
|
shift;;
|
|
--)
|
|
shift ; break;;
|
|
esac
|
|
done
|
|
|
|
if [ $# -lt 1 ] ; then
|
|
err "Missing arguments"
|
|
usage 1
|
|
fi
|
|
|
|
#
|
|
# Handle debug flags
|
|
#
|
|
case ${debug_enable} in
|
|
|
|
1)
|
|
#
|
|
# Enable all the HARP debugging features
|
|
#
|
|
sysctl -w net.harp.atm.atm_debug=1
|
|
sysctl -w net.harp.atm.atm_dev_print=1
|
|
sysctl -w net.harp.atm.atm_print_data=1
|
|
sysctl -w net.harp.ip.ipatm_print=1
|
|
sysctl -w net.harp.spans.spanscls_print=1
|
|
sysctl -w net.harp.uni.uniarp_print=1
|
|
sysctl -w net.harp.uni.unisig_print_msg=2
|
|
;;
|
|
|
|
-1)
|
|
#
|
|
# Disable all the HARP debugging features
|
|
#
|
|
sysctl -w net.harp.atm.atm_debug=0
|
|
sysctl -w net.harp.atm.atm_dev_print=0
|
|
sysctl -w net.harp.atm.atm_print_data=0
|
|
sysctl -w net.harp.ip.ipatm_print=0
|
|
sysctl -w net.harp.spans.spanscls_print=0
|
|
sysctl -w net.harp.uni.uniarp_print=0
|
|
sysctl -w net.harp.uni.unisig_print_msg=0
|
|
;;
|
|
esac
|
|
|
|
if [ "${1}" = "flush" ] ; then
|
|
#
|
|
# Remove all atmpif nodes
|
|
#
|
|
for i in `ngctl list | grep atmpif | awk '{print $6}'` ; do
|
|
ngctl shutdown [$i]:
|
|
done
|
|
exit 0
|
|
fi
|
|
|
|
ID=${1}
|
|
|
|
if [ $# -lt 5 -o $# -gt 6 ] ; then
|
|
err "wrong number of arguments"
|
|
usage 1
|
|
fi
|
|
|
|
LOC_IP=${2}
|
|
LOC_UDP_PORT=${3}
|
|
REM_IP=${4}
|
|
REM_UDP_PORT=${5}
|
|
PREF_IFACE=${6}
|
|
|
|
if [ "${LOC_IP}" = "" -o "${LOC_UDP_PORT}" = "" -o \
|
|
"${REM_IP}" = "" -o "${REM_UDP_PORT}" = "" ] ; then
|
|
err "bad argument"
|
|
usage 1
|
|
fi
|
|
|
|
#
|
|
# Default interface prefix: atmX
|
|
#
|
|
if [ "${PREF_IFACE}" = "" ] ; then
|
|
PREF_IFACE="atm"
|
|
fi
|
|
|
|
# Create the ATM PIF (Physical Interface) vatmpifXX
|
|
#
|
|
ngctl -f - <<EOF
|
|
mkpeer atmpif dummy link
|
|
name .:dummy vatmpif${ID}
|
|
EOF
|
|
|
|
# Attach a UDP socket to the ``link'' hook of the atm interface node
|
|
# using the ng_ksocket(8) node type.
|
|
#
|
|
echo ngctl mkpeer vatmpif${ID}: ksocket link inet/dgram/udp
|
|
ngctl -d mkpeer vatmpif${ID}: ksocket link inet/dgram/udp
|
|
|
|
# Enable HARP debugging of the API between the Netgraph node and the
|
|
# HARP stack
|
|
#
|
|
ngctl msg vatmpif${ID}: setconfig { debug=1 pcr=353207 macaddr=00:09:c0:00:00:cd }
|
|
|
|
# Bind the UDP socket to the local external IP address and port
|
|
#
|
|
echo ngctl msg vatmpif${ID}:link bind inet/${LOC_IP}:${LOC_UDP_PORT}
|
|
ngctl -d msg vatmpif${ID}:link bind inet/${LOC_IP}:${LOC_UDP_PORT}
|
|
|
|
# Connect the UDP socket to the peer's external IP address and port
|
|
#
|
|
echo ngctl msg vatmpif${ID}:link connect inet/${REM_IP}:${REM_UDP_PORT}
|
|
ngctl -d msg vatmpif${ID}:link connect inet/${REM_IP}:${REM_UDP_PORT}
|
|
|
|
# Display the atm interfaces:
|
|
#
|
|
atm show config
|
|
|
|
# Get the ATM device
|
|
#
|
|
ATMPIF=`atm show config | grep ^hva | tail -1 | cut -f 1 -d " "`
|
|
|
|
# Open a PVC
|
|
#
|
|
atm set netif ${ATMPIF} ${PREF_IFACE} 5
|
|
atm attach ${ATMPIF} sigpvc
|
|
ifconfig ${PREF_IFACE}0 1.${ID}.1.1/16
|
|
atm add pvc ${ATMPIF} ${ID} 40 AAL5 null IP ${PREF_IFACE}0 1.${ID}.2.2
|
|
atm show ipvcc
|
|
atm show vcc
|
|
atm show stats vcc
|
|
atm show stats interface ${ATMPIF}
|