You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.7 KiB

  1. #!/bin/sh /etc/rc.common
  2. START=90
  3. STOP=10
  4. USE_PROCD=1
  5. PROG=/usr/sbin/udp-broadcast-relay-redux
  6. NAME=udp-broadcast-relay-redux
  7. PIDCOUNT=0
  8. validate_section_udp_broadcast_relay_redux()
  9. {
  10. uci_validate_section udp_broadcast_relay_redux udp_broadcast_relay_redux "${1}" \
  11. 'id:uinteger' \
  12. 'port:port' \
  13. 'network:list(string)' \
  14. 'src_override:ip4addr' \
  15. 'dest_override:ip4addr'
  16. [ -z "$id" ] && return 1
  17. [ -z "$network" ] && return 1
  18. [ -z "$port" ] && return 1
  19. return 0
  20. }
  21. udp_broadcast_relay_redux_instance() {
  22. local net network ifname id port src_override dest_override
  23. validate_section_udp_broadcast_relay_redux "${1}" || {
  24. echo "Validation failed"
  25. return 1
  26. }
  27. PIDCOUNT="$((PIDCOUNT + 1))"
  28. procd_open_instance
  29. procd_set_param command "$PROG" "--id" "${id}" "--port" "${port}"
  30. for net in $network; do
  31. network_get_device ifname "$net"
  32. if [ -z "$ifname" ]; then
  33. network_get_physdev ifname "$net"
  34. fi
  35. if [ -n "$ifname" ]; then
  36. procd_append_param command "--dev" "$ifname"
  37. procd_append_param netdev "$ifname"
  38. fi
  39. done
  40. if [ -n "$src_override" ] ; then
  41. procd_append_param command "-s" "$src_override"
  42. fi
  43. if [ -n "$dest_override" ] ; then
  44. procd_append_param command "-t" "$dest_override"
  45. fi
  46. procd_add_jail ubr-${PIDCOUNT}
  47. procd_close_instance
  48. }
  49. start_service() {
  50. . /lib/functions.sh
  51. . /lib/functions/network.sh
  52. config_load udp_broadcast_relay_redux
  53. config_foreach udp_broadcast_relay_redux_instance udp_broadcast_relay_redux
  54. }
  55. service_triggers() {
  56. procd_add_reload_trigger "udp_broadcast_relay_redux"
  57. procd_add_validation validate_section_udp_broadcast_relay_redux
  58. }