br2684ctl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh /etc/rc.common
  2. START=50
  3. USE_PROCD=1
  4. start_daemon() {
  5. local cfg="$1"
  6. local atmdev disabled
  7. config_get_bool disabled "$cfg" disabled 0
  8. [ "$disabled" -eq 1 ] && return
  9. config_get atmdev "$cfg" atmdev 0
  10. local nameprefix
  11. config_get nameprefix "$cfg" nameprefix "nas"
  12. local unit
  13. config_get unit "$cfg" unit 0
  14. local vpi
  15. config_get vpi "$cfg" vpi 8
  16. local vci
  17. config_get vci "$cfg" vci 35
  18. local encaps
  19. config_get encaps "$cfg" encaps
  20. case "$encaps" in
  21. 1|vc) encaps=1;;
  22. *) encaps=0;;
  23. esac
  24. local payload
  25. config_get payload "$cfg" payload
  26. case "$payload" in
  27. 0|routed) payload=0;;
  28. *) payload=1;;
  29. esac
  30. local qos
  31. config_get qos "$cfg" qos
  32. local sendsize
  33. config_get sendsize "$cfg" sendsize
  34. found=
  35. for device in /sys/class/atm/*; do
  36. [ -d "$device" ] || break
  37. [ "$(cat $device/atmindex)" = "$atmdev" ] || continue
  38. found=1
  39. break
  40. done
  41. [ -n "$found" ] || return
  42. local circuit="$atmdev.$vpi.$vci"
  43. procd_open_instance
  44. procd_set_param command \
  45. /usr/sbin/br2684ctl_wrap "${nameprefix}${unit}" \
  46. -n "$nameprefix" -c "$unit" -e "$encaps" -p "$payload" \
  47. -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"} \
  48. -S /lib/netifd/br2684-up
  49. procd_close_instance
  50. }
  51. service_triggers() {
  52. local script=$(readlink "$initscript")
  53. local name=$(basename ${script:-$initscript})
  54. procd_open_trigger
  55. procd_add_raw_trigger hotplug.atm 2000 /etc/init.d/$name reload
  56. procd_add_config_trigger "config.change" "network" /etc/init.d/$name reload
  57. procd_close_trigger
  58. }
  59. start_service() {
  60. config_load network
  61. config_foreach start_daemon atm-bridge
  62. }