Hey all,
this is just to let everybody know that my email contact has changed to sr(a)foo-lounge.de . Of course, I'm still on the lists but if anyone aware of my former email address wishes to contact me directly, please refer to the new address in the future.
Thanks a lot and
cheers,
--Timo
Hello,
I'm developing a module for Kamailio. I had to use some features that
weren't developed so I implemented them by myself. I made a new function
that can replace the existing get_body_part() of the
"parser/parse_body.c" module.
char *get_body_part(struct sip_msg *msg, unsigned short type, unsigned
short subtype, int *len)
This function allows you to pick the first multipart part of the SIP
message which matches TYPE/SUBTYPE. It will return a pointer to the
multipart structure as well as its length. The code it is not
easy-readable but this function is working great. The point is, what if
I would like to search a multipart part within a SIP message that
matches TYPE/SUBTYPE but also the Content-ID header or the
Content-Length header?
I made this function:
char *get_body_part_strict(struct sip_msg *msg, unsigned short
content_type, unsigned short content_subtype, char *content_id, char
*content_length, int *len)
It returns the first multipart part of the SIP message which matches
"TYPE/SUBTYPE" and/or the "Content-ID" and/or the "Content-Length", and
its length. If you want to be less restrictive, you can unflag the
parameter by:
- setting 0/0 in case of the TYPE/SUBTYPE.
- setting NULL in case of the Content-ID and the Content-Length.
So setting Content-Length == NULL will make the function to skip the
Content-Length from its filter and will give you back the first part
which matches the TYPE/SUBTYPE and Content-ID, and its length.
I think this could be very useful for someone who wants to retrieve
specific parts of the multipart, this was my case. I would really like
to contribute back to Kamailio platform back and I would appreciate if
anyone can point me the correct contact information to check the
viability of this adding.
Thanks,
Luis Martin Gil
Module: sip-router
Branch: master
Commit: 0b8f2ee4c128cd2b532356087272445519c1c08b
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0b8f2ee…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Oct 27 16:45:17 2011 +0200
dispatcher(k): clarification about trying transition state from active to inactive
---
modules_k/dispatcher/README | 14 ++++++++------
modules_k/dispatcher/doc/dispatcher_admin.xml | 9 ++++++---
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/modules_k/dispatcher/README b/modules_k/dispatcher/README
index 19b17de..4d3403d 100644
--- a/modules_k/dispatcher/README
+++ b/modules_k/dispatcher/README
@@ -559,12 +559,14 @@ Note
3.21. ds_probing_threshhold (int)
- If you want to set a gateway into probing mode, you will need a
- specific number of requests until it will change from "active" to
- probing. The number of attempts can be set with this parameter. This
- parameter can be modified via ser config framework.
-
- Default value is "3".
+ If you want to set a gateway into inactive mode, there can be a
+ specific number of failed requests until it will change from "active"
+ to "inactive". It is using the state "trying", that allows selection of
+ gateway but indicates there was a failure previously with the gateway.
+ The number of attempts can be set with this parameter. This parameter
+ can be modified via ser config framework.
+
+ Default value is "1" (set inactive with first failure).
Example 1.22. Set the "ds_probing_threshhold" parameter
...
diff --git a/modules_k/dispatcher/doc/dispatcher_admin.xml b/modules_k/dispatcher/doc/dispatcher_admin.xml
index 9fc5fdb..037ad19 100644
--- a/modules_k/dispatcher/doc/dispatcher_admin.xml
+++ b/modules_k/dispatcher/doc/dispatcher_admin.xml
@@ -542,13 +542,16 @@ modparam("dispatcher", "force_dst", 1)
<section>
<title><varname>ds_probing_threshhold</varname> (int)</title>
<para>
- If you want to set a gateway into probing mode, you will need a specific number of requests until it will change from "active" to probing.
- The number of attempts can be set with this parameter.
+ If you want to set a gateway into inactive mode, there can be
+ a specific number of failed requests until it will change from "active"
+ to "inactive". It is using the state "trying", that allows selection
+ of gateway but indicates there was a failure previously with the
+ gateway. The number of attempts can be set with this parameter.
This parameter can be modified via ser config framework.
</para>
<para>
<emphasis>
- Default value is <quote>3</quote>.
+ Default value is <quote>1</quote> (set inactive with first failure).
</emphasis>
</para>
<example>
Module: sip-router
Branch: master
Commit: 372b113b6bd4447dfd73b8b6da6a5672730a5636
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=372b113…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Oct 27 16:07:33 2011 +0200
dispatcher(k): docs update and rebuild readme file
---
modules_k/dispatcher/README | 46 ++++++++++++---------
modules_k/dispatcher/doc/dispatcher_admin.xml | 55 +++++++++++++++---------
2 files changed, 61 insertions(+), 40 deletions(-)
diff --git a/modules_k/dispatcher/README b/modules_k/dispatcher/README
index 4ee0370..19b17de 100644
--- a/modules_k/dispatcher/README
+++ b/modules_k/dispatcher/README
@@ -751,25 +751,28 @@ ds_select_dst("1", "$var(a)");
4.5. ds_mark_dst([state])
- Mark the last used address from destination set as inactive
- ("i"/"I"/"0"), active ("a"/"A"/"1") or probing ("p"/"P"/"2"). With this
- function, an automatic detection of failed gateways can be implemented.
- When an address is marked as inactive, it will be ignored by
- 'ds_select_dst' and 'ds_select_domain'.
+ Mark the last used address from destination set as inactive ("i"/"I"),
+ active ("a"/"A"), disabled ("d"/"D") or trying ("t"/"T"). Apart of
+ disabled state, a destination can be set in probing mode by adding
+ ("p"/"P") flag. With this function, an automatic detection of failed
+ gateways can be implemented. When an address is marked as inactive or
+ disabled, it will be ignored by 'ds_select_dst' and 'ds_select_domain'.
The parameter state is optional, when it is missing, then the
destination will be marked inactive (i.e., same as 'i').
Possible values for state parameter:
- * "i", "I" or "0" - the last destination should be set to inactive
- and will be ignored in future requests.
- * "a", "A" or "1" - the last destination should be set to active and
- the error-counter should set to "0".
- * "p", "P" or "2" - the last destination will be set to probing. This
+ * "a" or "A" - the last destination should be set to active and the
+ error-counter should set to "0".
+ * "i" or "I" - the last destination should be set to inactive and
+ will be ignored in future requests.
+ * "t" or "T" - the last destination should be set to temporary trying
+ state and failure counter is incremented. When the failure counter
+ reaches the threshold, the destination will be set inactive.
+ * "p" and "P" - this has to be used in addition to one of the
+ previous flags - the last destination will be set to probing. This
mean the destination will be pinged with SIP OPTIONS requests from
- time to time to detect if it is up running or down. Note: You will
- need to call this function "threshhold"-times, before it will be
- actually set to probing.
+ time to time to detect if it is up running or down.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
@@ -778,7 +781,7 @@ ds_select_dst("1", "$var(a)");
failure_route[tryagain] {
...
if(t_check_status("500"))
- ds_mark_dst("i");
+ ds_mark_dst("ip"); # set to inactive and probing
...
}
...
@@ -860,9 +863,10 @@ onreply_route {
* _state_ : state of the destination address
+ "a": active
+ "i": inactive
+ + "t": trying
+ "d": disabled
- The states "a" or "i" can be followed by "p" to set probing mode
- (e.g. 'ap' or 'ip')
+ The states "a", "i" or "t" can be followed by "p" to set probing
+ mode (e.g. 'ap', 'ip' or 'tp').
* _group_: destination group id
* _address_: address of the destination in the _group_
@@ -916,14 +920,18 @@ onreply_route {
* _state_ : state of the destination address
+ "a": active
+ "i": inactive
+ + "t": trying
+ "d": disabled
- The states "a" or "i" can be followed by "p" to set probing mode
- (e.g. 'ap' or 'ip')
+ The states "a", "i" or "t" can be followed by "p" to set probing
+ mode (e.g. 'ap', 'ip' or 'tp').
* _group_: destination group id
* _address_: address of the destination in the _group_
Example:
- sercmd dispatcher.set_state _state_ _group_ _address_
+...
+# prototype: sercmd dispatcher.set_state _state_ _group_ _address_
+sercmd dispatcher.set_state ip 2 sip:127.0.0.1:5080
+...
6.2. dispatcher.list
diff --git a/modules_k/dispatcher/doc/dispatcher_admin.xml b/modules_k/dispatcher/doc/dispatcher_admin.xml
index 273c68c..9fc5fdb 100644
--- a/modules_k/dispatcher/doc/dispatcher_admin.xml
+++ b/modules_k/dispatcher/doc/dispatcher_admin.xml
@@ -876,10 +876,11 @@ ds_select_dst("1", "$var(a)");
</title>
<para>
Mark the last used address from destination set as inactive
- ("i"/"I"/"0"), active ("a"/"A"/"1") or probing ("p"/"P"/"2").
- With this function, an automatic detection of failed gateways
- can be implemented. When an address is marked as
- inactive, it will be ignored by 'ds_select_dst' and
+ ("i"/"I"), active ("a"/"A"), disabled ("d"/"D") or trying ("t"/"T").
+ Apart of disabled state, a destination can be set in probing mode by
+ adding ("p"/"P") flag. With this function, an automatic detection
+ of failed gateways can be implemented. When an address is marked as
+ inactive or disabled, it will be ignored by 'ds_select_dst' and
'ds_select_domain'.
</para>
<para>
@@ -889,21 +890,28 @@ ds_select_dst("1", "$var(a)");
<para>Possible values for state parameter:</para>
<itemizedlist>
<listitem>
- <para><emphasis>"i", "I" or "0"</emphasis> - the last destination
+ <para><emphasis>"a" or "A"</emphasis> - the last destination
+ should be set to active and the error-counter should set to "0".
+ </para>
+ </listitem>
+ <listitem>
+ <para><emphasis>"i" or "I"</emphasis> - the last destination
should be set to inactive and will be ignored in future
requests.</para>
</listitem>
<listitem>
- <para><emphasis>"a", "A" or "1"</emphasis> - the last destination
- should be set to active and the error-counter should set to "0".</para>
+ <para><emphasis>"t" or "T"</emphasis> - the last destination
+ should be set to temporary trying state and failure counter
+ is incremented. When the failure counter reaches the threshold,
+ the destination will be set inactive.
+ </para>
</listitem>
<listitem>
- <para><emphasis>"p", "P" or "2"</emphasis> - the last destination
+ <para><emphasis>"p" and "P"</emphasis> - this has to be used in
+ addition to one of the previous flags - the last destination
will be set to probing. This mean the destination will be pinged
with SIP OPTIONS requests from time to time to detect if it is
- up running or down. Note: You will need to call this
- function "threshhold"-times, before it will be actually set
- to probing.</para>
+ up running or down.</para>
</listitem>
</itemizedlist>
<para>
@@ -916,7 +924,7 @@ ds_select_dst("1", "$var(a)");
failure_route[tryagain] {
...
if(t_check_status("500"))
- ds_mark_dst("i");
+ ds_mark_dst("ip"); # set to inactive and probing
...
}
...
@@ -1033,11 +1041,12 @@ onreply_route {
<itemizedlist>
<listitem><para> <quote>a</quote>: active</para></listitem>
<listitem><para> <quote>i</quote>: inactive</para></listitem>
+ <listitem><para> <quote>t</quote>: trying</para></listitem>
<listitem><para> <quote>d</quote>: disabled</para></listitem>
</itemizedlist>
- <para>The states <quote>a</quote> or <quote>i</quote> can be
- followed by <quote>p</quote> to set probing mode (e.g. 'ap'
- or 'ip')</para>
+ <para>The states <quote>a</quote>, <quote>i</quote> or
+ <quote>t</quote> can be followed by <quote>p</quote>
+ to set probing mode (e.g. 'ap', 'ip' or 'tp').</para>
</listitem>
<listitem><para>_group_: destination group id</para></listitem>
@@ -1117,11 +1126,12 @@ onreply_route {
<itemizedlist>
<listitem><para> <quote>a</quote>: active</para></listitem>
<listitem><para> <quote>i</quote>: inactive</para></listitem>
+ <listitem><para> <quote>t</quote>: trying</para></listitem>
<listitem><para> <quote>d</quote>: disabled</para></listitem>
</itemizedlist>
- <para>The states <quote>a</quote> or <quote>i</quote> can be
- followed by <quote>p</quote> to set probing mode (e.g. 'ap'
- or 'ip')</para>
+ <para>The states <quote>a</quote>, <quote>i</quote> or
+ <quote>t</quote> can be followed by <quote>p</quote>
+ to set probing mode (e.g. 'ap', 'ip' or 'tp').</para>
</listitem>
<listitem><para>_group_: destination group id</para></listitem>
@@ -1131,9 +1141,12 @@ onreply_route {
<para>
Example:
</para>
- <programlisting format="linespecific">
- sercmd dispatcher.set_state _state_ _group_ _address_
- </programlisting>
+<programlisting format="linespecific">
+...
+# prototype: sercmd dispatcher.set_state _state_ _group_ _address_
+sercmd dispatcher.set_state ip 2 sip:127.0.0.1:5080
+...
+</programlisting>
</section>
<section>
<title>
Module: sip-router
Branch: master
Commit: cbe2e236846e6527a2fc9e6b40b80befe329825b
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cbe2e23…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Thu Oct 27 16:00:55 2011 +0200
dispatcher(k): new state trying for destination addresses
- the state trying (t) is a transition between active to inactive, when
inactive state is wanted after a certain number of failures specified
in probing threshold
- when in trying state, the destination is still selected, but
additional settings of trying state will increment an internal failure
counter which results in setting inactive state when probing threshold
is matched
- the functionality was before based on probing mode, but since 3.2
probing is not longer related to destination selection. This will
provide back the lost functionality
- ds_mark_dst(x) can have as parameter a combination between state and
probing mode, such as 'ip' - inactive and probing, or ap - active and
probing, or 'tp' - trying and probing
---
modules_k/dispatcher/dispatch.c | 417 ++++++++++++++++++-------------------
modules_k/dispatcher/dispatch.h | 10 +-
modules_k/dispatcher/dispatcher.c | 80 +++++--
3 files changed, 261 insertions(+), 246 deletions(-)
Diff: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=cbe…