Debian Codegraph @

src/modules/domainpolicy/README

raw
1 Domain Policy Module
2
3 Otmar Lendl
4
5 <[email protected]>
6
7 Klaus Darilion
8
9 <[email protected]>
10
11 Edited by
12
13 Otmar Lendl
14
15 <[email protected]>
16
17 Klaus Darilion
18
19 <[email protected]>
20
21 Copyright © 2002, 2003, 2006 Juha Heinanen, Otmar Lendl, Klaus Darilion
22 __________________________________________________________________
23
24 Table of Contents
25
26 1. Admin Guide
27
28 1. Overview
29 2. Dependencies
30 3. Parameters
31
32 3.1. db_url (string)
33 3.2. dp_table (string)
34 3.3. dp_col_rule (string)
35 3.4. dp_col_type (string)
36 3.5. dp_col_att (string)
37 3.6. dp_col_val (string)
38 3.7. port_override_avp (string)
39 3.8. transport_override_avp (string)
40 3.9. domain_replacement_avp (string)
41 3.10. domain_prefix_avp (string)
42 3.11. domain_suffix_avp (string)
43 3.12. send_socket_avp (string)
44
45 4. Functions
46
47 4.1. dp_can_connect()
48 4.2. dp_apply_policy()
49
50 5. Usage Scenarios
51
52 5.1. TLS Based Federation
53 5.2. SIP Hub based Federation
54 5.3. Walled Garden Federation
55
56 6. Known Limitations
57
58 List of Examples
59
60 1.1. Setting db_url parameter
61 1.2. Setting dp_table parameter
62 1.3. Setting dp_col_rule parameter
63 1.4. Setting dp_col_rule parameter
64 1.5. Setting dp_col_att parameter
65 1.6. Setting dp_col_val parameter
66 1.7. Setting port_override_avp parameter
67 1.8. Setting transport_override_avp parameter
68 1.9. Setting domain_replacement_avp parameter
69 1.10. Setting domain_prefix_avp parameter
70 1.11. Setting domain_suffix_avp parameter
71 1.12. Setting send_socket_avp parameter
72 1.13. dp_can_connect usage
73 1.14. dp_apply_policy usage
74
75 Chapter 1. Admin Guide
76
77 Table of Contents
78
79 1. Overview
80 2. Dependencies
81 3. Parameters
82
83 3.1. db_url (string)
84 3.2. dp_table (string)
85 3.3. dp_col_rule (string)
86 3.4. dp_col_type (string)
87 3.5. dp_col_att (string)
88 3.6. dp_col_val (string)
89 3.7. port_override_avp (string)
90 3.8. transport_override_avp (string)
91 3.9. domain_replacement_avp (string)
92 3.10. domain_prefix_avp (string)
93 3.11. domain_suffix_avp (string)
94 3.12. send_socket_avp (string)
95
96 4. Functions
97
98 4.1. dp_can_connect()
99 4.2. dp_apply_policy()
100
101 5. Usage Scenarios
102
103 5.1. TLS Based Federation
104 5.2. SIP Hub based Federation
105 5.3. Walled Garden Federation
106
107 6. Known Limitations
108
109 1. Overview
110
111 This module is considered obsolete. The drafts mentioned here have
112 expired. If you use this module, please send a note to the sr-dev
113 mailing list.
114
115 The Domain Policy module implements draft-lendl-domain-policy-ddds-02
116 in combination with draft-lendl-speermint-federations-02 and
117 draft-lendl-speermint-technical-policy-00. These IETF drafts define DNS
118 records with which a domain can announce its federation memberships. A
119 local database can be used to map policy rules to routing policy
120 decisions. This database can also contain rules concerning destination
121 domains independently of draft-lendl-domain-policy-ddds-02.
122
123 This module requires a database. No caching is implemented.
124
125 2. Dependencies
126
127 The module depends on the following modules (in other words the listed
128 modules must be loaded before this module):
129 * database -- Any database module
130
131 3. Parameters
132
133 3.1. db_url (string)
134 3.2. dp_table (string)
135 3.3. dp_col_rule (string)
136 3.4. dp_col_type (string)
137 3.5. dp_col_att (string)
138 3.6. dp_col_val (string)
139 3.7. port_override_avp (string)
140 3.8. transport_override_avp (string)
141 3.9. domain_replacement_avp (string)
142 3.10. domain_prefix_avp (string)
143 3.11. domain_suffix_avp (string)
144 3.12. send_socket_avp (string)
145
146 3.1. db_url (string)
147
148 This is URL of the database to be used.
149
150 Default value is “mysql://kamailio:kamailiorw@localhost/kamailio”
151
152 Example 1.1. Setting db_url parameter
153 modparam("domainpolicy", "db_url", "postgres://proxy:[email protected]/si
154 pdb")
155
156 3.2. dp_table (string)
157
158 Name of table containing the local support domain policy setup.
159
160 Default value is “domainpolicy”.
161
162 Example 1.2. Setting dp_table parameter
163 modparam("domainpolicy", "dp_table", "supportedpolicies")
164
165 3.3. dp_col_rule (string)
166
167 Name of column containing the domain policy rule name which is equal to
168 the URI as published in the domain policy NAPTRs.
169
170 Default value is “rule”.
171
172 Example 1.3. Setting dp_col_rule parameter
173 modparam("domainpolicy", "dp_col_rule", "rules")
174
175 3.4. dp_col_type (string)
176
177 Name of column containing the domain policy rule type. In the case of
178 federation names, this is "fed". For standard referrals according to
179 draft-lendl-speermint-technical-policy-00, this is "std". For direct
180 domain lookups, this is "dom".
181
182 Default value is “type”.
183
184 Example 1.4. Setting dp_col_rule parameter
185 modparam("domainpolicy", "dp_col_type", "type")
186
187 3.5. dp_col_att (string)
188
189 Name of column containing the AVP's name. If the rule stored in this
190 row triggers, than dp_can_connect() will add an AVP with that name.
191
192 Default value is “att”.
193
194 Example 1.5. Setting dp_col_att parameter
195 modparam("domainpolicy", "dp_col_att", "attribute")
196
197 3.6. dp_col_val (string)
198
199 Name of column containing the value for AVPs created by
200 dp_can_connect().
201
202 Default value is “val”.
203
204 Example 1.6. Setting dp_col_val parameter
205 modparam("domainpolicy", "dp_col_val", "values")
206
207 3.7. port_override_avp (string)
208
209 This parameter defines the name of the AVP where dp_apply_policy() will
210 look for an override port number.
211
212 Default value is “portoverride”.
213
214 Example 1.7. Setting port_override_avp parameter
215 # string named AVP
216 modparam("domainpolicy", "port_override_avp", "portoverride")
217
218 3.8. transport_override_avp (string)
219
220 Name of the AVP which contains the override transport setting.
221
222 Default value is “transportoverride”.
223
224 Example 1.8. Setting transport_override_avp parameter
225 # string named AVP
226 modparam("domainpolicy", "transport_override_avp", "transportoverride")
227
228 3.9. domain_replacement_avp (string)
229
230 Name of the AVP which contains a domain replacement.
231
232 Default value is “domainreplacement”.
233
234 Example 1.9. Setting domain_replacement_avp parameter
235 # string named AVP
236 modparam("domainpolicy", "domain_replacement_avp", "domainreplacement")
237
238 3.10. domain_prefix_avp (string)
239
240 Name of the AVP which contains a domain prefix.
241
242 Default value is “domainprefix”.
243
244 Example 1.10. Setting domain_prefix_avp parameter
245 # string named AVP
246 modparam("domainpolicy", "domain_prefix_avp", "domainprefix")
247
248 3.11. domain_suffix_avp (string)
249
250 Name of the AVP which contains a domain suffix.
251
252 Default value is “domainsuffix”.
253
254 Example 1.11. Setting domain_suffix_avp parameter
255 # string named AVP
256 modparam("domainpolicy", "domain_suffix_avp", "domainsuffix")
257
258 3.12. send_socket_avp (string)
259
260 Name of the AVP which contains a send_socket. The format of the send
261 socket (the payload of this AVP) must be in the format
262 [proto:]ip_address[:port]. The function dp_apply_policy will look for
263 this AVP and if defined, it will force the send socket to its value
264 (similar to the force_send_socket core function).
265
266 Default value is “sendsocket”.
267
268 Example 1.12. Setting send_socket_avp parameter
269 # string named AVP
270 modparam("domainpolicy", "send_socket_avp", "sendsocket")
271
272 4. Functions
273
274 4.1. dp_can_connect()
275 4.2. dp_apply_policy()
276
277 4.1. dp_can_connect()
278
279 Checks the interconnection policy of the caller. It uses the domain in
280 the request URI to perform the DP-DDDS algorithm according to
281 draft-lendl-domain-policy-ddds-02 to retrieve the domain's policy
282 announcements. As of this version, only records conforming to
283 draft-lendl-speermint-federations-02 and
284 draft-lendl-speermint-technical-policy-00 are supported.
285
286 Non-terminal NAPTR records will cause recursion to the replacement
287 domain. dp_can_connect() will thus look for policy rules in the
288 referenced domain. Furthermore, an AVP for "domainreplacement"
289 (containing the new domain) will be added to the call. This will
290 redirect SRV/A record lookups to the new domain.
291
292 In order to simplify direct domain-based peerings all destination
293 domains are treated as if they contain a top priority "D2P+SIP:dom"
294 rule with the domain itself as the value of the rule. Thus any database
295 row with type = 'dom' and rule = 'example.com' will override any
296 dynamic DNS-discovered rules.
297
298 For NAPTRs with service-type "D2P+SIP:fed", the federation IDs (as
299 extracted from the regexp field) are used to retrieve policy records
300 from a local local database (basically: "SELECT dp_col_att, dp_col_val
301 FROM dp_table WHERE dp_col_rule = '[federationID]' AND type = 'fed').
302 If records are found (and all other records with the same order value
303 are fulfillable) then AVPs will be created from the dp_col_att and
304 dp_col_val columns.
305
306 For NAPTRs with service-type "D2P+SIP:std", the same procedure is
307 performed. This time, the database lookup searched for type = 'std',
308 though.
309
310 "D2P+SIP:fed" and "D2P+SIP:std" can be mixed freely. If two rules with
311 the same "order" match and try to set the same AVP, then the behaviour
312 is undefined.
313
314 The dp_col_att column specifies the AVP's name. If the AVP start with
315 "s:" or "i:", the corresponding AVP type (string named or integer
316 named) will be generated. If the exact specifier is omitted, the AVP
317 type will be guessed.
318
319 The dp_col_val column will always be interpreted as string. Thus, the
320 AVP's value is always string based.
321
322 dp_can_connect returns:
323 * -2: on errors during the evaluation. (DNS, DB, ...)
324 * -1: D2P+SIP records were found, but the policy is not fullfillable.
325 * 1: D2P+SIP records were found and a call is possible
326 * 2: No D2P+SIP records were found. The destination domain does not
327 announce a policy for incoming SIP calls.
328
329 This function can be used from REQUEST_ROUTE.
330
331 Example 1.13. dp_can_connect usage
332 ...
333 dp_can_connect();
334 switch(retcode) {
335 case -2:
336 xlog("L_INFO","Errors during the DP evaluation\n");
337 sl_send_reply("404", "We can't connect you.");
338 break;
339 case -1:
340 xlog("L_INFO","We can't connect to that domain\n");
341 sl_send_reply("404", "We can't connect you.");
342 break;
343 case 1:
344 xlog("L_INFO","We found matching policy records\n");
345 avp_print();
346 dp_apply_policy();
347 t_relay();
348 break;
349 case 2:
350 xlog("L_INFO","No DP records found\n");
351 t_relay();
352 break;
353 }
354 ...
355
356 4.2. dp_apply_policy()
357
358 This function sets the destination URI according to the policy returned
359 from the dp_can_connect() function. Parameter exchange between
360 dp_can_connect() and dp_apply_policy() is done via AVPs. The AVPs can
361 be configured in the module's parameter section.
362
363 Note: The name of the AVPs must correspond with the names in the att
364 column in the domainpolicy table.
365
366 Setting the following AVPs in dp_can_connect() (or by any other means)
367 cause the following actions in dp_apply_policy():
368 * port_override_avp: If this AVP is set, the port in the destination
369 URI is set to this port. Setting an override port disables NAPTR
370 and SRV lookups according to RFC 3263.
371 * transport_override_avp: If this AVP is set, the transport parameter
372 in the destination URI is set to the specified transport ("udp",
373 "tcp", "tls"). Setting an override transport also disables NAPTR
374 lookups, but retains an SRV lookup according to RFC 3263.
375 * domain_replacement_avp: If this AVP is set, the domain in the
376 destination URI will be replaced by this domain.
377 A non-terminal NAPTR and thus a referral to a new domain implicitly
378 sets domain_replacement_avp to the new domain.
379 * domain_prefix_avp: If this AVP is set, the domain in the
380 destination URI will be prefixed with this "subdomain". E.g. if the
381 domain in the request URI is "example.com" and the
382 domain_prefix_avp contains "inbound", the domain in the destination
383 URI is set to "inbound.example.com".
384 * domain_suffix_avp: If this AVP is set, the domain in the
385 destination URI will have the content of the AVP appended to it.
386 E.g. if the domain in the request URI is "example.com" and the
387 domain_suffix_avp contains "myroot.com", the domain in the
388 destination URI is set to "example.com.myroot.com".
389 * send_socket_avp: If this AVP is set, the sending socket will be
390 forced to the socket in the AVP. The payload format of this AVP
391 must be [proto:]ip_address[:port].
392
393 If both prefix/suffix and domain replacements are used, then the
394 replacement is performed first and the prefix/suffix are applied to the
395 new domain.
396
397 This function can be used from REQUEST_ROUTE.
398
399 Example 1.14. dp_apply_policy usage
400 ...
401 if (dp_apply_policy()) {
402 t_relay();
403 }
404 ...
405
406 5. Usage Scenarios
407
408 5.1. TLS Based Federation
409 5.2. SIP Hub based Federation
410 5.3. Walled Garden Federation
411
412 This section describes how this module can be use to implement
413 selective VoIP peerings.
414
415 5.1. TLS Based Federation
416
417 This example shows how a secure peering fabric can be configured based
418 on TLS and Domain Policies.
419
420 Let's assume that an organization called "TLSFED.org" acts as an
421 umbrella for VoIP providers who want to peer with each other but don't
422 want to run open SIP proxies. TLSFED.org's secretary acts as an X.509
423 Certification Authority that signs the TLS keys of all member's SIP
424 proxies. Each member should automatically allow incoming calls from
425 other members. On the other hand, the configuration for this federation
426 must not interfere with a member's participation in other VoIP peering
427 fabrics. All this can be achieved by the following configuration for a
428 participating VoIP operation called example.com:
429 * Incoming SIP configuration
430 Calls from other members are expected to use TLS and authenticate
431 using a client-CERT. To implement this, we cannot share a TCP/TLS
432 port with other incoming connections. Thus we need to use
433 tls_server_domain[] to dedicate a TCP port for this federation.
434 tls_server_domain[1.2.3.4:5066] {
435 tls_certificate = "/path/to/tlsfed/example-com.key"
436 tls_private_key = "/path/to/tlsfed/example-com.crt"
437 tls_ca_list = "/path/to/tlsfed/ca.pem"
438 tls_method = tlsv1
439 tls_verify_client = 1
440 tls_require_cleint_certificate = 1
441 }
442 * Outgoing SIP configuration
443 Calls to other members must also use the proper client cert.
444 Therefore, a TLS client domain must be configured. We use the
445 federation name as TLS client domain identifier. Therefore, the
446 content of the "tls_client_domain_avp" must be set to this
447 identifier (e.g. by putting it as rule into the domainpolicy
448 table).
449 tls_client_domain["tlsfed"] {
450 tls_certificate = "/path/to/tlsfed/example-com.key"
451 tls_private_key = "/path/to/tlsfed/example-com.crt"
452 tls_ca_list = "/path/to/tlsfed/ca.pem"
453 tls_method = tlsv1
454 tls_verify_server = 1
455 }
456
457 5.2. SIP Hub based Federation
458
459 This example shows how a peering fabric based on a central SIP hub can
460 be configured.
461
462 Let's assume that an organization called "HUBFED.org" acts as an
463 umbrella for VoIP providers who want to peer with each other but don't
464 want to run open SIP proxies. Instead, HUBFED.org operates a central
465 SIP proxy which will relay calls between all participating members.
466 Each member thus only needs to allow incoming calls from that central
467 hub (which could be done by firewalling). All this can be achieved by
468 the following configuration for a participating VoIP operation called
469 example.com:
470 * DNS configuration
471 The destination network announces its membership in this
472 federation.
473 $ORIGIN destination.example.org
474 @ IN NAPTR 10 50 "U" "D2P+SIP:fed" (
475 "!^.*$!http://HUBFED.org/!" . )
476 * Outgoing SIP configuration
477 Calls to other members need to be redirected to the central proxy.
478 The domainpolicy table just needs to list the federation and link
479 it to the central proxy's domain name:
480 mysql> select * from domainpolicy;
481 +----+--------------------+------+-------------------+----------------+
482 | id | rule | type | att | val |
483 +----+--------------------+------+-------------------+----------------+
484 | 1 | http://HUBFED.org/ | fed | domainreplacement | sip.HUBFED.org |
485 +----+--------------------+------+-------------------+----------------+
486
487 5.3. Walled Garden Federation
488
489 This example assumes that a set of SIP providers have established a
490 secure Layer 3 network between their proxies. It does not matter
491 whether this network is built by means of IPsec, a private Layer 2
492 network, or by simple firewalling. We will use the 10.x network (for
493 the walled garden net) and "http://l3fed.org/" (as federation
494 identifier) in this example.
495
496 A member of this federation (e.g. example.com) can not announce its SIP
497 proxy's 10.x address in the standard SRV / A records of his domain, as
498 this address is only meaningful for other members of this federation.
499 In order to facilitate different IP address resolution paths within the
500 federation vs. outside the federation, all members of
501 "http://l3fed.org/" agree to prefix the destination domains with
502 "l3fed" before the SRV (or A) lookup.
503
504 Here is the configuration for example.com:
505 * DNS configuration
506 The destination network announces its membership in this
507 federation.
508 $ORIGIN example.com
509 @ IN NAPTR 10 50 "U" "D2P+SIP:fed" (
510 "!^.*$!http://l3fed.org/!" . )
511 _sip._udp IN SRV 10 10 5060 publicsip.example.com.
512 _sip._udp.l3fe IN SRV 10 10 5060 l3fedsip.example.com.
513
514 publicsip IN A 193.XXX.YYY.ZZZ
515 l3fedsip IN A 10.0.0.42
516 * Outgoing SIP configuration
517 The domainpolicy table just needs to link the federation identifier
518 to the agreed apon prefix:
519 mysql> select * from domainpolicy;
520 +----+-------------------+------+--------------+-------+
521 | id | rule | type | att | val |
522 +----+-------------------+------+--------------+-------+
523 | 1 | http://l3fed.org/ | fed | domainprefix | l3fed |
524 +----+-------------------+------+--------------+-------+
525
526 6. Known Limitations