4 * Copyright (C) 2007 iptelorg GmbH
6 * This file is part of ser, a free SIP server.
8 * ser is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version
13 * For a license to use the ser software under conditions
14 * other than those described here, or to purchase support for this
15 * software, please contact iptel.org by e-mail at the following addresses:
18 * ser is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * 2007-12-03 Initial version (Miklos)
30 * 2008-01-31 added DNS resolver parameters (Miklos)
34 #ifdef USE_DST_BLACKLIST
35 #include "dst_blacklist.h"
39 #include "dns_cache.h"
44 struct cfg_group_core default_core_cfg = {
45 L_DEFAULT, /* print only msg. < L_WARN */
46 #ifdef USE_DST_BLACKLIST
48 0, /* dst blacklist is disabled by default */
54 1, /* dns_try_ipv6 -- on by default */
56 0, /* dns_try_ipv6 -- off, if no ipv6 support */
58 0, /* dns_try_naptr -- off by default */
59 3, /* udp transport preference (for naptr) */
60 2, /* tcp transport preference (for naptr) */
61 1, /* tls transport preference (for naptr) */
62 -1, /* dns_retr_time */
64 -1, /* dns_servers_no */
65 1, /* dns_search_list */
66 1, /* dns_search_fmatch */
70 1, /* use_dns_cache -- on by default */
71 0, /* dns_cache_flags */
72 0, /* use_dns_failover -- off by default */
73 0, /* dns_srv_lb -- off by default */
74 DEFAULT_DNS_NEG_CACHE_TTL, /* neg. cache ttl */
75 DEFAULT_DNS_CACHE_MIN_TTL, /* minimum ttl */
76 DEFAULT_DNS_CACHE_MAX_TTL, /* maximum ttl */
77 DEFAULT_DNS_MAX_MEM, /* dns_cache_max_mem */
78 0, /* dns_cache_del_nonexp -- delete only expired entries by default */
82 void *core_cfg = &default_core_cfg;
84 cfg_def_t core_cfg_def[] = {
85 {"debug", CFG_VAR_INT, 0, 0, 0, 0, "debug level"},
86 #ifdef USE_DST_BLACKLIST
88 {"use_dst_blacklist", CFG_VAR_INT, 0, 1, use_dst_blacklist_fixup, 0,
89 "enable/disable destination blacklisting"},
90 {"dst_blacklist_expire", CFG_VAR_INT, 0, 0, 0, 0,
91 "how much time (in s) a blacklisted destination is kept in the list"},
92 {"dst_blacklist_mem", CFG_VAR_INT, 0, 0, blst_max_mem_fixup, 0,
93 "maximum shared memory amount (in KB) used for keeping the blacklisted destinations"},
97 {"dns_try_ipv6", CFG_VAR_INT, 0, 1, dns_try_ipv6_fixup, fix_dns_flags,
99 {"dns_try_ipv6", CFG_VAR_INT, 0, 1, dns_try_ipv6_fixup, 0,
101 "enable/disable IPv6 DNS lookups"},
103 {"dns_try_naptr", CFG_VAR_INT, 0, 1, 0, fix_dns_flags,
105 {"dns_try_naptr", CFG_VAR_INT, 0, 1, 0, 0,
107 "enable/disable NAPTR DNS lookups"},
108 {"dns_udp_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
109 "udp protocol preference when doing NAPTR lookups"},
110 {"dns_tcp_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
111 "tcp protocol preference when doing NAPTR lookups"},
112 {"dns_tls_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
113 "tls protocol preference when doing NAPTR lookups"},
114 {"dns_retr_time", CFG_VAR_INT, 0, 0, 0, resolv_reinit,
115 "time in s before retrying a dns request"},
116 {"dns_retr_no", CFG_VAR_INT, 0, 0, 0, resolv_reinit,
117 "number of dns retransmissions before giving up"},
118 {"dns_servers_no", CFG_VAR_INT, 0, 0, 0, resolv_reinit,
119 "how many dns servers from the ones defined in "
120 "/etc/resolv.conf will be used"},
121 {"dns_use_search_list", CFG_VAR_INT, 0, 1, 0, resolv_reinit,
122 "if set to 0, the search list in /etc/resolv.conf is ignored"},
123 {"dns_search_full_match", CFG_VAR_INT, 0, 1, 0, 0,
124 "enable/disable domain name checks against the search list "
126 {"dns_reinit", CFG_VAR_INT|CFG_INPUT_INT, 1, 1, dns_reinit_fixup, resolv_reinit,
127 "set to 1 in order to reinitialize the DNS resolver"},
130 {"use_dns_cache", CFG_VAR_INT, 0, 1, use_dns_cache_fixup, 0,
131 "enable/disable the dns cache"},
132 {"dns_cache_flags", CFG_VAR_INT, 0, 4, 0, fix_dns_flags,
133 "dns cache specific resolver flags "
134 "(1=ipv4 only, 2=ipv6 only, 4=prefer ipv6"},
135 {"use_dns_failover", CFG_VAR_INT, 0, 1, use_dns_failover_fixup, 0,
136 "enable/disable dns failover in case the destination "
137 "resolves to multiple ip addresses and/or multiple SRV records "
138 "(depends on use_dns_cache)"},
139 {"dns_srv_lb", CFG_VAR_INT, 0, 1, 0, fix_dns_flags,
140 "enable/disable load balancing to different srv records "
141 "of the same priority based on the srv records weights "
142 "(depends on dns_failover)"},
143 {"dns_cache_negative_ttl", CFG_VAR_INT, 0, 0, 0, 0,
144 "time to live for negative results (\"not found\") "
145 "in seconds. Use 0 to disable"},
146 {"dns_cache_min_ttl", CFG_VAR_INT, 0, 0, 0, 0,
147 "minimum accepted time to live for a record, in seconds"},
148 {"dns_cache_max_ttl", CFG_VAR_INT, 0, 0, 0, 0,
149 "maximum accepted time to live for a record, in seconds"},
150 {"dns_cache_mem", CFG_VAR_INT, 0, 0, dns_cache_max_mem_fixup, 0,
151 "maximum memory used for the dns cache in Kb"},
152 {"dns_cache_del_nonexp", CFG_VAR_INT, 0, 1, 0, 0,
153 "allow deletion of non-expired records from the cache when "
154 "there is no more space left for new ones"},