Matching of case for ASCII content
Sometimes administrators will want to match some arbitrary content for reservations or classes. For example, they may want to match on remote id. There may be some differences between equipment with how this content is added to remote id.
- Device 1 remote ID content:
some ascii string
Hex:736F6D6520617363696920737472696E67
- Device 2 remote ID content:
SOME ASCII STRING
Hex:534F4D4520415343494920535452494E47
Currently, Kea is only able to match these based on the hexadecimal content of the remote ID field. At no time is Kea able to decode these as it has no way to know how it was encoded. Therefore the administrator cannot predict what the match will be in advance. In ISC DHCP, one might match like this: ucase(binary-to-ascii(10,8,option agent.remote-id)) = "SOME ASCII STRING"
where the string would first be converted to ASCII and then converted to all uppercase letters so that strings would be, in a sense, case insensitive.
Suggest to add some equivalent of these functions to Kea so that matches could be done in a similar way.
Relevant ISC DHCP functions:
binary-to-ascii (numeric-expr1, numeric-expr2, data-expr1, data-expr2)
Converts the result of evaluating data-expr2 into a text string containing one number for each element of the result of evaluating data-expr2. Each number is separated from the other by the result of evaluating data-expr1. The result of evaluating numeric-expr1 specifies the base (2 through 16) into which the numbers should be converted. The result of evaluating numeric-expr2 specifies the width in bits of each number, which may be either 8, 16 or 32.
As an example of the preceding three types of expressions, to produce the name of a PTR record for the IP address being assigned to a client, one could write the following expression:
concat (binary-to-ascii (10, 8, ".", reverse (1, leased-address)), ".in-addr.arpa.");
lcase (data-expr)
The lcase function returns the result of evaluating data-expr converted to lower case. If data-expr evaluates to null, then the result is also null.
ucase (data-expr)
The ucase function returns the result of evaluating data-expr converted to upper case. If data-expr evaluates to null, then the result is also null.