* 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
* 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.
- ******************************************************************************/
+ *****************************************************************************/
-%typemap(in,numinputs=0,noblock=1) (ldns_rr **)
+
+/* ========================================================================= */
+/* SWIG setting and definitions. */
+/* ========================================================================= */
+
+/* Creates a temporary instance of (ldns_rr *). */
+%typemap(in, numinputs=0, noblock=1) (ldns_rr **)
{
- ldns_rr *$1_rr;
- $1 = &$1_rr;
+ ldns_rr *$1_rr;
+ $1 = &$1_rr;
}
-/* result generation */
-%typemap(argout,noblock=1) (ldns_rr **)
+/* Result generation, appends (ldns_rr *) after the result. */
+%typemap(argout, noblock=1) (ldns_rr **)
{
- $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_rr), SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ));
+ $result = SWIG_Python_AppendOutput($result,
+ SWIG_NewPointerObj(SWIG_as_voidptr($1_rr),
+ SWIGTYPE_p_ldns_struct_rr, SWIG_POINTER_OWN | 0 ));
}
-%nodefaultctor ldns_struct_rr; //no default constructor & destructor
-%nodefaultdtor ldns_struct_rr;
+%nodefaultctor ldns_struct_rr; /* No default constructor. */
+%nodefaultdtor ldns_struct_rr; /* No default destructor. */
%ignore ldns_struct_rr::_rdata_fields;
%newobject ldns_rr_clone;
%newobject ldns_rr_new;
+%newobject ldns_rr_new_frm_type;
%newobject ldns_rr_pop_rdf;
%delobject ldns_rr_free;
%rename(ldns_rr) ldns_struct_rr;
-#ifdef LDNS_DEBUG
-%rename(__ldns_rr_free) ldns_rr_free;
-%inline %{
-void _ldns_rr_free (ldns_rr* r) {
- printf("******** LDNS_RR free 0x%lX ************\n", (long unsigned int)r);
- ldns_rr_free(r);
-}
-%}
-#else
-%rename(_ldns_rr_free) ldns_rr_free;
-#endif
-
%newobject ldns_rr2str;
%newobject ldns_rr_type2str;
%newobject ldns_rr_class2str;
%newobject ldns_read_anchor_file;
-// clone rdf data on pull
+/* Clone rdf data on pull. */
+
+/* Clone will fail with NULL argument. */
%newobject _ldns_rr_rdf;
%rename(__ldns_rr_rdf) ldns_rr_rdf;
-%inline %{
-ldns_rdf* _ldns_rr_rdf(ldns_rr* rr, size_t i) {
- return ldns_rdf_clone(ldns_rr_rdf(rr, i));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rdf(ldns_rr *rr, size_t i)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rdf(rr, i);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_algorithm;
%rename(__ldns_rr_rrsig_algorithm) ldns_rr_rrsig_algorithm;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_algorithm(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_algorithm(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_algorithm(ldns_rr *rr) {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_algorithm(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_dnskey_algorithm;
%rename(__ldns_rr_dnskey_algorithm) ldns_rr_dnskey_algorithm;
-%inline %{
-ldns_rdf* _ldns_rr_dnskey_algorithm(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_dnskey_algorithm(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_dnskey_algorithm(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_dnskey_algorithm(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_dnskey_flags;
%rename(__ldns_rr_dnskey_flags) ldns_rr_dnskey_flags;
-%inline %{
-ldns_rdf* _ldns_rr_dnskey_flags(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_dnskey_flags(rr));
-}
+%inline
+ %{
+ ldns_rdf * _ldns_rr_dnskey_flags(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_dnskey_flags(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_dnskey_key;
%rename(__ldns_rr_dnskey_key) ldns_rr_dnskey_key;
-%inline %{
-ldns_rdf* _ldns_rr_dnskey_key(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_dnskey_key(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_dnskey_key(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_dnskey_key(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_dnskey_protocol;
%rename(__ldns_rr_dnskey_protocol) ldns_rr_dnskey_protocol;
-%inline %{
-ldns_rdf* _ldns_rr_dnskey_protocol(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_dnskey_protocol(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_dnskey_protocol(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_dnskey_protocol(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_owner;
%rename(__ldns_rr_owner) ldns_rr_owner;
-%inline %{
-ldns_rdf* _ldns_rr_owner(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_owner(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_owner(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_owner(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_a_address;
%rename(__ldns_rr_a_address) ldns_rr_a_address;
-%inline %{
-ldns_rdf* _ldns_rr_a_address(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_a_address(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_a_address(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_a_address(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_mx_exchange;
%rename(__ldns_rr_mx_exchange) ldns_rr_mx_exchange;
-%inline %{
-ldns_rdf* _ldns_rr_mx_exchange(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_mx_exchange(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_mx_exchange(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_mx_exchange(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_mx_preference;
%rename(__ldns_rr_mx_preference) ldns_rr_mx_preference;
-%inline %{
-ldns_rdf* _ldns_rr_mx_preference(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_mx_preference(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_mx_preference(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_mx_preference(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_ns_nsdname;
%rename(__ldns_rr_ns_nsdname) ldns_rr_ns_nsdname;
-%inline %{
-ldns_rdf* _ldns_rr_ns_nsdname(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_ns_nsdname(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_ns_nsdname(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_ns_nsdname(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_expiration;
%rename(__ldns_rr_rrsig_expiration) ldns_rr_rrsig_expiration;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_expiration(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_expiration(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_expiration(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_expiration(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_inception;
%rename(__ldns_rr_rrsig_inception) ldns_rr_rrsig_inception;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_inception(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_inception(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_inception(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_inception(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_keytag;
%rename(__ldns_rr_rrsig_keytag) ldns_rr_rrsig_keytag;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_keytag(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_keytag(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_keytag(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_keytag(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_labels;
%rename(__ldns_rr_rrsig_labels) ldns_rr_rrsig_labels;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_labels(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_labels(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_labels(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_labels(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_origttl;
%rename(__ldns_rr_rrsig_origttl) ldns_rr_rrsig_origttl;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_origttl(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_origttl(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_origttl(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_origttl(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_sig;
%rename(__ldns_rr_rrsig_sig) ldns_rr_rrsig_sig;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_sig(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_sig(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_sig(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_sig(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_signame;
%rename(__ldns_rr_rrsig_signame) ldns_rr_rrsig_signame;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_signame(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_signame(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_signame(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_signame(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
%newobject _ldns_rr_rrsig_typecovered;
%rename(__ldns_rr_rrsig_typecovered) ldns_rr_rrsig_typecovered;
-%inline %{
-ldns_rdf* _ldns_rr_rrsig_typecovered(ldns_rr* rr) {
- return ldns_rdf_clone(ldns_rr_rrsig_typecovered(rr));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_rrsig_typecovered(ldns_rr *rr)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_rrsig_typecovered(rr);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
-// end of pull cloning
+/* End of pull cloning. */
-// clone rdf data on push
+/* Clone rdf data on push. */
%rename(__ldns_rr_a_set_address) ldns_rr_a_set_address;
-%inline %{
-bool _ldns_rr_a_set_address(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_a_set_address(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_a_set_address(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_a_set_address(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_dnskey_set_algorithm) ldns_rr_dnskey_set_algorithm;
-%inline %{
-bool _ldns_rr_dnskey_set_algorithm(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_dnskey_set_algorithm(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_dnskey_set_algorithm(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_dnskey_set_algorithm(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_dnskey_set_flags) ldns_rr_dnskey_set_flags;
-%inline %{
-bool _ldns_rr_dnskey_set_flags(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_dnskey_set_flags(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_dnskey_set_flags(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_dnskey_set_flags(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_dnskey_set_key) ldns_rr_dnskey_set_key;
-%inline %{
-bool _ldns_rr_dnskey_set_key(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_dnskey_set_key(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_dnskey_set_key(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_dnskey_set_key(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_dnskey_set_protocol) ldns_rr_dnskey_set_protocol;
-%inline %{
-bool _ldns_rr_dnskey_set_protocol(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_dnskey_set_protocol(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_dnskey_set_protocol(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_dnskey_set_protocol(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_push_rdf) ldns_rr_push_rdf;
-%inline %{
-bool _ldns_rr_push_rdf(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_push_rdf(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_push_rdf(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_push_rdf(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_algorithm) ldns_rr_rrsig_set_algorithm;
-%inline %{
-bool _ldns_rr_rrsig_set_algorithm(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_algorithm(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_algorithm(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_algorithm(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_expiration) ldns_rr_rrsig_set_expiration;
-%inline %{
-bool _ldns_rr_rrsig_set_expiration(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_expiration(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_expiration(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_expiration(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_inception) ldns_rr_rrsig_set_inception;
-%inline %{
-bool _ldns_rr_rrsig_set_inception(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_inception(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_inception(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_inception(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_keytag) ldns_rr_rrsig_set_keytag;
-%inline %{
-bool _ldns_rr_rrsig_set_keytag(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_keytag(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_keytag(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_keytag(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_labels) ldns_rr_rrsig_set_labels;
-%inline %{
-bool _ldns_rr_rrsig_set_labels(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_labels(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_labels(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_labels(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_origttl) ldns_rr_rrsig_set_origttl;
-%inline %{
-bool _ldns_rr_rrsig_set_origttl(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_origttl(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_origttl(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_origttl(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_sig) ldns_rr_rrsig_set_sig;
-%inline %{
-bool _ldns_rr_rrsig_set_sig(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_sig(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_sig(ldns_rr *rr, ldns_rdf *rdf) {
+ return ldns_rr_rrsig_set_sig(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_signame) ldns_rr_rrsig_set_signame;
-%inline %{
-bool _ldns_rr_rrsig_set_signame(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_signame(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_signame(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_signame(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_rrsig_set_typecovered) ldns_rr_rrsig_set_typecovered;
-%inline %{
-bool _ldns_rr_rrsig_set_typecovered(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_rrsig_set_typecovered(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ bool _ldns_rr_rrsig_set_typecovered(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_rrsig_set_typecovered(rr, ldns_rdf_clone(rdf));
+ }
%}
%rename(__ldns_rr_set_owner) ldns_rr_set_owner;
-%inline %{
-void _ldns_rr_set_owner(ldns_rr* rr, ldns_rdf* rdf) {
- return ldns_rr_set_owner(rr, ldns_rdf_clone(rdf));
-}
+%inline
+%{
+ void _ldns_rr_set_owner(ldns_rr *rr, ldns_rdf *rdf)
+ {
+ return ldns_rr_set_owner(rr, ldns_rdf_clone(rdf));
+ }
%}
+%newobject _ldns_rr_set_rdf;
%rename(__ldns_rr_set_rdf) ldns_rr_set_rdf;
-%inline %{
- ldns_rdf* _ldns_rr_set_rdf(ldns_rr* rr, ldns_rdf* rdf, size_t pos) {
- return ldns_rr_set_rdf(rr, ldns_rdf_clone(rdf), pos);
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_set_rdf(ldns_rr *rr, ldns_rdf *rdf, size_t pos)
+ {
+ /* May leak memory on unsuccessful calls. */
+ ldns_rdf *new, *ret;
+
+ new = ldns_rdf_clone(rdf);
+
+ if ((ret = ldns_rr_set_rdf(rr, new, pos)) == NULL) {
+ ldns_rdf_deep_free(new);
+ }
+
+ return ret;
+ }
%}
-// end of push cloning
+/* End of push cloning. */
%rename(_ldns_rr_new_frm_str) ldns_rr_new_frm_str;
%rename(_ldns_rr_new_frm_fp_l) ldns_rr_new_frm_fp_l;
%rename(_ldns_rr_new_frm_fp) ldns_rr_new_frm_fp;
-%feature("docstring") ldns_struct_rr "Resource Record (RR)
-The RR is the basic DNS element that contains actual data. This class allows to create RR and manipulate with the content."
+/* ========================================================================= */
+/* Debugging related code. */
+/* ========================================================================= */
+
+
+#ifdef LDNS_DEBUG
+%rename(__ldns_rr_free) ldns_rr_free;
+%inline %{
+ void _ldns_rr_free (ldns_rr *r)
+ {
+ printf("******** LDNS_RR free 0x%lX ************\n", (long unsigned int)r);
+ ldns_rr_free(r);
+ }
+%}
+#else /* !LDNS_DEBUG */
+%rename(_ldns_rr_free) ldns_rr_free;
+#endif /* LDNS_DEBUG */
+
+
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
+
+/* None. */
+
+
+/* ========================================================================= */
+/* Encapsulating Python code. */
+/* ========================================================================= */
+
+
+%feature("docstring") ldns_struct_rr "Resource Record (RR).
+
+The RR is the basic DNS element that contains actual data. This class allows
+to create RR and manipulate with the content.
+
+Use :meth:`ldns_rr_new`, :meth:`ldns_rr_new_frm_type`, :meth:`new_frm_fp`,
+:meth:`new_frm_fp_l`, :meth:`new_frm_str` or :meth:`new_question_frm_str`
+to create :class:`ldns_rr` instances.
+"
%extend ldns_struct_rr {
- %pythoncode %{
+ %pythoncode
+ %{
def __init__(self):
- raise Exception("This class can't be created directly. Please use: ldns_rr_new, ldns_rr_new_frm_type, new_frm_fp(), new_frm_fp_l(), new_frm_str() or new_question_frm_str")
+ raise Exception("This class can't be created directly. " +
+ "Please use: ldns_rr_new(), ldns_rr_new_frm_type(), " +
+ "new_frm_fp(), new_frm_fp_l(), new_frm_str() or " +
+ "new_question_frm_str()")
__swig_destroy__ = _ldns._ldns_rr_free
- #LDNS_RR_CONSTRUCTORS_#
+ #
+ # LDNS_RR_CONSTRUCTORS_
+ #
+
@staticmethod
- def new_frm_str(str, default_ttl=0, origin=None, prev=None, raiseException=True):
- """Creates an rr object from a string.
-
- The string should be a fully filled-in rr, like ownername [space] TTL [space] CLASS [space] TYPE [space] RDATA.
-
- :param str: the string to convert
- :param default_ttl: default ttl value for the rr. If 0 DEF_TTL will be used
- :param origin: when the owner is relative add this
- :param prev: the previous ownername
- :param raiseException: if True, an exception occurs in case a rr instance can't be created
- :returns:
- * rr - (ldnsrr) RR instance or None. If the object can't be created and raiseException is True, an exception occurs.
+ def new_frm_str(string, default_ttl=0, origin=None, prev=None, raiseException=True):
+ """
+ Creates an rr object from a string.
+
+ The string should be a fully filled-in rr, like "owner_name
+ [space] TTL [space] CLASS [space] TYPE [space] RDATA."
+
+ :param string: The string to convert.
+ :type string: str
+ :param default_ttl: Default ttl value for the rr.
+ If 0 DEF_TTL will be used.
+ :type default_ttl: int
+ :param origin: When the owner is relative add this.
+ :type origin: :class:`ldns_dname`
+ :param prev: The previous owner name.
+ :type prev: :class:`ldns_rdf`
+ :param raiseException: If True, an exception occurs in case a rr
+ instance can't be created.
+ :throws Exception: If `raiseExceprion` is set and fails.
+ :throws TypeError: When parameters of incorrect types.
+ :return: (:class:`ldns_rr`) RR instance or None.
+
+ .. note::
+ The type checking of `origin` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
**Usage**
>>> import ldns
- >>> rr = ldns.ldns_rr.new_frm_str("www.nic.cz. IN A 192.168.1.1",300)
+ >>> rr = ldns.ldns_rr.new_frm_str("www.nic.cz. IN A 192.168.1.1", 300)
>>> print rr
www.nic.cz. 300 IN A 192.168.1.1
- """
- status, rr, prev = _ldns.ldns_rr_new_frm_str_(str, default_ttl, origin, prev)
+ >>> rr = ldns.ldns_rr.new_frm_str("test.nic.cz. 600 IN A 192.168.1.2")
+ >>> print rr
+ test.nic.cz. 600 IN A 192.168.1.2
+
+ """
+ if (not isinstance(origin, ldns_dname)) and \
+ isinstance(origin, ldns_rdf) and \
+ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_rr.new_frm_str() method will" +
+ " drop the possibility to accept ldns_rdf as origin." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ status, rr, prev = _ldns.ldns_rr_new_frm_str_(string, default_ttl,
+ origin, prev)
if status != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create RR, error: %d" % status)
+ if (raiseException):
+ raise Exception("Can't create RR, error: %d" % status)
return None
return rr
@staticmethod
- def new_question_frm_str(str, default_ttl=0, origin=None, prev=None, raiseException=True):
- """Creates an rr object from a string.
-
- The string is like new_frm_str but without rdata.
-
- :param str: the string to convert
- :param origin: when the owner is relative add this
- :param prev: the previous ownername
- :param raiseException: if True, an exception occurs in case a rr instance can't be created
- :returns:
- * rr - (ldnsrr) RR instance or None. If the object can't be created and raiseException is True, an exception occurs.
- """
- status, rr, prev = _ldns.ldns_rr_new_question_frm_str_(str, origin, prev)
+ def new_question_frm_str(string, default_ttl=0, origin=None, prev=None, raiseException=True):
+ """
+ Creates an rr object from a string.
+
+ The string is like :meth:`new_frm_str` but without rdata.
+
+ :param string: The string to convert.
+ :type string: str
+ :param origin: When the owner is relative add this.
+ :type origin: :class:`ldns_dname`
+ :param prev: The previous owner name.
+ :type prev: :class:`ldns_rdf`
+ :param raiseException: If True, an exception occurs in case
+ a rr instance can't be created.
+ :throws Exception: If `raiseExceprion` is set and fails.
+ :throws TypeError: When parameters of incorrect types.
+ :return: (:class:`ldns_rr`) RR instance or None. If the object
+ can't be created and `raiseException` is True,
+ an exception occurs.
+
+ .. note::
+ The type checking of `origin` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ if (not isinstance(origin, ldns_dname)) and \
+ isinstance(origin, ldns_rdf) and \
+ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_rr.new_question_frm_str() method will" +
+ " drop the possibility to accept ldns_rdf as origin." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ status, rr, prev = _ldns.ldns_rr_new_question_frm_str_(string,
+ origin, prev)
if status != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create RR, error: %d" % status)
+ if (raiseException):
+ raise Exception("Can't create RR, error: %d" % status)
return None
return rr
@staticmethod
- def new_frm_str_prev(str, default_ttl=0, origin=None, prev=None, raiseException=True):
- """Creates an rr object from a string.
-
- The string should be a fully filled-in rr, like ownername [space] TTL [space] CLASS [space] TYPE [space] RDATA.
-
- :param str: the string to convert
- :param default_ttl: default ttl value for the rr. If 0 DEF_TTL will be used
- :param origin: when the owner is relative add this
- :param prev: the previous ownername
- :param raiseException: if True, an exception occurs in case a rr instance can't be created
- :returns:
- * rr - (ldnsrr) RR instance or None. If the object can't be created and raiseException is True, an exception occurs.
+ def new_frm_str_prev(string, default_ttl=0, origin=None, prev=None, raiseException=True):
+ """
+ Creates an rr object from a string.
+
+ The string should be a fully filled-in rr, like "owner_name
+ [space] TTL [space] CLASS [space] TYPE [space] RDATA".
+
+ :param string: The string to convert.
+ :type string: str
+ :param default_ttl: Default ttl value for the rr.
+ If 0 DEF_TTL will be used.
+ :type default_ttl: int
+ :param origin: When the owner is relative add this.
+ :type origin: :class:`ldns_dname`
+ :param prev: The previous owner name.
+ :type prev: :class:`ldns_rdf`
+ :param raiseException: If True, an exception occurs in case when
+ a rr instance can't be created.
+ :throws Exception: If `raiseExceprion` is set and fails.
+ :throws TypeError: When parameters of incorrect types.
+ :return: None when fails, otherwise a tuple containing:
+
+ * rr - (:class:`ldns_rr`) RR instance or None.
+ If the object can't be created and `raiseException`
+ is True, an exception occurs.
- * prev - (ldns_rdf) ownername found in this string or None
- """
- status, rr, prev = _ldns.ldns_rr_new_frm_str_(str, default_ttl, origin, prev)
+ * prev - (:class:`ldns_rdf`) Owner name found in this string
+ or None.
+
+ .. note::
+ The type checking of `origin` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ if (not isinstance(origin, ldns_dname)) and \
+ isinstance(origin, ldns_rdf) and \
+ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_rr.new_frm_str_prev() method will" +
+ " drop the possibility to accept ldns_rdf as origin." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ status, rr, prev = _ldns.ldns_rr_new_frm_str_(string, default_ttl,
+ origin, prev)
if status != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create RR, error: %d" % status)
+ if (raiseException):
+ raise Exception("Can't create RR, error: %d" % status)
return None
return rr, prev
@staticmethod
def new_frm_fp(file, default_ttl=0, origin=None, prev=None, raiseException=True):
- """Creates a new rr from a file containing a string.
-
- :param file: file pointer
- :param default_ttl: If 0 DEF_TTL will be used
- :param origin: when the owner is relative add this.
- :param prev: when the owner is whitespaces use this.
- :param raiseException: if True, an exception occurs in case a resolver object can't be created
- :returns:
- * rr - (ldns_rr) RR object or None. If the object can't be created and raiseException is True, an exception occurs.
-
- * ttl - (int) None or TTL if the file contains a $TTL directive
-
- * origin - (ldns_rdf) None or dname if the file contains a $ORIGIN directive
-
- * prev - (ldns_rdf) None or updated value of prev parameter
"""
+ Creates a new rr from a file containing a string.
+
+ :param file: Opened file.
+ :param default_ttl: If 0 DEF_TTL will be used.
+ :type default_ttl: int
+ :param origin: When the owner is relative add this.
+ :type origin: :class:`ldns_dname`
+ :param prev: When the owner is white spaces use this.
+ :type prev: :class:`ldns_rdf`
+ :param raiseException: If True, an exception occurs in case
+ a resolver object can't be created.
+ :throws Exception: If `raiseException` is set and the input
+ cannot be read.
+ :throws TypeError: When parameters of incorrect types.
+ :return: None when fails, otherwise a tuple containing:
+
+ * rr - (:class:`ldns_rr`) RR object or None. If the object
+ can't be created and `raiseException` is True,
+ an exception occurs.
+
+ * ttl - (int) None or TTL if the file contains a TTL
+ directive.
+
+ * origin - (:class:`ldns_rdf`) None or dname rdf if the file
+ contains a ORIGIN directive.
+
+ * prev - (:class:`ldns_rdf`) None or updated value
+ of prev parameter.
+
+ .. note::
+ The type checking of `origin` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ if (not isinstance(origin, ldns_dname)) and \
+ isinstance(origin, ldns_rdf) and \
+ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_rr.new_frm_fp() method will" +
+ " drop the possibility to accept ldns_rdf as origin." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
res = _ldns.ldns_rr_new_frm_fp_(file, default_ttl, origin, prev)
if res[0] != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create RR, error: %d" % res[0])
+ if (raiseException):
+ raise Exception("Can't create RR, error: %d" % res[0])
return None
return res[1:]
@staticmethod
def new_frm_fp_l(file, default_ttl=0, origin=None, prev=None, raiseException=True):
- """Creates a new rr from a file containing a string.
-
- :param file: file pointer
- :param default_ttl: If 0 DEF_TTL will be used
- :param origin: when the owner is relative add this.
- :param prev: when the owner is whitespaces use this.
- :param raiseException: if True, an exception occurs in case a resolver object can't be created
- :returns:
- * rr - (ldns_rr) RR object or None. If the object can't be created and raiseException is True, an exception occurs.
-
- * line - (int) line number (for debugging)
-
- * ttl - (int) None or TTL if the file contains a $TTL directive
-
- * origin - (ldns_rdf) None or dname if the file contains a $ORIGIN directive
-
- * prev - (ldns_rdf) None or updated value of prev parameter
"""
+ Creates a new rr from a file containing a string.
+
+ :param file: Opened file.
+ :param default_ttl: If 0 DEF_TTL will be used.
+ :type default_ttl: int
+ :param origin: When the owner is relative add this.
+ :type origin: :class:`ldns_dname`
+ :param prev: When the owner is white spaces use this.
+ :type prev: :class:`ldns_rdf`
+ :param raiseException: Iif True, an exception occurs in case
+ a resolver object can't be created.
+ :throws Exception: If `raiseException` is set and the input
+ cannot be read.
+ :throws TypeError: When parameters of incorrect types.
+ :return: None when fails, otherwise a tuple containing:
+
+ * rr - (:class:`ldns_rr`) RR object or None. If the object
+ can't be created and `raiseException` is True,
+ an exception occurs.
+
+ * line - (int) line number (for debugging).
+
+ * ttl - (int) None or TTL if the file contains a TTL
+ directive .
+
+ * origin - (:class:`ldns_rdf`) None or dname rdf if the file
+ contains a ORIGIN directive.
+
+ * prev - (:class:`ldns_rdf`) None or updated value of prev
+ parameter.
+
+ .. note::
+ The type checking of `origin` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ if (not isinstance(origin, ldns_dname)) and \
+ isinstance(origin, ldns_rdf) and \
+ origin.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_rr.new_frm_fp_l() method will" +
+ " drop the possibility to accept ldns_rdf as origin." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
res = _ldns.ldns_rr_new_frm_fp_l_(file, default_ttl, origin, prev)
if res[0] != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create RR, error: %d" % res[0])
+ if (raiseException):
+ raise Exception("Can't create RR, error: %d" % res[0])
return None
return res[1:]
- #_LDNS_RR_CONSTRUCTORS#
+
+ #
+ # _LDNS_RR_CONSTRUCTORS
+ #
def __str__(self):
- """converts the data in the resource record to presentation format"""
+ """
+ Converts the data in the resource record to presentation format.
+
+ :return: (str)
+ """
return _ldns.ldns_rr2str(self)
def __cmp__(self, other):
- """compares two rrs.
+ """
+ Compares two rrs.
The TTL is not looked at.
- :param other:
- the second RR one
- :returns: (int) 0 if equal -1 if self comes before other RR +1 if other RR comes before self
+ :param other: The second RR one.
+ :type other: :class:`ldns_rr`
+ :throws TypeError: When `other` of non-:class:`ldns_rr` type.
+ :return: (int) 0 if equal, -1 if `self` comes before `other`,
+ 1 if `other` RR comes before `self`.
+ """
+ return _ldns.ldns_rr_compare(self, other)
+
+ @staticmethod
+ def class_by_name(string):
+ """
+ Retrieves a class identifier value by looking up its name.
+
+ :param string: Class name.
+ :type string: str
+ :throws TypeError: when `string` of inappropriate type.
+ :return: (int) Class identifier value, or 0 if not valid
+ class name given.
"""
- return _ldns.ldns_rr_compare(self,other)
+ return _ldns.ldns_get_rr_class_by_name(string)
def rdfs(self):
- """returns the list of rdata records."""
- for i in range(0,self.rd_count()):
+ """
+ Returns a generator object of rdata records.
+
+ :return: Generator of :class:`ldns_rdf`.
+ """
+ for i in range(0, self.rd_count()):
yield self.rdf(i)
- def print_to_file(self,output):
- """Prints the data in the resource record to the given file stream (in presentation format)."""
- _ldns.ldns_rr_print(output,self)
- #parameters: FILE *,const ldns_rr *,
+ def print_to_file(self, output):
+ """
+ Prints the data in the resource record to the given file stream
+ (in presentation format).
+
+ :param output: Opened file stream.
+ :throws TypeError: When `output` not a file.
+ """
+ _ldns.ldns_rr_print(output, self)
+ #parameters: FILE *, const ldns_rr *,
def get_type_str(self):
- """Converts an RR type value to its string representation, and returns that string."""
+ """
+ Converts an RR type value to its string representation,
+ and returns that string.
+
+ :return: (str) containing type identification.
+ """
return _ldns.ldns_rr_type2str(self.get_type())
#parameters: const ldns_rr_type,
def get_class_str(self):
- """Converts an RR class value to its string representation, and returns that string."""
+ """
+ Converts an RR class value to its string representation,
+ and returns that string.
+
+ :return: (str) containing class identification.
+ """
return _ldns.ldns_rr_class2str(self.get_class())
#parameters: const ldns_rr_class,
@staticmethod
- def dnskey_key_size_raw(keydata,len,alg):
- """get the length of the keydata in bits"""
- return _ldns.ldns_rr_dnskey_key_size_raw(keydata,len,alg)
+ def dnskey_key_size_raw(keydata, len, alg):
+ """
+ Get the length of the keydata in bits.
+
+ :param keydata: Key raw data.
+ :type keydata: unsigned char \*
+ :param len: Number of bytes of `keydata`.
+ :type len: size_t
+ :param alg: Algorithm identifier.
+ :type alg: ldns_algorithm
+
+ :return: (size_t) The length of key data in bits.
+ """
+ return _ldns.ldns_rr_dnskey_key_size_raw(keydata, len, alg)
#parameters: const unsigned char *,const size_t,const ldns_algorithm,
#retvals: size_t
def write_to_buffer(self,buffer,section):
- """Copies the rr data to the buffer in wire format.
+ """
+ Copies the rr data to the buffer in wire format.
- :param buffer: buffer to append the result to buffer
- :param section: the section in the packet this rr is supposed to be in (to determine whether to add rdata or not)
- :returns: (ldns_status) ldns_status
+ :param buffer: Buffer to append the result to.
+ :type buffer: :class:`ldns_buffer`
+ :param section: The section in the packet this rr is supposed
+ to be in (to determine whether to add rdata or not).
+ :type section: int
+ :throws TypeError: when arguments of mismatching types passed.
+ :return: (ldns_status) ldns_status
"""
- return _ldns.ldns_rr2buffer_wire(buffer,self,section)
+ return _ldns.ldns_rr2buffer_wire(buffer, self, section)
#parameters: ldns_buffer *,const ldns_rr *,int,
#retvals: ldns_status
def write_to_buffer_canonical(self,buffer,section):
- """Copies the rr data to the buffer in wire format, in canonical format according to RFC3597 (every dname in rdata fields of RR's mentioned in that RFC will be lowercased).
+ """
+ Copies the rr data to the buffer in wire format, in canonical
+ format according to RFC3597 (every dname in rdata fields
+ of RR's mentioned in that RFC will be converted to lower-case).
- :param buffer: buffer to append the result to buffer
- :param section: the section in the packet this rr is supposed to be in (to determine whether to add rdata or not)
- :returns: (ldns_status) ldns_status
+ :param buffer: Buffer to append the result to.
+ :type buffer: :class:`ldns_buffer`
+ :param section: The section in the packet this rr is supposed
+ to be in (to determine whether to add rdata or not).
+ :type section: int
+ :throws TypeError: when arguments of mismatching types passed.
+ :return: (ldns_status) ldns_status
"""
return _ldns.ldns_rr2buffer_wire_canonical(buffer,self,section)
#parameters: ldns_buffer *,const ldns_rr *,int,
#retvals: ldns_status
- def write_data_to_buffer(self,buffer):
- """Converts an rr's rdata to wireformat, while excluding the ownername and all the stuff before the rdata.
+ def write_data_to_buffer(self, buffer):
+ """
+ Converts an rr's rdata to wire format, while excluding the
+ owner name and all the stuff before the rdata.
- This is needed in DNSSEC keytag calculation, the ds calcalution from the key and maybe elsewhere.
+ This is needed in DNSSEC key-tag calculation, the ds
+ calculation from the key and maybe elsewhere.
- :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 `buffer` of non-:class:`ldns_buffer`
+ type.
+ :return: (ldns_status) ldns_status
"""
return _ldns.ldns_rr_rdata2buffer_wire(buffer,self)
- #parameters: ldns_buffer *,const ldns_rr *,
+ #parameters: ldns_buffer *, const ldns_rr *,
#retvals: ldns_status
- def write_rrsig_to_buffer(self,buffer):
- """Converts a rrsig to wireformat BUT EXCLUDE the rrsig rdata
+ def write_rrsig_to_buffer(self, buffer):
+ """
+ Converts a rrsig to wire format BUT EXCLUDE the rrsig rdata.
This is needed in DNSSEC verification.
- :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 `buffer` of non-:class:`ldns_buffer`
+ type.
+ :return: (ldns_status) ldns_status
"""
return _ldns.ldns_rrsig2buffer_wire(buffer,self)
#parameters: ldns_buffer *,const ldns_rr *,
#retvals: ldns_status
- #LDNS_RR_METHODS_#
+ #
+ # LDNS_RR_METHODS_
+ #
+
def a_address(self):
- """returns the address of a LDNS_RR_TYPE_A rr
+ """
+ Returns the address rdf of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA
+ rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the address or NULL on failure
+ :return: (:class:`ldns_rdf`) with the address or None on
+ failure.
"""
return _ldns._ldns_rr_a_address(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
- def a_set_address(self,f):
- """sets the address of a LDNS_RR_TYPE_A rr
+ def a_set_address(self, f):
+ """
+ Sets the address of a LDNS_RR_TYPE_A or LDNS_RR_TYPE_AAAA rr.
- :param f:
- the address to set
- :returns: (bool) true on success, false otherwise
+ :param f: The address to be set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: When `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_a_set_address(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_a_set_address(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def clone(self):
- """clones a rr and all its data
+ """
+ Clones a rr and all its data.
- :returns: (ldns_rr \*) the new rr or NULL on failure
+ :return: (:class:`ldns_rr`) The new rr or None on failure.
"""
return _ldns.ldns_rr_clone(self)
#parameters: const ldns_rr *,
#retvals: ldns_rr *
-
- def compare_ds(self,rr2):
- """returns true of the given rr's are equal.
+
+ def compare_ds(self, rr2):
+ """
+ Returns True if the given rr's are equal.
- Also returns true if one record is a DS that represents the same DNSKEY record as the other record
+ Also returns True if one record is a DS that represents the
+ same DNSKEY record as the other record.
- :param rr2:
- the second rr
- :returns: (bool) true if equal otherwise false
+ :param rr2: The second rr.
+ :type rr2: :class:`ldns_rr`
+ :throws TypeError: When `rr2` of non-:class:`ldns_rr` type.
+ :return: (bool) True if equal otherwise False.
"""
- return _ldns.ldns_rr_compare_ds(self,rr2)
- #parameters: const ldns_rr *,const ldns_rr *,
+ return _ldns.ldns_rr_compare_ds(self, rr2)
+ #parameters: const ldns_rr *, const ldns_rr *,
#retvals: bool
- def compare_no_rdata(self,rr2):
- """compares two rrs, up to the rdata.
+ def compare_no_rdata(self, rr2):
+ """
+ Compares two rrs, up to the rdata.
- :param rr2:
- the second one
- :returns: (int) 0 if equal -1 if rr1 comes before rr2 +1 if rr2 comes before rr1
+ :param rr2: Rhe second rr.
+ :type rr2: :class:`ldns_rr`
+ :throws TypeError: When `rr2` of non-:class:`ldns_rr` type.
+ :return: (int) 0 if equal, negative integer if `self` comes
+ before `rr2`, positive integer if `rr2` comes before `self`.
"""
- return _ldns.ldns_rr_compare_no_rdata(self,rr2)
- #parameters: const ldns_rr *,const ldns_rr *,
+ return _ldns.ldns_rr_compare_no_rdata(self, rr2)
+ #parameters: const ldns_rr *, const ldns_rr *,
#retvals: int
def dnskey_algorithm(self):
- """returns the algorithm of a LDNS_RR_TYPE_DNSKEY rr
+ """
+ Returns the algorithm of a LDNS_RR_TYPE_DNSKEY rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the algorithm or NULL on failure
+ :return: (:class:`ldns_rdf`) with the algorithm or None
+ on failure.
"""
return _ldns._ldns_rr_dnskey_algorithm(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_flags(self):
- """returns the flags of a LDNS_RR_TYPE_DNSKEY rr
+ """
+ Returns the flags of a LDNS_RR_TYPE_DNSKEY rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the flags or NULL on failure
+ :return: (:class:`ldns_rdf`) with the flags or None on failure.
"""
return _ldns._ldns_rr_dnskey_flags(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_key(self):
- """returns the key data of a LDNS_RR_TYPE_DNSKEY rr
+ """
+ Returns the key data of a LDNS_RR_TYPE_DNSKEY rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the key data or NULL on failure
+ :return: (:class:`ldns_rdf`) with the key data or None on
+ failure.
"""
return _ldns._ldns_rr_dnskey_key(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def dnskey_key_size(self):
- """get the length of the keydata in bits
+ """
+ Get the length of the keydata in bits.
- :returns: (size_t) the keysize in bits
+ :return: (size_t) the keysize in bits.
"""
return _ldns.ldns_rr_dnskey_key_size(self)
#parameters: const ldns_rr *,
#retvals: size_t
def dnskey_protocol(self):
- """returns the protocol of a LDNS_RR_TYPE_DNSKEY rr
+ """
+ Returns the protocol of a LDNS_RR_TYPE_DNSKEY rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the protocol or NULL on failure
+ :return: (:class:`ldns_rdf`) with the protocol or None on
+ failure.
"""
return _ldns._ldns_rr_dnskey_protocol(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
- def dnskey_set_algorithm(self,f):
- """sets the algorithm of a LDNS_RR_TYPE_DNSKEY rr
+ def dnskey_set_algorithm(self, f):
+ """
+ Sets the algorithm of a LDNS_RR_TYPE_DNSKEY rr
- :param f:
- the algorithm to set
- :returns: (bool) true on success, false otherwise
+ :param f: The algorithm to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: When `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_dnskey_set_algorithm(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_dnskey_set_algorithm(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def dnskey_set_flags(self,f):
- """sets the flags of a LDNS_RR_TYPE_DNSKEY rr
+ def dnskey_set_flags(self, f):
+ """
+ Sets the flags of a LDNS_RR_TYPE_DNSKEY rr.
- :param f:
- the flags to set
- :returns: (bool) true on success, false otherwise
+ :param f: The flags to be set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: When `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_dnskey_set_flags(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_dnskey_set_flags(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def dnskey_set_key(self,f):
- """sets the key data of a LDNS_RR_TYPE_DNSKEY rr
+ def dnskey_set_key(self, f):
+ """
+ Sets the key data of a LDNS_RR_TYPE_DNSKEY rr.
- :param f:
- the key data to set
- :returns: (bool) true on success, false otherwise
+ :param f: The key data to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: When `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_dnskey_set_key(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_dnskey_set_key(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def dnskey_set_protocol(self,f):
- """sets the protocol of a LDNS_RR_TYPE_DNSKEY rr
+ """
+ Sets the protocol of a LDNS_RR_TYPE_DNSKEY rr.
- :param f:
- the protocol to set
- :returns: (bool) true on success, false otherwise
+ :param f: The protocol to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: When `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
return _ldns._ldns_rr_dnskey_set_protocol(self,f)
#parameters: ldns_rr *,ldns_rdf *,
#retvals: bool
def get_class(self):
- """returns the class of the rr.
+ """
+ Returns the class of the rr.
- :returns: (ldns_rr_class) the class of the rr
+ :return: (int) The class identifier of the rr.
"""
return _ldns.ldns_rr_get_class(self)
#parameters: const ldns_rr *,
#retvals: ldns_rr_class
def get_type(self):
- """returns the type of the rr.
+ """
+ Returns the type of the rr.
- :returns: (ldns_rr_type) the type of the rr
+ :return: (int) The type identifier of the rr.
"""
return _ldns.ldns_rr_get_type(self)
#parameters: const ldns_rr *,
#retvals: ldns_rr_type
+ def is_question(self):
+ """
+ Returns the question flag of a rr structure.
+
+ :return: (bool) True if question flag is set.
+ """
+ return _ldns.ldns_rr_is_question(self)
+
def label_count(self):
- """counts the number of labels of the ownername.
+ """
+ Counts the number of labels of the owner name.
- :returns: (uint8_t) the number of labels
+ :return: (int) The number of labels.
"""
return _ldns.ldns_rr_label_count(self)
#parameters: ldns_rr *,
#retvals: uint8_t
def mx_exchange(self):
- """returns the mx host of a LDNS_RR_TYPE_MX rr
+ """
+ Returns the mx host of a LDNS_RR_TYPE_MX rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the name of the MX host or NULL on failure
+ :return: (:class:`ldns_rdf`) with the name of the MX host
+ or None on failure.
"""
return _ldns._ldns_rr_mx_exchange(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def mx_preference(self):
- """returns the mx pref.
-
- of a LDNS_RR_TYPE_MX rr
+ """
+ Returns the mx preference of a LDNS_RR_TYPE_MX rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the preference or NULL on failure
+ :return: (:class:`ldns_rdf`) with the preference or None
+ on failure.
"""
return _ldns._ldns_rr_mx_preference(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def ns_nsdname(self):
- """returns the name of a LDNS_RR_TYPE_NS rr
+ """
+ Returns the name of a LDNS_RR_TYPE_NS rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the name or NULL on failure
+ :return: (:class:`ldns_rdf`) A dname rdf with the name or
+ None on failure.
"""
return _ldns._ldns_rr_ns_nsdname(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def owner(self):
- """returns the owner name of an rr structure.
+ """
+ Returns the owner name of an rr structure.
- :returns: (ldns_rdf \*) ldns_rdf *
+ :return: (:class:`ldns_dname`) Owner name or None on failure.
"""
- return _ldns._ldns_rr_owner(self)
+ rdf = _ldns._ldns_rr_owner(self)
+ if rdf:
+ rdf = ldns_dname(rdf, clone=False)
+ return rdf
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def pop_rdf(self):
- """removes a rd_field member, it will be popped from the last position.
+ """
+ Removes a rd_field member, it will be popped from the last
+ position.
- :returns: (ldns_rdf \*) rdf which was popped (null if nothing)
+ :return: (:class:`ldns_rdf`) rdf which was popped, None if
+ nothing.
"""
return _ldns.ldns_rr_pop_rdf(self)
#parameters: ldns_rr *,
#retvals: ldns_rdf *
def push_rdf(self,f):
- """sets rd_field member, it will be placed in the next available spot.
+ """
+ Sets rd_field member, it will be placed in the next available
+ spot.
- :param f:
- :returns: (bool) bool
+ :param f: The rdf to be appended.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: When `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) Returns True if success, False otherwise.
"""
- return _ldns._ldns_rr_push_rdf(self,f)
- #parameters: ldns_rr *,const ldns_rdf *,
+ return _ldns._ldns_rr_push_rdf(self, f)
+ #parameters: ldns_rr *, const ldns_rdf *,
#retvals: bool
def rd_count(self):
- """returns the rd_count of an rr structure.
+ """
+ Returns the rd_count of an rr structure.
- :returns: (size_t) the rd count of the rr
+ :return: (size_t) the rd count of the rr.
"""
return _ldns.ldns_rr_rd_count(self)
#parameters: const ldns_rr *,
#retvals: size_t
- def rdf(self,nr):
- """returns the rdata field member counter.
+ def rdf(self, nr):
+ """
+ Returns the rdata field with the given index.
- :param nr:
- the number of the rdf to return
- :returns: (ldns_rdf \*) ldns_rdf *
+ :param nr: The index of the rdf to return.
+ :type nr: positive int
+ :throws TypeError: When `nr` not a positive integer.
+ :return: (:class:`ldns_rdf`) The given rdf or None if fails.
"""
- return _ldns._ldns_rr_rdf(self,nr)
- #parameters: const ldns_rr *,size_t,
+ return _ldns._ldns_rr_rdf(self, nr)
+ #parameters: const ldns_rr *, size_t,
#retvals: ldns_rdf *
def rrsig_algorithm(self):
- """returns the algorithm of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the algorithm identifier of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the algorithm or NULL on failure
+ :return: (:class:`ldns_rdf`) with the algorithm or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_algorithm(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_expiration(self):
- """returns the expiration time of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the expiration time of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the expiration time or NULL on failure
+ :return: (:class:`ldns_rdf`) with the expiration time or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_expiration(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_inception(self):
- """returns the inception time of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the inception time of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the inception time or NULL on failure
+ :return: (:class:`ldns_rdf`) with the inception time or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_inception(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_keytag(self):
- """returns the keytag of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the keytag of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the keytag or NULL on failure
+ :return: (:class:`ldns_rdf`) with the keytag or None on failure.
"""
return _ldns._ldns_rr_rrsig_keytag(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_labels(self):
- """returns the number of labels of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the number of labels of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the number of labels or NULL on failure
+ :return: (:class:`ldns_rdf`) with the number of labels or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_labels(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_origttl(self):
- """returns the original TTL of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the original TTL of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the original TTL or NULL on failure
+ :return: (:class:`ldns_rdf`) with the original TTL or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_origttl(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
- def rrsig_set_algorithm(self,f):
- """sets the algorithm of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_algorithm(self, f):
+ """
+ Sets the algorithm of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the algorithm to set
- :returns: (bool) true on success, false otherwise
+ :param f: The algorithm to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_algorithm(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_algorithm(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_expiration(self,f):
- """sets the expireation date of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_expiration(self, f):
+ """
+ Sets the expireation date of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the expireation date to set
- :returns: (bool) true on success, false otherwise
+ :param f: The expireation date to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_expiration(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_expiration(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_inception(self,f):
- """sets the inception date of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_inception(self, f):
+ """
+ Sets the inception date of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the inception date to set
- :returns: (bool) true on success, false otherwise
+ :param f: The inception date to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_inception(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_inception(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_keytag(self,f):
- """sets the keytag of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_keytag(self, f):
+ """
+ Sets the keytag of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the keytag to set
- :returns: (bool) true on success, false otherwise
+ :param f: The keytag to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_keytag(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_keytag(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_labels(self,f):
- """sets the number of labels of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_labels(self, f):
+ """
+ Sets the number of labels of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the number of labels to set
- :returns: (bool) true on success, false otherwise
+ :param f: The number of labels to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_labels(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_labels(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_origttl(self,f):
- """sets the original TTL of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_origttl(self, f):
+ """
+ Sets the original TTL of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the original TTL to set
- :returns: (bool) true on success, false otherwise
+ :param f: The original TTL to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_origttl(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_origttl(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_sig(self,f):
- """sets the signature data of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_sig(self, f):
+ """
+ Sets the signature data of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the signature data to set
- :returns: (bool) true on success, false otherwise
+ :param f: The signature data to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_sig(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_sig(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_signame(self,f):
- """sets the signers name of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_signame(self, f):
+ """
+ Sets the signers name of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the signers name to set
- :returns: (bool) true on success, false otherwise
+ :param f: The signers name to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_signame(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_signame(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
- def rrsig_set_typecovered(self,f):
- """sets the typecovered of a LDNS_RR_TYPE_RRSIG rr
+ def rrsig_set_typecovered(self, f):
+ """
+ Sets the typecovered of a LDNS_RR_TYPE_RRSIG rr.
- :param f:
- the typecovered to set
- :returns: (bool) true on success, false otherwise
+ :param f: The type covered to set.
+ :type f: :class:`ldns_rdf`
+ :throws TypeError: when `f` of non-:class:`ldns_rdf` type.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns._ldns_rr_rrsig_set_typecovered(self,f)
- #parameters: ldns_rr *,ldns_rdf *,
+ return _ldns._ldns_rr_rrsig_set_typecovered(self, f)
+ #parameters: ldns_rr *, ldns_rdf *,
#retvals: bool
def rrsig_sig(self):
- """returns the signature data of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the signature data of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the signature data or NULL on failure
+ :return: (:class:`ldns_rdf`) with the signature data or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_sig(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_signame(self):
- """returns the signers name of a LDNS_RR_TYPE_RRSIG RR
+ """
+ Returns the signers name of a LDNS_RR_TYPE_RRSIG RR.
- :returns: (ldns_rdf \*) a ldns_rdf* with the signers name or NULL on failure
+ :return: (:class:`ldns_rdf`) with the signers name or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_signame(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
def rrsig_typecovered(self):
- """returns the type covered of a LDNS_RR_TYPE_RRSIG rr
+ """
+ Returns the type covered of a LDNS_RR_TYPE_RRSIG rr.
- :returns: (ldns_rdf \*) a ldns_rdf* with the type covered or NULL on failure
+ :return: (:class:`ldns_rdf`) with the type covered or None
+ on failure.
"""
return _ldns._ldns_rr_rrsig_typecovered(self)
#parameters: const ldns_rr *,
#retvals: ldns_rdf *
- def set_class(self,rr_class):
- """sets the class in the rr.
+ def set_class(self, rr_class):
+ """
+ Sets the class in the rr.
- :param rr_class:
- set to this class
+ :param rr_class: Set to this class.
+ :type rr_class: int
+ :throws TypeError: when `rr_class` of non-integer type.
"""
- _ldns.ldns_rr_set_class(self,rr_class)
- #parameters: ldns_rr *,ldns_rr_class,
+ _ldns.ldns_rr_set_class(self, rr_class)
+ #parameters: ldns_rr *, ldns_rr_class,
#retvals:
- def set_owner(self,owner):
- """sets the owner in the rr structure.
+ def set_owner(self, owner):
+ """
+ Sets the owner in the rr structure.
- :param owner:
+ :param owner: Owner name.
+ :type owner: :class:`ldns_dname`
+ :throws TypeError: when `owner` of non-:class:`ldns_dname` type.
+
+ .. note::
+ The type checking of `owner` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
"""
- _ldns._ldns_rr_set_owner(self,owner)
- #parameters: ldns_rr *,ldns_rdf *,
- #retvals:
+ if (not isinstance(owner, ldns_dname)) and \
+ isinstance(owner, ldns_rdf) and \
+ owner.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_rr.new_frm_str() method will" +
+ " drop the possibility to accept ldns_rdf as owner." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ _ldns._ldns_rr_set_owner(self, owner)
+ #parameters: ldns_rr *, ldns_rdf *,
+ #retvals:
+
+ def set_question(self, question):
+ """
+ Sets the question flag in the rr structure.
+
+ :param question: Question flag.
+ :type question: bool
+ """
+ _ldns.ldns_rr_set_question(self, question)
+ #parameters: ldns_rr *, bool,
+ #retvals:
- def set_rd_count(self,count):
- """sets the rd_count in the rr.
+ def set_rd_count(self, count):
+ """
+ Sets the rd_count in the rr.
- :param count:
- set to this count
+ :param count: Set to this count.
+ :type count: positive int
+ :throws TypeError: when `count` of non-integer type.
"""
- _ldns.ldns_rr_set_rd_count(self,count)
- #parameters: ldns_rr *,size_t,
+ _ldns.ldns_rr_set_rd_count(self, count)
+ #parameters: ldns_rr *, size_t,
#retvals:
- def set_rdf(self,f,position):
- """sets a rdf member, it will be set on the position given.
+ def set_rdf(self, f, position):
+ """
+ Sets a rdf member, it will be set on the position given.
The old value is returned, like pop.
- :param f:
- :param position:
- the position the set the rdf
- :returns: (ldns_rdf \*) the old value in the rr, NULL on failyre
+ :param f: The rdf to be set.
+ :type f: :class:`ldns_rdf`
+ :param position: The position the set the rdf.
+ :type position: positive int
+ :throws TypeError: when mismatching types passed.
+ :return: (:class:`ldns_rdf`) the old value in the rr, None
+ on failure.
"""
- return _ldns._ldns_rr_set_rdf(self,f,position)
- #parameters: ldns_rr *,const ldns_rdf *,size_t,
+ return _ldns._ldns_rr_set_rdf(self, f, position)
+ #parameters: ldns_rr *, const ldns_rdf *, size_t,
#retvals: ldns_rdf *
- def set_ttl(self,ttl):
- """sets the ttl in the rr structure.
+ def set_ttl(self, ttl):
+ """
+ Sets the ttl in the rr structure.
- :param ttl:
- set to this ttl
+ :param ttl: Set to this ttl.
+ :type ttl: positive int
+ :throws TypeError: when `ttl` of non-integer type.
"""
- _ldns.ldns_rr_set_ttl(self,ttl)
- #parameters: ldns_rr *,uint32_t,
+ _ldns.ldns_rr_set_ttl(self, ttl)
+ #parameters: ldns_rr *, uint32_t,
#retvals:
- def set_type(self,rr_type):
- """sets the type in the rr.
+ def set_type(self, rr_type):
+ """
+ Sets the type in the rr.
- :param rr_type:
- set to this type
+ :param rr_type: Set to this type.
+ :type rr_type: ineteger
+ :throws TypeError: when `rr_type` of non-integer type.
"""
- _ldns.ldns_rr_set_type(self,rr_type)
- #parameters: ldns_rr *,ldns_rr_type,
- #retvals:
+ _ldns.ldns_rr_set_type(self, rr_type)
+ #parameters: ldns_rr *, ldns_rr_type,
+ #retvals:
+
+ def to_canonical(self):
+ """
+ Converts each dname in a rr to its canonical form.
+ """
+ _ldns.ldns_rr2canonical(self)
def ttl(self):
- """returns the ttl of an rr structure.
+ """
+ Returns the ttl of an rr structure.
- :returns: (uint32_t) the ttl of the rr
+ :return: (int) the ttl of the rr.
"""
return _ldns.ldns_rr_ttl(self)
#parameters: const ldns_rr *,
#retvals: uint32_t
+ @staticmethod
+ def type_by_name(string):
+ """
+ Retrieves a rr type identifier value by looking up its name.
+
+ Returns 0 if invalid name passed.
+
+ :param string: RR type name.
+ :type string: str
+ :throws TypeError: when `string` of inappropriate type.
+ :return: (int) RR type identifier, or 0 if no matching value
+ to identifier found.
+ """
+ return _ldns.ldns_get_rr_type_by_name(string)
+
def uncompressed_size(self):
- """calculates the uncompressed size of an RR.
+ """
+ Calculates the uncompressed size of an RR.
- :returns: (size_t) size of the rr
+ :return: (inetger) size of the rr.
"""
return _ldns.ldns_rr_uncompressed_size(self)
#parameters: const ldns_rr *,
#retvals: size_t
- #_LDNS_RR_METHODS#
- %}
+ #
+ # _LDNS_RR_METHODS
+ #
+ %}
}
-%nodefaultctor ldns_struct_rr_list; //no default constructor & destructor
-%nodefaultdtor ldns_struct_rr_list;
+
+/* ========================================================================= */
+/* SWIG setting and definitions. */
+/* ========================================================================= */
+
+
+%nodefaultctor ldns_struct_rr_list; /* No default constructor. */
+%nodefaultdtor ldns_struct_rr_list; /* No default destructor. */
%ignore ldns_struct_rr_list::_rrs;
+%newobject ldns_rr_list_cat_clone;
%newobject ldns_rr_list_clone;
%newobject ldns_rr_list_pop_rr;
%newobject ldns_rr_list_pop_rr_list;
%newobject ldns_rr_list_pop_rrset;
%newobject ldns_rr_list_rr;
%newobject ldns_rr_list_new;
+%newobject ldns_get_rr_list_hosts_frm_file;
+%newobject ldns_rr_list_subtype_by_rdf;
+%newobject ldns_rr_list2str;
%delobject ldns_rr_list_deep_free;
%delobject ldns_rr_list_free;
-%rename(ldns_rr_list) ldns_struct_rr_list;
-#ifdef LDNS_DEBUG
-%rename(__ldns_rr_list_deep_free) ldns_rr_list_deep_free;
-%rename(__ldns_rr_list_free) ldns_rr_list_free;
-%inline %{
-void _ldns_rr_list_deep_free(ldns_rr_list* r) {
- printf("******** LDNS_RR_LIST deep free 0x%lX ************\n", (long unsigned int)r);
- ldns_rr_list_deep_free(r);
-}
-
-void _ldns_rr_list_free(ldns_rr_list* r) {
- printf("******** LDNS_RR_LIST deep free 0x%lX ************\n", (long unsigned int)r);
- ldns_rr_list_free(r);
-}
-%}
-#else
-%rename(_ldns_rr_list_deep_free) ldns_rr_list_deep_free;
-%rename(_ldns_rr_list_free) ldns_rr_list_free;
-#endif
-
-/* clone data on push */
+/* Clone data on push. */
%rename(__ldns_rr_list_push_rr) ldns_rr_list_push_rr;
-%inline %{
-void _ldns_rr_list_push_rr(ldns_rr_list* r, ldns_rr *rr) {
- ldns_rr_list_push_rr(r, ldns_rr_clone(rr));
-}
+%inline
+%{
+ bool _ldns_rr_list_push_rr(ldns_rr_list* r, ldns_rr *rr)
+ {
+ bool ret;
+ ldns_rr *new;
+
+ new = ldns_rr_clone(rr);
+ if (!(ret = ldns_rr_list_push_rr(r, new))) {
+ ldns_rr_free(new);
+ }
+ return ret;
+ }
%}
%rename(__ldns_rr_list_push_rr_list) ldns_rr_list_push_rr_list;
-%inline %{
-void _ldns_rr_list_push_rr_list(ldns_rr_list* r, ldns_rr_list *r2) {
- ldns_rr_list_push_rr_list(r, ldns_rr_list_clone(r2));
-}
+%inline
+%{
+ bool _ldns_rr_list_push_rr_list(ldns_rr_list* r, ldns_rr_list *r2)
+ {
+ bool ret;
+ ldns_rr_list *new;
+
+ new = ldns_rr_list_clone(r2);
+ if (!(ret = ldns_rr_list_push_rr_list(r, new))) {
+ ldns_rr_list_deep_free(new);
+ }
+ return ret;
+ }
+%}
+
+
+%newobject _ldns_rr_list_set_rr;
+%rename(__ldns_rr_list_set_rr) ldns_rr_list_set_rr;
+%inline
+%{
+ ldns_rr * _ldns_rr_list_set_rr(ldns_rr_list * rrl, ldns_rr *rr,
+ size_t idx)
+ {
+ ldns_rr *ret;
+ ldns_rr *new;
+
+ new = ldns_rr_clone(rr);
+ if ((ret = ldns_rr_list_set_rr(rrl, new, idx)) == NULL) {
+ ldns_rr_free(new);
+ }
+ return ret;
+ }
%}
+
%rename(__ldns_rr_list_cat) ldns_rr_list_cat;
-%inline %{
-void _ldns_rr_list_cat(ldns_rr_list* r, ldns_rr_list *r2) {
- ldns_rr_list_cat(r, ldns_rr_list_clone(r2));
-}
+%inline
+%{
+ bool _ldns_rr_list_cat(ldns_rr_list *r, ldns_rr_list *r2)
+ {
+ return ldns_rr_list_cat(r, ldns_rr_list_clone(r2));
+ }
%}
-/* clone data on pull */
+/* End clone data on push. */
-%newobject _ldns_rr_list_rr;
+/* Clone data on pull. */
+
+%newobject _ldns_rr_list_rr;
%rename(__ldns_rr_list_rr) ldns_rr_list_rr;
-%inline %{
-ldns_rr* _ldns_rr_list_rr(ldns_rr_list* r, int i) {
- return ldns_rr_clone(ldns_rr_list_rr(r, i));
-}
+%inline
+%{
+ ldns_rr * _ldns_rr_list_rr(ldns_rr_list *r, int i)
+ {
+ ldns_rr *rr;
+ rr = ldns_rr_list_rr(r, i);
+ return (rr != NULL) ? ldns_rr_clone(rr) : NULL;
+ }
%}
-%newobject ldns_rr_list2str;
-
+%newobject _ldns_rr_list_owner;
%rename(__ldns_rr_list_owner) ldns_rr_list_owner;
-%inline %{
-ldns_rdf* _ldns_rr_list_owner(ldns_rr_list* r) {
- return ldns_rdf_clone(ldns_rr_list_owner(r));
-}
+%inline
+%{
+ ldns_rdf * _ldns_rr_list_owner(ldns_rr_list *r)
+ {
+ ldns_rdf *rdf;
+ rdf = ldns_rr_list_owner(r);
+ return (rdf != NULL) ? ldns_rdf_clone(rdf) : NULL;
+ }
%}
+/* End clone data on pull. */
+
+
+/* ========================================================================= */
+/* Debugging related code. */
+/* ========================================================================= */
+
+
+%rename(ldns_rr_list) ldns_struct_rr_list;
+#ifdef LDNS_DEBUG
+%rename(__ldns_rr_list_deep_free) ldns_rr_list_deep_free;
+%rename(__ldns_rr_list_free) ldns_rr_list_free;
+%inline
+%{
+ void _ldns_rr_list_deep_free(ldns_rr_list *r)
+ {
+ printf("******** LDNS_RR_LIST deep free 0x%lX ************\n",
+ (long unsigned int) r);
+ ldns_rr_list_deep_free(r);
+ }
+
+ void _ldns_rr_list_free(ldns_rr_list *r)
+ {
+ printf("******** LDNS_RR_LIST deep free 0x%lX ************\n",
+ (long unsigned int) r);
+ ldns_rr_list_free(r);
+ }
+%}
+#else
+%rename(_ldns_rr_list_deep_free) ldns_rr_list_deep_free;
+%rename(_ldns_rr_list_free) ldns_rr_list_free;
+#endif
+
+
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
+
+
+/* None. */
+
+
+/* ========================================================================= */
+/* Encapsulating Python code. */
+/* ========================================================================= */
+
%feature("docstring") ldns_struct_rr_list "List of Resource Records.
%extend ldns_struct_rr_list {
- %pythoncode %{
+ %pythoncode
+ %{
def __init__(self):
self.this = _ldns.ldns_rr_list_new()
if not self.this:
__swig_destroy__ = _ldns._ldns_rr_list_deep_free
- #LDNS_RR_LIST_CONSTRUCTORS_#
+ #
+ # LDNS_RR_LIST_CONSTRUCTORS_
+ #
+
+ @staticmethod
+ def new(raiseException=True):
+ """
+ Creates an empty RR List object.
+
+ :param raiseException: Set to True if an exception should
+ signal an error.
+ :type raiseException: bool
+ :throws Exception: when `raiseException` is True and error
+ occurs.
+ :return: :class:`ldns_rr_list` Empty RR list.
+ """
+ rrl = _ldns.ldns_rr_list_new()
+ if (not rrl) and raiseException:
+ raise Exception("Can't create RR List.")
+ return rrl
+
@staticmethod
def new_frm_file(filename="/etc/hosts", raiseException=True):
- """Creates an RR List object from a file content
+ """
+ Creates an RR List object from file content.
- Goes through a file and returns a rr_list containing all the defined hosts in there.
+ Goes through a file and returns a rr list containing
+ all the defined hosts in there.
- :param filename: the filename to use
- :returns: RR List object or None. If the object can't be created and raiseException is True, an exception occurs.
+ :param filename: The filename to use.
+ :type filename: str
+ :param raiseException: Set to True if an exception should
+ signal an error.
+ :type raiseException: bool
+ :throws TypeError: when `filename` of inappropriate type.
+ :throws Exception: when `raiseException` is True and error
+ occurs.
+ :return: RR List object or None. If the object can't be
+ created and `raiseException` is True, an exception occurs.
**Usage**
- >>> alist = ldns.ldns_rr_list.new_frm_file()
- >>> print alist
- localhost. 3600 IN A 127.0.0.1
- ...
+
+ >>> alist = ldns.ldns_rr_list.new_frm_file()
+ >>> print alist
+ localhost. 3600 IN A 127.0.0.1
+ ...
"""
rr = _ldns.ldns_get_rr_list_hosts_frm_file(filename)
- if (not rr) and (raiseException): raise Exception("Can't create RR List, error: %d" % status)
+ if (not rr) and (raiseException):
+ raise Exception("Can't create RR List.")
return rr
- #_LDNS_RR_LIST_CONSTRUCTORS#
+
+ #
+ # _LDNS_RR_LIST_CONSTRUCTORS
+ #
def __str__(self):
- """converts a list of resource records to presentation format"""
+ """
+ Converts a list of resource records to presentation format.
+
+ :return: (str) Presentation format.
+ """
return _ldns.ldns_rr_list2str(self)
- def print_to_file(self,output):
- """print a rr_list to output param[in] output the fd to print to param[in] list the rr_list to print"""
- _ldns.ldns_rr_list_print(output,self)
+ def print_to_file(self, output):
+ """
+ Print a rr_list to output.
+
+ :param output: Opened file to print to.
+ :throws TypeError: when `output` of inappropriate type.
+ """
+ _ldns.ldns_rr_list_print(output, self)
def to_canonical(self):
- """converts each dname in each rr in a rr_list to its canonical form."""
+ """
+ Converts each dname in each rr in a rr_list to its canonical
+ form.
+ """
_ldns.ldns_rr_list2canonical(self)
#parameters: ldns_rr_list *,
#retvals:
def rrs(self):
- """returns the list of rr records."""
- for i in range(0,self.rr_count()):
+ """
+ Returns a generator object of a list of rr records.
+
+ :return: (generator) generator object.
+ """
+ for i in range(0, self.rr_count()):
yield self.rr(i)
def is_rrset(self):
- """checks if an rr_list is a rrset."""
+ """
+ Checks if the rr list is a rr set.
+
+ :return: (bool) True if rr list is a rr set.
+ """
return _ldns.ldns_is_rrset(self)
- def __cmp__(self,rrl2):
- """compares two rr listss.
+ def __cmp__(self, rrl2):
+ """
+ Compares two rr lists.
- :param rrl2:
- the second one
- :returns: (int) 0 if equal -1 if this list comes before rrl2 +1 if rrl2 comes before this list
+ :param rrl2: The second one.
+ :type rrl2: :class:`ldns_rr_list`
+ :throws TypeError: when `rrl2` of non-:class:`ldns_rr_list`
+ type.
+ :return: (int) 0 if equal, -1 if this list comes before
+ `rrl2`, 1 if `rrl2` comes before this list.
"""
- return _ldns.ldns_rr_list_compare(self,rrl2)
+ return _ldns.ldns_rr_list_compare(self, rrl2)
def write_to_buffer(self, buffer):
- """Copies the rr_list data to the buffer in wire format.
+ """
+ Copies the rr_list data to the buffer in wire format.
- :param buffer: output buffer to append the result to
- :returns: (ldns_status) ldns_status
+ :param buffer: Output buffer to append the result to.
+ :type buffer: :class:`ldns_buffer`
+ :throws TypeError: when `buffer` of non-:class:`ldns_buffer`
+ type.
+ :return: (ldns_status) ldns_status
"""
- return _ldns.ldns_rr_list2buffer_wire(buffer,self)
+ return _ldns.ldns_rr_list2buffer_wire(buffer, self)
+
+ #
+ # LDNS_RR_LIST_METHODS_
+ #
- #LDNS_RR_LIST_METHODS_#
- def cat(self,right):
- """concatenates two ldns_rr_lists together.
+ def cat(self, right):
+ """
+ Concatenates two ldns_rr_lists together.
- This modifies rr list (to extend it and add the pointers from right).
+ This modifies rr list (to extend it and adds RRs from right).
- :param right:
- the rightside
- :returns: (bool) a left with right concatenated to it
+ :param right: The right-hand side.
+ :type right: :class:`ldns_rr_list`
+ :throws TypeError: when `right` of non-:class:`ldns_rr_list`
+ type.
+ :return: (bool) True if success.
"""
- return _ldns._ldns_rr_list_cat(self,right)
- #parameters: ldns_rr_list *,ldns_rr_list *,
+ return _ldns._ldns_rr_list_cat(self, right)
+ #parameters: ldns_rr_list *, ldns_rr_list *,
#retvals: bool
- def cat_clone(self,right):
- """concatenates two ldns_rr_lists together, but makes clones of the rr's (instead of pointer copying).
+ def cat_clone(self, right):
+ """
+ Concatenates two ldns_rr_lists together, creates a new list
+ of the rr's (instead of appending the content to an existing
+ list).
- :param right:
- the rightside
- :returns: (ldns_rr_list \*) a new rr_list with leftside/rightside concatenated
+ :param right: The right-hand side.
+ :type right: :class:`ldns_rr_list`
+ :throws TypeError: when `right` of non-:class:`ldns_rr_list`
+ type.
+ :return: (:class:`ldns_rr_list`) rr list with left-hand side +
+ right-hand side concatenated, on None on error.
"""
- return _ldns.ldns_rr_list_cat_clone(self,right)
- #parameters: ldns_rr_list *,ldns_rr_list *,
+ return _ldns.ldns_rr_list_cat_clone(self, right)
+ #parameters: ldns_rr_list *, ldns_rr_list *,
#retvals: ldns_rr_list *
def clone(self):
- """clones an rrlist.
+ """
+ Clones an rrlist.
- :returns: (ldns_rr_list \*) the cloned rr list
+ :return: (:class:`ldns_rr_list`) the cloned rr list,
+ or None on error.
"""
return _ldns.ldns_rr_list_clone(self)
#parameters: const ldns_rr_list *,
#retvals: ldns_rr_list *
- def contains_rr(self,rr):
- """returns true if the given rr is one of the rrs in the list, or if it is equal to one
+ def contains_rr(self, rr):
+ """
+ Returns True if the given rr is one of the rrs in the list,
+ or if it is equal to one.
- :param rr:
- the rr to check
- :returns: (bool) true if rr_list contains rr, false otherwise
+ :param rr: The rr to check.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: when `rr` of non-:class:`ldns_rr` type.
+ :return: (bool) True if rr_list contains `rr`, False otherwise.
"""
- return _ldns.ldns_rr_list_contains_rr(self,rr)
- #parameters: const ldns_rr_list *,ldns_rr *,
+ return _ldns.ldns_rr_list_contains_rr(self, rr)
+ #parameters: const ldns_rr_list *, ldns_rr *,
#retvals: bool
def owner(self):
- """Returns the owner domain name rdf of the first element of the RR If there are no elements present, NULL is returned.
+ """
+ Returns the owner domain name rdf of the first element of
+ the RR. If there are no elements present, None is returned.
- :returns: (ldns_rdf \*) dname of the first element, or NULL if the list is empty
+ :return: (:class:`ldns_dname`) dname of the first element,
+ or None if the list is empty.
"""
- return _ldns._ldns_rr_list_owner(self)
+ rdf = _ldns._ldns_rr_list_owner(self)
+ if rdf:
+ rdf = ldns_dname(rdf, clone=False)
+ return rdf
#parameters: const ldns_rr_list *,
#retvals: ldns_rdf *
def pop_rr(self):
- """pops the last rr from an rrlist.
+ """
+ Pops the last rr from an rrlist.
- :returns: (ldns_rr \*) NULL if nothing to pop. Otherwise the popped RR
+ :return: (:class:`ldns_rr`) None if nothing to pop.
+ Otherwise the popped RR.
"""
rr = _ldns.ldns_rr_list_pop_rr(self)
- #if hasattr(self, "_python_rr_refs") and rr in self._python_rr_refs:
- # self._python_rr_refs.remove(rr)
return rr
#parameters: ldns_rr_list *,
#retvals: ldns_rr *
- def pop_rr_list(self,size):
- """pops an rr_list of size s from an rrlist.
+ def pop_rr_list(self, size):
+ """
+ Pops an rr_list of size s from an rrlist.
- :param size:
- the number of rr's to pop
- :returns: (ldns_rr_list \*) NULL if nothing to pop. Otherwise the popped rr_list
+ :param size: The number of rr's to pop.
+ :type size: positive int
+ :throws TypeError: when `size` of inappropriate type.
+ :return: (:class:`ldns_rr_list`) None if nothing to pop.
+ Otherwise the popped rr list.
"""
- return _ldns.ldns_rr_list_pop_rr_list(self,size)
- #parameters: ldns_rr_list *,size_t,
+ return _ldns.ldns_rr_list_pop_rr_list(self, size)
+ #parameters: ldns_rr_list *, size_t,
#retvals: ldns_rr_list *
def pop_rrset(self):
- """pops the first rrset from the list, the list must be sorted, so that all rr's from each rrset are next to each other
+ """
+ Pops the first rrset from the list, the list must be sorted,
+ so that all rr's from each rrset are next to each other.
- :returns: (ldns_rr_list \*)
+ :return: (:class:`ldns_rr_list`) the first rrset, or None when
+ empty.
"""
return _ldns.ldns_rr_list_pop_rrset(self)
#parameters: ldns_rr_list *,
#retvals: ldns_rr_list *
- def push_rr(self,rr):
- """pushes an rr to an rrlist.
+ def push_rr(self, rr):
+ """
+ Pushes an rr to an rrlist.
- :param rr:
- the rr to push
- :returns: (bool) false on error, otherwise true
+ :param rr: The rr to push.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: when `rr` of non-:class:`ldns_rr` type.
+ :return: (bool) False on error, otherwise True.
"""
- #if hasattr(self, "_python_rr_refs"):
- # self._python_rr_refs.add(rr)
- #else:
- # self._python_rr_refs = set([rr])
- return _ldns._ldns_rr_list_push_rr(self,rr)
- #parameters: ldns_rr_list *,const ldns_rr *,
+ return _ldns._ldns_rr_list_push_rr(self, rr)
+ #parameters: ldns_rr_list *, const ldns_rr *,
#retvals: bool
- def push_rr_list(self,push_list):
- """pushes an rr_list to an rrlist.
+ def push_rr_list(self, push_list):
+ """
+ Pushes an rr list to an rr list.
- :param push_list:
- the rr_list to push
- :returns: (bool) false on error, otherwise true
+ :param push_list: The rr_list to push.
+ :type push_list: :class:`ldns_rr_list`
+ :throws TypeError: when `push_list` of non-:class:`ldns_rr_list`
+ type.
+ :returns: (bool) False on error, otherwise True.
"""
- return _ldns._ldns_rr_list_push_rr_list(self,push_list)
- #parameters: ldns_rr_list *,const ldns_rr_list *,
+ return _ldns._ldns_rr_list_push_rr_list(self, push_list)
+ #parameters: ldns_rr_list *, const ldns_rr_list *,
#retvals: bool
- def rr(self,nr):
- """returns a specific rr of an rrlist.
+ def rr(self, nr):
+ """
+ Returns a specific rr of an rrlist.
- :param nr:
- return this rr
- :returns: (ldns_rr \*) the rr at position nr
+ :param nr: Index of the desired rr.
+ :type nr: positive int
+ :throws TypeError: when `nr` of inappropriate type.
+ :return: (:class:`ldns_rr`) The rr at position `nr`, or None
+ if failed.
"""
- return _ldns._ldns_rr_list_rr(self,nr)
- #parameters: const ldns_rr_list *,size_t,
+ return _ldns._ldns_rr_list_rr(self, nr)
+ #parameters: const ldns_rr_list *, size_t,
#retvals: ldns_rr *
def rr_count(self):
- """returns the number of rr's in an rr_list.
+ """
+ Returns the number of rr's in an rr_list.
- :returns: (size_t) the number of rr's
+ :return: (int) The number of rr's.
"""
return _ldns.ldns_rr_list_rr_count(self)
#parameters: const ldns_rr_list *,
#retvals: size_t
- def set_rr(self,r,count):
- """set a rr on a specific index in a ldns_rr_list
+ def set_rr(self, r, idx):
+ """
+ Set a rr on a specific index in a ldns_rr_list.
- :param r:
- the rr to set
- :param count:
- index into the rr_list
- :returns: (ldns_rr \*) the old rr which was stored in the rr_list, or NULL is the index was too large set a specific rr
+ :param r: The rr to set.
+ :type r: :class:`ldns_rr`
+ :param idx: Index into the rr_list.
+ :type idx: positive int
+ :throws TypeError: when parameters of inappropriate types.
+ :return: (:class:`ldns_rr`) the old rr which was stored in
+ the rr_list, or None if the index was too large
+ to set a specific rr.
"""
- return _ldns.ldns_rr_list_set_rr(self,r,count)
- #parameters: ldns_rr_list *,const ldns_rr *,size_t,
+ return _ldns._ldns_rr_list_set_rr(self, r, idx)
+ #parameters: ldns_rr_list *, const ldns_rr *, size_t,
#retvals: ldns_rr *
- def set_rr_count(self,count):
- """sets the number of rr's in an rr_list.
+ def set_rr_count(self, count):
+ """
+ Sets the number of rr's in an rr_list.
- :param count:
- the number of rr in this list
+ :param count: The number of rr in this list.
+ :type count: positive int
+ :throws TypeError: when `count` of non-integer type.
+ :throws Exception: when `count` out of acceptable range.
+
+ .. warning::
+ Don't use this method unless you really know what you
+ are doing.
"""
- _ldns.ldns_rr_list_set_rr_count(self,count)
- #parameters: ldns_rr_list *,size_t,
+ # The function C has a tendency to generate an assertion fail when
+ # the count exceeds the list's capacity -- therefore the checking
+ # code.
+ if isinstance(count, int) and \
+ ((count < 0) or (count > self._rr_capacity)):
+ raise Exception("Given count %d is out of range " % (count) +
+ "of the rr list's capacity %d." % (self._rr_capacity))
+ _ldns.ldns_rr_list_set_rr_count(self, count)
+ #parameters: ldns_rr_list *, size_t,
#retvals:
def sort(self):
- """sorts an rr_list (canonical wire format).
-
- the sorting is done inband.
+ """
+ Sorts an rr_list (canonical wire format).
"""
_ldns.ldns_rr_list_sort(self)
#parameters: ldns_rr_list *,
#retvals:
- def subtype_by_rdf(self,r,pos):
- """Return the rr_list which matches the rdf at position field.
+ def subtype_by_rdf(self, r, pos):
+ """
+ Return the rr_list which matches the rdf at position field.
- Think type-covered stuff for RRSIG
+ Think type-covered stuff for RRSIG.
- :param r:
- the rdf to use for the comparison
- :param pos:
- at which position can we find the rdf
- :returns: (ldns_rr_list \*) a new rr list with only the RRs that match
+ :param r: The rdf to use for the comparison.
+ :type r: :class:`ldns_rdf`
+ :param pos: At which position we can find the rdf.
+ :type pos: positive int
+ :throws TypeError: when parameters of inappropriate types.
+ :return: (:class:`ldns_rr_list`) a new rr list with only
+ the RRs that match, or None when nothing matches.
"""
- return _ldns.ldns_rr_list_subtype_by_rdf(self,r,pos)
- #parameters: ldns_rr_list *,ldns_rdf *,size_t,
+ return _ldns.ldns_rr_list_subtype_by_rdf(self, r, pos)
+ #parameters: ldns_rr_list *, ldns_rdf *, size_t,
#retvals: ldns_rr_list *
def type(self):
- """Returns the type of the first element of the RR If there are no elements present, 0 is returned (LDNS_RR_TYPE_A).
+ """
+ Returns the type of the first element of the RR.
+
+ If there are no elements present, 0 is returned.
- :returns: (ldns_rr_type) rr_type of the first element, or 0 if the list is empty
+ :return: (int) rr_type of the first element,
+ or 0 if the list is empty.
"""
return _ldns.ldns_rr_list_type(self)
#parameters: const ldns_rr_list *,
#retvals: ldns_rr_type
- #_LDNS_RR_LIST_METHODS#
- %}
+
+ #
+ # _LDNS_RR_LIST_METHODS
+ #
+ %}
}
+
+/* ========================================================================= */
+/* SWIG setting and definitions. */
+/* ========================================================================= */
+
+
%newobject ldns_rr_descript;
-%nodefaultctor ldns_struct_rr_descriptor; //no default constructor & destructor
-%nodefaultdtor ldns_struct_rr_descriptor;
+%nodefaultctor ldns_struct_rr_descriptor; /* No default constructor. */
+%nodefaultdtor ldns_struct_rr_descriptor; /* No default destructor.*/
%rename(ldns_rr_descriptor) ldns_struct_rr_descriptor;
+/* ========================================================================= */
+/* Debugging related code. */
+/* ========================================================================= */
+
+/* None. */
-%feature("docstring") ldns_struct_rr_descriptor "Resource Record descriptor
-This structure contains, for all rr types, the rdata fields that are defined."
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
+
+
+%inline
+%{
+ /*
+ * Does nothing, but keeps the SWIG wrapper quiet about absent destructor.
+ */
+ void ldns_rr_descriptor_dummy_free(const ldns_rr_descriptor *rd)
+ {
+ (void) rd;
+ }
+%}
+
+
+/* ========================================================================= */
+/* Encapsulating Python code. */
+/* ========================================================================= */
+
+
+%feature("docstring") ldns_struct_rr_descriptor "Resource Record descriptor.
+
+This structure contains, for all rr types, the rdata fields that are defined.
+
+In order to create a class instance use :meth:`ldns_rr_descriptor`.
+"
%extend ldns_struct_rr_descriptor {
- %pythoncode %{
- def __init__(self):
- raise Exception("This class can't be created directly. Please use: ldns_rr_descript")
- #LDNS_RR_DESCRIPTOR_METHODS_#
- def field_type(self,field):
- """returns the rdf type for the given rdata field number of the rr type for the given descriptor.
+ %pythoncode
+ %{
+ def __init__(self, rr_type):
+ """
+ Returns the resource record descriptor for the given type.
+
+ :param rr_type: RR type.
+ :type rr_type: int
+ :throws TypeError: when `rr_type` of inappropriate type.
+ :return: (:class:`ldns_rr_descriptor`) RR descriptor class.
+ """
+ self.this = self.ldns_rr_descriptor(rr_type)
+
+ def __str__(self):
+ raise Exception("The content of this class cannot be printed.")
+
+ __swig_destroy__ = _ldns.ldns_rr_descriptor_dummy_free
+
+ #
+ # LDNS_RR_DESCRIPTOR_CONSTRUCTORS_
+ #
+
+ @staticmethod
+ def ldns_rr_descriptor(rr_type):
+ """
+ Returns the resource record descriptor for the given type.
+
+ :param rr_type: RR type.
+ :type rr_type: int
+ :throws TypeError: when `rr_type` of inappropriate type.
+ :return: (:class:`ldns_rr_descriptor`) RR descriptor class.
+ """
+ return _ldns.ldns_rr_descript(rr_type)
+ #parameters: uint16_t
+ #retvals: const ldns_rr_descriptor *
+
+ #
+ # _LDNS_RR_DESCRIPTOR_CONSTRUCTORS
+ #
+
+ #
+ # LDNS_RR_DESCRIPTOR_METHODS_
+ #
+
+ def field_type(self, field):
+ """
+ Returns the rdf type for the given rdata field number of the
+ rr type for the given descriptor.
- :param field:
- the field number
- :returns: (ldns_rdf_type) the rdf type for the field
+ :param field: The field number.
+ :type field: positive int
+ :throws TypeError: when `field` of non-inetger type.
+ :return: (int) the rdf type for the field.
"""
- return _ldns.ldns_rr_descriptor_field_type(self,field)
- #parameters: const ldns_rr_descriptor *,size_t,
+ return _ldns.ldns_rr_descriptor_field_type(self, field)
+ #parameters: const ldns_rr_descriptor *, size_t,
#retvals: ldns_rdf_type
def maximum(self):
- """returns the maximum number of rdata fields of the rr type this descriptor describes.
+ """
+ Returns the maximum number of rdata fields of the rr type this
+ descriptor describes.
- :returns: (size_t) the maximum number of rdata fields
+ :return: (int) the maximum number of rdata fields.
"""
return _ldns.ldns_rr_descriptor_maximum(self)
#parameters: const ldns_rr_descriptor *,
#retvals: size_t
def minimum(self):
- """returns the minimum number of rdata fields of the rr type this descriptor describes.
+ """
+ Returns the minimum number of rdata fields of the rr type this
+ descriptor describes.
- :returns: (size_t) the minimum number of rdata fields
+ :return: (int) the minimum number of rdata fields.
"""
return _ldns.ldns_rr_descriptor_minimum(self)
#parameters: const ldns_rr_descriptor *,
#retvals: size_t
- #_LDNS_RR_DESCRIPTOR_METHODS#
- %}
+ #
+ # _LDNS_RR_DESCRIPTOR_METHODS
+ #
+ %}
}
-/*
-rrsig checking wrappers
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
- copying of rr pointers into the good_keys list leads to double free
- problems, therefore we provide two options - either ignore the keys
- or get list of indexes of the keys. The latter allows fetching of the
- keys later on from the original key set
-*/
+
+/*
+ * rrsig checking wrappers
+ *
+ * Copying of rr pointers into the good_keys list leads to double free
+ * problems, therefore we provide two options - either ignore the keys
+ * or get list of indexes of the keys. The latter allows fetching of the
+ * keys later on from the original key set.
+ */
%rename(__ldns_verify_rrsig_keylist) ldns_verify_rrsig_keylist;
-%inline %{
-ldns_status ldns_verify_rrsig_keylist_status_only(ldns_rr_list *rrset,
- ldns_rr *rrsig,
- const ldns_rr_list *keys) {
+%inline
+%{
+ ldns_status ldns_verify_rrsig_keylist_status_only(ldns_rr_list *rrset,
+ ldns_rr *rrsig, const ldns_rr_list *keys)
+ {
ldns_rr_list *good_keys = ldns_rr_list_new();
- ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys, good_keys);
+ ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys,
+ good_keys);
ldns_rr_list_free(good_keys);
return status;
-}
+ }
%}
%rename(__ldns_verify_rrsig_keylist) ldns_verify_rrsig_keylist;
-%inline %{
-PyObject* ldns_verify_rrsig_keylist_(ldns_rr_list *rrset,
- ldns_rr *rrsig,
- const ldns_rr_list *keys) {
- PyObject* tuple;
- PyObject* keylist;
- ldns_rr_list *good_keys = ldns_rr_list_new();
- ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys, good_keys);
-
- tuple = PyTuple_New(2);
- PyTuple_SetItem(tuple, 0, SWIG_From_int(status));
- keylist = PyList_New(0);
- if (status == LDNS_STATUS_OK) {
- unsigned int i;
- for (i = 0; i < ldns_rr_list_rr_count(keys); i++)
- if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i)))
- PyList_Append(keylist, SWIG_From_int(i));
- }
- PyTuple_SetItem(tuple, 1, keylist);
- ldns_rr_list_free(good_keys);
- return tuple;
- }
+%inline
+%{
+ PyObject* ldns_verify_rrsig_keylist_(ldns_rr_list *rrset,
+ ldns_rr *rrsig, const ldns_rr_list *keys)
+ {
+ PyObject* tuple;
+ PyObject* keylist;
+ ldns_rr_list *good_keys = ldns_rr_list_new();
+ ldns_status status = ldns_verify_rrsig_keylist(rrset, rrsig, keys,
+ good_keys);
+
+ tuple = PyTuple_New(2);
+ PyTuple_SetItem(tuple, 0, SWIG_From_int(status));
+ keylist = PyList_New(0);
+ if (status == LDNS_STATUS_OK) {
+ unsigned int i;
+ for (i = 0; i < ldns_rr_list_rr_count(keys); i++) {
+ if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i))) {
+ PyList_Append(keylist, SWIG_From_int(i));
+ }
+ }
+ }
+ PyTuple_SetItem(tuple, 1, keylist);
+ ldns_rr_list_free(good_keys);
+ return tuple;
+ }
%}
%rename(__ldns_verify_rrsig_keylist_notime) ldns_verify_rrsig_keylist_notime;
-%inline %{
-ldns_status ldns_verify_rrsig_keylist_notime_status_only(ldns_rr_list *rrset,
- ldns_rr *rrsig,
- const ldns_rr_list *keys) {
+%inline
+%{
+ ldns_status ldns_verify_rrsig_keylist_notime_status_only(ldns_rr_list *rrset,
+ ldns_rr *rrsig, const ldns_rr_list *keys)
+ {
ldns_rr_list *good_keys = ldns_rr_list_new();
- ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys, good_keys);
+ ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys,
+ good_keys);
ldns_rr_list_free(good_keys);
return status;
-}
+ }
%}
%rename(__ldns_verify_rrsig_keylist_notime) ldns_verify_rrsig_keylist_notime;
-%inline %{
-PyObject* ldns_verify_rrsig_keylist_notime_(ldns_rr_list *rrset,
- ldns_rr *rrsig,
- const ldns_rr_list *keys) {
- PyObject* tuple;
- PyObject* keylist;
- ldns_rr_list *good_keys = ldns_rr_list_new();
- ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys, good_keys);
-
- tuple = PyTuple_New(2);
- PyTuple_SetItem(tuple, 0, SWIG_From_int(status));
- keylist = PyList_New(0);
- if (status == LDNS_STATUS_OK) {
- unsigned int i;
- for (i = 0; i < ldns_rr_list_rr_count(keys); i++)
- if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i)))
- PyList_Append(keylist, SWIG_From_int(i));
- }
- PyTuple_SetItem(tuple, 1, keylist);
- ldns_rr_list_free(good_keys);
- return tuple;
- }
+%inline
+%{
+ PyObject* ldns_verify_rrsig_keylist_notime_(ldns_rr_list *rrset,
+ ldns_rr *rrsig, const ldns_rr_list *keys)
+ {
+ PyObject* tuple;
+ PyObject* keylist;
+ ldns_rr_list *good_keys = ldns_rr_list_new();
+ ldns_status status = ldns_verify_rrsig_keylist_notime(rrset, rrsig, keys,
+ good_keys);
+
+ tuple = PyTuple_New(2);
+ PyTuple_SetItem(tuple, 0, SWIG_From_int(status));
+ keylist = PyList_New(0);
+ if (status == LDNS_STATUS_OK) {
+ unsigned int i;
+ for (i = 0; i < ldns_rr_list_rr_count(keys); i++) {
+ if (ldns_rr_list_contains_rr(good_keys, ldns_rr_list_rr(keys, i))) {
+ PyList_Append(keylist, SWIG_From_int(i));
+ }
+ }
+ }
+ PyTuple_SetItem(tuple, 1, keylist);
+ ldns_rr_list_free(good_keys);
+ return tuple;
+ }
%}
-/* -- end of rrsig checking wrappers */
-
+/* End of rrsig checking wrappers. */