pjsip logo pjsip.org
Open source SIP stack and media stack for presence, im/instant messaging, and multimedia communication
Loading

HOME

SIP/media Features
High Performance SIP
Small Footprint SIP
Symbian Port

FAQ

Documentation

Licensing

Download

Development (Trac)

Projects using pjsip

Mailing List

Open Source Links


About: PJLIB, PJLIB-UTIL, PJSIP, and PJMEDIA are created by: Benny Prijono
<bennylp@pjsip.org>


 

Home --> Documentations --> PJSIP Reference

pjsip_msg_body Struct Reference
[Message Body]

#include <sip_msg.h>

Data Fields

pjsip_media_type content_type
void * data
unsigned len
int(* print_body )(struct pjsip_msg_body *msg_body, char *buf, pj_size_t size)
void *(* clone_data )(pj_pool_t *pool, const void *data, unsigned len)

Detailed Description

Generic abstraction to message body. When an incoming message is parsed (pjsip_parse_msg()), the parser fills in all members with the appropriate value. The 'data' and 'len' member will describe portion of incoming packet which denotes the message body. When application needs to attach message body to outgoing SIP message, it must fill in all members of this structure.

Forward declaration for message body (sip_msg.h).


Field Documentation

MIME content type. For incoming messages, the parser will fill in this member with the content type found in Content-Type header.

For outgoing messages, application may fill in this member with appropriate value, because the stack will generate Content-Type header based on the value specified here.

If the content_type is empty, no Content-Type AND Content-Length header will be added to the message. The stack assumes that application adds these headers themselves.

Pointer to buffer which holds the message body data. For incoming messages, the parser will fill in this member with the pointer to the body string.

When sending outgoing message, this member doesn't need to point to the actual message body string. It can be assigned with arbitrary pointer, because the value will only need to be understood by the print_body() function. The stack itself will not try to interpret this value, but instead will always call the print_body() whenever it needs to get the actual body string.

The length of the data. For incoming messages, the parser will fill in this member with the actual length of message body.

When sending outgoing message, again just like the "data" member, the "len" member doesn't need to point to the actual length of the body string.

int(* pjsip_msg_body::print_body)(struct pjsip_msg_body *msg_body, char *buf, pj_size_t size)

Pointer to function to print this message body. Application must set a proper function here when sending outgoing message.

Parameters:
msg_body This structure itself.
buf The buffer.
size The buffer size.
Returns:
The length of the string printed, or -1 if there is not enough space in the buffer to print the whole message body.
void*(* pjsip_msg_body::clone_data)(pj_pool_t *pool, const void *data, unsigned len)

Clone the data part only of this message body. Note that this only duplicates the data part of the body instead of the whole message body. If application wants to duplicate the entire message body structure, it must call pjsip_msg_body_clone().

Parameters:
pool Pool used to clone the data.
data The data inside message body, to be cloned.
len The length of the data.
Returns:
New data duplicated from the original data.

The documentation for this struct was generated from the following file:

 


PJSIP Open Source, high performance, small footprint, and very very portable SIP stack
Copyright (C) 2006-2008 Teluu Inc.