diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-02-05 17:48:24 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-02-05 17:48:24 +0100 |
commit | 2feaba1d8dc2893d9f1064673e500312eaa70777 (patch) | |
tree | 47b86c6692b613859535e2ddc98cdfef1a112482 /examples | |
parent | 779f96a24c43209be841f9cc0e7715a2c57db487 (diff) | |
download | busybox-2feaba1d8dc2893d9f1064673e500312eaa70777.tar.gz |
dhcp service example: cater for servers hot giving subnet and/or router
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/var_service/dhcp_if/convert2ipconf | 19 |
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 test "$interface" || exit 1 test "$ip" || exit 1 +# some servers do not return subnet option. +# guess it for standard private networks. +if ! test "$mask"; then + if test "$ip" != "${ip#192.168.}"; then + mask=16 + elif test "$ip" != "${ip#172.16.}"; then + mask=12 + # repeat for each in 172.17. - 172.31. range? + elif test "$ip" != "${ip#10.}"; then + mask=8 + fi +fi + +# some servers do not return router option. +# assume DHCP server is the router. +if ! test "$router"; then + test "$serverid" && router="$serverid" +fi + { echo "let cfg=cfg+1" test "$interface" && echo "if[\$cfg]='$interface'" |