Skip to content

Instantly share code, notes, and snippets.

@rjmooney
rjmooney / main.c
Last active March 7, 2019 22:30
NetmaskFromCIDR
#include <stdio.h>
#include <arpa/inet.h>
uint32_t cidr_to_netmask(uint8_t cidr)
{
uint8_t unset_bits = 32 - cidr;
return ntohl(0xffffffff << unset_bits);
}
int main(void)

Keybase proof

I hereby claim:

  • I am rjmooney on github.
  • I am rjmooney (https://keybase.io/rjmooney) on keybase.
  • I have a public key ASAGonOvlRxed9rZ9G7-bXo8lIwhPjsWszLD_Ku35a8QZAo

To claim this, I am signing this object: