mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-30 01:52:51 +00:00
udhcpinject: Allow option 82 DHCP fields to be transparently injected into client DHCP requests
1. Added userspace application udhcpinject to inject DHCP option 82 transparently 2. Added README.md for example usage Fixes: WIFI-14018 Signed-off-by: alex18_huang <alex18_huang@accton.com>
This commit is contained in:
committed by
John Crispin
parent
6afbb92dec
commit
c5793bae3a
73
feeds/ucentral/udhcpinject/files/etc/init.d/dhcpinject
Executable file
73
feeds/ucentral/udhcpinject/files/etc/init.d/dhcpinject
Executable file
@@ -0,0 +1,73 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
START=95
|
||||
STOP=10
|
||||
|
||||
SERVICE_NAME="dhcpinject"
|
||||
PROG=/usr/bin/udhcpinject
|
||||
|
||||
start_service() {
|
||||
local ssid_list=""
|
||||
local ssids=""
|
||||
local ports=""
|
||||
|
||||
# Function to process each ssid
|
||||
append_ssid() {
|
||||
local value="$1"
|
||||
if [ -n "$ssids" ]; then
|
||||
ssids="$ssids,$value"
|
||||
else
|
||||
ssids="$value"
|
||||
fi
|
||||
}
|
||||
|
||||
append_port() {
|
||||
local value="$1"
|
||||
if [ -n "$ports" ]; then
|
||||
ports="$ports,$value"
|
||||
else
|
||||
ports="$value"
|
||||
fi
|
||||
}
|
||||
|
||||
# Load the dhcpinject config
|
||||
config_load dhcpinject
|
||||
|
||||
# Get the list of SSIDs
|
||||
config_list_foreach ssids ssid append_ssid
|
||||
|
||||
# Get the list of ports
|
||||
config_list_foreach uplink port append_port
|
||||
|
||||
# Fallback to eth0 if no ports are specified
|
||||
if [ -z "$ports" ]; then
|
||||
ports="eth0"
|
||||
fi
|
||||
|
||||
# Optional: Log or echo for debugging
|
||||
logger -t dhcp_inject "Generated SSIDs=$ssids, Uplink=$ports"
|
||||
|
||||
procd_open_instance "$SERVICE_NAME"
|
||||
procd_set_param command $PROG
|
||||
procd_set_param env SSIDs="$ssids" PORTs="$ports"
|
||||
procd_set_param respawn 3600 10 10
|
||||
procd_set_param file /etc/config/dhcpinject
|
||||
procd_set_param reload_signal SIGHUP
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
procd_kill $SERVICE_NAME
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
procd_send_signal $SERVICE_NAME
|
||||
}
|
||||
|
||||
restart_service() {
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
}
|
||||
Reference in New Issue
Block a user