While I admit that it is *extremely* unlikely to have a network larger than /8, such logic still looks a little clumsy. It does not cover all the valid netmasks neither it detects all possible invalid ones.
If you wish to test if the netmask is valid, this solution could be better: http://stackoverflow.com/questions/17401067/c-code-for-valid-netmask > This adds a warning to the log file if --topology is configured to use > subnet or net30 and the 'subnet mask' argument of an --ifconfig-push option > is not an subnet mask. The check done is to ensure the first octet is 0xff > (255) > > Trac: #755 > Signed-off-by: David Sommerseth <dav...@openvpn.net> > --- > src/openvpn/push.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/src/openvpn/push.c b/src/openvpn/push.c > index 9953079..0819bf8 100644 > --- a/src/openvpn/push.c > +++ b/src/openvpn/push.c > @@ -333,6 +333,16 @@ prepare_push_reply (struct context *c, struct gc_arena > *gc, > print_in_addr_t (ifconfig_local, 0, gc), > print_in_addr_t (c->c2.push_ifconfig_remote_netmask, > 0, gc)); > + > + /* Warn if ifconfig_remote_netmask does not contain > + * subnet mask in subnet topology */ > + if ((c->options.topology == TOP_SUBNET || c->options.topology == > TOP_NET30) > + && (c->c2.push_ifconfig_remote_netmask & 0xff000000) != 0xff000000) > + { > + msg(M_WARN, "WARNING: When --topology is subnet or net30, the > second argument " > + "to --ifconfig-push MUST be a subnet mask. This client will > not be able " > + "to connect."); > + } > } > > /* Send peer-id if client supports it */ > -- > 1.8.3.1 > > > ------------------------------------------------------------------------------ > _______________________________________________ > Openvpn-devel mailing list > Openvpn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-devel > ------------------------------------------------------------------------------ _______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel