On 18. mars 2018 12:42, Henri Verbeet wrote:
On 17 March 2018 at 19:30, Dagfinn Reiakvam dagfinn@reiakvam.no wrote:
IN_ADDR temp;
temp.S_un.S_addr = 0xffffffff << ( 32 - MaskLength);
*Mask = temp.S_un.S_un_b.s_b4 + ( temp.S_un.S_un_b.s_b3 << 8 ) + ( temp.S_un.S_un_b.s_b2 << 16 ) + ( temp.S_un.S_un_b.s_b1 << 24 );
Should that be "*mask = htonl(~0u << (32 - mask_len));"?
The tests would probably benefit from htonl() as well.
Thanks for your comments Henri.
Yes, that looks more tidy. I was not aware of the htonl() function. Where in particular do you think the tests would benefit from this function?
Also, I will not be using capital letter in my variables :)