Logo Search packages:      
Sourcecode: sofia-sip version File versions

sres_record.h

Go to the documentation of this file.
/*
 * This file is part of the Sofia-SIP package
 *
 * Copyright (C) 2005 Nokia Corporation.
 *
 * Contact: Pekka Pessi <pekka.pessi@nokia.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 */

#ifndef SOFIA_RESOLV_SRES_RECORD_H
/** Defined when <sofia-resolv/sres_record.h> has been included. */
#define SOFIA_RESOLV_SRES_RECORD_H
/**
 * @file sofia-resolv/sres_record.h Sofia DNS Resolver Records.
 *
 * @author Pekka Pessi <Pekka.Pessi@nokia.com>,
 *
 * @par Include Context
 * @code
 * #include <sys/types.h>
 * #include <sys/socket.h>
 * #include <netinet/in.h>
 * #include <sofia-resolv/sres_record.h>
 * @endcode
 *
 */

#include "sofia-resolv/sres_config.h"

#ifdef __cplusplus
extern "C" {
#endif

/** Common part of all DNS records. */
00050 typedef struct sres_common
{
00052   int               r_refcount;     /**< Number of references to this record */
00053   char             *r_name;   /**< Domain name */
00054   uint16_t          r_status; /**< Status of query (nonzero upon an error) */
00055   uint16_t          r_size;   /**< Size of this record */
00056   uint16_t          r_type;   /**< Record type (A, CNAME, A6, etc) */
00057   uint16_t          r_class;  /**< Record class (IN) */
00058   uint32_t          r_ttl;    /**< Time-to-live */
00059   uint16_t          r_rdlen;  /**< Length of record data */
00060   uint16_t          r_parsed; /**< Nonzero if parsed */
} sres_common_t;

/** Possible values for r_status (RCODE) in #sres_common */
00064 enum sres_status {
00065   SRES_OK = 0,                /**< No error condition. */
00066   SRES_FORMAT_ERR = 1,        /**< Server could not interpret query. */
00067   SRES_SERVER_ERR = 2,        /**< Server error. */
00068   SRES_NAME_ERR = 3,          /**< No domain name. */
00069   SRES_UNIMPL_ERR = 4,        /**< Not implemented. */
00070   SRES_AUTH_ERR = 5,          /**< Refused */

  /* Errors generated by sresolv */
00073   SRES_TIMEOUT_ERR = 32,      /**< Timeout occurred */
00074   SRES_RECORD_ERR = 33          /**< Name has no given record type */
};

/** Start of a zone of authority record (@RFC1035). */
00078 typedef struct sres_soa_record
{
00080   sres_common_t  soa_record[1];     /**< Common part of DNS records. */
00081   char          *soa_mname;   /**< Primary name server */
00082   char          *soa_rname;   /**< Person responsible for domain */
00083   uint32_t       soa_serial;  /**< Version number */
00084   uint32_t       soa_refresh; /**< Refresh intercal */
00085   uint32_t       soa_retry;   /**< Interval between refres retries */
00086   uint32_t       soa_expire;  /**< Upper limit on zone expiration time  */
00087   uint32_t       soa_minimum; /**< Minimum TTL for any record in zone */
} sres_soa_record_t;

/** Generic DNS record. */
00091 typedef struct sres_generic
{
00093   sres_common_t  g_record[1]; /**< Common part of DNS records. */
00094   uint8_t        g_data[128]; /**< Record data */
} sres_generic_t;

/** Address record (@RFC1035). */
00098 typedef struct sres_a_record
{
00100   sres_common_t  a_record[1]; /**< Common part of DNS records. */
00101   struct in_addr a_addr;      /**< IP4 address */
} sres_a_record_t;

/** IPv6 address used by sresolv library.
 *
 * @sa #sres_aaaa_record, #sres_a6_record
 */
00108 typedef struct
{
00110   uint8_t u6_addr[16];        /**< Array of 16 octets. */
} sres_in6_t;

/** Aggregated address record for IPv6 (@RFC2874, deprecated). */
00114 typedef struct sres_a6_record
{
00116   sres_common_t  a6_record[1];      /**< Common part of DNS records. */
00117   uint8_t        a6_prelen;   /**< Prefix length */
00118   uint8_t        a6_pad[3];   /**<  */
00119   sres_in6_t     a6_suffix;   /**< Address suffix */
00120   char          *a6_prename;  /**< Prefix name */
} sres_a6_record_t;

/** Address record for IPv6 (@RFC1886). */
00124 typedef struct sres_aaaa_record
{
00126   sres_common_t aaaa_record[1];     /**< Common part of DNS records. */
00127   sres_in6_t    aaaa_addr;    /**< IP6 address */
} sres_aaaa_record_t;

/** Canonic name record (@RFC1035). */
00131 typedef struct sres_cname_record
{
00133   sres_common_t  cn_record[1];      /**< Common part of DNS records. */
00134   char          *cn_cname;    /**<  */
} sres_cname_record_t;

/** Pointer record (@RFC1035). */
00138 typedef struct sres_ptr_record
{
00140   sres_common_t  ptr_record[1];     /**< Common part of DNS records. */
00141   char          *ptr_domain;  /**< Domain */
} sres_ptr_record_t;

/** Service location record (@RFC2782). */
00145 typedef struct sres_srv_record
{
00147   sres_common_t  srv_record[1];     /**< Common part of DNS records. */
00148   uint16_t       srv_priority;      /**< Priority */
00149   uint16_t       srv_weight;  /**< Weight */
00150   uint16_t       srv_port;    /**< Service port on the target host. */
  uint16_t       srv_pad;
00152   char          *srv_target;  /**< Domain name of the target host. */
} sres_srv_record_t;

/** Naming authority pointer record (@RFC2915). */
00156 typedef struct sres_naptr_record
{
00158   sres_common_t  na_record[1];      /**< Common part of DNS records. */
00159   uint16_t       na_order;    /**< Processing order for NAPTR records. */
00160   uint16_t       na_prefer;   /**< Preference */
00161   char          *na_flags;    /**< Flags for interpretation and rewriting */
00162   char          *na_services; /**< Services available. */
00163   char          *na_regexp;   /**< Substitution expression. */
00164   char          *na_replace;  /**< Replacement. */
} sres_naptr_record_t;


#ifndef SRES_RECORD_T
#define SRES_RECORD_T
/** Type representing any DNS record. */
00171 typedef union sres_record           sres_record_t;
#endif

/** Union of different DNS records */
00175 union sres_record
{
00177   sres_common_t       sr_record[1]; /**< Common part of all DNS records */
00178   sres_generic_t      sr_generic[1];      /**< Generic (unparsed) DNS record */
00179   sres_soa_record_t   sr_soa[1];    /**< SOA (start-of-authority) record */
00180   sres_a_record_t     sr_a[1];            /**< A (address) record */
00181   sres_cname_record_t sr_cname[1];  /**< CNAME (canonic name) record */
00182   sres_ptr_record_t   sr_ptr[1];    /**< PTR (pointer) record */
00183   sres_a6_record_t    sr_a6[1];           /**< A6 (IP6 address) record */
00184   sres_aaaa_record_t  sr_aaaa[1];   /**< AAAA (IP6 address) record */
00185   sres_srv_record_t   sr_srv[1];    /**< SRV record */
00186   sres_naptr_record_t sr_naptr[1];  /**< NAPTR record */
};

/** Protocol family classes. */
00190 enum sres_class {
00191   sres_class_in = 1,                  /**< Internet (@b IN) */
00192   sres_class_any = 255                /**< Any class */
};

/** Query types. */
00196 enum sres_qtypes {
00197   sres_type_a = 1,          /**< IPv4 address (#sres_a_record). */
00198   sres_type_ns = 2,         /**< Authoritative server. */
00199   sres_type_mf = 4,         /**< Mail forwarder. */
00200   sres_type_cname = 5,      /**< Canonical name (#sres_cname_record). */
00201   sres_type_soa = 6,        /**< Start of authority zone (#sres_soa_record). */
00202   sres_type_mb = 7,         /**< Mailbox domain name. */
00203   sres_type_mg = 8,         /**< Mail group member. */
00204   sres_type_mr = 9,         /**< Mail rename name. */
00205   sres_type_null = 10,      /**< Null resource record. */
00206   sres_type_wks = 11,       /**< Well known service. */
00207   sres_type_ptr = 12,       /**< Domain name pointer (#sres_ptr_record). */
00208   sres_type_hinfo = 13,     /**< Host information. */
00209   sres_type_minfo = 14,     /**< Mailbox information. */
00210   sres_type_mx = 15,        /**< Mail routing information. */
00211   sres_type_txt = 16,       /**< Text strings. */
00212   sres_type_rp = 17,        /**< Responsible person. */
00213   sres_type_afsdb = 18,     /**< AFS cell database. */
00214   sres_type_x25 = 19,       /**< X_25 calling address. */
00215   sres_type_isdn = 20,      /**< ISDN calling address. */
00216   sres_type_rt = 21,        /**< Router. */
00217   sres_type_nsap = 22,      /**< NSAP address. */
00218   sres_type_nsap_ptr = 23,  /**< Reverse NSAP lookup. */
00219   sres_type_sig = 24,       /**< Security signature. */
00220   sres_type_key = 25,       /**< Security key. */
00221   sres_type_px = 26,        /**< X.400 mail mapping. */
00222   sres_type_gpos = 27,      /**< ICBM record. */
00223   sres_type_aaaa = 28,      /**< IPv6 Address (#sres_aaaa_record). */
00224   sres_type_loc = 29,       /**< Location Information. */
00225   sres_type_nxt = 30,       /**< Next domain. */
00226   sres_type_eid = 31,       /**< Endpoint identifier. */
00227   sres_type_nimloc = 32,    /**< Nimrod Locator. */
00228   sres_type_srv = 33,       /**< Server Selection (@RFC2782,
                           #sres_srv_record). */
00230   sres_type_atma = 34,      /**< ATM Address */
00231   sres_type_naptr = 35,     /**< Naming Authority PoinTeR (@RFC2915,
                                 #sres_naptr_record) */
00233   sres_type_kx = 36,        /**< Key Exchange */
00234   sres_type_cert = 37,      /**< Certification record */
00235   sres_type_a6 = 38,        /**< IPv6 address (deprecates AAAA) */
00236   sres_type_dname = 39,     /**< Non-terminal DNAME (for IPv6) */
00237   sres_type_sink = 40,      /**< Kitchen sink (experimental) */
00238   sres_type_opt = 41,       /**< EDNS 0 option (@RFC2671) */

00240   sres_qtype_tsig = 250,    /**< Transaction signature. */
00241   sres_qtype_ixfr = 251,    /**< Incremental zone transfer. */
00242   sres_qtype_axfr = 252,    /**< Transfer zone of authority. */
00243   sres_qtype_mailb = 253,   /**< Transfer mailbox records. */
00244   sres_qtype_maila = 254,   /**< Transfer mail agent records. */
00245   sres_qtype_any = 255      /**< Wildcard match. */
};

/** Convert type to its name. */
SRESPUBFUN char const *sres_record_type(int type, char buffer[8]);

/** Compare two records. */
SRESPUBFUN int sres_record_compare(sres_record_t const *,
                           sres_record_t const *);

#ifdef __cplusplus
}
#endif

#endif /* SOFIA_RESOLV_SRES_CACHE_H */

Generated by  Doxygen 1.6.0   Back to index