]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/python/ldns_rdf.i
import ldns 1.6.16
[FreeBSD/FreeBSD.git] / contrib / python / ldns_rdf.i
1 /******************************************************************************
2  * ldns_rdf.i: LDNS record data
3  *
4  * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
5  *                     Karel Slany    (slany AT fit.vutbr.cz)
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are met:
10  *
11  *     * Redistributions of source code must retain the above copyright notice,
12  *       this list of conditions and the following disclaimer.
13  *     * Redistributions in binary form must reproduce the above copyright
14  *       notice, this list of conditions and the following disclaimer in the
15  *       documentation and/or other materials provided with the distribution.
16  *     * Neither the name of the organization nor the names of its
17  *       contributors may be used to endorse or promote products derived from
18  *       this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *****************************************************************************/
32
33
34 /* ========================================================================= */
35 /* SWIG setting and definitions. */
36 /* ========================================================================= */
37
38 /* Creates a temporary instance of (ldns_rdf *). */
39 %typemap(in, numinputs=0, noblock=1) (ldns_rdf **)
40 {
41   ldns_rdf *$1_rdf = NULL;
42   $1 = &$1_rdf;
43 }
44           
45 /* Result generation, appends (ldns_rdf *) after the result. */
46 %typemap(argout, noblock=1) (ldns_rdf **)
47 {
48   $result = SWIG_Python_AppendOutput($result,
49     SWIG_NewPointerObj(SWIG_as_voidptr($1_rdf),
50       SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0));
51 }
52
53 /*
54  * Automatic conversion of const (ldns_rdf *) parameter from string.
55  * Argument default value.
56  */
57 %typemap(arginit, noblock=1) const ldns_rdf *
58 {
59   char *$1_str = NULL;
60 }
61
62 /*
63  * Automatic conversion of const (ldns_rdf *) parameter from string.
64  * Preparation of arguments.
65  */
66 %typemap(in, noblock=1) const ldns_rdf * (void* argp, $1_ltype tmp = 0, int res)
67 {
68   if (Python_str_Check($input)) {
69     $1_str = SWIG_Python_str_AsChar($input);
70     if ($1_str == NULL) {
71       %argument_fail(SWIG_TypeError, "char *", $symname, $argnum);
72     }
73     tmp = ldns_dname_new_frm_str($1_str);
74     if (tmp == NULL) {
75       %argument_fail(SWIG_TypeError, "char *", $symname, $argnum);
76     }
77     $1 = ($1_ltype) tmp;
78   } else {
79     res = SWIG_ConvertPtr($input, &argp, SWIGTYPE_p_ldns_struct_rdf, 0 | 0);
80     if (!SWIG_IsOK(res)) {
81       %argument_fail(res, "ldns_rdf const *", $symname, $argnum);
82     }
83     $1 = ($1_ltype) argp;
84   }
85 }
86
87 /*
88  * Automatic conversion of const (ldns_rdf *) parameter from string.
89  * Freeing of allocated memory (in Python 3 when daling with strings).
90  */
91 %typemap(freearg, noblock=1) const ldns_rdf *
92 {
93   if ($1_str != NULL) {
94     /* Is not NULL only when a conversion form string occurred. */
95     SWIG_Python_str_DelForPy3($1_str); /* Is a empty macro for Python < 3. */
96   }
97 }
98
99 %nodefaultctor ldns_struct_rdf; /* No default constructor. */
100 %nodefaultdtor ldns_struct_rdf; /* No default destructor. */
101
102
103 /*
104  * This file must contain all %newobject and %delobject tags also for
105  * ldns_dname. This is because the ldns_dname is a derived class from ldns_rdf.
106  */
107
108
109 %newobject ldns_rdf_new;
110 %newobject ldns_rdf_new_frm_str;
111 %newobject ldns_rdf_new_frm_data;
112
113 %newobject ldns_rdf_address_reverse;
114 %newobject ldns_rdf_clone;
115 %newobject ldns_rdf2str;
116
117 %newobject ldns_dname_new;
118 %newobject ldns_dname_new_frm_str;
119 %newobject ldns_dname_new_frm_data;
120
121 %newobject ldns_dname_cat_clone;
122 %newobject ldns_dname_label;
123 %newobject ldns_dname_left_chop;
124 %newobject ldns_dname_reverse;
125
126 %delobject ldns_rdf_deep_free;
127 %delobject ldns_rdf_free;
128
129
130 /*
131  * Should the ldns_rdf_new() also be marked as deleting its data parameter?
132  */
133 %delobject ldns_rdf_set_data; /* Because data are directly coupled into rdf. */
134
135 %rename(ldns_rdf) ldns_struct_rdf;
136
137
138 /* ========================================================================= */
139 /* Debugging related code. */
140 /* ========================================================================= */
141
142 #ifdef LDNS_DEBUG
143 %rename(__ldns_rdf_deep_free) ldns_rdf_deep_free;
144 %rename(__ldns_rdf_free) ldns_rdf_free;
145 %inline
146 %{
147   /*!
148    * @brief Prints information about deallocated rdf and deallocates.
149    */
150   void _ldns_rdf_deep_free (ldns_rdf *r)
151   {
152     printf("******** LDNS_RDF deep free 0x%lX ************\n",
153       (long unsigned int) r);
154     ldns_rdf_deep_free(r);
155   }
156
157   /*!
158    * @brief Prints information about deallocated rdf and deallocates.
159    */
160   void _ldns_rdf_free (ldns_rdf* r)
161   {
162     printf("******** LDNS_RDF free 0x%lX ************\n",
163       (long unsigned int) r);
164     ldns_rdf_free(r);
165   }
166 %}
167 #else /* !LDNS_DEBUG */
168 %rename(_ldns_rdf_deep_free) ldns_rdf_deep_free;
169 %rename(_ldns_rdf_free) ldns_rdf_free;
170 #endif /* LDNS_DEBUG */
171
172
173 /* ========================================================================= */
174 /* Added C code. */
175 /* ========================================================================= */
176
177
178 %inline
179 %{
180         /*!
181          * @brief returns a human readable string containing rdf type.
182          */
183         const char *ldns_rdf_type2str(const ldns_rdf *rdf)
184         {
185                 if (rdf) {
186                         switch(ldns_rdf_get_type(rdf)) {
187                         case LDNS_RDF_TYPE_NONE:       return 0;
188                         case LDNS_RDF_TYPE_DNAME:      return "DNAME";
189                         case LDNS_RDF_TYPE_INT8:       return "INT8";
190                         case LDNS_RDF_TYPE_INT16:      return "INT16";
191                         case LDNS_RDF_TYPE_INT32:      return "INT32";
192                         case LDNS_RDF_TYPE_A:          return "A";
193                         case LDNS_RDF_TYPE_AAAA:       return "AAAA";
194                         case LDNS_RDF_TYPE_STR:        return "STR";
195                         case LDNS_RDF_TYPE_APL:        return "APL";
196                         case LDNS_RDF_TYPE_B32_EXT:    return "B32_EXT";
197                         case LDNS_RDF_TYPE_B64:        return "B64";
198                         case LDNS_RDF_TYPE_HEX:        return "HEX";
199                         case LDNS_RDF_TYPE_NSEC:       return "NSEC";
200                         case LDNS_RDF_TYPE_TYPE:       return "TYPE";
201                         case LDNS_RDF_TYPE_CLASS:      return "CLASS";
202                         case LDNS_RDF_TYPE_CERT_ALG:   return "CER_ALG";
203                         case LDNS_RDF_TYPE_ALG:        return "ALG";
204                         case LDNS_RDF_TYPE_UNKNOWN:    return "UNKNOWN";
205                         case LDNS_RDF_TYPE_TIME:       return "TIME";
206                         case LDNS_RDF_TYPE_PERIOD:     return "PERIOD";
207                         case LDNS_RDF_TYPE_TSIGTIME:   return "TSIGTIME";
208                         case LDNS_RDF_TYPE_TSIG:       return "TSIG";
209                         case LDNS_RDF_TYPE_INT16_DATA: return "INT16_DATA";
210                         case LDNS_RDF_TYPE_SERVICE:    return "SERVICE";
211                         case LDNS_RDF_TYPE_LOC:        return "LOC";
212                         case LDNS_RDF_TYPE_WKS:        return "WKS";
213                         case LDNS_RDF_TYPE_NSAP:       return "NSAP";
214                         case LDNS_RDF_TYPE_ATMA:       return "ATMA";
215                         case LDNS_RDF_TYPE_IPSECKEY:   return "IPSECKEY";
216                         case LDNS_RDF_TYPE_NSEC3_SALT: return "NSEC3_SALT";
217                         case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
218                             return "NSEC3_NEXT_OWNER";
219                         }
220                 }
221                 return 0;
222         }
223 %}
224
225
226 /* ========================================================================= */
227 /* Encapsulating Python code. */
228 /* ========================================================================= */
229
230 %feature("docstring") ldns_struct_rdf "Resource record data field.
231
232 The data is a network ordered array of bytes, which size is specified
233 by the (16-bit) size field. To correctly parse it, use the type
234 specified in the (16-bit) type field with a value from ldns_rdf_type."
235
236 %extend ldns_struct_rdf {
237  
238   %pythoncode
239   %{
240         def __init__(self):
241             """
242                Cannot be created directly from Python.
243             """
244             raise Exception("This class can't be created directly. " +
245                 "Please use: ldns_rdf_new, ldns_rdf_new_frm_data, " +
246                 "ldns_rdf_new_frm_str, ldns_rdf_new_frm_fp, " +
247                 "ldns_rdf_new_frm_fp_l")
248        
249         __swig_destroy__ = _ldns._ldns_rdf_deep_free
250
251         #
252         # LDNS_RDF_CONSTRUCTORS_
253         #
254
255         @staticmethod
256         def new_frm_str(string, rr_type, raiseException = True):
257             """
258                Creates a new rdf from a string of a given type.
259                
260                :param string: string to use
261                :type string: string
262                :param rr_type: The type of the rdf. See predefined `RDF_TYPE_`
263                    constants.
264                :type rr_type: integer
265                :param raiseException: If True, an exception occurs in case
266                    a RDF object can't be created.
267                :type raiseException: bool
268                :throws TypeError: When parameters of mismatching types.
269                :throws Exception: When raiseException set and rdf couldn't
270                    be created.
271                :return: :class:`ldns_rdf` object or None. If the object
272                    can't be created and `raiseException` is True,
273                    an exception occurs.
274
275                **Usage**
276
277                    >>> rdf = ldns.ldns_rdf.new_frm_str("74.125.43.99", ldns.LDNS_RDF_TYPE_A)
278                    >>> print rdf, rdf.get_type_str()
279                    A 74.125.43.99
280                    >>> name = ldns.ldns_resolver.new_frm_file().get_name_by_addr(rdf)
281                    >>> if (name): print name
282                    99.43.125.74.in-addr.arpa.   85277   IN      PTR     bw-in-f99.google.com.
283             """
284             rr = _ldns.ldns_rdf_new_frm_str(rr_type, string)
285             if (not rr) and raiseException:
286                 raise Exception("Can't create query packet, " +
287                     "error: %d" % status)
288             return rr
289
290         #
291         # _LDNS_RDF_CONSTRUCTORS
292         #
293
294         def __str__(self):
295             """
296                Converts the rdata field to presentation format.
297             """
298             return _ldns.ldns_rdf2str(self)
299
300         def __cmp__(self, other):
301             """
302                Compares two rdfs on their wire formats.
303                
304                (To order dnames according to rfc4034, use ldns_dname_compare.)
305                
306                :param other: The second one RDF.
307                :type other: :class:`ldns_rdf`
308                :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
309                :return: (int) -1, 0 or 1 if self comes before other,
310                    is equal or self comes after other respectively.
311             """
312             return _ldns.ldns_rdf_compare(self, other)
313
314         def __lt__(self, other):
315             """
316                 Compares two rdfs on their formats.
317
318                 :param other: The socond one RDF.
319                 :type other: :class:`ldns_rdf`
320                 :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
321                 :return: (bool) True when `self` is less than 'other'.
322             """
323             return _ldns.ldns_rdf_compare(self, other) == -1
324
325         def __le__(self, other):
326             """
327                 Compares two rdfs on their formats.
328
329                 :param other: The socond one RDF.
330                 :type other: :class:`ldns_rdf`
331                 :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
332                 :return: (bool) True when `self` is less than or equal to
333                     'other'.
334             """
335             return _ldns.ldns_rdf_compare(self, other) != 1
336
337         def __eq__(self, other):
338             """
339                 Compares two rdfs on their formats.
340
341                 :param other: The socond one RDF.
342                 :type other: :class:`ldns_rdf`
343                 :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
344                 :return: (bool) True when `self` is equal to 'other'.
345             """
346             return _ldns.ldns_rdf_compare(self, other) == 0
347
348         def __ne__(self, other):
349             """
350                 Compares two rdfs on their formats.
351
352                 :param other: The socond one RDF.
353                 :type other: :class:`ldns_rdf`
354                 :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
355                 :return: (bool) True when `self` is not equal to 'other'.
356             """
357             return _ldns.ldns_rdf_compare(self, other) != 0
358
359         def __gt__(self, other):
360             """
361                 Compares two rdfs on their formats.
362
363                 :param other: The socond one RDF.
364                 :type other: :class:`ldns_rdf`
365                 :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
366                 :return: (bool) True when `self` is greater than 'other'.
367             """
368             return _ldns.ldns_rdf_compare(self, other) == 1
369
370         def __ge__(self, other):
371             """
372                 Compares two rdfs on their formats.
373
374                 :param other: The socond one RDF.
375                 :type other: :class:`ldns_rdf`
376                 :throws TypeError: When `other` of non-:class:`ldns_rdf` type.
377                 :return: (bool) True when `self` is greater than or equal to
378                     'other'.
379             """
380             return _ldns.ldns_rdf_compare(self, other) != -1
381
382         def print_to_file(self, output):
383             """
384                Prints the data in the rdata field to the given `output` file
385                stream (in presentation format).
386             """
387             _ldns.ldns_rdf_print(output, self)
388
389         def get_type_str(self):
390             """
391                Returns the type of the rdf as a human readable string.
392
393                :return: String containing rdf type.
394             """
395             return ldns_rdf_type2str(self)
396
397         def write_to_buffer(self, buffer):
398             """
399                Copies the rdata data to the buffer in wire format.
400                
401                :param buffer: Buffer to append the rdf to.
402                :type param: :class:`ldns_buffer`
403                :throws TypeError: When `buffer` of non-:class:`ldns_buffer`
404                    type.
405                :return: (ldns_status) ldns_status
406             """
407             return _ldns.ldns_rdf2buffer_wire(buffer, self)
408             #parameters: ldns_buffer *, const ldns_rdf *,
409             #retvals: ldns_status
410
411         def write_to_buffer_canonical(self, buffer):
412             """
413                Copies the rdata data to the buffer in wire format.
414                If the rdata is a dname, the letters will be converted
415                to lower case during the conversion.
416                
417                :param buffer: LDNS buffer.
418                :type buffer: :class:`ldns_buffer`
419                :throws TypeError: When `buffer` of non-:class:`ldns_buffer`
420                    type.
421                :return: (ldns_status) ldns_status
422             """
423             return _ldns.ldns_rdf2buffer_wire_canonical(buffer, self)
424             #parameters: ldns_buffer *, const ldns_rdf *,
425             #retvals: ldns_status
426
427         #
428         # LDNS_RDF_METHODS_
429         #
430
431         def address_reverse(self):
432             """
433                Reverses an rdf, only actually useful for AAAA and A records.
434                
435                The returned rdf has the type LDNS_RDF_TYPE_DNAME!
436                
437                :return: (:class:`ldns_rdf`) The reversed rdf
438                    (a newly created rdf).
439             """
440             return _ldns.ldns_rdf_address_reverse(self)
441             #parameters: ldns_rdf *,
442             #retvals: ldns_rdf *
443
444         def clone(self):
445             """
446                Clones a rdf structure.
447                
448                The data are copied.
449                
450                :return: (:class:`ldns_rdf`) A new rdf structure.
451             """
452             return _ldns.ldns_rdf_clone(self)
453             #parameters: const ldns_rdf *,
454             #retvals: ldns_rdf *
455
456         def data(self):
457             """
458                Returns the data of the rdf.
459                
460                :return: (uint8_t \*) uint8_t* pointer to the rdf's data.
461             """
462             return _ldns.ldns_rdf_data(self)
463             #parameters: const ldns_rdf *,
464             #retvals: uint8_t *
465
466         def get_type(self):
467             """
468                Returns the type of the rdf.
469                
470                We need to prepend the prefix get_ here to prevent conflict
471                with the rdf_type TYPE.
472                
473                :return: (ldns_rdf_type) Identifier of the type.
474             """
475             return _ldns.ldns_rdf_get_type(self)
476             #parameters: const ldns_rdf *,
477             #retvals: ldns_rdf_type
478
479         def set_data(self, data):
480             """
481                Sets the data portion of the rdf.
482
483                The data are not copied, but are assigned to the rdf,
484                `data` are decoupled from the Python engine.
485                
486                :param data: Data to be set.
487                :type data: void \*
488             """
489             _ldns.ldns_rdf_set_data(self, data)
490             #parameters: ldns_rdf *, void *,
491             #retvals: 
492
493         def set_size(self, size):
494             """
495                Sets the size of the rdf.
496                
497                :param size: The new size.
498                :type size: integer
499                :throws TypeError: When size of non-integer type.
500             """
501             _ldns.ldns_rdf_set_size(self,size)
502             #parameters: ldns_rdf *,size_t,
503             #retvals: 
504
505         def set_type(self, atype):
506             """
507                Sets the type of the rdf.
508                
509                :param atype: rdf type
510                :type atype: integer
511                :throws TypeError: When atype of non-integer type.
512             """
513             _ldns.ldns_rdf_set_type(self, atype)
514             #parameters: ldns_rdf *, ldns_rdf_type,
515             #retvals: 
516
517         def size(self):
518             """
519                Returns the size of the rdf.
520                
521                :return: (size_t) uint16_t with the size.
522             """
523             return _ldns.ldns_rdf_size(self)
524             #parameters: const ldns_rdf *,
525             #retvals: size_t
526
527         @staticmethod
528         def dname_new_frm_str(string):
529             """
530                Creates a new dname rdf instance from a given string.
531             
532                This static method is equivalent to using of default
533                :class:`ldns_rdf` constructor.
534  
535                :parameter string: String to use.
536                :type string: string
537                :throws TypeError: When not a string used.
538                :return: :class:`ldns_rdf` or None if error.
539
540                .. warning::
541
542                    It is scheduled to be deprecated and removed. Use
543                    :class:`ldns_dname` constructor instead.
544             """
545             warnings.warn("The ldns_rdf.dname_new_frm_str() method is" +
546                 " scheduled to be deprecated in future releases." +
547                 " Use ldsn_dname constructor instead.",
548                 PendingDeprecationWarning, stacklevel=2)
549             return _ldns.ldns_dname_new_frm_str(string)
550
551         def absolute(self):
552             """
553                Checks whether the given dname string is absolute
554                (i.e., ends with a '.').
555
556                :return: (bool) True or False
557
558                .. note::
559
560                    This method was malfunctioning in ldns-1.3.16 and also
561                    possibly earlier.
562
563                .. warning::
564
565                    It is scheduled to be deprecated and removed. Convert
566                    :class:`ldns_rdf` to :class:`ldns_dname` to use the method.
567             """
568             warnings.warn("The ldns_rdf.absolute() method is scheduled" +
569                 " to be deprecated in future releases." +
570                 " Convert the ldns_rdf to ldsn_dname and the use its" +
571                 " methods.", PendingDeprecationWarning, stacklevel=2)
572             if self.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
573                 string = self.__str__()
574                 return _ldns.ldns_dname_str_absolute(string) != 0
575             else:
576                 return False
577
578         def make_canonical(self):
579             """
580                Put a dname into canonical format (i.e., convert to lower case).
581
582                Performs no action if not a dname.
583
584                .. warning::
585
586                    This method is scheduled to be deprecated and removed.
587                    Convert :class:`ldns_rdf` to :class:`ldns_dname` to use
588                    the method.
589             """
590             warnings.warn("The ldns_rdf.make_canonical() method is scheduled" +
591                 " to be deprecated in future releases." +
592                 " Convert the ldns_rdf to ldsn_dname and the use its" +
593                 " methods.", PendingDeprecationWarning, stacklevel=2)
594             _ldns.ldns_dname2canonical(self)
595
596         def dname_compare(self, other):
597             """
598                Compares two dname rdf according to the algorithm
599                for ordering in RFC4034 Section 6.
600
601                :param other: The second dname rdf to compare.
602                :type other: :class:`ldns_rdf`
603                :throws TypeError: When not a :class:`ldns_rdf` used.
604                :throws Exception: When not dnames compared.
605                :return: (int) -1, 0 or 1 if `self` comes before `other`,
606                    `self` is equal or `self` comes after `other` respectively.
607
608                .. warning::
609
610                    It is scheduled to be deprecated and removed. Convert
611                    :class:`ldns_rdf` to :class:`ldns_dname`.
612             """
613             warnings.warn("The ldns_rdf.dname_compare() method is" +
614                 " scheduled to be deprecated in future releases." +
615                 " Convert the ldns_rdf to ldsn_dname and the use its" +
616                 " methods.", PendingDeprecationWarning, stacklevel=2)
617             #
618             # The wrapped function generates asserts instead of setting
619             # error status. They cannot be caught from Python so a check
620             # is necessary. 
621             #
622             if not isinstance(other, ldns_rdf):
623                 raise TypeError("Parameter must be derived from ldns_rdf.")
624             if (self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \
625                (other.get_type() != _ldns.LDNS_RDF_TYPE_DNAME):
626                 raise Exception("Both operands must be dname rdfs.")
627             return _ldns.ldns_dname_compare(self, other)
628
629         def cat(self, rd2):
630             """
631                Concatenates `rd2` after `this` dname (`rd2` is copied,
632                `this` dname is modified).
633                
634                :param rd2: The right-hand side.
635                :type rd2: :class:`ldns_rdf`
636                :throws TypeError: When `rd2` of non-:class:`ldns_rdf` or
637                    non-:class:`ldns_dname` type.
638                :return: (ldns_status) LDNS_STATUS_OK on success.
639
640                .. warning::
641
642                   It is scheduled to be deprecated and removed. Convert
643                   :class:`ldns_rdf` to :class:`ldns_dname`.
644             """
645             warnings.warn("The ldns_rdf.cat() method is scheduled" +
646                 " to be deprecated in future releases." +
647                 " Convert the ldns_rdf to ldsn_dname and the use its" +
648                 " methods.", PendingDeprecationWarning, stacklevel=2)
649             return _ldns.ldns_dname_cat(self, rd2)
650             #parameters: ldns_rdf *, ldns_rdf *,
651             #retvals: ldns_status
652
653         def cat_clone(self, rd2):
654             """
655                Concatenates two dnames together.
656
657                :param rd2: The right-hand side.
658                :type rd2: :class:`ldns_rdf`
659                :throws TypeError: When `rd2` of non-:class:`ldns_rdf` or
660                    non-:class:`ldns_dname` type.
661                :return: (:class:`ldns_rdf`) A new rdf with
662                    left-hand side + right-hand side content None when
663                    error.
664
665                .. warning::
666
667                    It is scheduled to be deprecated and removed. Convert
668                    :class:`ldns_rdf` to :class:`ldns_dname`.
669             """
670             warnings.warn("The ldns_rdf.cat_clone() method is scheduled" +
671                 " to be deprecated in future releases." +
672                 " Convert the ldns_rdf to ldsn_dname and the use its" +
673                 " methods.", PendingDeprecationWarning, stacklevel=2)
674             return _ldns.ldns_dname_cat_clone(self, rd2)
675             #parameters: const ldns_rdf *, const ldns_rdf *,
676             #retvals: ldns_rdf *
677
678         def interval(self, middle, next):
679             """
680                Check whether the `middle` lays in the interval defined by
681                `this` and `next` (`this` <= `middle` < `next`).
682
683                This method is useful for nsec checking
684
685                :param middle: The dname to check.
686                :type middle: :class:`ldns_rdf`
687                :param next: The boundary.
688                :type next: :class:`ldns_rdf`
689                :throws TypeError: When `middle` or `next` of
690                    non-:class:`ldns_rdf` type.
691                :throws Exception: When non-dname rdfs compared.
692                :return: (int) 0 on error or unknown,
693                    -1 when middle is in the interval, 1 when not.
694
695                .. warning::
696
697                    It is scheduled to be deprecated and removed. Convert
698                    :class:`ldns_rdf` to :class:`ldns_dname`.
699             """
700             warnings.warn("The ldns_rdf.interval() method is scheduled" +
701                 " to be deprecated in future releases." +
702                 " Convert the ldns_rdf to ldsn_dname and the use its" +
703                 " methods.", PendingDeprecationWarning, stacklevel=2)
704             #
705             # The wrapped function generates asserts instead of setting
706             # error status. They cannot be caught from Python so a check
707             # is necessary. 
708             #
709             if (not isinstance(middle, ldns_rdf)) or \
710                (not isinstance(next, ldns_rdf)):
711                 raise TypeError("Parameters must be derived from ldns_rdf.")
712             if (self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \
713                (middle.get_type() != _ldns.LDNS_RDF_TYPE_DNAME) or \
714                (next.get_type() != _ldns.LDNS_RDF_TYPE_DNAME):
715                 raise Exception("All operands must be dname rdfs.")
716             return _ldns.ldns_dname_interval(self, middle, next)
717             #parameters: const ldns_rdf *, const ldns_rdf *, const ldns_rdf *,
718             #retvals: int
719
720         def is_subdomain(self, parent):
721             """
722                Tests whether the name of the given instance falls under
723                `parent` (i.e., is a sub-domain of `parent`).
724
725                This function will return False if the given dnames
726                are equal.
727                
728                :param parent: The parent's name.
729                :type parent: :class:`ldns_rdf`
730                :throws TypeError: When `parent` of non-:class:`ldns_rdf` type.
731                :return: (bool) True if `this` falls under `parent`, otherwise
732                    False.
733
734                .. warning::
735
736                    It is scheduled to be deprecated and removed. Convert
737                    :class:`ldns_rdf` to :class:`ldns_dname`.
738             """
739             warnings.warn("The ldns_rdf.is_subdomain() method is scheduled" +
740                 " to be deprecated in future releases." +
741                 " Convert the ldns_rdf to ldsn_dname and the use its" +
742                 " methods.", PendingDeprecationWarning, stacklevel=2)
743             return _ldns.ldns_dname_is_subdomain(self, parent)
744             #parameters: const ldns_rdf *, const ldns_rdf *,
745             #retvals: bool
746
747         def label(self, labelpos):
748             """
749                Look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try
750                and retrieve a specific label.
751                
752                The labels are numbered starting from 0 (left most).
753                
754                :param labelpos: Index of the label. (Labels are numbered
755                    0, which is the left most.)
756                :type labelpos: integer
757                :throws TypeError: When `labelpos` of non-integer type.
758                :return: (:class:`ldns_rdf`) A new rdf with the label
759                    as name or None on error.
760
761                .. warning::
762
763                    It is scheduled to be deprecated and removed. Convert
764                    :class:`ldns_rdf` to :class:`ldns_dname`.
765             """
766             warnings.warn("The ldns_rdf.label() method is scheduled" +
767                 " to be deprecated in future releases." +
768                 " Convert the ldns_rdf to ldsn_dname and the use its" +
769                 " methods.", PendingDeprecationWarning, stacklevel=2)
770             return _ldns.ldns_dname_label(self, labelpos)
771             #parameters: const ldns_rdf *, uint8_t,
772             #retvals: ldns_rdf *
773
774         def label_count(self):
775             """
776                Count the number of labels inside a LDNS_RDF_DNAME type rdf.
777                
778                :return: (uint8_t) The number of labels. Will return 0 if
779                    not a dname.
780
781                .. warning::
782
783                    It is scheduled to be deprecated and removed. Convert
784                    :class:`ldns_rdf` to :class:`ldns_dname`.
785             """
786             warnings.warn("The ldns_rdf.label_count() method is scheduled" +
787                 " to be deprecated in future releases." +
788                 " Convert the ldns_rdf to ldsn_dname and the use its" +
789                 " methods.", PendingDeprecationWarning, stacklevel=2)
790             return _ldns.ldns_dname_label_count(self)
791             #parameters: const ldns_rdf *,
792             #retvals: uint8_t
793
794         def left_chop(self):
795             """
796                Chop one label off the left side of a dname.
797                
798                (e.g., wwww.nlnetlabs.nl, becomes nlnetlabs.nl)
799                
800                :return: (:class:`ldns_rdf`) The remaining dname or None when
801                    error.
802
803                .. warning::
804
805                    It is scheduled to be deprecated and removed. Convert
806                    :class:`ldns_rdf` to :class:`ldns_dname`.
807             """
808             warnings.warn("The ldns_rdf.left_chop() method is scheduled" +
809                 " to be deprecated in future releases." +
810                 " Convert the ldns_rdf to ldsn_dname and the use its" +
811                 " methods.", PendingDeprecationWarning, stacklevel=2)
812             return _ldns.ldns_dname_left_chop(self)
813             #parameters: const ldns_rdf *,
814             #retvals: ldns_rdf *
815
816         def reverse(self):
817             """
818                Returns a clone of the given dname with the labels reversed.
819
820                When reversing non-dnames a "." (root name) dname is returned.
821                
822                :return: (:class:`ldns_rdf`) Clone of the dname with the labels
823                    reversed or ".".
824
825                .. warning::
826
827                    It is scheduled to be deprecated and removed. Convert
828                    :class:`ldns_rdf` to :class:`ldns_dname`.
829             """
830             warnings.warn("The ldns_rdf.reverse() method is scheduled" +
831                 " to be deprecated in future releases." +
832                 " Convert the ldns_rdf to ldsn_dname and the use its" +
833                 " methods.", PendingDeprecationWarning, stacklevel=2)
834             return _ldns.ldns_dname_reverse(self)
835             #parameters: const ldns_rdf *,
836             #retvals: ldns_rdf *
837
838         #
839         # _LDNS_RDF_METHODS
840         #
841   %}
842