Domain Name Codec¶
pcapkit.corekit.schema.domain_name reads and writes the label sequence of
RFC 1035 Section 3.1, with the compression pointers of
RFC 1035 Section 4.1.4, and renders it in presentation form, for DNS and for
ICMPv6’s DNS Search List option (RFC 8106 Section 5.2).
Added in version 1.9.0: Moved here from pcapkit.protocols.application.dns.schema (#2934).
- pcapkit.corekit.schema.domain_name.read_name(data, pos, *, compression=True, alias='DNS')[source]¶
Read the domain name at
posindata.- Parameters:
- Return type:
- Returns:
Every label of the name, the root’s left out; how many of them are written in full at
pos; the offset the pointer ending the name there points to, orNonewhere the root label ends it; and the offset just past the name atpos.- Raises:
ProtocolError – If the name runs past the end of
data, holds a label type other than a plain label or, wherecompressionallows one, a pointer (RFC 6891 Section 5), or its pointers loop.
- pcapkit.corekit.schema.domain_name.make_name(labels, *, literal=None, pointer=None, alias='DNS')[source]¶
Write a domain name, the inverse of
read_name().- Parameters:
labels (
Sequence[bytes]) – Every label of the name, the root’s left out.literal (
int|None) – How many oflabelsto write in full; all of them ifNone.pointer (
int|None) – Offset a compression pointer after them points to, orNoneto end the name with the root label.alias (
str) – Prefix of the error message.
- Return type:
- Returns:
The name’s octets.
- Raises:
ProtocolError – If a label written is empty or longer than 63 octets,
literalis not a count oflabels, orpointerdoes not fit in 14 bits.
- pcapkit.corekit.schema.domain_name.name_to_text(labels)[source]¶
Render labels in presentation form (RFC 1035 Section 5.1).
- pcapkit.corekit.schema.domain_name.text_to_labels(text, *, alias='DNS')[source]¶
Read a name in presentation form into labels, the inverse of
name_to_text().- Parameters:
- Return type:
- Returns:
Every label of the name, the root’s left out.
- Raises:
ProtocolError – If
textholds an empty label, or a backslash not followed by a character or by three decimal digits up to 255.