Hi guys!
I am trying to parse Call-ID from received message within my custom
kamailio module but every time I parse it and persist it within shared
memory of my module the kamailio sends back (to UA) SIP message with
`{Call-ID-hex-stream}0d` instead of `{Call-ID-hex-stream}00`
So it seems that kamailio adds `CR` byte to Call-ID which I am parsing.
This is how I am parsing and persisting the Call-ID (in my opinion it's
without affecting the original message but yet it seems that I am wrong):
First of all I parse Call-ID so I have `str` structure where the
`call_id_str.s` is pointing to the begining of Call-ID within `sip_msg_t`
structure and `call_id_str.len` has the length of that Call-ID.
Secondly I am trying to copy the string from received SIP message into my
own structure (I mean copy not just point to it since I need it also when
the message is gone). I've prepared this function:
int shm_copy_string(const char *original_string, int original_length, char
**new_string) {
// allocate shared memory for new string
*new_string = (char *) shm_malloc(sizeof(char) * (original_length + 1));
if (*new_string == NULL) {
ERR("cannot allocate shm memory");
return -1;
}
// copy original string to new string
memcpy(new_string, &original_string, original_length);
// end new string with null character
(*new_string)[original_length] = '\0';
return 0;
}
I am calling this function within my module like this:
shm_copy_string(call_id_str.s, call_id_str.len, &call_id);
I don't manipulate with the pointer to original message in any way but
still the message which kamailio sends back to my UA has that `CR` and it
causes me big problems since UA cannot match the Call-ID.
Also weird is that when I skip copying of the Call-ID on Registration
message it is not affected so UA can register but then when I am trying to
call from UA to UA I am getting as a response for my INVITE the `407 Proxy
Authentication Required` with malformed Call-ID.
Messages where I don't parse Call-ID are OK so the problem must be in this
function.
Has anyone came across this issue? How-come response SIP message is
affected when I didn't add anything to the message?
Thanks in advance for any help