]>
git.saurik.com Git - apple/network_cmds.git/blob - unbound/pythonmod/pythonmod_utils.h
a901f391a460b98849b8043517d76f6f795e43da
2 * pythonmod_utils.h: utils header file
4 * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
5 * Marek Vavrusa (xvavru00 AT stud.fit.vutbr.cz)
7 * This software is open source.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * * Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
20 * * Neither the name of the organization nor the names of its
21 * contributors may be used to endorse or promote products derived from this
22 * software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
38 * Utility functions for the python module that perform stores and loads and
41 #ifndef PYTHONMOD_UTILS_H
42 #define PYTHONMOD_UTILS_H
44 #include "util/module.h"
47 * Store the reply_info and query_info pair in message cache (qstate->msg_cache)
49 * @param qstate: module environment
50 * @param qinfo: query info, the query for which answer is stored.
51 * @param msgrep: reply in dns_msg
52 * @param is_referral: If true, then the given message to be stored is a
53 * referral. The cache implementation may use this as a hint.
54 * It will store only the RRsets, not the message.
55 * @return 0 on alloc error (out of memory).
57 int storeQueryInCache(struct module_qstate
* qstate
, struct query_info
* qinfo
, struct reply_info
* msgrep
, int is_referral
);
61 * Invalidate the message associated with query_info stored in message cache.
63 * This function invalidates the record in message cache associated with the given query only if such a record exists.
65 * @param qstate: module environment
66 * @param qinfo: query info, the query for which answer is stored.
68 void invalidateQueryInCache(struct module_qstate
* qstate
, struct query_info
* qinfo
);
71 * Create response according to the ldns packet content
73 * This function fills qstate.return_msg up with data of a given packet
75 * @param qstate: module environment
76 * @param pkt: a sldns_buffer which contains sldns_packet data
77 * @return 0 on failure, out of memory or parse error.
79 int createResponse(struct module_qstate
* qstate
, sldns_buffer
* pkt
);
82 * Convert reply->addr to string
83 * @param reply: comm reply with address in it.
84 * @param dest: destination string.
85 * @param maxlen: length of string buffer.
87 void reply_addr2str(struct comm_reply
* reply
, char* dest
, int maxlen
);
89 #endif /* PYTHONMOD_UTILS_H */