Compare commits

...

1 Commits

Author SHA1 Message Date
Suvendhu Hansa
87a455393c icwmp,obuspc: tr111 force dhcp opt125 2024-04-11 12:21:42 +05:30
2 changed files with 30 additions and 4 deletions

View File

@@ -176,7 +176,7 @@ configure_send_op125() {
uci -q set network."${intf}".sendopts="$new_send_opt"
else
new_send_opt="$sendopt$opt125"
uci -q add_list dhcp."${intf}".dhcp_option="$new_send_opt"
uci -q add_list dhcp."${intf}".dhcp_option_force="$new_send_opt"
fi
}
@@ -270,7 +270,20 @@ enable_dnsmasq_option125() {
local proto="$(uci -q get dhcp."${lan}".dhcpv4)"
if [ "${proto}" = "server" ]; then
# if opt125 is present with dhcp_option make it forced
opt_list="$(uci -q get dhcp."${lan}".dhcp_option)"
for sopt in $opt_list; do
if [[ "$sopt" == "$opt125"* ]]; then
uci -q del_list dhcp."${lan}".dhcp_option="${sopt}"
uci -q add_list dhcp."${lan}".dhcp_option_force="${sopt}"
uci commit dhcp
break
fi
done
# Now check if opt125 has device information sub-options
opt_list="$(uci -q get dhcp."${lan}".dhcp_option_force)"
base_opt=""
for sopt in $opt_list; do
@@ -282,7 +295,7 @@ enable_dnsmasq_option125() {
done
if [ ${send125_present} -eq 0 ]; then
uci -q del_list dhcp."${lan}".dhcp_option="${base_opt}"
uci -q del_list dhcp."${lan}".dhcp_option_force="${base_opt}"
configure_send_op125 "${base_opt}" "${lan}" "dhcp"
ubus call uci commit '{"config":"dhcp"}'
fi

View File

@@ -237,11 +237,24 @@ configure_dnsmasq_op125() {
service="$(uci -q get dhcp."${intf}".dhcpv4)"
if [ "${service}" = "server" ]; then
# if opt125 is present with dhcp_option make it forced
opt_list="$(uci -q get dhcp."${intf}".dhcp_option)"
for sopt in $opt_list; do
if [[ "$sopt" == "$opt125"* ]]; then
uci -q del_list dhcp."${intf}".dhcp_option="$sopt"
uci -q del_list dhcp."${intf}".dhcp_option_force="$sopt"
uci -q commit dhcp
break
fi
done
# Now check if opt125 has usp controller sub-options
opt_list="$(uci -q get dhcp."${intf}".dhcp_option_force)"
for sopt in $opt_list; do
if [[ "$sopt" == "$opt125"* ]]; then
base_opt=$(check_for_suboptions "${sopt:4}")
uci -q del_list dhcp."${intf}".dhcp_option="$sopt"
uci -q del_list dhcp."${intf}".dhcp_option_force="$sopt"
uci -q commit dhcp
break
fi
@@ -313,7 +326,7 @@ configure_dnsmasq_op125() {
hex_endpoint_len=$(printf "%02X" "${endpoint_len}")
opt125="${opt125}:1D:${hex_endpoint_len}${hex_endpoint}"
uci -q add_list dhcp."${intf}".dhcp_option="$opt125"
uci -q add_list dhcp."${intf}".dhcp_option_force="$opt125"
ubus call uci commit '{"config":"dhcp"}'
}