IsEmpty() const
Indicates whether the name is empty (not specified).
IsFromCString() const
Indicates whether the name is specified from a C string.
IsFromMessage() const
Indicates whether the name is specified from a message.
GetFromType() const
Gets the type of `Name` object indicating whether it is empty, specified by a C string or from a message.
Set()
Sets the name from a given C string.
SetFromMessage()
Sets the name from a message at a given offset.
GetAsCString() const
Gets the name as a C string. MUST be used only when the type is `kTypeString`. Otherwise its behavior is undefined.
GetAsMessage() const
Gets the name message and offset. MUST be used only when the type is `kTypeMessage`. Otherwise its behavior is undefined.
Matches() const
Matches the `Name` with a given set of labels and domain name. This method allows the caller to specify name components separately, enabling scenarios like comparing "service instance name" with separate instance label (which can include dot character), service type, and domain strings. @p aFirstLabel can be `nullptr` if not needed. But if non-null, it is treated as a single label and can itself include dot `.` character. The @p aLabels MUST NOT be `nullptr` and MUST follow "..", i.e., a sequence of one or more labels separated by dot '.' char, and it MUST NOT end with dot `.`. @p aDomain MUST NOT be `nullptr` and MUST have at least one label and MUST always end with a dot `.` character. If the above conditions are not satisfied, the behavior of this method is undefined.
AppendTo() const
Encodes and appends the name to a message. If the name is empty (not specified), then root "." is appended to @p aMessage. If the name is from a C string then the string is checked and appended (similar to static `AppendName(const char *aName, Message &)` method). If the the name is from a message, then it is read from the message and appended to @p aMessage. Note that in this case independent of whether the name is compressed or not in its original message, the name is appended as full (uncompressed) in @p aMessage.
AppendLabel()
Encodes and appends a single name label to a message. The @p aLabel is assumed to contain a single name label as a C string (null-terminated). Unlike `AppendMultipleLabels()` which parses the label string and treats it as sequence of multiple (dot-separated) labels, this method always appends @p aLabel as a single whole label. This allows the label string to even contain dot '.' character, which, for example, is useful for "Service Instance Names" where portion is a user-friendly name and can contain dot characters.
AppendMultipleLabels()
Encodes and appends a sequence of name labels to a given message. The @p aLabels must follow "..", i.e., a sequence of labels separated by dot '.' char. E.g., "_http._tcp", "_http._tcp." (same as previous one), "host-1.test". Validates that the @p aLabels is a valid name format, i.e., no empty label, and labels are `kMaxLabelLength` (63) characters or less.
AppendTerminator()
Appends a name label terminator to a message. An encoded name is terminated by an empty label (a zero byte).
AppendPointerLabel()
Appends a pointer type name label to a message. Pointer label is used for name compression. It allows an entire name or a list of labels at the end of an encoded name to be replaced with a pointer to a prior occurrence of the same name within the message.
AppendName()
Encodes and appends a full name to a message. The @p aName must follow "..", i.e., a sequence of labels separated by dot '.' char. E.g., "example.com", "example.com." (same as previous one), "local.", "default.service.arpa", "." or "" (root). Validates that the @p aName is a valid name format, i.e. no empty labels, and labels are `kMaxLabelLength` (63) characters or less, and the name is `kMaxLength` (255) characters or less.
ParseName()
Parses and skips over a full name in a message.
ReadLabel()
Reads a name label from a message. Can be used to read labels one by one in a name. After a successful label read, @p aOffset is updated to point to the start of the next label. When we reach the end of the name, kErrorNotFound is returned. This method handles compressed names which use pointer labels. So as the labels in a name are read, the @p aOffset may jump back in the message and at the end the @p aOffset does not necessarily point to the end of the original name field. Unlike `ReadName()` which requires and verifies that the read label to contain no dot '.' character, this method allows the read label to include any character.
ReadName()
Reads a full name from a message. On successful read, the read name follows "...", i.e., a sequence of labels separated by dot '.' character. The read name will ALWAYS end with a dot. Verifies that the labels after the first label in message do not contain any dot character. If they do, returns `kErrorParse`.
ReadName()
Reads a full name from a message. On successful read, the read name follows "...", i.e., a sequence of labels separated by dot '.' character. The read name will ALWAYS end with a dot. Verifies that the labels after the first label in message do not contain any dot character. If they do, returns `kErrorParse`.
CompareLabel()
Compares a single name label from a message with a given label string. Can be used to compare labels one by one. It checks whether the label read from @p aMessage matches @p aLabel string (case-insensitive comparison). Unlike `CompareName()` which requires the labels in the the name string to contain no dot '.' character, this method allows @p aLabel to include any character.
CompareMultipleLabels()
Parses and compares multiple name labels from a message. Can be used to read and compare a group of labels from an encoded DNS name in a message with possibly more labels remaining to read. The @p aLabels must follow "..", i.e., a sequence of labels separated by dot '.' char.
CompareName()
Parses and compares a full name from a message with a given name. Checks whether the encoded name in a message matches a given name string (using case-insensitive comparison). It checks the name in the message in place and handles compressed names. If the name read from the message does not match @p aName, it returns `kErrorNotFound`. `kErrorNone` indicates that the name matches @p aName. The @p aName must follow "..", i.e., a sequence of labels separated by dot '.' char. E.g., "example.com", "example.com." (same as previous one), "local.", "default.service.arpa", "." or "" (root).
CompareName()
Parses and compares a full name from a message with a given name. Checks whether the encoded name in a message matches a given name string (using case-insensitive comparison). It checks the name in the message in place and handles compressed names. If the name read from the message does not match @p aName, it returns `kErrorNotFound`. `kErrorNone` indicates that the name matches @p aName. The @p aName must follow "..", i.e., a sequence of labels separated by dot '.' char. E.g., "example.com", "example.com." (same as previous one), "local.", "default.service.arpa", "." or "" (root).
CompareName()
Parses and compares a full name from a message with a given name. Checks whether the encoded name in a message matches a given name string (using case-insensitive comparison). It checks the name in the message in place and handles compressed names. If the name read from the message does not match @p aName, it returns `kErrorNotFound`. `kErrorNone` indicates that the name matches @p aName. The @p aName must follow "..", i.e., a sequence of labels separated by dot '.' char. E.g., "example.com", "example.com." (same as previous one), "local.", "default.service.arpa", "." or "" (root).
Extracts label(s) from a name by checking that it contains a given suffix name (e.g., suffix name can be a domain name) and removing it. Both @p aName and @p aSuffixName MUST follow the same style regarding inclusion of trailing dot ('.'). Otherwise `kErrorParse` is returned. The @p aLabels buffer may be the same as @p aName for in-place label extraction. In this case, the implementation avoids unnecessary character copies.
Extracts label(s) from a name by checking that it contains a given suffix name (e.g., suffix name can be a domain name) and removing it. Both @p aName and @p aSuffixName MUST follow the same style regarding inclusion of trailing dot ('.'). Otherwise `kErrorParse` is returned. The @p aLabels buffer may be the same as @p aName for in-place label extraction. In this case, the implementation avoids unnecessary character copies.
StripName()
IsSubDomainOf()
Tests if a DNS name is a sub-domain of a given domain. Both @p aName and @p aDomain can end without dot ('.').
IsSameDomain()
Tests if the two DNS name are the same domain. Both @p aDomain1 and @p aDomain2 can end without dot ('.').
CompareAndSkipLabels()
AppendLabel()
Encodes and appends a single name label to a message. The @p aLabel is assumed to contain a single name label as a C string (null-terminated). Unlike `AppendMultipleLabels()` which parses the label string and treats it as sequence of multiple (dot-separated) labels, this method always appends @p aLabel as a single whole label. This allows the label string to even contain dot '.' character, which, for example, is useful for "Service Instance Names" where portion is a user-friendly name and can contain dot characters.