unbound: pythonmod/pythonmod_utils.h File Reference

unbound 0.1

Functions
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).
void | invalidateQueryInCache (struct module_qstate *qstate, struct query_info *qinfo)
| Invalidate the message associated with query_info stored in message cache.
int | createResponse (struct module_qstate *qstate, struct sldns_buffer *pkt)
| Create response according to the ldns packet content.
void | reply_addr2str (struct comm_reply *reply, char *dest, int maxlen)
| Convert reply->addr to string.
void | delegpt_addr_addr2str (struct delegpt_addr *target, char *dest, int maxlen)
| Convert target->addr to string.

## 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

  qstate | module environment
  qinfo | query info, the query for which answer is stored.
  msgrep | reply in dns_msg
  is_referral | If 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::is_valrec, 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

  qstate | module environment
  qinfo | query 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(), packed_rrset_data::ttl, and reply_info::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

  qstate | module environment
  pkt | a sldns_buffer which contains sldns_packet data

Returns
  0 on failure, out of memory or parse error.

References BIT_CD, module_qstate::env, msg_parse::flags, log_dns_msg(), log_err(), parse_create_msg(), parse_extract_edns_from_response_msg(), 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.

## ◆ reply_addr2str()

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

Convert reply->addr to string.

Parameters

  reply | comm reply with address in it.
  dest | destination string.
  maxlen | length 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

  target | delegpt_addr with address in it.
  dest | destination string.
  maxlen | length of string buffer.

References delegpt_addr::addr.