--- /dev/null
+/**
+ \page tutorial1_mx Tutorial 1: Qeurying for MX records
+ \dontinclude ldns-mx.c
+
+ The full source code can be found in \link examples/ldns-mx.c \endlink
+
+ This is a simple example that queries for an MX record
+
+ First of all, we need to include the correct header files, so
+ that all functions are available to us:
+
+ \skip include
+ \until dns.h
+
+ in our main function, we declare some variables that we are going to use:
+
+ \skipline ldns_resolver
+ \until ldns_status
+
+ - The \c ldns_resolver structure keeps a list of nameservers, and can perform queries for us
+ - An \c ldns_rdf is a basic data type of dns, the RDATA. See (todo link) overview for a description about the building blocks of DNS.
+ \c domain will contain the name the user specifies when calling the program
+ - An \c ldns_pkt is a DNS packet, for instance a complete query, or an answer
+ - The \c ldns_rr_list structure contains a list of DNS Resource Records (RRs). In this case, we will store the MX records we find in the list.
+ - \c ldns_status is the basic type for status messages in ldns. Most functions will return a value of this type.
+
+
+ First, we parse the command line argument (checks omitted on this page, see full source code), and store it in our \c domain variable:
+ \skipline ldns_dname_new_frm_str
+
+ Then, we create the resolver structure:
+ \skipline ldns_resolver_new
+
+ We tell the resolver to query for our domain, type MX, of class IN:
+ \skipline ldns_resolver_query
+ \until )
+
+ This should return a packet if everything goes well.
+
+ We get all RRs of type MX from the answer packet and store them in our list:
+ \skipline ldns_pkt_rr_list_by_type
+ \until )
+
+ If this list is not empty, we sort and print it:
+ \skipline ldns_rr_list_sort
+ \skipline ldns_rr_list_print
+*/
/* use the resolver to send it a query for the mx
* records of the domain given on the command line
*/
- p = ldns_resolver_query(res, domain, LDNS_RR_TYPE_MX, LDNS_RR_CLASS_IN, LDNS_RD);
+ p = ldns_resolver_query(res,
+ domain,
+ LDNS_RR_TYPE_MX,
+ LDNS_RR_CLASS_IN,
+ LDNS_RD);
ldns_rdf_deep_free(domain);
/* retrieve the MX records from the answer section of that
* packet
*/
- mx = ldns_pkt_rr_list_by_type(p, LDNS_RR_TYPE_MX, LDNS_SECTION_ANSWER);
+ mx = ldns_pkt_rr_list_by_type(p,
+ LDNS_RR_TYPE_MX,
+ LDNS_SECTION_ANSWER);
if (!mx) {
fprintf(stderr,
" *** invalid answer name %s after MX query for %s\n",
# directories like "/usr/src/myproject". Separate the files or directories
# with spaces.
-INPUT = . ldns/
+INPUT = . ldns/ doc/ examples/
# If the value of the INPUT tag contains directories, you can use the
# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp
# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm
-FILE_PATTERNS = *.h
+FILE_PATTERNS = *.h *.c *.doxygen
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
# directories that contain example code fragments that are included (see
# the \include command).
-EXAMPLE_PATH =
+EXAMPLE_PATH = examples
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp