Debian Codegraph @

src/modules/xprint/README

raw
1 The Xprint Module
2
3 Elena-Ramona Modroiu
4
5 Asipto
6
7 Copyright © 2003 FhG FOKUS
8 __________________________________________________________________
9
10 Table of Contents
11
12 1. Admin Guide
13
14 1. Overview
15 2. Implemented Specifiers
16 3. Parameters
17
18 3.1. buf_size (integer)
19
20 4. Functions
21
22 4.1. xplog(level, format)
23 4.2. xpdbg(format)
24
25 2. Developer Guide
26
27 1. Module API
28
29 1.1. Functions
30
31 1.1.1. int xbind(xl_api_t *xl_api)
32 1.1.2. int xparse(char *s, xl_elog_p *el)
33 1.1.3. int shm_xparse(char *s, xl_elog_p *el)
34 1.1.4. int xparse2(char *s, xl_elog_p *el, xl_parse_cb
35 cb)
36
37 1.1.5. int shm_xparse2(char *s, xl_elog_p *el,
38 xl_parse_cb cb)
39
40 1.1.6. xfree(xl_elog_p el)
41 1.1.7. shm_xfree(xl_elog_p el)
42 1.1.8. int xprint(struct sip_msg* msg, xl_elog_p el,
43 char *buf, int *len)
44
45 1.1.9. str *xnulstr()
46
47 List of Examples
48
49 1.1. Set buf_size parameter
50 1.2. xplog usage
51 1.3. xpdbg usage
52
53 Chapter 1. Admin Guide
54
55 Table of Contents
56
57 1. Overview
58 2. Implemented Specifiers
59 3. Parameters
60
61 3.1. buf_size (integer)
62
63 4. Functions
64
65 4.1. xplog(level, format)
66 4.2. xpdbg(format)
67
68 1. Overview
69
70 IMPORTANT: this is former xlog module from SIP Express Router (SER)
71 kept because it is used by other modules via API to get the value for
72 strings with specifiers. If you want to print log messages from
73 configuration file, use the real module named 'xlog'.
74
75 This module provides the possibility to print user formatted log or
76 debug messages from SER scripts, similar to printf function but now a
77 specifier is replaced with a part of the SIP request. Section 2,
78 “Implemented Specifiers” shows what can be printed out.
79
80 2. Implemented Specifiers
81
82 * %% : '%'
83 * %br : request's first branch
84 * %bR : request's all branches
85 * %ci : call-id
86 * %cs : cseq
87 * %ct : contact header
88 * %Cxy : color printing based on escape sequences (x - foreground
89 color, y - background color). The values for colors: x - default
90 color of the terminal; s - Black; r - Red; g - Green; y - Yellow; b
91 - Blue; p - Purple; c - Cyan; w - White
92 * %ds : destination set
93 * %fu : 'From' uri
94 * %ft : 'From' tag
95 * %Hn : host's hostname (if system hostname is FQDN, part before
96 first .)
97 * %Hd : host's domain (if system hostname is FQDN, part behind first
98 .)
99 * %Hf : host's FQDN hostname
100 * %Hi : host's IP address
101 * %mb : whole SIP message buffer
102 * %mf : flags set for current SIP request
103 * %mi : SIP message id
104 * %ml : SIP message length
105 * %mx : SIP message id (in hex notation)
106 * %nh : message's next hop
107 * %pp : process id (pid)
108 * %px : process id (pid) (in hex notation)
109 * %rm : request's method
110 * %ru : request's r-uri
111 * %rr : reply's reason
112 * %rs : reply's status
113 * %rt : 'Refer-To' uri
114 * %Ri : IP address of the interface where the request has been
115 received
116 * %Rp : received port
117 * %si : IP source address
118 * %sp : source port
119 * %tu : 'To' uri
120 * %tt : 'To' tag
121 * %Ts : unix time stamp
122 * %Tf : string formatted time
123 * %Tx : unix time stamp (in hex notation)
124 * %ua : User agent header field
125 * %uq : unique id (per SER's process) - to make really unique id use
126 %uq-%px-%mx or %uq-%px-%Tx
127 * %{name[N]} : print the body of the Nth header identified by 'name'.
128 If [N] is omitted then the body of the first header is printed. The
129 first header is got when N=0, for the second N=1, a.s.o. To print
130 the last header of that type, use -1, no other negative values are
131 supported now. No white spaces are allowed inside the specifier
132 (before }, before or after {, [, ] symbols). When N='*', all
133 headers of that type are printed.
134 The module should identify most of compact header names (the ones
135 recognized by ser which should be all at this moment), if not, the
136 compact form has to be specified explicitly. It is recommended to
137 use dedicated specifiers for headers (e.g., %ua for user agent
138 header), if they are available -- they are faster.
139 * %<name[N]> : print the value of AVP optionally %indexed by the [N]
140 value It uses AVPs subindexing, e.g. if you don't specify subindex
141 and there are more AVPs with the same name, the result is NULL. To
142 specify first AVP use [1], negative values are indexes counted
143 backward through the list.
144 * %@select.framework[N].value : print the value of select framework
145 call. For detailed info what calls are available see select
146 framework documentation (and modules documentation, as modules can
147 extend select framework calls).
148 * %| or %(space) : end of %@select.framework identifier. If you need
149 to concatenate select framework call and another non-whitespace
150 literal, you need to explicitly set the end of the select framework
151 identifier.
152 E.g. %@ruri.user%|@%@ruri.host converts all featured request uri
153 into user@host form only.
154
155 3. Parameters
156
157 3.1. buf_size (integer)
158
159 3.1. buf_size (integer)
160
161 Maximum size of the log message.
162
163 Default value is 4096.
164
165 Example 1.1. Set buf_size parameter
166 ...
167 modparam("xprint", "buf_size", 8192)
168 ...
169
170 4. Functions
171
172 4.1. xplog(level, format)
173 4.2. xpdbg(format)
174
175 4.1. xplog(level, format)
176
177 Print a formatted message using LOG function.
178
179 Meaning of the parameters is as follows:
180 * level - The level that will be used in LOG function. It can be:
181 + L_ALERT
182 + L_CRIT
183 + L_ERR
184 + L_WARN
185 + L_NOTICE
186 + L_INFO
187 + L_DBG
188 What really matters is the third letter of the value.
189 * format - The formatted string to be printed.
190
191 Example 1.2. xplog usage
192 ...
193 xplog("L_ERR", "time [%Tf] method <%rm> r-uri <%ru> 2nd via <%{via[1]}>\n");
194 ...
195
196 4.2. xpdbg(format)
197
198 Print a formatted message using DBG function.
199
200 Meaning of the parameters is as follows:
201 * format - The formatted string to be printed.
202
203 Example 1.3. xpdbg usage
204 ...
205 xpdbg("time [%Tf] method <%rm> r-uri <%ru>\n");
206 ...
207
208 Chapter 2. Developer Guide
209
210 Table of Contents
211
212 1. Module API
213
214 1.1. Functions
215
216 1.1.1. int xbind(xl_api_t *xl_api)
217 1.1.2. int xparse(char *s, xl_elog_p *el)
218 1.1.3. int shm_xparse(char *s, xl_elog_p *el)
219 1.1.4. int xparse2(char *s, xl_elog_p *el, xl_parse_cb cb)
220 1.1.5. int shm_xparse2(char *s, xl_elog_p *el, xl_parse_cb
221 cb)
222
223 1.1.6. xfree(xl_elog_p el)
224 1.1.7. shm_xfree(xl_elog_p el)
225 1.1.8. int xprint(struct sip_msg* msg, xl_elog_p el, char
226 *buf, int *len)
227
228 1.1.9. str *xnulstr()
229
230 1. Module API
231
232 1.1. Functions
233
234 1.1.1. int xbind(xl_api_t *xl_api)
235 1.1.2. int xparse(char *s, xl_elog_p *el)
236 1.1.3. int shm_xparse(char *s, xl_elog_p *el)
237 1.1.4. int xparse2(char *s, xl_elog_p *el, xl_parse_cb cb)
238 1.1.5. int shm_xparse2(char *s, xl_elog_p *el, xl_parse_cb cb)
239 1.1.6. xfree(xl_elog_p el)
240 1.1.7. shm_xfree(xl_elog_p el)
241 1.1.8. int xprint(struct sip_msg* msg, xl_elog_p el, char *buf,
242 int *len)
243
244 1.1.9. str *xnulstr()
245
246 1.1. Functions
247
248 1.1.1. int xbind(xl_api_t *xl_api)
249
250 Bind to the xprint module API.
251
252 Meaning of the parameters is as follows:
253 * xl_api - structure that the xprint module functions are bind to.
254 The functions can be executed as xl_api.xparse(),
255 xl_api.xprint()...
256
257 Return value: 0 - success, <0 - error.
258
259 1.1.2. int xparse(char *s, xl_elog_p *el)
260
261 Parse an xl-formatted string in private memory.
262
263 Meaning of the parameters is as follows:
264 * s - string to be parsed.
265 * el - returned xl-lib list.
266
267 Return value: 0 - success, <0 - error.
268
269 1.1.3. int shm_xparse(char *s, xl_elog_p *el)
270
271 Parse an xl-formatted string in shared memory. See xparse() function
272 for details.
273
274 1.1.4. int xparse2(char *s, xl_elog_p *el, xl_parse_cb cb)
275
276 Parse an xl-formatted string in private memory. This function is able
277 to identify regular expression back references, for example \1, \2,
278 \3... When a back reference is found the callback function is called
279 that is supposed to farther parse the back reference and fill in the
280 xl_elog structure.
281
282 Meaning of the parameters is as follows:
283 * s - string to be parsed.
284 * el - returned xl-lib list.
285 * cb - callback function for parsing the regular expression back
286 references.
287
288 The prototype of the callback function is: typedef int (*xl_parse_cb)
289 (str *s, int shm, xl_elog_p el);
290
291 Parameters of the callback function:
292 * s - regular expression back reference to be parsed (without the
293 leading '\' character).
294 * shm - indicates whether or not shared memory needs to be used. (1:
295 shared memory, 0: private memory)
296 * el - pointer to the xl-lib list item that is supposed to be filled
297 in.
298
299 Return value: 0 - success, <0 - error.
300
301 1.1.5. int shm_xparse2(char *s, xl_elog_p *el, xl_parse_cb cb)
302
303 Parse an xl-formatted string in shared memory supporting regular
304 expression back references. See xparse2() function for details.
305
306 1.1.6. xfree(xl_elog_p el)
307
308 Free the xl-lib list allocated by xparse() or xparse2().
309
310 Meaning of the parameters is as follows:
311 * el - xl-lib list to be freed.
312
313 1.1.7. shm_xfree(xl_elog_p el)
314
315 Free the xl-lib list allocated by shm_xparse() or shm_xparse2().
316
317 Meaning of the parameters is as follows:
318 * el - xl-lib list to be freed.
319
320 1.1.8. int xprint(struct sip_msg* msg, xl_elog_p el, char *buf, int *len)
321
322 Evaluate the xl-formatted string and print the result into a buffer.
323
324 Meaning of the parameters is as follows:
325 * msg - SIP message pointer.
326 * el - xl-lib list to be evaluated.
327 * buf - pre-allocated buffer that is filled in with the result.
328 * len - length of the printed string. len needs to be set to the
329 maximum length of the result buffer before calling this function.
330
331 Return value: 0 - success, <0 - error.
332
333 1.1.9. str *xnulstr()
334
335 Return the string "<null>".