1 /******************************************************************************
2 * ldns_rdf.i: LDNS record data
4 * Copyright (c) 2009, Zdenek Vasicek (vasicek AT fit.vutbr.cz)
5 * Karel Slany (slany AT fit.vutbr.cz)
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
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.
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 *****************************************************************************/
34 /* ========================================================================= */
35 /* SWIG setting and definitions. */
36 /* ========================================================================= */
38 /* Creates a temporary instance of (ldns_rdf *). */
39 %typemap(in, numinputs=0, noblock=1) (ldns_rdf **)
41 ldns_rdf *$1_rdf = NULL;
45 /* Result generation, appends (ldns_rdf *) after the result. */
46 %typemap(argout, noblock=1) (ldns_rdf **)
48 $result = SWIG_Python_AppendOutput($result,
49 SWIG_NewPointerObj(SWIG_as_voidptr($1_rdf),
50 SWIGTYPE_p_ldns_struct_rdf, SWIG_POINTER_OWN | 0));
54 * Automatic conversion of const (ldns_rdf *) parameter from string.
55 * Argument default value.
57 %typemap(arginit, noblock=1) const ldns_rdf *
63 * Automatic conversion of const (ldns_rdf *) parameter from string.
64 * Preparation of arguments.
66 %typemap(in, noblock=1) const ldns_rdf * (void* argp, $1_ltype tmp = 0, int res)
68 if (Python_str_Check($input)) {
69 $1_str = SWIG_Python_str_AsChar($input);
71 %argument_fail(SWIG_TypeError, "char *", $symname, $argnum);
73 tmp = ldns_dname_new_frm_str($1_str);
75 %argument_fail(SWIG_TypeError, "char *", $symname, $argnum);
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);
88 * Automatic conversion of const (ldns_rdf *) parameter from string.
89 * Freeing of allocated memory (in Python 3 when daling with strings).
91 %typemap(freearg, noblock=1) const ldns_rdf *
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. */
99 %nodefaultctor ldns_struct_rdf; /* No default constructor. */
100 %nodefaultdtor ldns_struct_rdf; /* No default destructor. */
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.
109 %newobject ldns_rdf_new;
110 %newobject ldns_rdf_new_frm_str;
111 %newobject ldns_rdf_new_frm_data;
113 %newobject ldns_rdf_address_reverse;
114 %newobject ldns_rdf_clone;
115 %newobject ldns_rdf2str;
117 %newobject ldns_dname_new;
118 %newobject ldns_dname_new_frm_str;
119 %newobject ldns_dname_new_frm_data;
121 %newobject ldns_dname_cat_clone;
122 %newobject ldns_dname_label;
123 %newobject ldns_dname_left_chop;
124 %newobject ldns_dname_reverse;
126 %delobject ldns_rdf_deep_free;
127 %delobject ldns_rdf_free;
131 * Should the ldns_rdf_new() also be marked as deleting its data parameter?
133 %delobject ldns_rdf_set_data; /* Because data are directly coupled into rdf. */
135 %rename(ldns_rdf) ldns_struct_rdf;
138 /* ========================================================================= */
139 /* Debugging related code. */
140 /* ========================================================================= */
143 %rename(__ldns_rdf_deep_free) ldns_rdf_deep_free;
144 %rename(__ldns_rdf_free) ldns_rdf_free;
148 * @brief Prints information about deallocated rdf and deallocates.
150 void _ldns_rdf_deep_free (ldns_rdf *r)
152 printf("******** LDNS_RDF deep free 0x%lX ************\n",
153 (long unsigned int) r);
154 ldns_rdf_deep_free(r);
158 * @brief Prints information about deallocated rdf and deallocates.
160 void _ldns_rdf_free (ldns_rdf* r)
162 printf("******** LDNS_RDF free 0x%lX ************\n",
163 (long unsigned int) r);
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 */
173 /* ========================================================================= */
175 /* ========================================================================= */
181 * @brief returns a human readable string containing rdf type.
183 const char *ldns_rdf_type2str(const ldns_rdf *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";
226 /* ========================================================================= */
227 /* Encapsulating Python code. */
228 /* ========================================================================= */
230 %feature("docstring") ldns_struct_rdf "Resource record data field.
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."
236 %extend ldns_struct_rdf {
242 Cannot be created directly from Python.
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")
249 __swig_destroy__ = _ldns._ldns_rdf_deep_free
252 # LDNS_RDF_CONSTRUCTORS_
256 def new_frm_str(string, rr_type, raiseException = True):
258 Creates a new rdf from a string of a given type.
260 :param string: string to use
262 :param rr_type: The type of the rdf. See predefined `RDF_TYPE_`
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
271 :return: :class:`ldns_rdf` object or None. If the object
272 can't be created and `raiseException` is True,
277 >>> rdf = ldns.ldns_rdf.new_frm_str("74.125.43.99", ldns.LDNS_RDF_TYPE_A)
278 >>> print rdf, rdf.get_type_str()
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.
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)
291 # _LDNS_RDF_CONSTRUCTORS
296 Converts the rdata field to presentation format.
298 return _ldns.ldns_rdf2str(self)
300 def __cmp__(self, other):
302 Compares two rdfs on their wire formats.
304 (To order dnames according to rfc4034, use ldns_dname_compare.)
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.
312 return _ldns.ldns_rdf_compare(self, other)
314 def __lt__(self, other):
316 Compares two rdfs on their formats.
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'.
323 return _ldns.ldns_rdf_compare(self, other) == -1
325 def __le__(self, other):
327 Compares two rdfs on their formats.
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
335 return _ldns.ldns_rdf_compare(self, other) != 1
337 def __eq__(self, other):
339 Compares two rdfs on their formats.
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'.
346 return _ldns.ldns_rdf_compare(self, other) == 0
348 def __ne__(self, other):
350 Compares two rdfs on their formats.
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'.
357 return _ldns.ldns_rdf_compare(self, other) != 0
359 def __gt__(self, other):
361 Compares two rdfs on their formats.
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'.
368 return _ldns.ldns_rdf_compare(self, other) == 1
370 def __ge__(self, other):
372 Compares two rdfs on their formats.
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
380 return _ldns.ldns_rdf_compare(self, other) != -1
382 def print_to_file(self, output):
384 Prints the data in the rdata field to the given `output` file
385 stream (in presentation format).
387 _ldns.ldns_rdf_print(output, self)
389 def get_type_str(self):
391 Returns the type of the rdf as a human readable string.
393 :return: String containing rdf type.
395 return ldns_rdf_type2str(self)
397 def write_to_buffer(self, buffer):
399 Copies the rdata data to the buffer in wire format.
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`
405 :return: (ldns_status) ldns_status
407 return _ldns.ldns_rdf2buffer_wire(buffer, self)
408 #parameters: ldns_buffer *, const ldns_rdf *,
409 #retvals: ldns_status
411 def write_to_buffer_canonical(self, buffer):
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.
417 :param buffer: LDNS buffer.
418 :type buffer: :class:`ldns_buffer`
419 :throws TypeError: When `buffer` of non-:class:`ldns_buffer`
421 :return: (ldns_status) ldns_status
423 return _ldns.ldns_rdf2buffer_wire_canonical(buffer, self)
424 #parameters: ldns_buffer *, const ldns_rdf *,
425 #retvals: ldns_status
431 def address_reverse(self):
433 Reverses an rdf, only actually useful for AAAA and A records.
435 The returned rdf has the type LDNS_RDF_TYPE_DNAME!
437 :return: (:class:`ldns_rdf`) The reversed rdf
438 (a newly created rdf).
440 return _ldns.ldns_rdf_address_reverse(self)
441 #parameters: ldns_rdf *,
446 Clones a rdf structure.
450 :return: (:class:`ldns_rdf`) A new rdf structure.
452 return _ldns.ldns_rdf_clone(self)
453 #parameters: const ldns_rdf *,
458 Returns the data of the rdf.
460 :return: (uint8_t \*) uint8_t* pointer to the rdf's data.
462 return _ldns.ldns_rdf_data(self)
463 #parameters: const ldns_rdf *,
468 Returns the type of the rdf.
470 We need to prepend the prefix get_ here to prevent conflict
471 with the rdf_type TYPE.
473 :return: (ldns_rdf_type) Identifier of the type.
475 return _ldns.ldns_rdf_get_type(self)
476 #parameters: const ldns_rdf *,
477 #retvals: ldns_rdf_type
479 def set_data(self, data):
481 Sets the data portion of the rdf.
483 The data are not copied, but are assigned to the rdf,
484 `data` are decoupled from the Python engine.
486 :param data: Data to be set.
489 _ldns.ldns_rdf_set_data(self, data)
490 #parameters: ldns_rdf *, void *,
493 def set_size(self, size):
495 Sets the size of the rdf.
497 :param size: The new size.
499 :throws TypeError: When size of non-integer type.
501 _ldns.ldns_rdf_set_size(self,size)
502 #parameters: ldns_rdf *,size_t,
505 def set_type(self, atype):
507 Sets the type of the rdf.
509 :param atype: rdf type
511 :throws TypeError: When atype of non-integer type.
513 _ldns.ldns_rdf_set_type(self, atype)
514 #parameters: ldns_rdf *, ldns_rdf_type,
519 Returns the size of the rdf.
521 :return: (size_t) uint16_t with the size.
523 return _ldns.ldns_rdf_size(self)
524 #parameters: const ldns_rdf *,
528 def dname_new_frm_str(string):
530 Creates a new dname rdf instance from a given string.
532 This static method is equivalent to using of default
533 :class:`ldns_rdf` constructor.
535 :parameter string: String to use.
537 :throws TypeError: When not a string used.
538 :return: :class:`ldns_rdf` or None if error.
542 It is scheduled to be deprecated and removed. Use
543 :class:`ldns_dname` constructor instead.
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)
553 Checks whether the given dname string is absolute
554 (i.e., ends with a '.').
556 :return: (bool) True or False
560 This method was malfunctioning in ldns-1.3.16 and also
565 It is scheduled to be deprecated and removed. Convert
566 :class:`ldns_rdf` to :class:`ldns_dname` to use the method.
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
578 def make_canonical(self):
580 Put a dname into canonical format (i.e., convert to lower case).
582 Performs no action if not a dname.
586 This method is scheduled to be deprecated and removed.
587 Convert :class:`ldns_rdf` to :class:`ldns_dname` to use
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)
596 def dname_compare(self, other):
598 Compares two dname rdf according to the algorithm
599 for ordering in RFC4034 Section 6.
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.
610 It is scheduled to be deprecated and removed. Convert
611 :class:`ldns_rdf` to :class:`ldns_dname`.
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)
618 # The wrapped function generates asserts instead of setting
619 # error status. They cannot be caught from Python so a check
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)
631 Concatenates `rd2` after `this` dname (`rd2` is copied,
632 `this` dname is modified).
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.
642 It is scheduled to be deprecated and removed. Convert
643 :class:`ldns_rdf` to :class:`ldns_dname`.
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
653 def cat_clone(self, rd2):
655 Concatenates two dnames together.
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
667 It is scheduled to be deprecated and removed. Convert
668 :class:`ldns_rdf` to :class:`ldns_dname`.
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 *,
678 def interval(self, middle, next):
680 Check whether the `middle` lays in the interval defined by
681 `this` and `next` (`this` <= `middle` < `next`).
683 This method is useful for nsec checking
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.
697 It is scheduled to be deprecated and removed. Convert
698 :class:`ldns_rdf` to :class:`ldns_dname`.
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)
705 # The wrapped function generates asserts instead of setting
706 # error status. They cannot be caught from Python so a check
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 *,
720 def is_subdomain(self, parent):
722 Tests whether the name of the given instance falls under
723 `parent` (i.e., is a sub-domain of `parent`).
725 This function will return False if the given dnames
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
736 It is scheduled to be deprecated and removed. Convert
737 :class:`ldns_rdf` to :class:`ldns_dname`.
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 *,
747 def label(self, labelpos):
749 Look inside the rdf and if it is an LDNS_RDF_TYPE_DNAME try
750 and retrieve a specific label.
752 The labels are numbered starting from 0 (left most).
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.
763 It is scheduled to be deprecated and removed. Convert
764 :class:`ldns_rdf` to :class:`ldns_dname`.
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,
774 def label_count(self):
776 Count the number of labels inside a LDNS_RDF_DNAME type rdf.
778 :return: (uint8_t) The number of labels. Will return 0 if
783 It is scheduled to be deprecated and removed. Convert
784 :class:`ldns_rdf` to :class:`ldns_dname`.
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 *,
796 Chop one label off the left side of a dname.
798 (e.g., wwww.nlnetlabs.nl, becomes nlnetlabs.nl)
800 :return: (:class:`ldns_rdf`) The remaining dname or None when
805 It is scheduled to be deprecated and removed. Convert
806 :class:`ldns_rdf` to :class:`ldns_dname`.
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 *,
818 Returns a clone of the given dname with the labels reversed.
820 When reversing non-dnames a "." (root name) dname is returned.
822 :return: (:class:`ldns_rdf`) Clone of the dname with the labels
827 It is scheduled to be deprecated and removed. Convert
828 :class:`ldns_rdf` to :class:`ldns_dname`.
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 *,