Re: Custom SIP INFO message parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

A simple solution would be to copy the information in rdata into a
null terminated string and deal with it like so:

// allocate memory for our null terminated string for the length of
the received data + 1
char *body = malloc(rdata->msg_info.msg->body->len + 1);

// zero the allocated memory
memset(body, 0, rdata->msg_info.msg->body->len + 1);

// copy over from rdata into body. the last byte of body will be zero.
memcpy(body, rdata->msg_info.msg->body->data,
    rdata->msg_info.msg->body->len);

// the SIP INFO data is now a string in `body`

// ... do stuff with it

// make sure you free the memory afterwards
free(body);

On Wed, Apr 5, 2017 at 12:19 PM, John Gathm <john.gathm@xxxxxxxxx> wrote:
> Hi
> I'm sending custom SIP INFO message from my PBX to my PJSIP client.
>
> I'm able to hook on the reception of the SIP INFO message with the
> on_call_tsx_state pjsua callback.
>
> I an see my custom data embedded in in the msg_bug, the whole INFO message.
>
> However, I'm wondering as best  practice what is the correct way, using the
> various PJSIP parsing and pj_str functions, to extract my custom data from
> the SIP INFO message.
>
> How should I extact "Custom_INFO_message: some_data" data whithin the SIP
> message body ?
>
> J.G.
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip@xxxxxxxxxxxxxxx
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org



[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux