diff options
author | Denys Vlasenko | 2019-02-08 10:37:05 +0100 |
---|---|---|
committer | Denys Vlasenko | 2019-02-08 10:37:05 +0100 |
commit | 5a387e26c2460428d4d5d9a2b2f074a31a994da1 (patch) | |
tree | 3bcf565f0e56e6d7f2daea30d202251eb07b2d5a /examples | |
parent | 2feaba1d8dc2893d9f1064673e500312eaa70777 (diff) | |
download | busybox-5a387e26c2460428d4d5d9a2b2f074a31a994da1.zip busybox-5a387e26c2460428d4d5d9a2b2f074a31a994da1.tar.gz |
dhcp service example: rewrite "private network to mask" as case statement
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'examples')
-rwxr-xr-x | examples/var_service/dhcp_if/convert2ipconf | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/examples/var_service/dhcp_if/convert2ipconf b/examples/var_service/dhcp_if/convert2ipconf index 038b1f7..31e3c7f 100755 --- a/examples/var_service/dhcp_if/convert2ipconf +++ b/examples/var_service/dhcp_if/convert2ipconf @@ -29,14 +29,19 @@ 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 + case "$ip" in + 10.*) + mask=8;; + 192.168.*) + mask=16;; + #172.16-31.x.x + 172.1[6789].*) + mask=12;; + 172.2[0123456789].*) + mask=12;; + 172.3[01].*) + mask=12;; + esac fi # some servers do not return router option. |