Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/zeroconf/_protocol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,3 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
"""

from ..const import _FLAGS_QR_MASK, _FLAGS_QR_QUERY, _FLAGS_QR_RESPONSE, _FLAGS_TC


class DNSMessage:
"""A base class for DNS messages."""

__slots__ = ('flags',)

def __init__(self, flags: int) -> None:
"""Construct a DNS message."""
self.flags = flags

def is_query(self) -> bool:
"""Returns true if this is a query."""
return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_QUERY

def is_response(self) -> bool:
"""Returns true if this is a response."""
return (self.flags & _FLAGS_QR_MASK) == _FLAGS_QR_RESPONSE

@property
def truncated(self) -> bool:
"""Returns true if this is a truncated."""
return (self.flags & _FLAGS_TC) == _FLAGS_TC
80 changes: 80 additions & 0 deletions src/zeroconf/_protocol/incoming.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

import cython


cdef cython.uint DNS_COMPRESSION_HEADER_LEN
cdef cython.uint MAX_DNS_LABELS
cdef cython.uint DNS_COMPRESSION_POINTER_LEN
cdef cython.uint MAX_NAME_LENGTH


cdef cython.uint _TYPE_A
cdef cython.uint _TYPE_CNAME
cdef cython.uint _TYPE_PTR
cdef cython.uint _TYPE_TXT
cdef cython.uint _TYPE_SRV
cdef cython.uint _TYPE_HINFO
cdef cython.uint _TYPE_AAAA
cdef cython.uint _TYPE_NSEC
cdef cython.uint _FLAGS_QR_MASK
cdef cython.uint _FLAGS_QR_MASK
cdef cython.uint _FLAGS_TC
cdef cython.uint _FLAGS_QR_QUERY
cdef cython.uint _FLAGS_QR_RESPONSE

cdef object UNPACK_3H
cdef object UNPACK_6H
cdef object UNPACK_HH
cdef object UNPACK_HHiH

cdef object DECODE_EXCEPTIONS

cdef object IncomingDecodeError

cdef class DNSIncoming:

cdef bint _did_read_others
cdef public unsigned int flags
cdef unsigned int offset
cdef public bytes data
cdef unsigned int _data_len
cdef public object name_cache
cdef public object questions
cdef object _answers
cdef public object id
cdef public object num_questions
cdef public object num_answers
cdef public object num_authorities
cdef public object num_additionals
cdef public object valid
cdef public object now
cdef public object scope_id
cdef public object source

@cython.locals(
off=cython.uint,
label_idx=cython.uint,
length=cython.uint,
link=cython.uint
)
cdef _decode_labels_at_offset(self, unsigned int off, cython.list labels, object seen_pointers)

cdef _read_header(self)

cdef _read_questions(self)

@cython.locals(
length=cython.uint
)
cdef bytes _read_character_string(self)

cdef _read_string(self, unsigned int length)

@cython.locals(
name_start=cython.uint
)
cdef _read_record(self, object domain, unsigned int type_, object class_, object ttl, object length)

cdef _read_bitmap(self, unsigned int end)

cdef _read_name(self)
Loading