Thanks Scott,
I should have updated first prior to ringing the Alarm.
Joegen
On 03/19/2012 03:16 AM, Scott Godin wrote:
Ahhh - that is a bug I just found and fixed recently.
It's odd because the bug had been there since May 2011, and I
just stumbled on it in the last month as well.
-fixed a nasty bug in NameAddr - where unknown parameters
uri parameters on a
NameAddr/Uri with no angle brackets are treated as
NameAddr parameters. When this is
done, the memory for these parameters was only a temporary
Data object.
Look at changes in NameAddr::parse
Scott
On Sun, Mar 18, 2012 at 8:43 AM, Joegen
Baclor <jbaclor@xxxxxxxxx>
wrote:
Hi Scott,
I think I have accidentally come across a bug in the tag
parser. The original from-tag that isn't parsed correctly
is
tag=fromtag12345
If I change it to
tag=tag12345
It is parsed correctly. I think the string "from" is
affecting the way parameters are parsed.
Joegen
---------------------
Here is the test code:
int main(int argc , char** argv)
{
using namespace resip;
Data buffer =
"OPTIONS sip:homer@192.168.1.11:5060;transport=tcp
SIP/2.0\r\n"
"From: sip:homertest@192.168.1.10:5060;tag=fromtag12345\r\n"
"To: sip:homer@192.168.1.11:5060;tag=totag6789\r\n"
"Contact: sip:homertest@192.168.1.10:5060;transport=tcp\r\n"
"Via: SIP/2.0/TCP
192.168.1.10:5060;branch=z9hG4bK1234\r\n"
"CSeq: 1 OPTIONS\r\n"
"User-Agent: sipXecs\r\n"
"Call-ID: homertest12345\r\n\r\n";
SipMessage* msg = SipMessage::make(buffer);
std::string fromTag;
std::string toTag;
if (msg->exists(h_To))
toTag = msg->const_header(h_To).exists(p_tag) ?
msg->const_header(h_To).param(p_tag).c_str() :
std::string();
if (msg->exists(h_From))
fromTag = msg->const_header(h_From).exists(p_tag)
? msg->const_header(h_From).param(p_tag).c_str() :
std::string();
std::cout << "From-tag: " << fromTag
<< " To-Tag: " << toTag;
return 0;
}
On 03/17/2012 11:58 PM, Scott Godin wrote:
Some background info....
For a NameAddr header (ie. To/From/Contact, etc.).
It is possible to have parameters at different
levels. There are user parameters, uri parameters,
and NameAddr/header parameters.
Example:
In this example "phone-context" is a user
parameter, "user=phone" is a uri parameter, and
"q" is a NameAddr/header parameter.
Use of the angle brackets makes it explicit
when differentiating between URI and
NameAddr/header parameters. When the angle
brackets are not present resip will assume all
known Uri parameters are Uri parameters (ie. ob,
gr, lr, maddr, method, transport, etc. - see
Uri.hxx), and any unknown parameters are treated
as NameAddr/header parameters
(see NameAddr::parse). Note: The treatment of
parameters in the RFC3261 grammars
are ambiguous when angle brackets are not used.
tag is NOT a known URI parameter and thus
should be accessible as you have described. Is it
possible the From header you are parsing was built
by hand and not parsed off the wire: ie.
fromHeader.uri().param(p_tag) = "123"; <- thus
making the tag parameter a Uri
parameter explicitly?
There is no reason the From and To header would
parse differently.
Perhaps you can post a simple test program that
demonstrates this. See
stack/test/testSipMessage.cxx line 1889 where
there is a test case that demonstrates from tag
parsing.
Scott
On Fri, Mar 16, 2012 at
2:10 AM, Joegen Baclor <jbaclor@xxxxxxxxx>
wrote:
On 03/16/2012 08:25 AM, Joegen Baclor
wrote:
If From or
To is constructed without the angle
brackets Example: From: sip:user@10.0.0.1:5060;tag=123
the tag is not accessible via
header(h_From).param(p_tag) accesor. it
returns empty. Is this intentional?
joegen
Correction, I seem to only encounter this in
From. To header seems to treat tags correctly
if there are no angle brackets enclosing the
URI.
the code looks like this:
ASSERT_COND(msg->exists(h_From));
if (msg->exists(h_From))
{
fromUser =
msg->const_header(h_From).uri().user().c_str();
fromTag =
msg->const_header(h_From).exists(p_tag) ?
msg->const_header(h_From).param(p_tag).c_str()
: std::string();
ASSERT_STR_EQ(fromUser.c_str(),
"homertest");
ASSERT_STR_EQ(fromTag.c_str(),
"fromtag12345");
}
The from header looks like this: From: sip:homertest@192.168.1.10:5060;tag=fromtag12345
Tag would be empty in this case. If I put
angle brackets, then tag is parsed correctly.
|