HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
Working with SIP Messages 173
Handling Messages with Syntax Errors
In this sample, the application receives a CSeq without the method part. To fix
the CSeq header, the application takes the method from the message request line
and uses the RvSipCSeqHeaderFix() function to fix the CSeq header.
/*=========================================================================================*/
RvStatus AppFixCSeqHeaderInMsg(RvSipMsgHandle hMsg)
{
RvStatus rv;
RvSipCSeqHeaderHandle hCSeq;
RvInt32 cseqBadSyntaxLen;
RvChar *cseqBadSyntaxStr;
RvChar startLineMethodStr[10];
RvInt32 startLineMethodStrLen = 10;
RvChar *cseqCorrectHeaderValueStr;
hCSeq = RvSipMsgGetCSeqHeader(hMsg);
if(hCSeq == NULL)
{
printf("no cseq header in given message");
return RV_ERROR_NOT_FOUND;
}
/*Checks the length of the bad-syntax string, and allocates a buffer with the correct
size.*/
cseqBadSyntaxLen = RvSipCSeqHeaderGetStringLength(hCSeq, RVSIP_CSEQ_BAD_SYNTAX);
if(cseqBadSyntaxLen == 0)
{
printf("cseq header is correct. no need to fix it.");
return RV_OK;
}
cseqBadSyntaxStr = malloc(cseqBadSyntaxLen + 1);
/*Gets the cseq bad-syntax string. Assuming that the CSeq header was "CSeq: 3", and the
method was missing, the bad-syntax string will be "3".*/
rv = RvSipCSeqHeaderGetStrBadSyntax(hCSeq,
cseqBadSyntaxStr,
cseqBadSyntaxLen+1,
&cseqBadSyntaxLen);
if(rv != RV_OK)
{
printf("Failed to get bad-syntax string from cseq header");
return RV_ERROR_UNKNOWN;