pythonmod_utils.h File Reference

Utility functions for the python module that perform stores and loads and conversions. More...

#include "util/module.h"

Functions

int storeQueryInCache (struct module_qstate *qstate, struct query_info *qinfo, struct reply_info *msgrep, int is_referral)
 Store the reply_info and query_info pair in message cache (qstate->msg_cache). More...
 
void invalidateQueryInCache (struct module_qstate *qstate, struct query_info *qinfo)
 Invalidate the message associated with query_info stored in message cache. More...
 
int createResponse (struct module_qstate *qstate, struct sldns_buffer *pkt)
 Create response according to the ldns packet content. More...
 
void reply_addr2str (struct comm_reply *reply, char *dest, int maxlen)
 Convert reply->addr to string. More...
 
void delegpt_addr_addr2str (struct delegpt_addr *target, char *dest, int maxlen)
 Convert target->addr to string. More...
 

Detailed Description

Utility functions for the python module that perform stores and loads and conversions.

Function Documentation

◆ storeQueryInCache()

int storeQueryInCache ( struct module_qstate qstate,
struct query_info qinfo,
struct reply_info msgrep,
int  is_referral 
)

Store the reply_info and query_info pair in message cache (qstate->msg_cache).

Parameters
qstatemodule environment
qinfoquery info, the query for which answer is stored.
msgrepreply in dns_msg
is_referralIf true, then the given message to be stored is a referral. The cache implementation may use this as a hint. It will store only the RRsets, not the message.
Returns
0 on alloc error (out of memory).

References reply_info::authoritative, dns_cache_store(), module_qstate::env, module_qstate::prefetch_leeway, module_qstate::qstarttime, and module_qstate::query_flags.

◆ invalidateQueryInCache()

void invalidateQueryInCache ( struct module_qstate qstate,
struct query_info qinfo 
)

Invalidate the message associated with query_info stored in message cache.

This function invalidates the record in message cache associated with the given query only if such a record exists.

Parameters
qstatemodule environment
qinfoquery info, the query for which answer is stored.

References packed_rrset_data::count, lruhash_entry::data, ub_packed_rrset_key::entry, module_qstate::env, rrset_ref::key, lruhash_entry::lock, log_info(), module_env::msg_cache, module_env::now, module_qstate::query_flags, query_info_hash(), reply_info::ref, packed_rrset_data::rr_ttl, rrset_array_lock(), rrset_array_unlock(), reply_info::rrset_count, packed_rrset_data::rrsig_count, slabhash_lookup(), reply_info::ttl, and packed_rrset_data::ttl.

◆ createResponse()

int createResponse ( struct module_qstate qstate,
struct sldns_buffer pkt 
)

Create response according to the ldns packet content.

This function fills qstate.return_msg up with data of a given packet

Parameters
qstatemodule environment
pkta sldns_buffer which contains sldns_packet data
Returns
0 on failure, out of memory or parse error.

References module_qstate::env, log_err(), parse_packet(), regional_alloc(), module_env::scratch, and sldns_buffer_set_position().

◆ reply_addr2str()

void reply_addr2str ( struct comm_reply reply,
char *  dest,
int  maxlen 
)

Convert reply->addr to string.

Parameters
replycomm reply with address in it.
destdestination string.
maxlenlength of string buffer.

References comm_reply::client_addr.

◆ delegpt_addr_addr2str()

void delegpt_addr_addr2str ( struct delegpt_addr target,
char *  dest,
int  maxlen 
)

Convert target->addr to string.

Parameters
targetdelegpt_addr with address in it.
destdestination string.
maxlenlength of string buffer.

References delegpt_addr::addr.