Message Opcodes

DNS Opcodes describe what kind of operation a DNS message is requesting or replying to. Opcodes are embedded in the flags field in the DNS header.

class dns.opcode.Opcode(value)[source]
IQUERY = 1

Inverse Query (historical)

NOTIFY = 4

Notify

QUERY = 0

Query

STATUS = 2

Server Status (unspecified and unimplemented anywhere)

UPDATE = 5

Dynamic Update

dns.opcode.QUERY = Opcode.QUERY
dns.opcode.IQUERY = Opcode.IQUERY
dns.opcode.STATUS = Opcode.STATUS
dns.opcode.NOTIFY = Opcode.NOTIFY
dns.opcode.UPDATE = Opcode.UPDATE
dns.opcode.from_text(text: str) Opcode[source]

Convert text into an opcode.

Parameters:

text (str) – The textual opcode.

Raises:

dns.opcode.UnknownOpcode – If the opcode is unknown.

Return type:

dns.opcode.Opcode

dns.opcode.to_text(value: Opcode) str[source]

Convert an opcode to text.

Parameters:

value (dns.opcode.Opcode) – The opcode value.

Raises:

dns.opcode.UnknownOpcode – If the opcode is unknown.

Return type:

str

dns.opcode.from_flags(flags: int) Opcode[source]

Extract an opcode from DNS message flags.

Parameters:

flags (int) – The DNS message flags.

Return type:

dns.opcode.Opcode

dns.opcode.to_flags(value: Opcode) int[source]

Convert an opcode to a value suitable for ORing into DNS message flags.

Parameters:

value (dns.opcode.Opcode) – The DNS opcode value.

Return type:

int

dns.opcode.is_update(flags: int) bool[source]

Is the opcode in flags UPDATE?

Parameters:

flags (int) – The DNS message flags.

Return type:

bool