Copyright © 2003 FhG FOKUS
search(re)
search_body(re)
search_append(re, txt)
search_append_body(re, txt)
replace(re, txt)
replace_body(re, txt)
replace_all(re, txt)
replace_body_all(re, txt)
subst('/re/repl/flags')
subst_uri('/re/repl/flags')
subst_user('/re/repl/flags')
subst_body('/re/repl/flags')
append_to_reply(txt)
append_hf(txt)
append_hf(txt, hdr)
insert_hf(txt)
insert_hf(txt, hdr)
append_urihf(prefix, suffix)
is_present_hf(hf_name)
append_time()
is_method(name)
remove_hf(hname)
has_body()
,
has_body(mime)
is_privacy(privacy_type)
search
usagesearch_body
usagesearch_append
usagesearch_append_body
usagereplace
usagereplace_body
usagereplace_all
usagereplace_body_all
usagesubst
usagesubst_uri
usagesubst
usagesubst_body
usageappend_to_reply
usageappend_hf
usageappend_hf
usageinsert_hf
usageinsert_hf
usageappend_urihf
usageis_present_hf
usageappend_time
usageis_method
usageremove_hf
usagehas_body
usageis_privacy
usageThis is mostly an example module. It implements text based operation (search, replace, append a.s.o).
search ignores folded lines. For example, search("(From|f):.*@foo.bar") doesn't match the following From header field:
From: medabeda <sip:medameda@foo.bar>;tag=1234
The following modules must be loaded before this module:
No dependencies on other OpenSER modules.
The following libraries or applications must be installed before running OpenSER with this module loaded:
None.
search(re)
Searches for the re in the message.
Meaning of the parameters is as follows:
re - Regular expression.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
search_body(re)
Searches for the re in the body of the message.
Meaning of the parameters is as follows:
re - Regular expression.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
search_append(re, txt)
Searches for the first match of re and appends txt after it.
Meaning of the parameters is as follows:
re - Regular expression.
txt - String to be appended.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
search_append_body(re, txt)
Searches for the first match of re in the body of the message and appends txt after it.
Meaning of the parameters is as follows:
re - Regular expression.
txt - String to be appended.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
replace(re, txt)
Replaces the first occurrence of re with txt.
Meaning of the parameters is as follows:
re - Regular expression.
txt - String.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
replace_body(re, txt)
Replaces the first occurrence of re in the body of the message with txt.
Meaning of the parameters is as follows:
re - Regular expression.
txt - String.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
replace_all(re, txt)
Replaces all occurrence of re with txt.
Meaning of the parameters is as follows:
re - Regular expression.
txt - String.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
replace_body_all(re, txt)
Replaces all occurrence of re in the body of the message with txt.
Meaning of the parameters is as follows:
re - Regular expression.
txt - String.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
subst('/re/repl/flags')
Replaces re with repl (sed or perl like).
Meaning of the parameters is as follows:
'/re/repl/flags' - sed like regular expression. flags can be a combination of i (case insensitive), g (global) or s (match newline don't treat it as end of line).
're' - is regular expresion
'repl' - is replacement string - may contain pseudo-varibales
'flags' - substitution flags (i - ignore case, g - global)
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
Example 1-9. subst
usage
... # replace the uri in to: with the message uri (just an example) if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1\u\2/ig') ) {}; # replace the uri in to: with the value of avp sip_address (just an example) if ( subst('/^To:(.*)sip:[^@]*@[a-zA-Z0-9.]+(.*)$/t:\1$avp(sip_address)\2/ig') ) {}; ...
subst_uri('/re/repl/flags')
Runs the re substitution on the message uri (like subst but works only on the uri)
Meaning of the parameters is as follows:
'/re/repl/flags' - sed like regular expression. flags can be a combination of i (case insensitive), g (global) or s (match newline don't treat it as end of line).
're' - is regular expresion
'repl' - is replacement string - may contain pseudo-varibales
'flags' - substitution flags (i - ignore case, g - global)
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
Example 1-10. subst_uri
usage
... # adds 3463 prefix to numeric uris, and save the original uri (\0 match) # as a parameter: orig_uri (just an example) if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:3463\1@\2;orig_uri=\0/i')){$ # adds the avp 'uri_prefix' as prefix to numeric uris, and save the original # uri (\0 match) as a parameter: orig_uri (just an example) if (subst_uri('/^sip:([0-9]+)@(.*)$/sip:$avp(uri_prefix)\1@\2;orig_uri=\0/i')){$ ...
subst_user('/re/repl/flags')
Runs the re substitution on the message uri (like subst_uri but works only on the user portion of the uri)
Meaning of the parameters is as follows:
'/re/repl/flags' - sed like regular expression. flags can be a combination of i (case insensitive), g (global) or s (match newline don't treat it as end of line).
're' - is regular expresion
'repl' - is replacement string - may contain pseudo-varibales
'flags' - substitution flags (i - ignore case, g - global)
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
subst_body('/re/repl/flags')
Replaces re with repl (sed or perl like) in the body of the message.
Meaning of the parameters is as follows:
'/re/repl/flags' - sed like regular expression. flags can be a combination of i (case insensitive), g (global) or s (match newline don't treat it as end of line).
're' - is regular expresion
'repl' - is replacement string - may contain pseudo-varibales
'flags' - substitution flags (i - ignore case, g - global)
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
append_to_reply(txt)
Append txt as header to the reply.
Meaning of the parameters is as follows:
txt - String which may contains pseudo-variables.
This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, ERROR_ROUTE.
append_hf(txt)
Appends 'txt' as header after the last header field.
Meaning of the parameters is as follows:
txt - Header field to be appended. The value can contain pseudo-variables which will be replaced at run time.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
append_hf(txt, hdr)
Appends 'txt' as header after first 'hdr' header field.
Meaning of the parameters is as follows:
txt - Header field to be appended. The value can contain pseudo-variables which will be replaced at run time.
hdr - Header name after which the 'txt' is appended.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
insert_hf(txt)
Inserts 'txt' as header before the first header field.
Meaning of the parameters is as follows:
txt - Header field to be inserted. The value can contain pseudo-variables which will be replaced at run time.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
insert_hf(txt, hdr)
Inserts 'txt' as header before first 'hdr' header field.
Meaning of the parameters is as follows:
txt - Header field to be inserted. The value can contain pseudo-variables which will be replaced at run time.
hdr - Header name before which the 'txt' is inserted.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
append_urihf(prefix, suffix)
Append header field name with original Request-URI in middle.
Meaning of the parameters is as follows:
prefix - string (usually at least header field name).
suffix - string (usually at least line terminator).
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
is_present_hf(hf_name)
Return true if a header field is present in message.
The function is also able to distinguish the compact names. For exmaple "From" will match with "f" |
Meaning of the parameters is as follows:
hf_name - Header field name.(long or compact form)
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
append_time()
Adds a time header to the reply of the request. You must use it before functions that are likely to send a reply, e.g., save() from 'registrar' module. Header format is: "Date: %a, %d %b %Y %H:%M:%S GMT", with the legend:
%a abbreviated week of day name (locale)
%d day of month as decimal number
%b abbreviated month name (locale)
%Y year with century
%H hour
%M minutes
%S seconds
Return true if a header was succesfully appended.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE, BRANCH_ROUTE.
is_method(name)
Check if the method of the message matches the name. If name is a known method (invite, cancel, ack, bye, options, info, update, register, message, subscribe, notify, refer, prack), the function performs method ID testing (integer comparison) instead of ignore case string comparison.
The 'name' can be a list of methods in the form of 'method1|method2|...'. In this case, the function returns true if the SIP message's method is one from the list. IMPORTANT NOTE: in the list must be only methods defined in OpenSER with ID (invite, cancel, ack, bye, options, info, update, register, message, subscribe, notify, refer, prack, publish; for more see: http://www.iana.org/assignments/sip-parameters).
If used for replies, the function tests the value of method field from CSeq header.
Meaning of the parameters is as follows:
name - SIP method name
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE, and BRANCH_ROUTE.
remove_hf(hname)
Remove from message all headers with name "hname"
Returns true if at least one header is found and removed.
Meaning of the parameters is as follows:
hname - header name to be removed.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and BRANCH_ROUTE.
has_body()
,
has_body(mime)
The function returns true if the SIP message has a body attached. The checked includes also the "Content-Lenght" header presence and value.
If a paramter is given, the mime described will be also checked against the "Content-Type" header.
Meaning of the parameters is as follows:
mime - mime to be checked against the "Content-Type" header. If not present or 0, this check will be disabled.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and BRANCH_ROUTE.
is_privacy(privacy_type)
The function returns true if the SIP message has a Privacy header field that includes the given privacy_type among its privacy values. See http://www.iana.org/assignments/sip-priv-values for possible privacy type values.
This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE, FAILURE_ROUTE and BRANCH_ROUTE.
Search functions are applied to the original request, i.e., they ignore all changes resulting from message processing in OpenSER script.
Take a look at http://openser.org/.
First at all check if your question was already answered on one of our mailing lists:
User Mailing List - http://openser.org/cgi-bin/mailman/listinfo/users
Developer Mailing List - http://openser.org/cgi-bin/mailman/listinfo/devel
E-mails regarding any stable OpenSER release should be sent to
<users@openser.org>
and e-mails regarding development versions
should be sent to <devel@openser.org>
.
If you want to keep the mail private, send it to
<team@openser.org>
.
Please follow the guidelines provided at: http://sourceforge.net/tracker/?group_id=139143.