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.

65 lines
1.4 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2012 OpenWrt.org
  3. START=91
  4. SERVICE_SIG="KILL"
  5. SERVICE_PID_FILE="/var/run/dhcrelay4.pid"
  6. SERVICE_USE_PID=1
  7. start() {
  8. . /lib/functions/network.sh
  9. config_load dhcrelay
  10. local args=""
  11. local enabled
  12. config_get_bool enabled ipv4 enabled 0
  13. [ "$enabled" -eq 0 ] && return 0
  14. # listen interfaces
  15. local interfaces
  16. local ifname
  17. config_get interfaces ipv4 interfaces
  18. for net in $interfaces; do
  19. if network_get_device ifname "$net"; then
  20. append args "-i $ifname"
  21. fi
  22. done
  23. config_get interfaces ipv4 upstream_interfaces
  24. for net in $interfaces; do
  25. if network_get_device ifname "$net"; then
  26. append args "-iu $ifname"
  27. fi
  28. done
  29. config_get interfaces ipv4 downstream_interfaces
  30. for net in $interfaces; do
  31. if network_get_device ifname "$net"; then
  32. append args "-id $ifname"
  33. fi
  34. done
  35. # link selection sub-option (RFC3527)
  36. local link_selection
  37. config_get link_selection ipv4 link_selection
  38. if network_get_device ifname "$link_selection"; then
  39. append args "-U $ifname"
  40. fi
  41. # relay mode
  42. local relay_mode
  43. config_get relay_mode ipv4 relay_mode
  44. [ -n "$relay_mode" ] && append args "-m $relay_mode"
  45. # dhcp server address
  46. local server
  47. config_get server ipv4 dhcpserver
  48. [ -n "$server" ] || return 0
  49. append args "$server"
  50. service_start /usr/sbin/dhcrelay -4 -q \
  51. -pf $SERVICE_PID_FILE $args
  52. }
  53. stop() {
  54. service_stop /usr/sbin/dhcrelay
  55. }