Debian Codegraph @

src/modules/maxfwd/README

raw
1 maxfwd Module
2
3 Bogdan-Andrei Iancu
4
5 Voice Sistem SRL
6
7 Edited by
8
9 Bogdan-Andrei Iancu
10
11 Copyright © 2003 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. max_limit (integer)
27
28 4. Functions
29
30 4.1. maxfwd_process(max_value)
31 4.2. mf_process_maxfwd_header(max_value)
32 4.3. process_maxfwd(max_value)
33 4.4. is_maxfwd_lt(max_value)
34 4.5. maxfwd_at_least(max_value)
35 4.6. mf_lowlimit(max_value)
36
37 List of Examples
38
39 1.1. Set max_limit parameter
40 1.2. maxfwd_process usage
41 1.3. is_maxfwd_lt usage
42
43 Chapter 1. Admin Guide
44
45 Table of Contents
46
47 1. Overview
48 2. Dependencies
49
50 2.1. Kamailio Modules
51 2.2. External Libraries or Applications
52
53 3. Parameters
54
55 3.1. max_limit (integer)
56
57 4. Functions
58
59 4.1. maxfwd_process(max_value)
60 4.2. mf_process_maxfwd_header(max_value)
61 4.3. process_maxfwd(max_value)
62 4.4. is_maxfwd_lt(max_value)
63 4.5. maxfwd_at_least(max_value)
64 4.6. mf_lowlimit(max_value)
65
66 1. Overview
67
68 The module implements all of the operations that handle the Max-Forward
69 SIP header field, like adding it (if not present) or decrementing and
70 checking the value of the existent one.
71
72 The SIP Max-Forward header is used to prevent loops in a SIP network.
73 Every server that process and forward a SIP request lowers the
74 Max-Forward value with one. When the value reaches zero, the request is
75 not forwarded and an error response is sent to the UAC.
76
77 2. Dependencies
78
79 2.1. Kamailio Modules
80 2.2. External Libraries or Applications
81
82 2.1. Kamailio Modules
83
84 The following modules must be loaded before this module:
85 * No dependencies on other Kamailio modules.
86
87 2.2. External Libraries or Applications
88
89 The following libraries or applications must be installed before
90 running Kamailio with this module loaded:
91 * None.
92
93 3. Parameters
94
95 3.1. max_limit (integer)
96
97 3.1. max_limit (integer)
98
99 Set an upper limit for the max-forward value in the outgoing requests.
100 If the header is present, the decremented value is not allowed to
101 exceed this max_limits - if it does, the header value will by decreased
102 to “max_limit”.
103
104 Note: This check is done when calling the maxfwd_process() function.
105
106 The range of values stretches from 1 to 256, which is the maximum
107 MAX-FORWARDS value allowed by RFC 3261. The value can be changed at
108 runtime.
109
110 Default value is “70”.
111
112 Example 1.1. Set max_limit parameter
113 ...
114 modparam("maxfwd", "max_limit", 32)
115 ...
116
117 4. Functions
118
119 4.1. maxfwd_process(max_value)
120 4.2. mf_process_maxfwd_header(max_value)
121 4.3. process_maxfwd(max_value)
122 4.4. is_maxfwd_lt(max_value)
123 4.5. maxfwd_at_least(max_value)
124 4.6. mf_lowlimit(max_value)
125
126 4.1. maxfwd_process(max_value)
127
128 If no Max-Forward header is present in the received request, a header
129 will be added having the original value equal with “max_value”. If a
130 Max-Forward header is already present, its value will be decremented
131 (if not 0). The parameter can be a variable.
132
133 Return codes:
134 * 2 (true) - header was not found and a new header was successfully
135 added.
136 * 1 (true) - header was found and its value was successfully
137 decremented (had a non-0 value).
138 * -1 (false) - the header was found and its value is 0 (cannot be
139 decremented).
140 * -2 (false) - error during processing.
141
142 The return code may be extensively tested via script variable “retcode”
143 (or “$?”).
144
145 Meaning of the parameters is as follows:
146 * max_value - Value to be added if there is no Max-Forwards header
147 field in the message.
148
149 This function can be used from REQUEST_ROUTE.
150
151 Example 1.2. maxfwd_process usage
152 ...
153 # initial sanity checks -- messages with
154 # max_forwards==0, or excessively long requests
155 if (!maxfwd_process("10") && $retcode==-1) {
156 sl_send_reply("483","Too Many Hops");
157 exit;
158 };
159 ...
160
161 4.2. mf_process_maxfwd_header(max_value)
162
163 Same as maxfwd_process(max_value).
164
165 4.3. process_maxfwd(max_value)
166
167 Same as maxfwd_process(max_value).
168
169 4.4. is_maxfwd_lt(max_value)
170
171 Checks if the Max-Forward header value is less than the “max_value”
172 parameter value. It considers also the value of the new inserted header
173 (if locally added). The parameter can be a variable.
174
175 Return codes:
176 * 1 (true) - header was found or set and its value is strictly less
177 than “max_value”.
178 * -1 (false) - the header was found or set and its value is greater
179 or equal to “max_value”.
180 * -2 (false) - header was not found or not set.
181 * -3 (false) - error during processing.
182
183 The return code may be extensively tested via script variable “retcode”
184 (or “$?”).
185
186 Meaning of the parameters is as follows:
187 * max_value - value to check the Max-Forward.value against (as less
188 than).
189
190 Example 1.3. is_maxfwd_lt usage
191 ...
192 # next hop is a gateway, so make no sense to
193 # forward if MF is 0 (after decrement)
194 if ( is_maxfwd_lt("1") ) {
195 sl_send_reply("483","Too Many Hops");
196 exit;
197 };
198 ...
199
200 4.5. maxfwd_at_least(max_value)
201
202 Same as is_maxfwd_lt(max_value).
203
204 4.6. mf_lowlimit(max_value)
205
206 Same as is_maxfwd_lt(max_value).