"Fossies" - the Fresh Open Source Software Archive

Member "knot-2.8.3/src/libknot/rrtype/rdname.h" (16 Jul 2019, 1912 Bytes) of package /linux/misc/dns/knot-2.8.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "rdname.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.7.6_vs_2.8.0.

    1 /*  Copyright (C) 2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
    2 
    3     This program is free software: you can redistribute it and/or modify
    4     it under the terms of the GNU General Public License as published by
    5     the Free Software Foundation, either version 3 of the License, or
    6     (at your option) any later version.
    7 
    8     This program is distributed in the hope that it will be useful,
    9     but WITHOUT ANY WARRANTY; without even the implied warranty of
   10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11     GNU General Public License for more details.
   12 
   13     You should have received a copy of the GNU General Public License
   14     along with this program.  If not, see <https://www.gnu.org/licenses/>.
   15  */
   16 /*!
   17  * \file
   18  *
   19  * \addtogroup rrtype
   20  * @{
   21  */
   22 
   23 #pragma once
   24 
   25 #include "libknot/descriptor.h"
   26 #include "libknot/dname.h"
   27 #include "libknot/rdata.h"
   28 
   29 static inline
   30 const knot_dname_t *knot_cname_name(const knot_rdata_t *rdata)
   31 {
   32     assert(rdata);
   33     return rdata->data;
   34 }
   35 
   36 static inline
   37 const knot_dname_t *knot_dname_target(const knot_rdata_t *rdata)
   38 {
   39     assert(rdata);
   40     return rdata->data;
   41 }
   42 
   43 static inline
   44 const knot_dname_t *knot_ns_name(const knot_rdata_t *rdata)
   45 {
   46     assert(rdata);
   47     return rdata->data;
   48 }
   49 
   50 static inline
   51 const knot_dname_t *knot_mx_name(const knot_rdata_t *rdata)
   52 {
   53     assert(rdata);
   54     return rdata->data + 2;
   55 }
   56 
   57 static inline
   58 const knot_dname_t *knot_srv_name(const knot_rdata_t *rdata)
   59 {
   60     assert(rdata);
   61     return rdata->data + 6;
   62 }
   63 
   64 static inline
   65 const knot_dname_t *knot_rdata_name(const knot_rdata_t *rdata, uint16_t type)
   66 {
   67     assert(rdata);
   68     switch (type) {
   69         case KNOT_RRTYPE_NS:
   70             return knot_ns_name(rdata);
   71         case KNOT_RRTYPE_MX:
   72             return knot_mx_name(rdata);
   73         case KNOT_RRTYPE_SRV:
   74             return knot_srv_name(rdata);
   75         case KNOT_RRTYPE_CNAME:
   76             return knot_cname_name(rdata);
   77         case KNOT_RRTYPE_DNAME:
   78             return knot_dname_target(rdata);
   79     }
   80 
   81     return NULL;
   82 }
   83 
   84 /*! @} */