[pjsip] How to find the size of Content-Length field

Benny Prijono bennylp at pjsip.org
Fri Sep 28 11:09:17 EDT 2007


Guru Prakash Pulipati wrote:
> Hi All
>  
> I am planning to write pack/unpack functions for sip messages,
> but I am stuck with some fields as I dont know there size.
>  
> for example,
> "Content-Length" which specifies the size of the SIP message body,
> but where can I get the size of the Content-Length field.

I hope I understand you question correctly.

If you have the pjsip_rx_data, then you can get the Content-Length 
header of the incoming message from:

    pjsip_clen_hdr *clen = rdata->msg_info.clen;
    if (clen) {
       printf("Content length is %d\n", clen->len);
    }

If you don't have pjsip_rx_data, you can find Content-Length header 
from a message using:

   pjsip_clen_hdr *clen = (pjsip_clen_hdr*)
                          pjsip_msg_find_hdr(msg,
                                             PJSIP_H_CONTENT_LENGTH,
                                             NULL);

HTH,
  -benny





More information about the pjsip mailing list