in reply to Enumerating IP Addresses in a Subnet
in thread algorithm for network address enumeration

You're right to subtract both the first and last addresses that fall under the mask, but if the input contains an explicit broadcast address like the OP says it's better to stick with that for output; I believe some old equipment uses 0 instead of -1 for broadcast.

(And your regexp works, but "\." is a bit better than ".".)

Nifty implementation though.

  • Comment on Re^3: algorithm for network address enumeration

Replies are listed 'Best First'.
Re^4: algorithm for network address enumeration
by ikegami (Patriarch) on Feb 10, 2005 at 19:53 UTC
    You're right to subtract both the first and last addresses that fall under the mask, but if the input contains an explicit broadcast address like the OP says it's better to stick with that for output; I believe some old equipment uses 0 instead of -1 for broadcast.

    I provided an excessive amount of info, so that he can easily customize it to his needs.

    And your regexp works, but "\." is a bit better than ".".)

    Thanks. Noticed and fixed. Actually, I replaced the regexp with split(/\./). It's probably a tad slower, but it mirrors the join.