Loading ...
Sorry, an error occurred while loading the content.

Clips for converting IP subnet masks to/from prefix lengths

Expand Messages
  • tobyrjr
    (I didn t get any hits on this list when searching for subnet so I m thinking/hoping these are original) A simple clip for converting an IPv4 prefix length
    Message 1 of 1 , Oct 22, 2006
    • 0 Attachment
      (I didn't get any hits on this list when searching for "subnet" so I'm
      thinking/hoping these are original)

      A simple clip for converting an IPv4 prefix length to a subnet mask (SNM)

      ^!Prompt A prefix length of ^?[Prefix length] is equivalent to a
      subnet mask of ^$Calc(256 - (256/2^(min(^?[Prefix
      length];8))))$.^$Calc(256 - (256/2^(min((max(0;^?[Prefix
      length]-8));8))))$.^$Calc(256 - (256/2^(min((max(0;^?[Prefix
      length]-16));8))))$.^$Calc(256 - (256/2^(min((max(0;^?[Prefix
      length]-24));8))))$


      A simple clip for converting an IPv4 subnet mask (SNM) to a prefix length

      ^!Prompt A prefix length of ^?[A Octet].^?[B Octet].^?[C Octet].^?[D
      Octet] is equivalent to a prefix length of ^$Calc(8-(LOG2(256-^?[A
      Octet])) + 8-(LOG2(256-^?[B Octet])) + 8-(LOG2(256-^?[C Octet])) +
      8-(LOG2(256-^?[D Octet])))$

      I imagine these could be improved for e.g. imput validation, but the
      maths works!

      best wishes
      Toby
    Your message has been successfully submitted and would be delivered to recipients shortly.