[Kamailio-Devel] [ openser-Feature Requests-2135690 ] Improve $(hdr[N]) handling of comma-separated header bodies
SourceForge.net
noreply at sourceforge.net
Mon Sep 29 11:26:24 CEST 2008
Feature Requests item #2135690, was opened at 2008-09-29 11:26
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743023&aid=2135690&group_id=139143
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jerome Martin (tramjoe)
Assigned to: Nobody/Anonymous (nobody)
Summary: Improve $(hdr[N]) handling of comma-separated header bodies
Initial Comment:
The SIP headers can have two different forms allowing multiple header bodies in a messages: either multiple comma-separated bodies in a single header line, or many header lines containing a single body. Those two forms can be combined in the same message and are semantically strictly equivalent. Kamailio internals do a proper job in handling this AFAIK (i.e. for Via: header), but user-side $(hdr(foobar)[N]) form requires additionnal user-side parsing to acheive this. Here is an example of what is required to currently extract the 2nd Via: body in a SIP message and stay compatible with both forms:
# If we have a comma-separated list of via bodies in
# the first Via header, extract the destination
# address from there
$avp(s:destination_address) = $(hdr(Via)[0]{s.select,1,,}{s.select,0,;}{s.select,2, });
if (!$avp(s:destination_address)) {
# Else, extract it from the second Via header
$avp(s:destination_address) = $(hdr(Via)[1]{s.select,0,;}{s.select,1, });
# We used single-body Via headers
} else {
# Using multi-body Via headers
}
# Now $avp(s:destination_address) holds the relay address for the reply
This proposal aims at adding handling of comma-separated bodies in a single header line while still staying fully backward compatible with multi-line headers (aka 1 body per header, multiple headers.).
In order to do so, I suggest to keep the exact same syntax on the script-side: $(avp(foobar)[N]), but instead of having N mean "the N-th occurence of header line foobar", I would like N to mean "the N-th body of header foobar".
Examples :
1/ Only single body headers:
Foobar: body1
Foobar: body2
This would be handled the same as currently:
$(avp(Foobar)[1]) == "body1"
$(avp(Foobar)[2]) == "body2"
2/ Only multibody header:
Foobar: body1, body2
Currently, we have:
$(avp(Foobar)[1]) == "body1,body2"
$(avp(Foobar)[2]) == <null>
I suggest we return instead:
$(avp(Foobar)[1]) == "body1"
$(avp(Foobar)[2]) == "body2"
The effect here is that the same code works for example 1 AND example 2 no matter what form is used by the sending UA.
3/ Mixed header forms:
Foobar: body1
Foobar: body2, body3
Foobar: body4
$(avp(Foobar)[1]) == "body1"
$(avp(Foobar)[2]) == "body2"
$(avp(Foobar)[3]) == "body3"
$(avp(Foobar)[4]) == "body4"
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=743023&aid=2135690&group_id=139143
More information about the Devel
mailing list