dhcpd code changes

David W. Hankins dhankins at isc.org
Sat Nov 14 00:12:33 UTC 2009


On Fri, Nov 13, 2009 at 02:19:49PM +0530, Ashmath Khan wrote:
> > Right. But <= is currently not supported by ISC DHCP.
> thanks.

One of the sad results of knowing multiple human languages is that you
find yourself switching between them sometimes, to everyone's surprise.

It seems I just did that with DHCP's config-programming-language and
C...

Ohwell, let's try this again in valid DHCP syntax this time;

    class "0-11" {
      # Ethernet hardware addresses where the last three octets are
      # between 0x00 and 0x11 inclusive.
      match if (extract-int(substring(hardware, 0, 1), 8) = 1 and
                (((extract-int(suffix(hardware, 4), 32) &
                   15790320) = 0) or # 0xf0f0f0
		 ((extract-int(suffix(hardware, 4), 32) &
		   15790318) = 0) or # 0xf0f0ee
		 ((extract-int(suffix(hardware, 4), 32) &
                   15789808) = 0) or # 0xf0eef0
                 ((extract-int(suffix(hardware, 4), 32) &
                   15789806) = 0) or # 0xf0eeee
                 ((extract-int(suffix(hardware, 4), 32) &
                   15659248) = 0) or # 0xeef0f0
                 ((extract-int(suffix(hardware, 4), 32) &
                   15659246) = 0) or # 0xeef0ee
                 ((extract-int(suffix(hardware, 4), 32) &
                   15658736) = 0) or # 0xeeeef0
                 ((extract-int(suffix(hardware, 4), 32) &
                   15658734) = 0))); # 0xeeeeee
    }

Which is admittedly ugly.  So you may prefer capitalizing on integer
rounding on divide instead (extract-int is unsigned);

    class "0-11" {
      # Ethernet hardware addresses where the last three octets are
      # between 0x00 and 0x11 inclusive.
      match if (extract-int(substring(hardware, 0, 1), 8) = 1 and
                (((extract-int(substring(hardware, 4, 1), 8) / 18) = 0) and
		 ((extract-int(substring(hardware, 5, 1), 8) / 18) = 0) and
		 ((extract-int(substring(hardware, 6, 1), 8) / 18) = 0)));
    }

0x11 is 17, so 17 / 18 will produce a zero.  0x12 is 18, so 18/18 will
produce a 1 and fail the equal operator.

-- 
David W. Hankins	"If you don't do it right the first time,
Software Engineer		     you'll just have to do it again."
Internet Systems Consortium, Inc.		-- Jack T. Hankins
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/dhcp-workers/attachments/20091113/3047272f/attachment.bin>


More information about the dhcp-workers mailing list