[OpenSIPS-Users] struct sip_msg

Anca Vamanu anca at opensips.org
Wed Sep 2 14:37:13 CEST 2009


Hi Ghaith,

You must explicitly call parse_headers for the message to be parsed and 
for the fields in sip_msg to be filled.
Example:
    parse_headers(msg,HDR_EOH_F, 0); -  will parse all headers.

However beware that this function will not parse the headers value also. 
You must call the parse function for that header and it will fill the 
'parsed' filed of the struct hdr_field with a structure specific for 
that filed
Example: If you want to parse the value of the Contact header filed, you 
call
    parse_contact(msg->contact).
and it will fill the parsed filed with a contact_body_t structure that 
contains the parsed value of the Contact header.
    (contact_body_t* )msg->contact->parsed;

I suggest learning by example technique :), look in other modules that 
use the parser and see how it is done there. One option is function 
*extract_sdialog_info* function from modules/presence/subscribe.c file.

Regards,
Anca

Ghaith ALKAYYEM wrote:
> Hello list,
>
> I was trying to play with the SIP header, So when i tried to access the
> fields (to,from) in the sip_msg structure through a module c function
> they were NULL and everything was included in the field headers.
> I'd like to know whether there's something wrong or it's natural for
> these fields to be NULL.
>
> struct sip_msg {
> 	unsigned int id;               /* message id, unique/process*/
> 	struct msg_start first_line;   /* Message first line */
> 	struct via_body* via1;         /* The first via */
> 	struct via_body* via2;         /* The second via */
> 	struct hdr_field* headers;     /* All the parsed headers*/
> 	struct hdr_field* last_header; /* Pointer to the last parsed header*/
> 	hdr_flags_t parsed_flag;       /* Already parsed header field types */
>
> 	/* Via, To, CSeq, Call-Id, From, end of header*/
> 	/* pointers to the first occurrences of these headers;
> 	 * everything is also saved in 'headers' (see above)
> 	 */
>
> 	/* shorcuts to known headers */
> 	struct hdr_field* h_via1;
> 	struct hdr_field* h_via2;
> 	struct hdr_field* callid;
> 	struct hdr_field* to;
> 	struct hdr_field* cseq;
> 	struct hdr_field* from;
> 	...
> 	...
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>   




More information about the Users mailing list