Scriptable functions

Network

ntohs(netshort)

This subroutine converts values between the host and network byte order. Specifically, ntohs() converts 16-bit quantities from network byte order to host byte order.

Parameters:netshort – 16-bit short addr
Return type:converted addr

Cache

storeQueryInCache(qstate, qinfo, msgrep, is_referral)

Store pending query in local cache.

Parameters:
Return type:

boolean

invalidateQueryInCache(qstate, qinfo)

Invalidate record in local cache.

Parameters:

EDNS options

register_edns_option(env, code, bypass_cache_stage=False, no_aggregation=False)

Register EDNS option code.

Parameters:
  • envmodule_env
  • code – option code(integer)
  • bypass_cache_stage – whether to bypass the cache response stage
  • no_aggregation – whether this query should be unique
Returns:

1 if successful, 0 otherwise

Return type:

integer

edns_opt_list_find(list, code)

Find the EDNS option code in the EDNS option list.

Parameters:
  • list – linked list of edns_option
  • code – option code (integer)
Returns:

the edns option if found or None

Return type:

edns_option or None

edns_opt_list_remove(list, code);

Remove an ENDS option code from the list. .. note:: All edns_option with the code will be removed

Parameters:
  • list – linked list of edns_option
  • code – option code (integer)
Returns:

1 if at least one edns_option was removed, 0 otherwise

Return type:

integer

edns_opt_list_append(list, code, data, region)

Append given EDNS option code with data to the list.

Parameters:
  • list – linked list of edns_option
  • code – option code (integer)
  • data – EDNS data. Must be a bytearray
  • regionregional
edns_opt_list_is_empty(list)

Check if an EDNS option list is empty.

Parameters:list – linked list of edns_option
Returns:1 if list is empty, 0 otherwise
Return type:integer

Inplace callbacks

inplace_cb_reply(qinfo, qstate, rep, rcode, edns, opt_list_out, region)

Function prototype for callback functions used in register_inplace_cb_reply, register_inplace_cb_reply_cache, register_inplace_cb_reply_local and register_inplace_cb_reply_servfail.

Parameters:
register_inplace_cb_reply(py_cb, env)

Register py_cb as an inplace reply callback function.

Parameters:
  • py_cb – Python function that follows inplace_cb_reply’s prototype. Must be callable.
  • envmodule_env
Returns:

True on success, False otherwise

Return type:

boolean

register_inplace_cb_reply_cache(py_cb, env)

Register py_cb as an inplace reply_cache callback function.

Parameters:
  • py_cb – Python function that follows inplace_cb_reply’s prototype. Must be callable.
  • envmodule_env
Returns:

True on success, False otherwise

Return type:

boolean

register_inplace_cb_reply_local(py_cb, env)

Register py_cb as an inplace reply_local callback function.

Parameters:
  • py_cb – Python function that follows inplace_cb_reply’s prototype. Must be callable.
  • envmodule_env
Returns:

True on success, False otherwise

Return type:

boolean

register_inplace_cb_reply_servfail(py_cb, env)

Register py_cb as an inplace reply_servfail callback function.

Parameters:
  • py_cb – Python function that follows inplace_cb_reply’s prototype. Must be callable.
  • envmodule_env
Returns:

True on success, False otherwise

Return type:

boolean

Logging

verbose(level, msg)

Log a verbose message, pass the level for this message. No trailing newline is needed.

Parameters:
  • level – verbosity level for this message, compared to global verbosity setting.
  • msg – string message
log_info(msg)

Log informational message. No trailing newline is needed.

Parameters:msg – string message
log_err(msg)

Log error message. No trailing newline is needed.

Parameters:msg – string message
log_warn(msg)

Log warning message. No trailing newline is needed.

Parameters:msg – string message
log_hex(msg, data, length)

Log a hex-string to the log. Can be any length. performs mallocs to do so, slow. But debug useful.

Parameters:
  • msg – string desc to accompany the hexdump.
  • data – data to dump in hex format.
  • length – length of data.
log_dns_msg(str, qinfo, reply)

Log DNS message.

Parameters:
log_query_info(verbosity_value, str, qinf)

Log query information.

Parameters:
  • verbosity_value – see constants
  • str – string message
  • qinfquery_info
regional_log_stats(r)

Log regional statistics.

Parameters:rregional

Debugging

strextstate(module_ext_state)

Debug utility, module external qstate to string.

Parameters:module_ext_state – the state value.
Return type:descriptive string.
strmodulevent(module_event)

Debug utility, module event to string.

Parameters:module_event – the module event value.
Return type:descriptive string.
ldns_rr_type2str(atype)

Convert RR type to string.

ldns_rr_class2str(aclass)

Convert RR class to string.