aboutsummaryrefslogtreecommitdiff
path: root/contrib/python/ldns_packet.i
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2014-05-14 18:41:34 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2014-05-14 18:41:34 +0000
commit65be028f32ed37dce84f6328d4a7172132c8c224 (patch)
tree4edff3f361b23a13a9807a3a0906f9026c3a81a5 /contrib/python/ldns_packet.i
parent04f3ab9612d73d7516f230df46e860daf892dc71 (diff)
import ldns 1.6.17vendor/ldns/1.6.17
Notes
Notes: svn path=/vendor/ldns/dist/; revision=266072 svn path=/vendor/ldns/1.6.17/; revision=266073; tag=vendor/ldns/1.6.17
Diffstat (limited to 'contrib/python/ldns_packet.i')
-rw-r--r--contrib/python/ldns_packet.i1348
1 files changed, 925 insertions, 423 deletions
diff --git a/contrib/python/ldns_packet.i b/contrib/python/ldns_packet.i
index 9316479f13b3..eeff4aa2359a 100644
--- a/contrib/python/ldns_packet.i
+++ b/contrib/python/ldns_packet.i
@@ -14,8 +14,8 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the organization nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -28,17 +28,26 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- ******************************************************************************/
+ *****************************************************************************/
+
+
+/* ========================================================================= */
+/* SWIG setting and definitions. */
+/* ========================================================================= */
+
+/* Creates a temporary instance of (ldns_pkt *). */
%typemap(in,numinputs=0,noblock=1) (ldns_pkt **)
{
- ldns_pkt *$1_pkt;
- $1 = &$1_pkt;
+ ldns_pkt *$1_pkt;
+ $1 = &$1_pkt;
}
-/* result generation */
+/* Result generation, appends (ldns_pkt *) after the result. */
%typemap(argout,noblock=1) (ldns_pkt **)
{
- $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_pkt), SWIGTYPE_p_ldns_struct_pkt, SWIG_POINTER_OWN | 0 ));
+ $result = SWIG_Python_AppendOutput($result,
+ SWIG_NewPointerObj(SWIG_as_voidptr($1_pkt),
+ SWIGTYPE_p_ldns_struct_pkt, SWIG_POINTER_OWN | 0 ));
}
%newobject ldns_pkt_new;
@@ -49,83 +58,322 @@
%newobject ldns_update_pkt_new;
-%nodefaultctor ldns_struct_pkt; //no default constructor & destructor
-%nodefaultdtor ldns_struct_pkt;
+%nodefaultctor ldns_struct_pkt; /* No default constructor. */
+%nodefaultdtor ldns_struct_pkt; /* No default destructor. */
%rename(ldns_pkt) ldns_struct_pkt;
-#ifdef LDNS_DEBUG
-%rename(__ldns_pkt_free) ldns_pkt_free;
-%inline %{
-void _ldns_pkt_free (ldns_pkt* p) {
- printf("******** LDNS_PKT free 0x%lX ************\n", (long unsigned int)p);
- ldns_pkt_free(p);
-}
-%}
-#else
-%rename(_ldns_pkt_free) ldns_pkt_free;
-#endif
%newobject ldns_pkt2str;
%newobject ldns_pkt_opcode2str;
%newobject ldns_pkt_rcode2str;
%newobject ldns_pkt_algorithm2str;
%newobject ldns_pkt_cert_algorithm2str;
+%newobject ldns_pkt_get_section_clone;
-/* cloning of packet_lists to make them independent of the original packet */
+/* Clone data on pull. */
-%newobject _ldns_pkt_additional;
-%newobject _ldns_pkt_answer;
-%newobject _ldns_pkt_authority;
-%newobject _ldns_pkt_question;
+%newobject _ldns_pkt_additional;
%rename(__ldns_pkt_additional) ldns_pkt_additional;
-%inline %{
-ldns_rr_list* _ldns_pkt_additional(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_additional(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_additional(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_additional(p));
+ }
%}
+%newobject _ldns_pkt_answer;
%rename(__ldns_pkt_answer) ldns_pkt_answer;
-%inline %{
-ldns_rr_list* _ldns_pkt_answer(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_answer(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_answer(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_answer(p));
+ }
%}
+%newobject _ldns_pkt_answerfrom;
+%rename(__ldns_pkt_answerfrom) ldns_pkt_answerfrom;
+%inline
+%{
+ ldns_rdf * _ldns_pkt_answerfrom(ldns_pkt *p)
+ {
+ ldns_rdf *rdf;
+
+ rdf = ldns_pkt_answerfrom(p);
+ if (rdf != NULL) {
+ rdf = ldns_rdf_clone(rdf);
+ }
+ return rdf;
+ }
+%}
+
+%newobject _ldns_pkt_authority;
%rename(__ldns_pkt_authority) ldns_pkt_authority;
-%inline %{
-ldns_rr_list* _ldns_pkt_authority(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_authority(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_authority(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_authority(p));
+ }
+%}
+
+%newobject _ldns_pkt_edns_data;
+%rename(__ldns_pkt_edns_data) ldns_pkt_edns_data;
+%inline
+%{
+ ldns_rdf * _ldns_pkt_edns_data(ldns_pkt *p)
+ {
+ ldns_rdf *rdf;
+
+ rdf = ldns_pkt_edns_data(p);
+ if (rdf != NULL) {
+ rdf = ldns_rdf_clone(rdf);
+ }
+ return rdf;
+ }
%}
+%newobject _ldns_pkt_tsig;
+%rename(__ldns_pkt_tsig) ldns_pkt_tsig;
+%inline
+%{
+ ldns_rr * _ldns_pkt_tsig(const ldns_pkt *pkt)
+ {
+ return ldns_rr_clone(ldns_pkt_tsig(pkt));
+ }
+%}
+
+%newobject _ldns_pkt_question;
%rename(__ldns_pkt_question) ldns_pkt_question;
-%inline %{
-ldns_rr_list* _ldns_pkt_question(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_question(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_question(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_question(p));
+ }
%}
-/* clone data when pushed in */
+/* End of pull cloning. */
+
+/* Clone data on push. */
+
+%newobject _ldns_pkt_query_new;
+%rename(__ldns_pkt_query_new) ldns_pkt_query_new;
+%inline
+%{
+ ldns_pkt * _ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type,
+ ldns_rr_class rr_class, uint16_t flags)
+ {
+ return ldns_pkt_query_new(ldns_rdf_clone(rr_name), rr_type, rr_class,
+ flags);
+ }
+%}
%rename(__ldns_pkt_push_rr) ldns_pkt_push_rr;
-%inline %{
-bool _ldns_pkt_push_rr(ldns_pkt* p, ldns_pkt_section sec, ldns_rr *rr) {
- return ldns_pkt_push_rr(p, sec, ldns_rr_clone(rr));
-}
+%inline
+%{
+ bool _ldns_pkt_push_rr(ldns_pkt *p, ldns_pkt_section sec, ldns_rr *rr)
+ {
+ return ldns_pkt_push_rr(p, sec, ldns_rr_clone(rr));
+ }
+%}
+
+%rename(__ldns_pkt_safe_push_rr) ldns_pkt_safe_push_rr;
+%inline
+%{
+ bool _ldns_pkt_safe_push_rr(ldns_pkt *pkt, ldns_pkt_section sec,
+ ldns_rr *rr)
+ {
+ /* Prevents memory leaks when fails. */
+ ldns_rr *rr_clone = NULL;
+ bool ret;
+
+ if (rr != NULL) {
+ rr_clone = ldns_rr_clone(rr);
+ }
+ ret = ldns_pkt_safe_push_rr(pkt, sec, rr_clone);
+ if (!ret) {
+ ldns_rr_free(rr_clone);
+ }
+
+ return ret;
+ }
%}
%rename(__ldns_pkt_push_rr_list) ldns_pkt_push_rr_list;
-%inline %{
-bool _ldns_pkt_push_rr_list(ldns_pkt* p, ldns_pkt_section sec, ldns_rr_list *rrl) {
- return ldns_pkt_push_rr_list(p, sec, ldns_rr_list_clone(rrl));
-}
+%inline
+%{
+ bool _ldns_pkt_push_rr_list(ldns_pkt *p, ldns_pkt_section sec,
+ ldns_rr_list *rrl)
+ {
+ return ldns_pkt_push_rr_list(p, sec, ldns_rr_list_clone(rrl));
+ }
+%}
+
+%rename(__ldns_pkt_safe_push_rr_list) ldns_pkt_safe_push_rr_list;
+%inline
+%{
+ bool _ldns_pkt_safe_push_rr_list(ldns_pkt *p, ldns_pkt_section s,
+ ldns_rr_list *rrl)
+ {
+ /* Prevents memory leaks when fails. */
+ ldns_rr_list *rrl_clone = NULL;
+ bool ret;
+
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ ret = ldns_pkt_safe_push_rr_list(p, s, rrl_clone);
+ if (!ret) {
+ ldns_rr_list_free(rrl_clone);
+ }
+
+ return ret;
+ }
+%}
+
+%rename(__ldns_pkt_set_additional) ldns_pkt_set_additional;
+%inline
+%{
+ void _ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_additional(p, rrl_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_answer) ldns_pkt_set_answer;
+%inline
+%{
+ void _ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_answer(p, rrl_clone);
+ }
+%}
+
+%rename (__ldns_pkt_set_answerfrom) ldns_pkt_set_answerfrom;
+%inline
+%{
+ void _ldns_pkt_set_answerfrom(ldns_pkt *packet, ldns_rdf *rdf)
+ {
+ ldns_rdf *rdf_clone = NULL;
+ if (rdf != NULL) {
+ rdf_clone = ldns_rdf_clone(rdf);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_answerfrom(packet, rdf_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_authority) ldns_pkt_set_authority;
+%inline
+%{
+ void _ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_authority(p, rrl_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_edns_data) ldns_pkt_set_edns_data;
+%inline
+%{
+ void _ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *rdf)
+ {
+ ldns_rdf *rdf_clone = NULL;
+ if (rdf != NULL) {
+ rdf_clone = ldns_rdf_clone(rdf);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_edns_data(packet, rdf_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_question) ldns_pkt_set_question;
+%inline
+%{
+ void _ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_question(p, rrl_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_tsig) ldns_pkt_set_tsig;
+%inline
+%{
+ void _ldns_pkt_set_tsig(ldns_pkt *pkt, ldns_rr *rr)
+ {
+ ldns_rr *rr_clone = NULL;
+ if (rr != NULL) {
+ rr_clone = ldns_rr_clone(rr);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_tsig(pkt, rr_clone);
+ }
+%}
+
+/* End of push cloning. */
+
+
+/* ========================================================================= */
+/* Debugging related code. */
+/* ========================================================================= */
+
+#ifdef LDNS_DEBUG
+%rename(__ldns_pkt_free) ldns_pkt_free;
+%inline
+%{
+ /*!
+ * @brief Prints information about deallocated pkt and deallocates.
+ */
+ void _ldns_pkt_free (ldns_pkt* p) {
+ printf("******** LDNS_PKT free 0x%lX ************\n",
+ (long unsigned int) p);
+ ldns_pkt_free(p);
+ }
%}
+#else /* !LDNS_DEBUG */
+%rename(_ldns_pkt_free) ldns_pkt_free;
+#endif /* LDNS_DEBUG */
+
+
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
+
+/* None. */
+
+
+/* ========================================================================= */
+/* Encapsulating Python code. */
+/* ========================================================================= */
%feature("docstring") ldns_struct_pkt "LDNS packet object.
-The ldns_pkt object contains DNS packed (either a query or an answer). It is the complete representation of what you actually send to a nameserver, and what you get back (see :class:`ldns.ldns_resolver`).
+The :class:`ldns_pkt` object contains DNS packed (either a query or an answer).
+It is the complete representation of what you actually send to a name server,
+and what you get back (see :class:`ldns.ldns_resolver`).
**Usage**
@@ -148,40 +396,91 @@ nic.cz. 758 IN NS e.ns.nic.cz.
;; WHEN: Thu Jan 11 12:54:33 2009
;; MSG SIZE rcvd: 75
-This simple example instances a resolver in order to resolve NS for nic.cz.
-"
+This simple example instances a resolver in order to resolve NS for nic.cz."
%extend ldns_struct_pkt {
- %pythoncode %{
+ %pythoncode
+ %{
def __init__(self):
- raise Exception("This class can't be created directly. Please use: ldns_pkt_new(), ldns_pkt_query_new() or ldns_pkt_query_new_frm_str()")
+ """
+ Cannot be created directly from Python.
+ """
+ raise Exception("This class can't be created directly. " +
+ "Please use: ldns_pkt_new, ldns_pkt_query_new " +
+ "or ldns_pkt_query_new_frm_str")
__swig_destroy__ = _ldns._ldns_pkt_free
- #LDNS_PKT_CONSTRUCTORS_#
+ #
+ # LDNS_PKT_CONSTRUCTORS_
+ #
+
+ @staticmethod
+ def new():
+ """
+ Creates new empty packet structure.
+
+ :return: (:class:`ldns_pkt` ) New empty packet.
+ """
+ return _ldns.ldns_pkt_new()
+
@staticmethod
def new_query(rr_name, rr_type, rr_class, flags):
- """Creates a packet with a query in it for the given name, type and class.
-
- :param rr_name: the name to query for
- :param rr_type: the type to query for
- :param rr_class: the class to query for
- :param flags: packet flags
- :returns: new ldns_pkt object
"""
- return _ldns.ldns_pkt_query_new(rr_name, rr_type, rr_class, flags)
+ Creates a packet with a query in it for the given name,
+ type and class.
+
+ :param rr_name: The name to query for.
+ :type rr_name: :class:`ldns_dname`
+ :param rr_type: The type to query for.
+ :type rr_type: ldns_rr_type
+ :param rr_class: The class to query for.
+ :type rr_class: ldns_rr_class
+ :param flags: Packet flags.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_pkt`) New object.
+
+ .. note::
+ The type checking of parameter `rr_name` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ if (not isinstance(rr_name, ldns_dname)) and \
+ isinstance(rr_name, ldns_rdf) and \
+ rr_name.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_pkt.new_query() method will" +
+ " drop the possibility to accept ldns_rdf." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ if not isinstance(rr_name, ldns_rdf):
+ raise TypeError("Parameter must be derived from ldns_rdf.")
+ if (rr_name.get_type() != _ldns.LDNS_RDF_TYPE_DNAME):
+ raise Exception("Operands must be ldns_dname.")
+ return _ldns._ldns_pkt_query_new(rr_name, rr_type, rr_class, flags)
@staticmethod
def new_query_frm_str(rr_name, rr_type, rr_class, flags, raiseException = True):
- """Creates a query packet for the given name, type, class.
-
- :param rr_name: the name to query for
- :param rr_type: the type to query for
- :param rr_class: the class to query for
- :param flags: packet flags
- :param raiseException: if True, an exception occurs in case a resolver object can't be created
- :returns: query packet object or None. If the object can't be created and raiseException is True, an exception occurs.
+ """
+ Creates a query packet for the given name, type, class.
+
+ :param rr_name: The name to query for.
+ :type rr_name: str
+ :param rr_type: The type to query for.
+ :type rr_type: ldns_rr_type
+ :param rr_class: The class to query for.
+ :type rr_class: ldns_rr_class
+ :param flags: Packet flags.
+ :type flags: uint16_t
+ :param raiseException: If True, an exception occurs in case a
+ packet object can't be created.
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When raiseException set and packet couldn't
+ be created.
+ :return: (:class:`ldns_pkt`) Query packet object or None.
+ If the object can't be created and raiseException is True,
+ an exception occurs.
**Usage**
@@ -209,30 +508,57 @@ This simple example instances a resolver in order to resolve NS for nic.cz.
if (raiseException): raise Exception("Can't create query packet, error: %d" % status)
return None
return pkt
- #_LDNS_PKT_CONSTRUCTORS#
+
+ #
+ # _LDNS_PKT_CONSTRUCTORS
+ #
def __str__(self):
- """Converts the data in the DNS packet to presentation format"""
+ """
+ Converts the data in the DNS packet to presentation format.
+
+ :return: (str)
+ """
return _ldns.ldns_pkt2str(self)
def opcode2str(self):
- """Converts a packet opcode to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a packet opcode to its mnemonic and returns that as an
+ allocated null-terminated string.
+
+ :return: (str)
+ """
return _ldns.ldns_pkt_opcode2str(self.get_opcode())
def rcode2str(self):
- """Converts a packet rcode to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a packet rcode to its mnemonic and returns that as an
+ allocated null-terminated string.
+
+ :return: (str)
+ """
return _ldns.ldns_pkt_rcode2str(self.get_rcode())
- def print_to_file(self,output):
- """Prints the data in the DNS packet to the given file stream (in presentation format)."""
- _ldns.ldns_pkt_print(output,self)
+ def print_to_file(self, output):
+ """
+ Prints the data in the DNS packet to the given file stream
+ (in presentation format).
+
+ :param output: Opened file to write to.
+ :type output: file
+ :throws TypeError: When arguments of inappropriate types.
+ """
+ _ldns.ldns_pkt_print(output, self)
#parameters: FILE *,const ldns_pkt *,
def write_to_buffer(self, buffer):
- """Copies the packet data to the buffer in wire format.
+ """
+ Copies the packet data to the buffer in wire format.
- :param buffer: buffer to append the result to
- :returns: (ldns_status) ldns_status
+ :param buffer: Buffer to append the result to.
+ :type buffer: :class:`ldns_buffer`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) ldns_status
"""
return _ldns.ldns_pkt2buffer_wire(buffer, self)
#parameters: ldns_buffer *,const ldns_pkt *,
@@ -240,847 +566,1023 @@ This simple example instances a resolver in order to resolve NS for nic.cz.
@staticmethod
def algorithm2str(alg):
- """Converts a signing algorithms to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a signing algorithms to its mnemonic and returns that
+ as an allocated null-terminated string.
+
+ :param alg: The algorithm to convert to text.
+ :type alg: ldns_algorithm
+ :return: (str)
+ """
return _ldns.ldns_pkt_algorithm2str(alg)
#parameters: ldns_algorithm,
@staticmethod
def cert_algorithm2str(alg):
- """Converts a cert algorithm to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a cert algorithm to its mnemonic and returns that as an
+ allocated null-terminated string.
+
+ :param alg: Cert algorithm to convert to text.
+ :type alg: ldns_cert_algorithm
+ :return: (str)
+ """
return _ldns.ldns_pkt_cert_algorithm2str(alg)
#parameters: ldns_algorithm,
- #LDNS_PKT_METHODS_#
+ #
+ # LDNS_PKT_METHODS_
+ #
+
def aa(self):
- """Read the packet's aa bit.
+ """
+ Read the packet's aa bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_aa(self)
#parameters: const ldns_pkt *,
#retvals: bool
def ad(self):
- """Read the packet's ad bit.
+ """
+ Read the packet's ad bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_ad(self)
#parameters: const ldns_pkt *,
#retvals: bool
def additional(self):
- """Return the packet's additional section.
+ """
+ Return the packet's additional section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The additional section.
"""
return _ldns._ldns_pkt_additional(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def all(self):
+ """
+ Return the packet's question, answer, authority and additional
+ sections concatenated.
+
+ :return: (:class:`ldns_rr_list`) Concatenated sections.
+ """
return _ldns.ldns_pkt_all(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def all_noquestion(self):
+ """
+ Return the packet's answer, authority and additional sections
+ concatenated.
+ Like :meth:`all` but without the questions.
+
+ :return: (:class:`ldns_rr_list`) Concatenated sections except
+ questions.
+ """
return _ldns.ldns_pkt_all_noquestion(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def ancount(self):
- """Return the packet's an count.
+ """
+ Return the packet's an count.
- :returns: (uint16_t) the an count
+ :return: (int) The an count.
"""
return _ldns.ldns_pkt_ancount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def answer(self):
- """Return the packet's answer section.
+ """
+ Return the packet's answer section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The answer section.
"""
return _ldns._ldns_pkt_answer(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def answerfrom(self):
- """Return the packet's answerfrom.
+ """
+ Return the packet's answerfrom.
- :returns: (ldns_rdf \*) the name of the server
+ :return: (:class:`ldns_rdf`) The name of the server.
"""
- return _ldns.ldns_pkt_answerfrom(self)
+ return _ldns._ldns_pkt_answerfrom(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rdf *
def arcount(self):
- """Return the packet's ar count.
+ """
+ Return the packet's ar count.
- :returns: (uint16_t) the ar count
+ :return: (int) The ar count.
"""
return _ldns.ldns_pkt_arcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def authority(self):
- """Return the packet's authority section.
+ """
+ Return the packet's authority section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The authority section.
"""
return _ldns._ldns_pkt_authority(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def cd(self):
- """Read the packet's cd bit.
+ """
+ Read the packet's cd bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_cd(self)
#parameters: const ldns_pkt *,
#retvals: bool
def clone(self):
- """clones the given packet, creating a fully allocated copy
+ """
+ Clones the packet, creating a fully allocated copy.
- :returns: (ldns_pkt \*) ldns_pkt* pointer to the new packet
+ :return: (:class:`ldns_pkt`) New packet clone.
"""
return _ldns.ldns_pkt_clone(self)
#parameters: ldns_pkt *,
#retvals: ldns_pkt *
def edns(self):
- """returns true if this packet needs and EDNS rr to be sent.
+ """
+ Returns True if this packet needs and EDNS rr to be sent.
- At the moment the only reason is an expected packet size larger than 512 bytes, but for instance dnssec would be a good reason too.
+ At the moment the only reason is an expected packet size larger
+ than 512 bytes, but for instance DNSSEC would be a good reason
+ too.
- :returns: (bool) true if packet needs edns rr
+ :return: (bool) True if packet needs EDNS rr.
"""
return _ldns.ldns_pkt_edns(self)
#parameters: const ldns_pkt *,
#retvals: bool
def edns_data(self):
- """return the packet's edns data
+ """
+ Return the packet's edns data.
- :returns: (ldns_rdf \*) the data
+ :return: (:class:`ldns_rdf`) The ensd data.
"""
- return _ldns.ldns_pkt_edns_data(self)
+ return _ldns._ldns_pkt_edns_data(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rdf *
def edns_do(self):
- """return the packet's edns do bit
+ """
+ Return the packet's edns do bit
- :returns: (bool) the bit's value
+ :return: (bool) The bit's value.
"""
return _ldns.ldns_pkt_edns_do(self)
#parameters: const ldns_pkt *,
#retvals: bool
def edns_extended_rcode(self):
- """return the packet's edns extended rcode
+ """
+ Return the packet's edns extended rcode.
- :returns: (uint8_t) the rcode
+ :return: (uint8_t) The rcode.
"""
return _ldns.ldns_pkt_edns_extended_rcode(self)
#parameters: const ldns_pkt *,
#retvals: uint8_t
def edns_udp_size(self):
- """return the packet's edns udp size
+ """
+ Return the packet's edns udp size.
- :returns: (uint16_t) the size
+ :return: (uint16_t) The udp size.
"""
return _ldns.ldns_pkt_edns_udp_size(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def edns_version(self):
- """return the packet's edns version
+ """
+ Return the packet's edns version.
- :returns: (uint8_t) the version
+ :return: (uint8_t) The edns version.
"""
return _ldns.ldns_pkt_edns_version(self)
#parameters: const ldns_pkt *,
#retvals: uint8_t
def edns_z(self):
- """return the packet's edns z value
+ """
+ Return the packet's edns z value.
- :returns: (uint16_t) the z value
+ :return: (uint16_t) The z value.
"""
return _ldns.ldns_pkt_edns_z(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def empty(self):
- """check if a packet is empty
+ """
+ Check if a packet is empty.
- :returns: (bool) true: empty, false: empty
+ :return: (bool) True: empty, False: not empty
"""
return _ldns.ldns_pkt_empty(self)
#parameters: ldns_pkt *,
#retvals: bool
def get_opcode(self):
- """Read the packet's code.
+ """
+ Read the packet's code.
- :returns: (ldns_pkt_opcode) the opcode
+ :return: (ldns_pkt_opcode) the opcode
"""
return _ldns.ldns_pkt_get_opcode(self)
#parameters: const ldns_pkt *,
#retvals: ldns_pkt_opcode
def get_rcode(self):
- """Return the packet's respons code.
+ """
+ Return the packet's response code.
- :returns: (ldns_pkt_rcode) the respons code
+ :return: (ldns_pkt_rcode) The response code.
"""
return _ldns.ldns_pkt_get_rcode(self)
#parameters: const ldns_pkt *,
#retvals: ldns_pkt_rcode
- def get_section_clone(self,s):
- """return all the rr_list's in the packet.
-
- Clone the lists, instead of returning pointers.
+ def get_section_clone(self, s):
+ """
+ Return the selected rr_list's in the packet.
- :param s:
- what section(s) to return
- :returns: (ldns_rr_list \*) ldns_rr_list with the rr's or NULL if none were found
+ :param s: What section(s) to return.
+ :type s: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) RR list with the rr's or None
+ if none were found.
"""
- return _ldns.ldns_pkt_get_section_clone(self,s)
+ return _ldns.ldns_pkt_get_section_clone(self, s)
#parameters: const ldns_pkt *,ldns_pkt_section,
#retvals: ldns_rr_list *
def id(self):
- """Read the packet id.
+ """
+ Read the packet id.
- :returns: (uint16_t) the packet id
+ :return: (uint16_t) The packet id.
"""
return _ldns.ldns_pkt_id(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def nscount(self):
- """Return the packet's ns count.
+ """
+ Return the packet's ns count.
- :returns: (uint16_t) the ns count
+ :return: (uint16_t) The ns count.
"""
return _ldns.ldns_pkt_nscount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
- def push_rr(self,section,rr):
- """push an rr on a packet
+ def push_rr(self, section, rr):
+ """
+ Push an rr on a packet.
- :param section:
- where to put it
- :param rr:
- rr to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param section: Where to put it.
+ :type section: ldns_pkt_section
+ :param rr: RR to push.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the rr was added.
"""
return _ldns._ldns_pkt_push_rr(self,section,rr)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *,
#retvals: bool
- def push_rr_list(self,section,list):
- """push a rr_list on a packet
+ def push_rr_list(self, section, list):
+ """
+ Push a rr_list on a packet.
- :param section:
- where to put it
- :param list:
- the rr_list to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param section: Where to put it.
+ :type section: ldns_pkt_section
+ :param list: The rr_list to push.
+ :type list: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the rr was added.
"""
return _ldns._ldns_pkt_push_rr_list(self,section,list)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr_list *,
#retvals: bool
def qdcount(self):
- """Return the packet's qd count.
+ """
+ Return the packet's qd count.
- :returns: (uint16_t) the qd count
+ :return: (uint16_t) The qd count.
"""
return _ldns.ldns_pkt_qdcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def qr(self):
- """Read the packet's qr bit.
+ """
+ Read the packet's qr bit.
- :returns: (bool) value of the bit
+ :return: (bool) value of the bit
"""
return _ldns.ldns_pkt_qr(self)
#parameters: const ldns_pkt *,
#retvals: bool
def querytime(self):
- """Return the packet's querytime.
+ """
+ Return the packet's query time.
- :returns: (uint32_t) the querytime
+ :return: (uint32_t) The query time.
"""
return _ldns.ldns_pkt_querytime(self)
#parameters: const ldns_pkt *,
#retvals: uint32_t
def question(self):
- """Return the packet's question section.
+ """
+ Return the packet's question section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The question section.
"""
return _ldns._ldns_pkt_question(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def ra(self):
- """Read the packet's ra bit.
+ """
+ Read the packet's ra bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_ra(self)
#parameters: const ldns_pkt *,
#retvals: bool
def rd(self):
- """Read the packet's rd bit.
+ """
+ Read the packet's rd bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_rd(self)
#parameters: const ldns_pkt *,
#retvals: bool
def reply_type(self):
- """looks inside the packet to determine what kind of packet it is, AUTH, NXDOMAIN, REFERRAL, etc.
+ """
+ Looks inside the packet to determine what kind of packet it is,
+ AUTH, NXDOMAIN, REFERRAL, etc.
- :returns: (ldns_pkt_type) the type of packet
+ :return: (ldns_pkt_type) The type of packet.
"""
return _ldns.ldns_pkt_reply_type(self)
#parameters: ldns_pkt *,
#retvals: ldns_pkt_type
- def rr(self,sec,rr):
- """check to see if an rr exist in the packet
+ def rr(self, sec, rr):
+ """
+ Check to see if an rr exist in the packet.
- :param sec:
- in which section to look
- :param rr:
- the rr to look for
- :returns: (bool)
+ :param sec: In which section to look.
+ :type sec: ldns_pkt_section
+ :param rr: The rr to look for.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) Return True is exists.
"""
- return _ldns.ldns_pkt_rr(self,sec,rr)
+ return _ldns.ldns_pkt_rr(self, sec, rr)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *,
#retvals: bool
- def rr_list_by_name(self,r,s):
- """return all the rr with a specific name from a packet.
-
- Optionally specify from which section in the packet
+ def rr_list_by_name(self, r, s):
+ """
+ Return all the rr with a specific name from a packet.
- :param r:
- the name
- :param s:
- the packet's section
- :returns: (ldns_rr_list \*) a list with the rr's or NULL if none were found
+ :param r: The name.
+ :type r: :class:`ldns_rdf`
+ :param s: The packet's section.
+ :type s: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) A list with the rr's or None
+ if none were found.
"""
return _ldns.ldns_pkt_rr_list_by_name(self,r,s)
#parameters: ldns_pkt *,ldns_rdf *,ldns_pkt_section,
#retvals: ldns_rr_list *
- def rr_list_by_name_and_type(self,ownername,atype,sec):
- """return all the rr with a specific type and type from a packet.
-
- Optionally specify from which section in the packet
+ def rr_list_by_name_and_type(self, ownername, atype, sec):
+ """
+ Return all the rr with a specific type and type from a packet.
- :param ownername:
- the name
- :param atype:
- :param sec:
- the packet's section
- :returns: (ldns_rr_list \*) a list with the rr's or NULL if none were found
+ :param ownername: The name.
+ :type ownername: :class:`ldns_rdf`
+ :param atype: The type.
+ :type atype: ldns_rr_type
+ :param sec: The packet's section.
+ :type sec: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) A list with the rr's or None
+ if none were found.
"""
- return _ldns.ldns_pkt_rr_list_by_name_and_type(self,ownername,atype,sec)
+ return _ldns.ldns_pkt_rr_list_by_name_and_type(self, ownername, atype, sec)
#parameters: const ldns_pkt *,const ldns_rdf *,ldns_rr_type,ldns_pkt_section,
#retvals: ldns_rr_list *
- def rr_list_by_type(self,t,s):
- """return all the rr with a specific type from a packet.
-
- Optionally specify from which section in the packet
+ def rr_list_by_type(self, t, s):
+ """
+ Return all the rr with a specific type from a packet.
- :param t:
- the type
- :param s:
- the packet's section
- :returns: (ldns_rr_list \*) a list with the rr's or NULL if none were found
+ :param t: The type.
+ :type t: ldns_rr_type
+ :param s: The packet's section.
+ :type s: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) A list with the rr's or None
+ if none were found.
"""
- return _ldns.ldns_pkt_rr_list_by_type(self,t,s)
+ return _ldns.ldns_pkt_rr_list_by_type(self, t, s)
#parameters: const ldns_pkt *,ldns_rr_type,ldns_pkt_section,
#retvals: ldns_rr_list *
- def safe_push_rr(self,sec,rr):
- """push an rr on a packet, provided the RR is not there.
+ def safe_push_rr(self, sec, rr):
+ """
+ Push an rr on a packet, provided the RR is not there.
- :param sec:
- where to put it
- :param rr:
- rr to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param sec: Where to put it.
+ :type sec: ldns_pkt_section
+ :param rr: RR to push.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the rr was added.
"""
- return _ldns.ldns_pkt_safe_push_rr(self,sec,rr)
+ return _ldns._ldns_pkt_safe_push_rr(self,sec,rr)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *,
#retvals: bool
- def safe_push_rr_list(self,sec,list):
- """push an rr_list to a packet, provided the RRs are not already there.
+ def safe_push_rr_list(self, sec, list):
+ """
+ Push an rr_list to a packet, provided the RRs are not already
+ there.
- :param sec:
- where to put it
- :param list:
- the rr_list to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param sec: Where to put it.
+ :type sec: ldns_pkt_section
+ :param list: The rr_list to push.
+ :type list: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the list was added.
"""
- return _ldns.ldns_pkt_safe_push_rr_list(self,sec,list)
+ return _ldns._ldns_pkt_safe_push_rr_list(self, sec, list)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr_list *,
#retvals: bool
- def section_count(self,s):
- return _ldns.ldns_pkt_section_count(self,s)
- #parameters: const ldns_pkt *,ldns_pkt_section,
- #retvals: uint16_t
-
- def set_aa(self,b):
- """Set the packet's aa bit.
+ def set_aa(self, b):
+ """
+ Set the packet's aa bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_aa(self,b)
+ _ldns.ldns_pkt_set_aa(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_ad(self,b):
- """Set the packet's ad bit.
+ def set_ad(self, b):
+ """
+ Set the packet's ad bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_ad(self,b)
+ _ldns.ldns_pkt_set_ad(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_additional(self,rr):
- """directly set the additional section
+ def set_additional(self, rr):
+ """
+ Directly set the additional section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_additional(self,rr)
+ _ldns._ldns_pkt_set_additional(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_ancount(self,c):
- """Set the packet's an count.
+ def set_ancount(self, c):
+ """
+ Set the packet's an count.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_ancount(self,c)
+ _ldns.ldns_pkt_set_ancount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_answer(self,rr):
- """directly set the answer section
+ def set_answer(self, rr):
+ """
+ Directly set the answer section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_answer(self,rr)
+ _ldns._ldns_pkt_set_answer(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_answerfrom(self,r):
- """Set the packet's answering server.
+ def set_answerfrom(self, r):
+ """
+ Set the packet's answering server.
- :param r:
- the address
+ :param r: The address.
+ :type r: :class:`ldns_rdf`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_answerfrom(self,r)
+ _ldns._ldns_pkt_set_answerfrom(self, r)
#parameters: ldns_pkt *,ldns_rdf *,
#retvals:
- def set_arcount(self,c):
- """Set the packet's arcount.
+ def set_arcount(self, c):
+ """
+ Set the packet's arcount.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_pkt_set_arcount(self,c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_authority(self,rr):
- """directly set the auhority section
+ def set_authority(self, rr):
+ """
+ Directly set the authority section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_authority(self,rr)
+ _ldns._ldns_pkt_set_authority(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_cd(self,b):
- """Set the packet's cd bit.
+ def set_cd(self, b):
+ """
+ Set the packet's cd bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_cd(self,b)
+ _ldns.ldns_pkt_set_cd(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_edns_data(self,data):
- """Set the packet's edns data.
+ def set_edns_data(self, data):
+ """
+ Set the packet's edns data.
- :param data:
- the data
+ :param data: The data.
+ :type data: :class:`ldns_rdf`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_data(self,data)
+ _ldns._ldns_pkt_set_edns_data(self, data)
#parameters: ldns_pkt *,ldns_rdf *,
#retvals:
- def set_edns_do(self,value):
- """Set the packet's edns do bit.
+ def set_edns_do(self, value):
+ """
+ Set the packet's edns do bit.
- :param value:
- the bit's new value
+ :param value: The bit's new value.
+ :type value: bool
"""
- _ldns.ldns_pkt_set_edns_do(self,value)
+ _ldns.ldns_pkt_set_edns_do(self, value)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_edns_extended_rcode(self,c):
- """Set the packet's edns extended rcode.
+ def set_edns_extended_rcode(self, c):
+ """
+ Set the packet's edns extended rcode.
- :param c:
- the code
+ :param c: The code.
+ :type c: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_extended_rcode(self,c)
+ _ldns.ldns_pkt_set_edns_extended_rcode(self, c)
#parameters: ldns_pkt *,uint8_t,
#retvals:
- def set_edns_udp_size(self,s):
- """Set the packet's edns udp size.
+ def set_edns_udp_size(self, s):
+ """
+ Set the packet's edns udp size.
- :param s:
- the size
+ :param s: The size.
+ :type s: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_udp_size(self,s)
+ _ldns.ldns_pkt_set_edns_udp_size(self, s)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_edns_version(self,v):
- """Set the packet's edns version.
+ def set_edns_version(self, v):
+ """
+ Set the packet's edns version.
- :param v:
- the version
+ :param v: The version.
+ :type v: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_version(self,v)
+ _ldns.ldns_pkt_set_edns_version(self, v)
#parameters: ldns_pkt *,uint8_t,
#retvals:
- def set_edns_z(self,z):
- """Set the packet's edns z value.
+ def set_edns_z(self, z):
+ """
+ Set the packet's edns z value.
- :param z:
- the value
+ :param z: The value.
+ :type z: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_z(self,z)
+ _ldns.ldns_pkt_set_edns_z(self, z)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_flags(self,flags):
- """sets the flags in a packet.
+ def set_flags(self, flags):
+ """
+ Sets the flags in a packet.
- :param flags:
- ORed values: LDNS_QR| LDNS_AR for instance
- :returns: (bool) true on success otherwise false
+ :param flags: ORed values: LDNS_QR| LDNS_AR for instance.
+ :type flags: int
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns.ldns_pkt_set_flags(self,flags)
+ return _ldns.ldns_pkt_set_flags(self, flags)
#parameters: ldns_pkt *,uint16_t,
#retvals: bool
- def set_id(self,id):
- """Set the packet's id.
+ def set_id(self, id):
+ """
+ Set the packet's id.
- :param id:
- the id to set
+ :param id: The id to set.
+ :type id: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_id(self,id)
+ _ldns.ldns_pkt_set_id(self, id)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_nscount(self,c):
- """Set the packet's ns count.
+ def set_nscount(self, c):
+ """
+ Set the packet's ns count.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_nscount(self,c)
+ _ldns.ldns_pkt_set_nscount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_opcode(self,c):
- """Set the packet's opcode.
+ def set_opcode(self, c):
+ """
+ Set the packet's opcode.
- :param c:
- the opcode
+ :param c: The opcode.
+ :type c: ldns_pkt_opcode
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_opcode(self,c)
+ _ldns.ldns_pkt_set_opcode(self, c)
#parameters: ldns_pkt *,ldns_pkt_opcode,
#retvals:
- def set_qdcount(self,c):
- """Set the packet's qd count.
+ def set_qdcount(self, c):
+ """
+ Set the packet's qd count.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_qdcount(self,c)
+ _ldns.ldns_pkt_set_qdcount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_qr(self,b):
- """Set the packet's qr bit.
+ def set_qr(self, b):
+ """
+ Set the packet's qr bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_qr(self,b)
+ _ldns.ldns_pkt_set_qr(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_querytime(self,t):
- """Set the packet's query time.
+ def set_querytime(self, t):
+ """
+ Set the packet's query time.
- :param t:
- the querytime in msec
+ :param t: The query time in msec.
+ :type t: uint32_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_querytime(self,t)
+ _ldns.ldns_pkt_set_querytime(self, t)
#parameters: ldns_pkt *,uint32_t,
#retvals:
- def set_question(self,rr):
- """directly set the question section
+ def set_question(self, rr):
+ """
+ Directly set the question section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_question(self,rr)
+ _ldns._ldns_pkt_set_question(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_ra(self,b):
- """Set the packet's ra bit.
+ def set_ra(self, b):
+ """
+ Set the packet's ra bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_ra(self,b)
+ _ldns.ldns_pkt_set_ra(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
def set_random_id(self):
- """Set the packet's id to a random value.
+ """
+ Set the packet's id to a random value.
"""
_ldns.ldns_pkt_set_random_id(self)
#parameters: ldns_pkt *,
#retvals:
- def set_rcode(self,c):
- """Set the packet's respons code.
+ def set_rcode(self, c):
+ """
+ Set the packet's respons code.
- :param c:
- the rcode
+ :param c: The rcode.
+ :type c: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_rcode(self,c)
+ _ldns.ldns_pkt_set_rcode(self, c)
#parameters: ldns_pkt *,uint8_t,
#retvals:
- def set_rd(self,b):
- """Set the packet's rd bit.
+ def set_rd(self, b):
+ """
+ Set the packet's rd bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_rd(self,b)
+ _ldns.ldns_pkt_set_rd(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_section_count(self,s,x):
- """Set a packet's section count to x.
+ def set_section_count(self, s, x):
+ """
+ Set a packet's section count to x.
- :param s:
- the section
- :param x:
- the section count
+ :param s: The section.
+ :type s: ldns_pkt_section
+ :param x: The section count.
+ :type x: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_section_count(self,s,x)
+ _ldns.ldns_pkt_set_section_count(self, s, x)
#parameters: ldns_pkt *,ldns_pkt_section,uint16_t,
#retvals:
- def set_size(self,s):
- """Set the packet's size.
+ def set_size(self, s):
+ """
+ Set the packet's size.
- :param s:
- the size
+ :param s: The size.
+ :type s: int
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_pkt_set_size(self,s)
#parameters: ldns_pkt *,size_t,
#retvals:
- def set_tc(self,b):
- """Set the packet's tc bit.
+ def set_tc(self, b):
+ """
+ Set the packet's tc bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_tc(self,b)
+ _ldns.ldns_pkt_set_tc(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_timestamp(self,timeval):
- _ldns.ldns_pkt_set_timestamp(self,timeval)
+ def set_timestamp(self, timeval):
+ """
+ Set the packet's time stamp.
+
+ :param timestamp: The time stamp.
+ :type timestamp: struct timeval
+ :throws TypeError: When arguments of inappropriate types.
+ """
+ _ldns.ldns_pkt_set_timestamp(self, timeval)
#parameters: ldns_pkt *,struct timeval,
#retvals:
- def set_tsig(self,t):
- """Set the packet's tsig rr.
+ def set_tsig(self, t):
+ """
+ Set the packet's tsig rr.
- :param t:
- the tsig rr
+ :param t: The tsig rr.
+ :type t: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_tsig(self,t)
+ _ldns._ldns_pkt_set_tsig(self, t)
#parameters: ldns_pkt *,ldns_rr *,
#retvals:
def size(self):
- """Return the packet's size in bytes.
+ """
+ Return the packet's size in bytes.
- :returns: (size_t) the size
+ :return: (size_t) The size.
"""
return _ldns.ldns_pkt_size(self)
#parameters: const ldns_pkt *,
#retvals: size_t
def tc(self):
- """Read the packet's tc bit.
+ """
+ Read the packet's tc bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_tc(self)
#parameters: const ldns_pkt *,
#retvals: bool
def timestamp(self):
- """Return the packet's timestamp.
+ """
+ Return the packet's time stamp.
- :returns: (struct timeval) the timestamp
+ :return: (struct timeval) The time stamp.
"""
return _ldns.ldns_pkt_timestamp(self)
#parameters: const ldns_pkt *,
#retvals: struct timeval
def tsig(self):
- """Return the packet's tsig pseudo rr's.
+ """
+ Return the packet's tsig pseudo rr's.
- :returns: (ldns_rr \*) the tsig rr
+ :return: (:class:`ldns_rr`) The tsig rr.
"""
- return _ldns.ldns_pkt_tsig(self)
+ return _ldns._ldns_pkt_tsig(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr *
- #_LDNS_PKT_METHODS#
+ #
+ # _LDNS_PKT_METHODS#
+ #
+
+ #
+ # LDNS update methods
+ #
+
+ #
+ # LDNS_METHODS_
+ #
- #LDNS update methods
- #LDNS_METHODS_#
- def update_pkt_tsig_add(self,r):
- """add tsig credentials to a packet from a resolver
+ def update_ad(self):
+ """
+ Get the ad count.
+
+ :return: (uint16_t) The ad count.
+ """
+ return _ldns.ldns_update_ad(self)
+ #parameters: ldns_pkt *
+ #retvals: uint16_t
+
+ def update_pkt_tsig_add(self, r):
+ """
+ Add tsig credentials to a packet from a resolver.
- :param r:
- resolver to copy from
- :returns: (ldns_status) status wether successfull or not
+ :param r: Resolver to copy from.
+ :type r: :class:`ldns_resolver`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) Status whether successful or not.
"""
- return _ldns.ldns_update_pkt_tsig_add(self,r)
+ return _ldns.ldns_update_pkt_tsig_add(self, r)
#parameters: ldns_pkt *,ldns_resolver *,
#retvals: ldns_status
def update_prcount(self):
- """Get the zo count.
+ """
+ Get the pr count.
- :returns: (uint16_t) the pr count
+ :return: (uint16_t) The pr count.
"""
return _ldns.ldns_update_prcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
- def update_set_adcount(self,c):
- """Set the ad count.
+ def update_set_adcount(self, c):
+ """
+ Set the ad count.
- :param c:
- the ad count to set
+ :param c: The ad count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_update_set_adcount(self,c)
+ _ldns.ldns_update_set_adcount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def update_set_prcount(self,c):
- """Set the pr count.
+ def update_set_prcount(self, c):
+ """
+ Set the pr count.
- :param c:
- the pr count to set
+ :param c: The pr count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_update_set_prcount(self,c)
+ _ldns.ldns_update_set_prcount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def update_set_upcount(self,c):
- """Set the up count.
+ def update_set_upcount(self, c):
+ """
+ Set the up count.
- :param c:
- the up count to set
+ :param c: The up count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_update_set_upcount(self,c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def update_set_zo(self,v):
- _ldns.ldns_update_set_zo(self,v)
+ def update_set_zo(self, c):
+ """
+ Set the zo count.
+
+ :param c: The zo count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ """
+ _ldns.ldns_update_set_zo(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
def update_upcount(self):
- """Get the zo count.
+ """
+ Get the up count.
- :returns: (uint16_t) the up count
+ :return: (uint16_t) The up count.
"""
return _ldns.ldns_update_upcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def update_zocount(self):
- """Get the zo count.
+ """
+ Get the zo count.
- :returns: (uint16_t) the zo count
+ :return: (uint16_t) The zo count.
"""
return _ldns.ldns_update_zocount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
- #_LDNS_METHODS#
- %}
+ #
+ # _LDNS_METHODS
+ #
+ %}
}