Debian Codegraph @

src/modules/mangler/README

raw
1 The Mangler Module - SDP mangling
2
3 Gabriel Vasile
4
5 FhG FOKUS
6
7 Copyright © 2003 FhG FOKUS
8 __________________________________________________________________
9
10 Table of Contents
11
12 1. Admin Guide
13
14 1. Overview
15 2. Parameters
16
17 2.1. contact_flds_separator (string)
18
19 3. Functions
20
21 3.1. sdp_mangle_ip(pattern, newip)
22 3.2. sdp_mangle_port(offset)
23 3.3. encode_contact(encoding_prefix)
24 3.4. decode_contact()
25 3.5. decode_contact_header()
26
27 List of Examples
28
29 1.1. Set db_url parameter
30 1.2. sdp_mangle_ip usage
31 1.3. sdp_mangle_port usage
32 1.4. encode_contact usage
33 1.5. decode_contact usage
34 1.6. decode_contact_header usage
35
36 Chapter 1. Admin Guide
37
38 Table of Contents
39
40 1. Overview
41 2. Parameters
42
43 2.1. contact_flds_separator (string)
44
45 3. Functions
46
47 3.1. sdp_mangle_ip(pattern, newip)
48 3.2. sdp_mangle_port(offset)
49 3.3. encode_contact(encoding_prefix)
50 3.4. decode_contact()
51 3.5. decode_contact_header()
52
53 1. Overview
54
55 This is a module to help with SDP mangling - changing data in the SDP.
56
57 2. Parameters
58
59 2.1. contact_flds_separator (string)
60
61 2.1. contact_flds_separator (string)
62
63 First char of this parameter is used as a separator for
64 encoding/decoding Contact headers. If you set this parameter to "-",
65 then an encoded URI will look like
66 "sip:user-password-ip-port-protocol@PublicIP"
67
68 Warning
69
70 The first character of this field must be set to a value which is not
71 used inside username, password or other fields of contact. Otherwise it
72 is possible for the decoding step to fail/produce wrong results.
73
74 Default value is "*".
75
76 Example 1.1. Set db_url parameter
77 ...
78 modparam("mangler", "contact_flds_separator", "-")
79 ...
80
81 3. Functions
82
83 3.1. sdp_mangle_ip(pattern, newip)
84 3.2. sdp_mangle_port(offset)
85 3.3. encode_contact(encoding_prefix)
86 3.4. decode_contact()
87 3.5. decode_contact_header()
88
89 3.1. sdp_mangle_ip(pattern, newip)
90
91 Changes IP addresses inside SDP document in lines describing
92 connections like c=IN IP4 . Currently this function only changes IP4
93 addresses since IP6 probably will not need to traverse NAT :)
94
95 The function returns negative on error, or number of replacements + 1.
96
97 Meaning of the parameters is as follows:
98 * pattern - An IP address/mask pair used to match IP's located inside
99 SDP package in lines c=IN IP4 ip. This line will only be changed if
100 located IP is in the network described by this pattern. Examples of
101 valid patterns are "10.0.0.0/255.0.0.0" or "10.0.0.0/8" etc.
102 * newip - A string representing the new IP to be put inside SDP
103 package if old IP address matches pattern.
104
105 Example 1.2. sdp_mangle_ip usage
106 ...
107 sdp_mangle_ip("10.0.0.0/8","193.175.135.38");
108 ...
109
110 3.2. sdp_mangle_port(offset)
111
112 Changes ports in SDP document in lines starting a media section like
113 "m=audio 13451".
114
115 The function returns negative on error, or number of replacements + 1.
116
117 Meaning of the parameters is as follows:
118 * offset - A string representing an integer which will be
119 added/subtracted from the located port.
120
121 Example 1.3. sdp_mangle_port usage
122 ...
123 sdp_mangle_port("-12000");
124 ...
125
126 3.3. encode_contact(encoding_prefix)
127
128 This function will encode URIs inside the "Contact" header in the
129 following manner "sip:username:password@ip:port;transport=protocol"
130 goes sip:enc_pref*username*ip*port*protocol@public_ip. "*" (asterisk)
131 is the default separator.
132
133 The function returns negative on error, 1 on success.
134
135 Meaning of the parameters is as follows:
136 * encoding_prefix - Something to allow us to determine that a contact
137 is encoded public IP--a routable IP, most probably you should put
138 your external IP of your NAT box.
139
140 Example 1.4. encode_contact usage
141 ...
142 if (src_ip == 10.0.0.0/8) encode_contact("enc_prefix","193.175.135.38");
143 ...
144
145 3.4. decode_contact()
146
147 This function will decode the URI in first line in packets which come
148 with encoded URI in the following manner
149 sip:enc_pref*username*ip*port*protocol*src_ip*src_port*src_proto@public
150 _ip;parameters is converted to sip:username:password@ip:port;parameters
151 and will set destination URI to sip:src_ip:src_port;transport=src_proto
152 (so that the next forward() or t_relay() will send the message back to
153 src_ip:src_port using src_proto). It uses the default set parameter for
154 contact encoding separator.
155
156 The function returns negative on error, 1 on success.
157
158 Example 1.5. decode_contact usage
159 ...
160 if (uri =~ "^enc*") { decode_contact(); }
161 ...
162
163 3.5. decode_contact_header()
164
165 This function will decode URIs inside the "Contact" header in the same
166 manner as decode_contact(). The difference is that no dst_uri is set
167 (src_ip, src_port and src_proto are ignored) and instead of changing
168 the request URI, the Contact header URI is modified. It uses the
169 default set parameter for contact encoding separator.
170
171 The function returns negative on error, 1 on success.
172
173 Example 1.6. decode_contact_header usage
174 ...
175 if (uri =~ "^enc*") { decode_contact_header(); }
176 ...