"Fossies" - the Fresh Open Source Software Archive

Member "knot-2.8.3/src/utils/kdig/kdig_params.h" (16 Jul 2019, 5009 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 "kdig_params.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) 2019 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 #pragma once
   18 
   19 #include <stdbool.h>
   20 
   21 #include "utils/common/params.h"
   22 #include "utils/common/exec.h"
   23 #include "utils/common/sign.h"
   24 #include "libknot/libknot.h"
   25 #include "contrib/sockaddr.h"
   26 
   27 #if USE_DNSTAP
   28 # include "contrib/dnstap/reader.h"
   29 # include "contrib/dnstap/writer.h"
   30 #endif // USE_DNSTAP
   31 
   32 /*! \brief Operation mode of kdig. */
   33 typedef enum {
   34     /*!< Standard 1-message query/reply. */
   35     OPERATION_QUERY,
   36     /*!< Zone transfer (AXFR or IXFR). */
   37     OPERATION_XFR,
   38     /*!< Dump dnstap file. */
   39     OPERATION_LIST_DNSTAP,
   40 } operation_t;
   41 
   42 /*! \brief DNS header and EDNS flags. */
   43 typedef struct {
   44     /*!< Authoritative answer flag. */
   45     bool    aa_flag;
   46     /*!< Truncated flag. */
   47     bool    tc_flag;
   48     /*!< Recursion desired flag. */
   49     bool    rd_flag;
   50     /*!< Recursion available flag. */
   51     bool    ra_flag;
   52     /*!< Z flag. */
   53     bool    z_flag;
   54     /*!< Authenticated data flag. */
   55     bool    ad_flag;
   56     /*!< Checking disabled flag. */
   57     bool    cd_flag;
   58     /*!< DNSSEC OK flag. */
   59     bool    do_flag;
   60 } flags_t;
   61 
   62 /*! \brief Basic parameters for DNS query. */
   63 typedef struct query query_t; // Forward declaration due to configuration.
   64 struct query {
   65     /*!< List node (for list container). */
   66     node_t      n;
   67     /*!< Reference to global config. */
   68     const query_t   *conf;
   69     /*!< Name to query on. */
   70     char        *owner;
   71     /*!< List of nameservers to query to. */
   72     list_t      servers;
   73     /*!< Local interface (optional). */
   74     srv_info_t  *local;
   75     /*!< Operation mode. */
   76     operation_t operation;
   77     /*!< Version of ip protocol to use. */
   78     ip_t        ip;
   79     /*!< Protocol type (TCP, UDP) to use. */
   80     protocol_t  protocol;
   81     /*!< Use TCP Fast Open. */
   82     bool        fastopen;
   83     /*!< Port/service to connect to. */
   84     char        *port;
   85     /*!< UDP buffer size (16unsigned + -1 uninitialized). */
   86     int32_t     udp_size;
   87     /*!< Number of UDP retries. */
   88     uint32_t    retries;
   89     /*!< Wait for network response in seconds (-1 means forever). */
   90     int32_t     wait;
   91     /*!< Ignore truncated response. */
   92     bool        ignore_tc;
   93     /*!< Class number (16unsigned + -1 uninitialized). */
   94     int32_t     class_num;
   95     /*!< Type number (16unsigned + -1 uninitialized). */
   96     int32_t     type_num;
   97     /*!< SOA serial for IXFR and NOTIFY (32unsigned + -1 uninitialized). */
   98     int64_t     serial;
   99     /*!< NOTIFY query. */
  100     bool        notify;
  101     /*!< Header flags. */
  102     flags_t     flags;
  103     /*!< Output settings. */
  104     style_t     style;
  105     /*!< IDN conversion. */
  106     bool        idn;
  107     /*!< Query for NSID. */
  108     bool        nsid;
  109     /*!< EDNS version (8unsigned + -1 uninitialized). */
  110     int16_t     edns;
  111     /*!< EDNS client cookie. */
  112     knot_edns_cookie_t cc;
  113     /*!< EDNS server cookie. */
  114     knot_edns_cookie_t sc;
  115     /*!< Repeat query after BADCOOKIE. */
  116     bool        badcookie;
  117     /*!< EDNS0 padding (16unsigned + -1 ~ uninitialized, -2 ~ default, -3 ~ none). */
  118     int32_t     padding;
  119     /*!< Query alignment with EDNS0 padding (0 ~ uninitialized). */
  120     uint16_t    alignment;
  121     /*!< TLS parameters. */
  122     tls_params_t    tls;
  123     /*!< Transaction signature. */
  124     knot_tsig_key_t tsig_key;
  125     /*!< EDNS client subnet. */
  126     knot_edns_client_subnet_t subnet;
  127     /*!< Lits of custom EDNS options. */
  128     list_t      edns_opts;
  129 #if USE_DNSTAP
  130     /*!< Context for dnstap reader input. */
  131     dt_reader_t *dt_reader;
  132     /*!< Context for dnstap writer output. */
  133     dt_writer_t *dt_writer;
  134 #endif // USE_DNSTAP
  135 };
  136 
  137 /*! \brief EDNS option data. */
  138 typedef struct {
  139     /*! List node (for list container). */
  140     node_t  n;
  141     /*!< OPTION-CODE field. */
  142     uint16_t code;
  143     /*!< OPTION-LENGTH field. */
  144     uint16_t length;
  145     /*!< OPTION-DATA field. */
  146     uint8_t *data;
  147 } ednsopt_t;
  148 
  149 /*! \brief Settings for kdig. */
  150 typedef struct {
  151     /*!< Stop processing - just print help, version,... */
  152     bool    stop;
  153     /*!< List of DNS queries to process. */
  154     list_t  queries;
  155     /*!< Default settings for queries. */
  156     query_t *config;
  157 } kdig_params_t;
  158 
  159 query_t *query_create(const char *owner, const query_t *config);
  160 void query_free(query_t *query);
  161 void complete_queries(list_t *queries, const query_t *conf);
  162 
  163 ednsopt_t *ednsopt_create(uint16_t code, uint16_t length, uint8_t *data);
  164 ednsopt_t *ednsopt_dup(const ednsopt_t *opt);
  165 void ednsopt_free(ednsopt_t *opt);
  166 
  167 void ednsopt_list_init(list_t *list);
  168 void ednsopt_list_deinit(list_t *list);
  169 int ednsopt_list_dup(list_t *dst, const list_t *src);
  170 bool ednsopt_list_empty(const list_t *list);
  171 
  172 int kdig_init(kdig_params_t *params);
  173 int kdig_parse(kdig_params_t *params, int argc, char *argv[]);
  174 void kdig_clean(kdig_params_t *params);