BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJSIP Reference

pjsip_msg_body Struct Reference

#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

◆ content_type

pjsip_media_type pjsip_msg_body::content_type

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.

◆ data

void* pjsip_msg_body::data

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.

◆ len

unsigned pjsip_msg_body::len

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.

◆ print_body

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_bodyThis structure itself.
bufThe buffer.
sizeThe 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.

◆ clone_data

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
poolPool used to clone the data.
dataThe data inside message body, to be cloned.
lenThe 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.