Sandeep,
|Good day to you, I hope that you are well?
I think we are moving forward, but my engineer is now experiencing problems whereby it seems that the message is becoming corrupted before the outgoing message can be transmitted. The following is my engineer's description of the problem:
Using "transport_adapter_sample.c" as an example, I am trying to add an attribute to the outgoing SDP message.
I have modified the example code as follows:
/* You may do anything to the local_sdp, e.g. adding new attributes, or
* even modifying the SDP if you want.
*/
if (1)
{
/* Say we add a proprietary attribute here.. */
pjmedia_sdp_attr *mikey_attr;
mikey_attr = PJ_POOL_ALLOC_T(sdp_pool, pjmedia_sdp_attr);
pj_strdup2(sdp_pool, &mikey_attr->name, "key-mgmt");
pj_strdup2(sdp_pool, &mikey_attr->value, "mikey ");
Create_DH_HMAC_SDP_Attribute(sdp_pool, local_sdp, mikey_attr);
pjmedia_sdp_attr_add(&local_sdp->attr_count, local_sdp->attr, my_attr);
}
Create_DH_HMAC_SDP_Attribute creates a base64 encoded attribute and appends it to "mikey_attr->value".
using
pj_strcat2(&mikey_atrr->value, base64_buffer);
This appears to work okay, and the attribute is added to the local_sdp, and results in an attribute pj_string something like
"mikey AQcF/kkSBAA............." About 157 bytes in length.
When I step through the routine pjsua_media_channel_create_sdp in pjsua_media.c a call is made to
sdp->conn = pjmedia_sdp_conn_clone(pool, m->conn);
which then overwrites my attribute, resulting in a corrupted message being sent.
Any thoughts/suggestions would be extremely welcome.
Many thanks...
Tim
From: McLeod, Tim
Sent: 11 January 2013 11:02
To: 'pjsip list'
Subject: RE: [pjsip] Custom Session Negotiation
Sandeep,
Thank you for your very quick response. I have passed your suggestion to my engineer who has confirmed that this is exactly the information he needed. Excellent work.
Thanks again...
Tim
From: pjsip [mailto:pjsip-bounces@lists.pjsip.org] On Behalf Of Sandeep Karanth
Sent: 11 January 2013 05:17
To: pjsip list
Subject: Re: [pjsip] Custom Session Negotiation
Hi Tim,
I guess probably you are using below part of transport_encode_sdp() function to add your custom attribute to sdp.
if (1)
{
/* Say we add a proprietary attribute here.. */
pjmedia_sdp_attr *my_attr;
my_attr = PJ_POOL_ALLOC_T(sdp_pool, pjmedia_sdp_attr);
pj_strdup2(sdp_pool, &my_attr->name, "X-adapter");
pj_strdup2(sdp_pool, &my_attr->value, "some value");
pjmedia_sdp_attr_add(&local_sdp->media[media_index]->attr_count, local_sdp->media[media_index]->attr, my_attr);
}
I think you are probably substituting in the above block 'X-adapter' with your custom attribute. The problem is that pjmedia_sdp_attr_add function highlighted above is adding that parameter as a media parameter and hence it will come as a media parameter.
You can instead substitute the above line with pjmedia_sdp_attr_add(&local_sdp->attr_count,local_sdp->attr,my_attr); and try again. Hopefully this should solve your problem!
Regards,
Sandeep
On Fri, Jan 11, 2013 at 10:20 AM, Sandeep Karanth <sandeepk.kdp@gmail.commailto:sandeepk.kdp@gmail.com> wrote:
Correct me if am wrong! So what you are looking to do is to add a session level attribute i.e a=somevalue before any of the media parameter (m) lines
but instead it is getting added after some (m) parameter and hence it is effect your custom "a" attribute in effect is becoming a media level attribute??
On Thu, Jan 10, 2013 at 7:40 PM, McLeod, Tim <Tim.McLeod@cassidian.commailto:Tim.McLeod@cassidian.com> wrote:
Furthering our project for experimenting with various methods of providing secure VoIP communications we have a need to provide custom negotiation mechanisms. My engineer is currently looking into how this might be incorporated into the existing pjsua functionality. He is encountering difficulties.
He is attempting to insert MIKEY session attributes into SDP message, i.e. a=key-mgmt: mikey {base64 encoded mikey message} by using the function "transport_encode_sdp" in the transport adapter to add the desired mikey message. When capturing the SIP invite message in Wireshark, the coding is translated as a media attribute, the suspicion being that this is the case because it is added to the message after the media description. Is there a clean way to add a session description before the media attribute?
Your help would (once again) be very much appreciated.
Tim McLeod MBCS CITP
Principal Engineer
Tel: +44 1633 715097tel:%2B44%201633%20715097
Mob: +44 7765 088364tel:%2B44%207765%20088364
Email: tim.mcleod@cassidian.commailto:tim.mcleod@cassidian.com
RLI: tim.mcleod@eads.r.mil.ukmailto:tim.mcleod@eads.r.mil.uk
Website: www.cassidian.comhttp://www.cassidian.com/
The information contained within this e-mail and any files attached to this e-mail is private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure. If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system. Cassidian Limited, Registered Office : Quadrant House, Celtic Springs, Coedkernew, Newport, NP10 8FZ Company No: 04191036 http://www.cassidian.com
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.orgmailto:pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
The information contained within this e-mail and any files attached to this e-mail is private and in addition may include commercially sensitive information. The contents of this e-mail are for the intended recipient only and therefore if you wish to disclose the information contained within this e-mail or attached files, please contact the sender prior to any such disclosure. If you are not the intended recipient, any disclosure, copying or distribution is prohibited. Please also contact the sender and inform them of the error and delete the e-mail, including any attached files from your system. Cassidian Limited, Registered Office : Quadrant House, Celtic Springs, Coedkernew, Newport, NP10 8FZ Company No: 04191036 http://www.cassidian.com
Tim,
So are you telling me that when you see the wireshark trace the
custom attribute you added is present but in a corrupted state? I don't
think that pjmedia_sdp_conn_clone is corrupting your attribute, coz if u
see the definition of that function it shudn't be affected in anyway!
I am suspecting that something is done wrongly in Create_DH_HMAC_SDP_Attribute
fucntion of yours. I wud be helpful if barebone expansion of this function
is known.
On Wed, Jan 16, 2013 at 6:01 PM, McLeod, Tim Tim.McLeod@cassidian.comwrote:
Sandeep,
|Good day to you, I hope that you are well?
I think we are moving forward, but my engineer is now experiencing
problems whereby it seems that the message is becoming corrupted before the
outgoing message can be transmitted. The following is my engineer’s
description of the problem:
Using “transport_adapter_sample.c” as an example, I am trying to add an
attribute to the outgoing SDP message.
I have modified the example code as follows:
/* You may do anything to the local_sdp, e.g. adding new
attributes, or
* even modifying the SDP if you want.
*/
if (1)
{
/* Say we add a proprietary attribute here.. */
pjmedia_sdp_attr *mikey_attr;
mikey_attr = PJ_POOL_ALLOC_T(sdp_pool, pjmedia_sdp_attr);
pj_strdup2(sdp_pool, &mikey_attr->name, "key-mgmt");
pj_strdup2(sdp_pool, &mikey_attr->value, "mikey ");
Create_DH_HMAC_SDP_Attribute(sdp_pool, local_sdp, mikey_attr);
pjmedia_sdp_attr_add(&local_sdp->attr_count,
local_sdp->attr, my_attr);
}
Create_DH_HMAC_SDP_Attribute creates a base64 encoded attribute and
appends it to “mikey_attr->value”.
using
pj_strcat2(&mikey_atrr->value, base64_buffer);
This appears to work okay, and the attribute is added to the local_sdp,
and results in an attribute pj_string something like
“mikey AQcF/kkSBAA………….” About 157 bytes in length.
When I step through the routine pjsua_media_channel_create_sdp in
pjsua_media.c a call is made to
sdp->conn = pjmedia_sdp_conn_clone(pool, m->conn);
which then overwrites my attribute, resulting in a corrupted message being
sent.
Any thoughts/suggestions would be extremely welcome.
Many thanks…
Tim
From: McLeod, Tim
Sent: 11 January 2013 11:02
To: 'pjsip list'
Subject: RE: [pjsip] Custom Session Negotiation
Sandeep,
Thank you for your very quick response. I have passed your suggestion to
my engineer who has confirmed that this is exactly the information he
needed. Excellent work.
Thanks again…
Tim
From: pjsip [mailto:pjsip-bounces@lists.pjsip.org] *On Behalf Of *Sandeep
Karanth
Sent: 11 January 2013 05:17
To: pjsip list
Subject: Re: [pjsip] Custom Session Negotiation
Hi Tim,
I guess probably you are using below part of *transport_encode_sdp()
*function * *to add your custom attribute to sdp.
if (1)
{
/* Say we add a proprietary attribute here.. */
pjmedia_sdp_attr *my_attr;
my_attr = PJ_POOL_ALLOC_T(sdp_pool, pjmedia_sdp_attr);
pj_strdup2(sdp_pool, &my_attr->name, "X-adapter");
pj_strdup2(sdp_pool, &my_attr->value, "some value");
pjmedia_sdp_attr_add(&local_sdp->media[media_index]->attr_count,
local_sdp->media[media_index]->attr, my_attr);
}
I think you are probably substituting in the above block 'X-adapter' with
your custom attribute. The problem is that pjmedia_sdp_attr_add function
highlighted above is adding that parameter as a media parameter and hence
it will come as a media parameter.
You can instead substitute the above line with
pjmedia_sdp_attr_add(&local_sdp->attr_count,local_sdp->attr,my_attr); and
try again. Hopefully this should solve your problem!
Regards,
Sandeep
On Fri, Jan 11, 2013 at 10:20 AM, Sandeep Karanth sandeepk.kdp@gmail.com
wrote:
Correct me if am wrong! So what you are looking to do is to add a session
level attribute i.e a=somevalue before any of the media parameter (m) lines
but instead it is getting added after some (m) parameter and hence it is
effect your custom "a" attribute in effect is becoming a media level
attribute??
On Thu, Jan 10, 2013 at 7:40 PM, McLeod, Tim Tim.McLeod@cassidian.com
wrote:
Furthering our project for experimenting with various methods of
providing secure VoIP communications we have a need to provide custom
negotiation mechanisms. My engineer is currently looking into how this
might be incorporated into the existing pjsua functionality. He is
encountering difficulties.
He is attempting to insert MIKEY session attributes into SDP message, i.e.
a=key-mgmt: mikey {base64 encoded mikey message} by using the function
“transport_encode_sdp” in the transport adapter to add the desired mikey
message. When capturing the SIP invite message in Wireshark, the coding is
translated as a media attribute, the suspicion being that this is the case
because it is added to the message after the media description. Is there a
clean way to add a session description before the media attribute?
Your help would (once again) be very much appreciated.
Tim McLeod MBCS CITP
Principal Engineer
Tel: +44 1633 715097
Mob: +44 7765 088364
Email: tim.mcleod@cassidian.com
Website: www.cassidian.com
The information contained within this e-mail and any files attached to
this e-mail is private and in addition may include commercially sensitive
information. The contents of this e-mail are for the intended recipient
only and therefore if you wish to disclose the information contained within
this e-mail or attached files, please contact the sender prior to any such
disclosure. If you are not the intended recipient, any disclosure, copying
or distribution is prohibited. Please also contact the sender and inform
them of the error and delete the e-mail, including any attached files from
your system. Cassidian Limited, Registered Office : Quadrant House, Celtic
Springs, Coedkernew, Newport, NP10 8FZ Company No: 04191036
http://www.cassidian.com
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
The information contained within this e-mail and any files attached to
this e-mail is private and in addition may include commercially sensitive
information. The contents of this e-mail are for the intended recipient
only and therefore if you wish to disclose the information contained within
this e-mail or attached files, please contact the sender prior to any such
disclosure. If you are not the intended recipient, any disclosure, copying
or distribution is prohibited. Please also contact the sender and inform
them of the error and delete the e-mail, including any attached files from
your system. Cassidian Limited, Registered Office : Quadrant House, Celtic
Springs, Coedkernew, Newport, NP10 8FZ Company No: 04191036
http://www.cassidian.com
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Hi!!
On Mit, 2013-01-16 at 12:31 +0000, McLeod, Tim wrote:
[...]
I think we are moving forward, but my engineer is now experiencing problems whereby it seems that the message is becoming corrupted before the outgoing message can be transmitted. The following is my engineer's description of the problem:
Using "transport_adapter_sample.c" as an example, I am trying to add an attribute to the outgoing SDP message.
I have modified the example code as follows:
/* You may do anything to the local_sdp, e.g. adding new attributes, or
* even modifying the SDP if you want.
*/
if (1)
{
/* Say we add a proprietary attribute here.. */
pjmedia_sdp_attr *mikey_attr;
mikey_attr = PJ_POOL_ALLOC_T(sdp_pool, pjmedia_sdp_attr);
pj_strdup2(sdp_pool, &mikey_attr->name, "key-mgmt");
pj_strdup2(sdp_pool, &mikey_attr->value, "mikey ");
Create_DH_HMAC_SDP_Attribute(sdp_pool, local_sdp, mikey_attr);
pjmedia_sdp_attr_add(&local_sdp->attr_count, local_sdp->attr, my_attr);
}
Create_DH_HMAC_SDP_Attribute creates a base64 encoded attribute and appends it to "mikey_attr->value".
using
pj_strcat2(&mikey_atrr->value, base64_buffer);
This appears to work okay, and the attribute is added to the local_sdp, and results in an attribute pj_string something like
"mikey AQcF/kkSBAA............." About 157 bytes in length.
When I step through the routine pjsua_media_channel_create_sdp in pjsua_media.c a call is made to
sdp->conn = pjmedia_sdp_conn_clone(pool, m->conn);
which then overwrites my attribute, resulting in a corrupted message being sent.
Any thoughts/suggestions would be extremely welcome.
I didn't look into the source of strcat2() ATM but all pjlib string
functions do not care about the allocation (and so they cannot possibly
enlarge it - if it is actually possible at all).
So what happens is IMHO:
So better allocate enough space for "mikey " and the base64 string (and
not only around 7 bytes ....).
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
Hi Bernd,
On 01/29/2013 11:46 AM, Bernd Petrovitsch wrote:
I didn't look into the source of strcat2() ATM but all pjlib string
functions do not care about the allocation (and so they cannot possibly
enlarge it - if it is actually possible at all).
please take a look at pj_strcat2. You'll notice, dst assumes it owns
the memory beyond the string it currently encapsulates.
In order to correct the semantical ambiguity of the word "grow" from
my previous posting on this topic, please understand: create a new
pj_str_t, thus the pj_pool_t, that will be the concatenation of both
strings and assign that new string to dst afterwards.
So what happens is IMHO:
So better allocate enough space for "mikey " and the base64 string (and
not only around 7 bytes ....).
How much space is enough space ;o)
BTW pj_strdup2 allocates exactly six bytes, while
pj_strdup2_with_null allocates seven in this case.
IMHO the proposed "void pj_strcat3(pj_pool_t*,pj_str_t*,const
char*)" solution leans more to the PJ library programming style.
Best Regards,
Alain Totouom
--
""
(o)(o)
o00o()o00o__
1024D/A9F85A52 2000-01-18 Alain Totouom totouom@gmx.de
PGP Fingerprint DA180DF2 FBD25F67 0656452D E3A27531 A9F85A52
Hi!
On Die, 2013-01-29 at 14:09 +0100, Alain Totouom wrote:
[... fully agreed part omitted ... ]
How much space is enough space ;o)
Enough is enough;-)
In the above case it is pretty easy to predict - and the application (s
programmer) must solve it anyways.
BTW pj_strdup2 allocates exactly six bytes, while
pj_strdup2_with_null allocates seven in this case.
Yes, but that's not really relevant here as the base64-string is much
longer.
IMHO the proposed "void pj_strcat3(pj_pool_t*,pj_str_t*,const
char*)" solution leans more to the PJ library programming style.
Yes, that would fit more to the pjsip-string function design.
On the other hand, strcat() also doesn't care about the allocation,
though.
Personally I miss more of a
"pj_str_t pj_sprintf(pj_pool_t *, const char *fmt, ....);" which
calculates and allocates the necessary memory from the given pool.
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services