Debian Codegraph @

src/modules/diversion/README

raw
1 Diversion Module
2
3 Jan Janak
4
5 FhG FOKUS
6
7 Edited by
8
9 Jan Janak
10
11 Copyright © 2004 FhG FOKUS
12 __________________________________________________________________
13
14 Table of Contents
15
16 1. Admin Guide
17
18 1. Overview
19 2. Dependencies
20
21 2.1. Kamailio Modules
22 2.2. External Libraries or Applications
23
24 3. Parameters
25
26 3.1. suffix (string)
27
28 4. Functions
29
30 4.1. add_diversion(reason [, uri])
31
32 5. Diversion Example
33
34 2. Developer Guide
35
36 List of Examples
37
38 1.1. suffix usage
39 1.2. add_diversion usage
40
41 Chapter 1. Admin Guide
42
43 Table of Contents
44
45 1. Overview
46 2. Dependencies
47
48 2.1. Kamailio Modules
49 2.2. External Libraries or Applications
50
51 3. Parameters
52
53 3.1. suffix (string)
54
55 4. Functions
56
57 4.1. add_diversion(reason [, uri])
58
59 5. Diversion Example
60
61 1. Overview
62
63 The module implements the Diversion extensions as per RFC 5806. The
64 diversion extensions are useful in various scenarios involving call
65 forwarding. Typically one needs to communicate the original recipient
66 of the call to the PSTN gateway and this is what the diversion
67 extensions can be used for.
68
69 Warning
70
71 Note that RFC 5806 has historic status.
72
73 2. Dependencies
74
75 2.1. Kamailio Modules
76 2.2. External Libraries or Applications
77
78 2.1. Kamailio Modules
79
80 None.
81
82 2.2. External Libraries or Applications
83
84 The following libraries or applications must be installed before
85 running Kamailio with this module loaded:
86 * None.
87
88 3. Parameters
89
90 3.1. suffix (string)
91
92 3.1. suffix (string)
93
94 The suffix to be appended to the end of the header field. You can use
95 the parameter to specify additional parameters to be added to the
96 header field, see the example.
97
98 Default value is “” (empty string).
99
100 Example 1.1. suffix usage
101 modparam("diversion", "suffix", ";privacy=full")
102
103 4. Functions
104
105 4.1. add_diversion(reason [, uri])
106
107 4.1. add_diversion(reason [, uri])
108
109 The function adds a new diversion header field before any other
110 existing Diversion header field in the message (the newly added
111 Diversion header field will become the topmost Diversion header field).
112 If 'uri' parameter is missing, the inbound (without any modifications
113 done by the proxy server) Request-URI will be used as the Diversion
114 URI.
115
116 Meaning of the parameters is as follows:
117 * reason - The reason string to be added as the reason parameter
118 * uri - The URI to be set in Diversion header
119
120 The parameters can contain pseudo-variables.
121
122 This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
123 BRANCH_ROUTE.
124
125 Example 1.2. add_diversion usage
126 ...
127 add_diversion("user-busy");
128 add_diversion("user-busy", "$ru");
129 ...
130
131 5. Diversion Example
132
133 The following example shows a Diversion header field added to INVITE
134 message. The original INVITE received by the user agent of
135 sip:[email protected] is:
136 INVITE sip:[email protected] SIP/2.0
137 Via: SIP/2.0/UDP 1.2.3.4:5060
138 From: "mark" <sip:[email protected]>;tag=ldgheoihege
139 To: "Bob" <sip:[email protected]>
140 Call-ID: [email protected]
141 CSeq: 3 INVITE
142 Contact: <sip:[email protected]>
143 Content-Length: 0
144
145 The INVITE message is diverted by the user agent of sip:[email protected]
146 because the user was talking to someone else and the new destination is
147 sip:[email protected] :
148 INVITE sip:[email protected] SIP/2.0
149 Via: SIP/2.0/UDP 5.6.7.8:5060
150 Via: SIP/2.0/UDP 1.2.3.4:5060
151 From: "mark" <sip:[email protected]>;tag=ldgheoihege
152 To: "Bob" <sip:[email protected]>
153 Call-ID: [email protected]
154 CSeq: 3 INVITE
155 Diversion: <sip:[email protected]>;reason=user-busy
156 Contact: <sip:[email protected]>
157 Content-Length: 0
158
159 Chapter 2. Developer Guide
160
161 According to the specification a new “Diversion” header field should be
162 inserted as the topmost Diversion header field in the message, that
163 means before any other existing Diversion header field in the message.
164 In addition to that, the add_diversion function can be called several
165 times and each time it should insert the new Diversion header field as
166 the topmost one.
167
168 In order to implement this, add_diversion function creates the anchor
169 in data_lump lists as a static variable to ensure that the next call of
170 the function will use the same anchor and would insert new Diversion
171 headers before the one created in the previous execution. To my
172 knowledge this is the only way of inserting the diversion header field
173 before any other created in previous runs of the function.
174
175 The anchor kept this way is only valid for a single message and we have
176 to invalidate it when another message is being processed. For this
177 reason, the function also stores the id of the message in another
178 static variable and compares the value of that variable with the id of
179 the SIP message being processed. If they differ then the anchor will be
180 invalidated and the function creates a new one.
181
182 The following code snippet shows the code that invalidates the anchor,
183 new anchor will be created when the anchor variable is set to 0.
184 static inline int add_diversion_helper(struct sip_msg* msg, str* s)
185 {
186 static struct lump* anchor = 0;
187 static int msg_id = 0;
188
189 if (msg_id != msg->id) {
190 msg_id = msg->id;
191 anchor = 0;
192 }
193 ...
194 }