Add DSCP class-name keyword support#492
Conversation
Claude review of PR #492 (e0408af)Suggestions
Nits
CLAUDE.md improvements
|
Allow DSCP matchers (ip4.dscp, ip6.dscp) to accept symbolic class names (cs0-cs7, af11-af43, ef, be) in addition to numeric values. The class name table is based on iptables' dscp_helper.c and the IANA DSCP registry. Matching is case-insensitive.
Add unit tests for bf_dscp_class_to_str/bf_dscp_class_from_str conversion functions, keyword parsing in ip4_dscp and ip6_dscp matchers, and e2e tests exercising class name keywords with both valid and invalid inputs.
2433b38 to
e0408af
Compare
| assert(payload); | ||
| assert(raw_payload); | ||
|
|
||
| if (!bf_dscp_class_from_str(raw_payload, (uint8_t *)payload)) |
There was a problem hiding this comment.
Claude: nit: Other _bf_parse_* functions pass payload directly to their corresponding *_from_str call without a cast (e.g. bf_icmp_type_from_str(raw_payload, payload), bf_ipproto_from_str(raw_payload, payload)). The explicit (uint8_t *) cast is safe but unnecessary in C (void * converts implicitly) and inconsistent with the existing pattern.
| assert(str); | ||
| assert(dscp); | ||
|
|
||
| if (bf_streq_i(str, "be")) { |
There was a problem hiding this comment.
Claude: suggestion: The "be" alias is handled as a special case before the main loop. Adding {"be", 0} at the end of _bf_dscp_classes would fold it into the generic loop, removing this branch. bf_dscp_class_to_str(0) would still return "cs0" because it appears first in the array, preserving the canonicalization behavior.
| } | ||
|
|
||
| /* DSCP class name to codepoint mapping, based on iptables | ||
| * dscp_helper.c and http://www.iana.org/assignments/dscp-registry. |
There was a problem hiding this comment.
Claude: nit: The IANA link uses plain HTTP. Consider updating to https://www.iana.org/assignments/dscp-registry/dscp-registry.xhtml.
As mentioned in #383, add support for DSCP class name keywords in
ip4.dscpandip6.dscpmatchers. Instead of requiring users to memorize numeric DSCP codepoints, rules can now use standard class names:Supported keywords follow the IANA DSCP registry and match iptables conventions (see
dscp_helper.c):Keywords are case-insensitive. Numeric values (0–63, decimal or hex) continue to work as before.
Testing