Skip to content

canonical forms for strings (aka: the mac-address issue) #156

@samans

Description

@samans

mac-address in both IETF and IEEE yang is defined as a string.
The canonical representations are not the same.

IETF Format: pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}’;
Canonical representation is documented as: "lowercase characters, and equivalent to MacAddress in SMIv2".

IEEE Format: pattern "[0-9a-fA-F]{2}(-[0-9a-fA-F]{2}){5}";
Canonical representation is documented as: "uses uppercase characters".

More information found:
2025-11-mac-address.pdf

Bottom Line: When a pattern has options, provide a way to indicate the canonical form, so that the end-user can follow the pattern, but be assured of what format will be used for string compare.

For example

 typedef mac-address {
   type string {
     pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
     canonical '[0-9a-f]{6}';
   }

Would indicate that whatever the string was, the comparison will be based off of the value as formatted with no ":" and in lower-case.
This would allow both the IETF and IEEE mac-address definitions to be updated and then they could be compared.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions