[ipxe-devel] [ipxe/ipxe] [dhcp/ipv4] Support for DHCP option 121: Classless static route option (#67)
multun
notifications at github.com
Mon Apr 30 23:24:43 UTC 2018
multun commented on this pull request.
> + sprintf(buf, "255.255.255.%d", n_octet);
+ addr_len = 4;
+ } else if (cidr > 16) {
+ sprintf(buf, "255.255.%d.0", n_octet);
+ addr_len = 3;
+ } else if (cidr > 8) {
+ sprintf(buf, "255.%d.0.0", n_octet);
+ addr_len = 2;
+ } else if (cidr > 0) {
+ sprintf(buf, "%d.0.0.0", n_octet);
+ addr_len = 1;
+ } else if (cidr == 0) {
+ sprintf(buf, "0.0.0.0");
+ addr_len = 0;
+ } else {
+ DBGC(cidr, "Unknown netmask descriptor /%d.\n", cidr);
I don't quite get what's the point of having an individual format string for each full byte. Isn't converting it to a netmask already sufficient ?
```python
def cidr_to_netmask(cidr):
return tuple(0xFF & ~((1 << (8 - min(8, cidr - i * 8))) - 1) for i in range(4))
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/ipxe/ipxe/pull/67#pullrequestreview-116469263
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ipxe.org/pipermail/ipxe-devel/attachments/20180430/0c06dc80/attachment.htm>
More information about the ipxe-devel
mailing list