Maintained by: NLnet Labs
Functions
pythonmod_utils.c File Reference

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

#include "config.h"
#include "util/module.h"
#include "util/netevent.h"
#include "util/net_help.h"
#include "services/cache/dns.h"
#include "services/cache/rrset.h"
#include "util/data/msgparse.h"
#include "util/data/msgreply.h"
#include "util/storage/slabhash.h"
#include "util/regional.h"
#include "ldns/sbuffer.h"
#include <Python.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, 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...
 

Detailed Description

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

Function Documentation

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, and module_qstate::prefetch_leeway.

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, 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.

int createResponse ( struct module_qstate qstate,
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 BIT_CD, module_qstate::env, log_dns_msg(), log_err(), parse_create_msg(), parse_extract_edns(), parse_packet(), dns_msg::qinfo, module_qstate::region, regional_alloc(), dns_msg::rep, module_qstate::return_msg, module_env::scratch, sldns_buffer_set_position(), VERB_ALGO, verbose(), and verbosity.

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::addr.