HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
Working with SIP Messages 161
Creating a New SIP Message
CREATING A NEW
SIP M
ESSAGE
You can create a new message by performing the following steps:
To create a new message
1. Create a message with the Construct() function.
2. Set the start-line values: request-line values, if this is a request,
or the status-line values, if this is a response.
3. Add headers as required.
4. Add a message body as required.
Sample Code
The following code demonstrates how to create a new message.
/*===================================================================================*/
RvSipMsgHandle createMessage(
RvSipMsgMgrHandle hMgr,
HRPOOL hPool)
{
RvSipMsgHandle hMsg;
RvStatus status;
RvSipAddressHandle uri;
RvInt length;
RvSipPartyHeaderHandle toHeader;
/*Constructs a new message object.*/
status = RvSipMsgConstruct(hMgr, hPool, &hMsg);
if(status!= RV_OK)
return NULL;
/*Sets the status-code for the status-line.*/
RvSipMsgSetStatusCode(hMsg, 200, RV_TRUE);
/*Creates and sets the To header with a URL value.*/
status = RvSipToHeaderConstructInMsg(hMsg, &toHeader);
if(status!= RV_OK)
return NULL;
status = RvSipAddrConstructInPartyHeader(toHeader, RVSIP_ADDRTYPE_URL, &uri);
if(status!= RV_OK)