On 01/12/16 09:01, Gert Doering wrote: > Hi, > > On Wed, Nov 30, 2016 at 11:41:27PM +0100, David Sommerseth wrote: >> + if ((c->options.topology == TOP_SUBNET || c->options.topology == >> TOP_NET30) >> + && (c->c2.push_ifconfig_remote_netmask & 0xff000000) != >> 0xff000000) > > Are you sure of that? I would assume that this is stored in network > byte order (as it's an in_addr_t) so you can't directly compare it to > a number but need to run through ntohl() first. > > On *intel* it might end up being the same, but code dealing with IPv4 > addresses and ports always needs to be checked on both endiannesses.
Good point! I didn't consider endianess too careful, I just looked at what we do in print_in_addr_t(), realised that we always call it with 0 in the flags argument in same prepare_push_reply() function. ia.s_addr = (flags & IA_NET_ORDER) ? addr : htonl (addr); And now (when I have slightly more brainpower) I see I misread the logic, so .... > Some random code I just found in a BSD header file does it that way: > > #define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ > #define in_allhosts(x) ((x).s_addr == htonl(INADDR_ALLHOSTS_GROUP)) > > ... so it certainly needs the htonl() ... Yes! > (What you can do is "peek at byte 0", which will always be the same > part of the netmask [network byte order!], and which might actually > make this easier to read .-) ) You mean like this? in_addr_t nmask = htonl(c->c2.push_ifconfig_remote_netmask); if ( nmask[0] == 0xff ) { ... -- kind regards, David Sommerseth OpenVPN Technologies, Inc
signature.asc
Description: OpenPGP digital signature
------------------------------------------------------------------------------
_______________________________________________ Openvpn-devel mailing list Openvpn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openvpn-devel