aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-02-05 17:48:24 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-02-05 17:48:24 +0100
commit2feaba1d8dc2893d9f1064673e500312eaa70777 (patch)
tree47b86c6692b613859535e2ddc98cdfef1a112482
parent779f96a24c43209be841f9cc0e7715a2c57db487 (diff)
downloadbusybox-w32-2feaba1d8dc2893d9f1064673e500312eaa70777.tar.gz
busybox-w32-2feaba1d8dc2893d9f1064673e500312eaa70777.tar.bz2
busybox-w32-2feaba1d8dc2893d9f1064673e500312eaa70777.zip
dhcp service example: cater for servers hot giving subnet and/or router
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rwxr-xr-xexamples/var_service/dhcp_if/convert2ipconf19
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/var_service/dhcp_if/convert2ipconf b/examples/var_service/dhcp_if/convert2ipconf
index 62a288ebf..038b1f7f1 100755
--- a/examples/var_service/dhcp_if/convert2ipconf
+++ b/examples/var_service/dhcp_if/convert2ipconf
@@ -26,6 +26,25 @@ exec 2>&1
26test "$interface" || exit 1 26test "$interface" || exit 1
27test "$ip" || exit 1 27test "$ip" || exit 1
28 28
29# some servers do not return subnet option.
30# guess it for standard private networks.
31if ! test "$mask"; then
32 if test "$ip" != "${ip#192.168.}"; then
33 mask=16
34 elif test "$ip" != "${ip#172.16.}"; then
35 mask=12
36 # repeat for each in 172.17. - 172.31. range?
37 elif test "$ip" != "${ip#10.}"; then
38 mask=8
39 fi
40fi
41
42# some servers do not return router option.
43# assume DHCP server is the router.
44if ! test "$router"; then
45 test "$serverid" && router="$serverid"
46fi
47
29{ 48{
30echo "let cfg=cfg+1" 49echo "let cfg=cfg+1"
31test "$interface" && echo "if[\$cfg]='$interface'" 50test "$interface" && echo "if[\$cfg]='$interface'"