Discussion:
[SR-Users] Wrong from/to header compose way in print_to and print_from
dongwf
2014-09-17 08:06:39 UTC
Permalink
Hi kamailio dev:
I am writing a module to implement some features, my version is 4.1.2, I am not sure if it is a known issue, I found:
1. When I get a INVITE request with from/to like from:"display"<***@sip.com>, then I call tm's new_dlg_uas with the sip req, now the dlg's rem_uri set as value: "display"<***@sip.com>;
2. After that, when I need use the dlg to send BYE with tm's req_within with the above saved dlg, the print_to function will check the rem_uri's first value if "<" or not, now my uri has display name, so the outgoing BYE's to header becomes to:<"display"<***@sip.com>>, is it wrong? Should we check the last char in the rem_uri as ">"?

The detail code is :
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);

memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....
Daniel-Constantin Mierla
2014-09-17 08:25:17 UTC
Permalink
Hello,

your remarks seems legit -- if you send a patch, I will review and
commit it. Otherwise, open an issue on bugh tracker and will be fixed soon.

Cheers,
Daniel
Post by dongwf
I am writing a module to implement some features, my version is 4.1.2,
1. When I get a INVITE request with from/to like
2. After that, when I need use the dlg to send BYE with tm's
req_within with the above saved dlg, the print_to function will check
the rem_uri's first value if "<" or not, now my uri has display name,
is it wrong? Should we check the last char in the rem_uri as ">"?
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);
memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
dongwf
2014-09-19 10:57:16 UTC
Permalink
Hi Daniel:
I added my fixing in attached t_msgbuilder.c, please take a review, mainly change in build_uac_req, print_to and print_from, thanks!







At 2014-09-17 04:25:17, "Daniel-Constantin Mierla" <***@gmail.com> wrote:
Hello,

your remarks seems legit -- if you send a patch, I will review and commit it. Otherwise, open an issue on bugh tracker and will be fixed soon. I tested the patch with my scenario, it works fine.

Cheers,
Daniel


On 17/09/14 10:06, dongwf wrote:

Hi kamailio dev:
I am writing a module to implement some features, my version is 4.1.2, I am not sure if it is a known issue, I found:
1. When I get a INVITE request with from/to like from:"display"<***@sip.com>, then I call tm's new_dlg_uas with the sip req, now the dlg's rem_uri set as value: "display"<***@sip.com>;
2. After that, when I need use the dlg to send BYE with tm's req_within with the above saved dlg, the print_to function will check the rem_uri's first value if "<" or not, now my uri has display name, so the outgoing BYE's to header becomes to:<"display"<***@sip.com>>, is it wrong? Should we check the last char in the rem_uri as ">"?

The detail code is :
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);

memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....






_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-***@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Daniel-Constantin Mierla
2014-09-19 16:03:32 UTC
Permalink
Hello,

can you send the changes as patch (diff) file?

If you got kamailio from git, then you can do:

git diff > /path/to/file.patch

It is easier to review the changes and be sure we are not overwriting a
new version of the file.

Cheers,
Daniel
Post by dongwf
I added my fixing in attached t_msgbuilder.c, please take a review,
mainly change in build_uac_req, print_to and print_from, thanks!
Hello,
your remarks seems legit -- if you send a patch, I will review and
commit it. Otherwise, open an issue on bugh tracker and will be
fixed soon. I tested the patch with my scenario, it works fine.
Cheers,
Daniel
Post by dongwf
I am writing a module to implement some features, my version is
1. When I get a INVITE request with from/to like
2. After that, when I need use the dlg to send BYE with tm's
req_within with the above saved dlg, the print_to function will
check the rem_uri's first value if "<" or not, now my uri has
display name, so the outgoing BYE's to header becomes
last char in the rem_uri as ">"?
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);
memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda -http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 -http://www.asipto.com
Sep 22-25, Berlin, Germany
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
dongwf
2014-09-22 10:27:26 UTC
Permalink
Hi:
Sorry for the unconvinient, I didn't use git, I use diff tool generated diff for t_msgbuilder.c as below, is it ok for you?

1400c1400
< + ((dialog->rem_uri.s[0]!='<')?2:0);
---
+ ((dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>')?2:0);
1403c1403
< if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') memapp(w, "<", 1);
1405c1405
< if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') memapp(w, ">", 1);
1425c1425
< + ((dialog->loc_uri.s[0]!='<')?2:0);
---
+ ((dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>')?2:0);
1428c1428
< if(dialog->loc_uri.s[0]!='<') memapp(w, "<", 1);
---
if(dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>') memapp(w, "<", 1);
1430c1430
< if(dialog->loc_uri.s[0]!='<') memapp(w, ">", 1);
---
if(dialog->loc_uri.s[dialog->loc_uri.len -1]!='>') memapp(w, ">", 1);
1551c1551
< if(dialog->rem_uri.s[0]!='<') *len += 2; /* To-URI < > */
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') *len += 2; /* To-URI < > */
1554c1554
< if(dialog->loc_uri.s[0]!='<') *len += 2; /* From-URI < > */
---
if(dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>') *len += 2; /* From-URI < > */
At 2014-09-20 00:03:32, "Daniel-Constantin Mierla" <***@gmail.com> wrote:
Hello,

can you send the changes as patch (diff) file?

If you got kamailio from git, then you can do:

git diff > /path/to/file.patch

It is easier to review the changes and be sure we are not overwriting a new version of the file.

Cheers,
Daniel


On 19/09/14 12:57, dongwf wrote:

Hi Daniel:
I added my fixing in attached t_msgbuilder.c, please take a review, mainly change in build_uac_req, print_to and print_from, thanks!






At 2014-09-17 04:25:17, "Daniel-Constantin Mierla" <***@gmail.com> wrote:
Hello,

your remarks seems legit -- if you send a patch, I will review and commit it. Otherwise, open an issue on bugh tracker and will be fixed soon. I tested the patch with my scenario, it works fine.

Cheers,
Daniel


On 17/09/14 10:06, dongwf wrote:

Hi kamailio dev:
I am writing a module to implement some features, my version is 4.1.2, I am not sure if it is a known issue, I found:
1. When I get a INVITE request with from/to like from:"display"<***@sip.com>, then I call tm's new_dlg_uas with the sip req, now the dlg's rem_uri set as value: "display"<***@sip.com>;
2. After that, when I need use the dlg to send BYE with tm's req_within with the above saved dlg, the print_to function will check the rem_uri's first value if "<" or not, now my uri has display name, so the outgoing BYE's to header becomes to:<"display"<***@sip.com>>, is it wrong? Should we check the last char in the rem_uri as ">"?

The detail code is :
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);

memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....






_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-***@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Daniel-Constantin Mierla
2014-09-23 06:39:37 UTC
Permalink
Hello,

I applied the patch copying manually the changes -- you can try the
master branch to see if all works as expected. Son it will get
backported to stable branches.

For future reference, you should use:

diff -u oldfile newfile >/tmp/file.patch

Then send the file.patch as attachment. Then one can save it locally
from email and use:

patch -pX<file.patch

to apply the changes.

Thanks for troubleshooting and patching the issue.

Cheers,
Daniel
Post by dongwf
Sorry for the unconvinient, I didn't use git, I use diff tool
generated diff for t_msgbuilder.c as below, is it ok for you?
1400c1400
< + ((dialog->rem_uri.s[0]!='<')?2:0);
---
+ ((dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>')?2:0);
1403c1403
< if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') memapp(w, "<", 1);
1405c1405
< if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') memapp(w, ">", 1);
1425c1425
< + ((dialog->loc_uri.s[0]!='<')?2:0);
---
+ ((dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>')?2:0);
1428c1428
< if(dialog->loc_uri.s[0]!='<') memapp(w, "<", 1);
---
if(dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>') memapp(w, "<", 1);
1430c1430
< if(dialog->loc_uri.s[0]!='<') memapp(w, ">", 1);
---
if(dialog->loc_uri.s[dialog->loc_uri.len -1]!='>') memapp(w, ">", 1);
1551c1551
< if(dialog->rem_uri.s[0]!='<') *len += 2; /* To-URI < > */
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') *len += 2; /*
To-URI < > */
1554c1554
< if(dialog->loc_uri.s[0]!='<') *len += 2; /* From-URI < > */
---
if(dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>') *len += 2; /*
From-URI < > */
Hello,
can you send the changes as patch (diff) file?
git diff > /path/to/file.patch
It is easier to review the changes and be sure we are not
overwriting a new version of the file.
Cheers,
Daniel
I added my fixing in attached t_msgbuilder.c, please take a
review, mainly change in build_uac_req, print_to and print_from,
thanks!
At 2014-09-17 04:25:17, "Daniel-Constantin Mierla"
Hello,
your remarks seems legit -- if you send a patch, I will
review and commit it. Otherwise, open an issue on bugh
tracker and will be fixed soon. I tested the patch with my
scenario, it works fine.
Cheers,
Daniel
Post by dongwf
I am writing a module to implement some features, my version
1. When I get a INVITE request with from/to like
2. After that, when I need use the dlg to send BYE with tm's
req_within with the above saved dlg, the print_to function
will check the rem_uri's first value if "<" or not, now my
uri has display name, so the outgoing BYE's to header
check the last char in the rem_uri as ">"?
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);
memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda -http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 -http://www.asipto.com
Sep 22-25, Berlin, Germany
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda -http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 -http://www.asipto.com
Sep 22-25, Berlin, Germany
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
dongwf
2014-09-23 08:36:54 UTC
Permalink
Oh, sorry, it's my first time to report patch for the project, will follow the guide in future :-)






At 2014-09-23 14:39:37, "Daniel-Constantin Mierla" <***@gmail.com> wrote:
Hello,

I applied the patch copying manually the changes -- you can try the master branch to see if all works as expected. Son it will get backported to stable branches.

For future reference, you should use:

diff -u oldfile newfile >/tmp/file.patch

Then send the file.patch as attachment. Then one can save it locally from email and use:

patch -pX<file.patch

to apply the changes.

Thanks for troubleshooting and patching the issue.

Cheers,
Daniel


On 22/09/14 12:27, dongwf wrote:

Hi:
Sorry for the unconvinient, I didn't use git, I use diff tool generated diff for t_msgbuilder.c as below, is it ok for you?

1400c1400
< + ((dialog->rem_uri.s[0]!='<')?2:0);
---
+ ((dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>')?2:0);
1403c1403
< if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') memapp(w, "<", 1);
1405c1405
< if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') memapp(w, ">", 1);
1425c1425
< + ((dialog->loc_uri.s[0]!='<')?2:0);
---
+ ((dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>')?2:0);
1428c1428
< if(dialog->loc_uri.s[0]!='<') memapp(w, "<", 1);
---
if(dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>') memapp(w, "<", 1);
1430c1430
< if(dialog->loc_uri.s[0]!='<') memapp(w, ">", 1);
---
if(dialog->loc_uri.s[dialog->loc_uri.len -1]!='>') memapp(w, ">", 1);
1551c1551
< if(dialog->rem_uri.s[0]!='<') *len += 2; /* To-URI < > */
---
if(dialog->rem_uri.s[dialog->rem_uri.len - 1]!='>') *len += 2; /* To-URI < > */
1554c1554
< if(dialog->loc_uri.s[0]!='<') *len += 2; /* From-URI < > */
---
if(dialog->loc_uri.s[dialog->loc_uri.len - 1]!='>') *len += 2; /* From-URI < > */
At 2014-09-20 00:03:32, "Daniel-Constantin Mierla" <***@gmail.com> wrote:
Hello,

can you send the changes as patch (diff) file?

If you got kamailio from git, then you can do:

git diff > /path/to/file.patch

It is easier to review the changes and be sure we are not overwriting a new version of the file.

Cheers,
Daniel


On 19/09/14 12:57, dongwf wrote:

Hi Daniel:
I added my fixing in attached t_msgbuilder.c, please take a review, mainly change in build_uac_req, print_to and print_from, thanks!






At 2014-09-17 04:25:17, "Daniel-Constantin Mierla" <***@gmail.com> wrote:
Hello,

your remarks seems legit -- if you send a patch, I will review and commit it. Otherwise, open an issue on bugh tracker and will be fixed soon. I tested the patch with my scenario, it works fine.

Cheers,
Daniel


On 17/09/14 10:06, dongwf wrote:

Hi kamailio dev:
I am writing a module to implement some features, my version is 4.1.2, I am not sure if it is a known issue, I found:
1. When I get a INVITE request with from/to like from:"display"<***@sip.com>, then I call tm's new_dlg_uas with the sip req, now the dlg's rem_uri set as value: "display"<***@sip.com>;
2. After that, when I need use the dlg to send BYE with tm's req_within with the above saved dlg, the print_to function will check the rem_uri's first value if "<" or not, now my uri has display name, so the outgoing BYE's to header becomes to:<"display"<***@sip.com>>, is it wrong? Should we check the last char in the rem_uri as ">"?

The detail code is :
static inline char* print_to(char* w, dlg_t* dialog, struct cell* t)
{
t->to.s = w;
t->to.len = TO_LEN + dialog->rem_uri.len + CRLF_LEN
+ ((dialog->rem_uri.s[0]!='<')?2:0);

memapp(w, TO, TO_LEN);
if(dialog->rem_uri.s[0]!='<') memapp(w, "<", 1);
memapp(w, dialog->rem_uri.s, dialog->rem_uri.len);
if(dialog->rem_uri.s[0]!='<') memapp(w, ">", 1);
....






_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-***@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
--
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Next Kamailio Advanced Trainings 2014 - http://www.asipto.com
Sep 22-25, Berlin, Germany
Loading...