Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: one or more of CIDR/IP address manipulation functions #220

Open
jay7x opened this issue Mar 29, 2024 · 1 comment
Open

RFC: one or more of CIDR/IP address manipulation functions #220

jay7x opened this issue Mar 29, 2024 · 1 comment

Comments

@jay7x
Copy link
Member

jay7x commented Mar 29, 2024

I'd like to propose having extlib::parse_cidr() function which returns a Structure similar to what ipcalc.pl returns (with bit values stripped):

➜  ipcalc 192.168.0.0/24
Address:   192.168.0.0
Netmask:   255.255.255.0
Wildcard:  0.0.0.255
Network:   192.168.0.0/24
HostMin:   192.168.0.1
HostMax:   192.168.0.254
Broadcast: 192.168.0.255
Hosts/Net: 254

My original problem was to get first usable IP in a routable range I have.

Please add your ideas and use-cases in comments below

@jay7x
Copy link
Member Author

jay7x commented Mar 29, 2024

I got some comments in Slack/IRC:

Lumiere
if you do that parse_cidr, I'd love it to also return the subnet_size (or whatever we want to word it) so "24" in that case (I know I could get it with split, but getting everything at once is nice)

libera - @kjetilho
Yury - I personally do this in Ruby code in ERB, but for EPP that would certainly be useful. I'd want "subnet_size: 24", to. HostMin is not useful for me - what is your usecase? where people put their routers vary quite a bit. it can even be .0, since no one uses zero broadcast anymore.
perhaps a separate function ipaddr_next(address, n) for the nth address after address?
the name ipaddr_add() is probably as intuitive - or more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant