-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcfg_core.c
213 lines (208 loc) · 7.86 KB
/
cfg_core.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
* $Id$
*
* Copyright (C) 2007 iptelorg GmbH
*
* This file is part of ser, a free SIP server.
*
* ser is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* For a license to use the ser software under conditions
* other than those described here, or to purchase support for this
* software, please contact iptel.org by e-mail at the following addresses:
* info@iptel.org
*
* ser 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* History
* -------
* 2007-12-03 Initial version (Miklos)
* 2008-01-31 added DNS resolver parameters (Miklos)
*/
/*!
* \file
* \brief SIP-router core ::
* \ingroup core
* Module: \ref core
*/
#include "dprint.h"
#ifdef USE_DST_BLACKLIST
#include "dst_blacklist.h"
#endif
#include "resolve.h"
#ifdef USE_DNS_CACHE
#include "dns_cache.h"
#endif
#if defined PKG_MALLOC || defined SHM_MEM
#include "pt.h"
#endif
#include "msg_translator.h" /* fix_global_req_flags() */
#include "cfg/cfg.h"
#include "cfg_core.h"
struct cfg_group_core default_core_cfg = {
L_WARN, /* print only msg. < L_WARN */
LOG_DAEMON, /* log_facility -- see syslog(3) */
L_DBG, /* memdbg */
#ifdef USE_DST_BLACKLIST
/* blacklist */
0, /* dst blacklist is disabled by default */
DEFAULT_BLST_TIMEOUT,
DEFAULT_BLST_MAX_MEM,
#endif
/* resolver */
#ifdef USE_IPV6
1, /* dns_try_ipv6 -- on by default */
#else
0, /* dns_try_ipv6 -- off, if no ipv6 support */
#endif
0, /* dns_try_naptr -- off by default */
30, /* udp transport preference (for naptr) */
20, /* tcp transport preference (for naptr) */
10, /* tls transport preference (for naptr) */
20, /* sctp transport preference (for naptr) */
-1, /* dns_retr_time */
-1, /* dns_retr_no */
-1, /* dns_servers_no */
1, /* dns_search_list */
1, /* dns_search_fmatch */
0, /* dns_reinit */
/* DNS cache */
#ifdef USE_DNS_CACHE
1, /* use_dns_cache -- on by default */
0, /* dns_cache_flags */
0, /* use_dns_failover -- off by default */
0, /* dns_srv_lb -- off by default */
DEFAULT_DNS_NEG_CACHE_TTL, /* neg. cache ttl */
DEFAULT_DNS_CACHE_MIN_TTL, /* minimum ttl */
DEFAULT_DNS_CACHE_MAX_TTL, /* maximum ttl */
DEFAULT_DNS_MAX_MEM, /* dns_cache_max_mem */
0, /* dns_cache_del_nonexp -- delete only expired entries by default */
#endif
#ifdef PKG_MALLOC
0, /* mem_dump_pkg */
#endif
#ifdef SHM_MEM
0, /* mem_dump_shm */
#endif
DEFAULT_MAX_WHILE_LOOPS, /* max_while_loops */
0, /* udp_mtu (disabled by default) */
0, /* udp_mtu_try_proto -> default disabled */
0, /* force_rport */
L_DBG, /* memlog */
1 /* mem_summary -flags: 0 off, 1 shm/pkg_status, 2 shm/pkg_sums */
};
void *core_cfg = &default_core_cfg;
cfg_def_t core_cfg_def[] = {
{"debug", CFG_VAR_INT|CFG_ATOMIC, 0, 0, 0, 0,
"debug level"},
{"log_facility", CFG_VAR_INT|CFG_INPUT_STRING, 0, 0, log_facility_fixup, 0,
"syslog facility, see \"man 3 syslog\""},
{"memdbg", CFG_VAR_INT|CFG_ATOMIC, 0, 0, 0, 0,
"log level for memory debugging messages"},
#ifdef USE_DST_BLACKLIST
/* blacklist */
{"use_dst_blacklist", CFG_VAR_INT, 0, 1, use_dst_blacklist_fixup, 0,
"enable/disable destination blacklisting"},
{"dst_blacklist_expire", CFG_VAR_INT, 0, 0, 0, 0,
"how much time (in s) a blacklisted destination is kept in the list"},
{"dst_blacklist_mem", CFG_VAR_INT, 0, 0, blst_max_mem_fixup, 0,
"maximum shared memory amount (in KB) used for keeping the blacklisted destinations"},
#endif
/* resolver */
#ifdef USE_DNS_CACHE
{"dns_try_ipv6", CFG_VAR_INT, 0, 1, dns_try_ipv6_fixup, fix_dns_flags,
#else
{"dns_try_ipv6", CFG_VAR_INT, 0, 1, dns_try_ipv6_fixup, 0,
#endif
"enable/disable IPv6 DNS lookups"},
#ifdef USE_DNS_CACHE
{"dns_try_naptr", CFG_VAR_INT, 0, 1, 0, fix_dns_flags,
#else
{"dns_try_naptr", CFG_VAR_INT, 0, 1, 0, 0,
#endif
"enable/disable NAPTR DNS lookups"},
{"dns_udp_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
"udp protocol preference when doing NAPTR lookups"},
{"dns_tcp_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
"tcp protocol preference when doing NAPTR lookups"},
{"dns_tls_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
"tls protocol preference when doing NAPTR lookups"},
{"dns_sctp_pref", CFG_VAR_INT, 0, 0, 0, reinit_naptr_proto_prefs,
"sctp protocol preference when doing NAPTR lookups"},
{"dns_retr_time", CFG_VAR_INT, 0, 0, 0, resolv_reinit,
"time in s before retrying a dns request"},
{"dns_retr_no", CFG_VAR_INT, 0, 0, 0, resolv_reinit,
"number of dns retransmissions before giving up"},
{"dns_servers_no", CFG_VAR_INT, 0, 0, 0, resolv_reinit,
"how many dns servers from the ones defined in "
"/etc/resolv.conf will be used"},
{"dns_use_search_list", CFG_VAR_INT, 0, 1, 0, resolv_reinit,
"if set to 0, the search list in /etc/resolv.conf is ignored"},
{"dns_search_full_match", CFG_VAR_INT, 0, 1, 0, 0,
"enable/disable domain name checks against the search list "
"in DNS answers"},
{"dns_reinit", CFG_VAR_INT|CFG_INPUT_INT, 1, 1, dns_reinit_fixup, resolv_reinit,
"set to 1 in order to reinitialize the DNS resolver"},
/* DNS cache */
#ifdef USE_DNS_CACHE
{"use_dns_cache", CFG_VAR_INT, 0, 1, use_dns_cache_fixup, 0,
"enable/disable the dns cache"},
{"dns_cache_flags", CFG_VAR_INT, 0, 4, 0, fix_dns_flags,
"dns cache specific resolver flags "
"(1=ipv4 only, 2=ipv6 only, 4=prefer ipv6"},
{"use_dns_failover", CFG_VAR_INT, 0, 1, use_dns_failover_fixup, 0,
"enable/disable dns failover in case the destination "
"resolves to multiple ip addresses and/or multiple SRV records "
"(depends on use_dns_cache)"},
{"dns_srv_lb", CFG_VAR_INT, 0, 1, 0, fix_dns_flags,
"enable/disable load balancing to different srv records "
"of the same priority based on the srv records weights "
"(depends on dns_failover)"},
{"dns_cache_negative_ttl", CFG_VAR_INT, 0, 0, 0, 0,
"time to live for negative results (\"not found\") "
"in seconds. Use 0 to disable"},
{"dns_cache_min_ttl", CFG_VAR_INT, 0, 0, 0, 0,
"minimum accepted time to live for a record, in seconds"},
{"dns_cache_max_ttl", CFG_VAR_INT, 0, 0, 0, 0,
"maximum accepted time to live for a record, in seconds"},
{"dns_cache_mem", CFG_VAR_INT, 0, 0, dns_cache_max_mem_fixup, 0,
"maximum memory used for the dns cache in Kb"},
{"dns_cache_del_nonexp", CFG_VAR_INT, 0, 1, 0, 0,
"allow deletion of non-expired records from the cache when "
"there is no more space left for new ones"},
#endif
#ifdef PKG_MALLOC
{"mem_dump_pkg", CFG_VAR_INT, 0, 0, 0, mem_dump_pkg_cb,
"dump process memory status, parameter: pid_number"},
#endif
#ifdef SHM_MEM
{"mem_dump_shm", CFG_VAR_INT, 0, 0, mem_dump_shm_fixup, 0,
"dump shared memory status"},
#endif
{"max_while_loops", CFG_VAR_INT|CFG_ATOMIC, 0, 0, 0, 0,
"maximum iterations allowed for a while loop" },
{"udp_mtu", CFG_VAR_INT|CFG_ATOMIC, 0, 65535, 0, 0,
"fallback to a congestion controlled protocol if send size"
" exceeds udp_mtu"},
{"udp_mtu_try_proto", CFG_VAR_INT, 1, 4, 0, fix_global_req_flags,
"if send size > udp_mtu use proto (1 udp, 2 tcp, 3 tls, 4 sctp)"},
{"force_rport", CFG_VAR_INT, 0, 1, 0, fix_global_req_flags,
"force rport for all the received messages" },
{"memlog", CFG_VAR_INT|CFG_ATOMIC, 0, 0, 0, 0,
"log level for memory status/summary information"},
{"mem_summary", CFG_VAR_INT|CFG_ATOMIC, 0, 3, 0, 0,
"memory debugging information displayed on exit (flags): "
" 0 - off, 1 - dump all the used blocks (status),"
" 2 - summary of used blocks" },
{0, 0, 0, 0, 0, 0}
};