sip_parser.c File Reference


Detailed Description

SIP parser.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>.
Date:
Created: Thu Oct 5 14:01:24 2000 ppessi

#include "config.h"
#include <sofia-sip/su_tagarg.h>
#include "sofia-sip/sip_parser.h"
#include <sofia-sip/msg_mclass.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <limits.h>

Include dependency graph for sip_parser.c:

Functions

msg_mclass_t const * sip_default_mclass (void)
 Return built-in SIP parser object.
issize_t sip_extract_body (msg_t *msg, sip_t *sip, char b[], isize_t bsiz, int eos)
 Extract SIP message body, including separator line.
int sip_version_d (char **ss, char const **ver)
 Parse SIP version.
isize_t sip_version_xtra (char const *version)
 Calculate extra space required by version string.
void sip_version_dup (char **pp, char const **dd, char const *s)
 Duplicate a transport string.
char const * sip_method_name (sip_method_t method, char const *name)
 Return string corresponding to the method.
sip_method_t sip_method_d (char **ss, char const **return_name)
 Parse a SIP method name.
sip_method_t sip_method_code (char const *name)
 Return code corresponding to the method code.
issize_t sip_transport_d (char **ss, char const **ttransport)
 Decode transport.
isize_t sip_transport_xtra (char const *transport)
 Calculate extra space required by sip_transport_dup().
void sip_transport_dup (char **pp, char const **dd, char const *s)
 Duplicate a transport string.
char * sip_word_at_word_d (char **ss)
 Parse SIP <word "@" word> construct used in Call-ID.
int sip_complete_message (msg_t *msg)
 Complete SIP message.

Variables

char const sip_parser_version []
 SIP parser version.
char const sip_version_2_0 []
 SIP version 2.0.
msg_mclass_t const sip_mclass []
 Default message class.
char const *const sip_method_names []
 Well-known SIP method names.


Function Documentation

int sip_complete_message ( msg_t msg  ) 

Complete SIP message.

Add sip_content_length and sip_separator if they are missing. The test that all necessary message components ( From, To, CSeq, Call-ID, Content-Length and message separator are present.

Return values:
0 when successful
-1 upon an error: headers are missing and they could not be added

issize_t sip_extract_body ( msg_t msg,
sip_t sip,
char  b[],
isize_t  bsiz,
int  eos 
)

Extract SIP message body, including separator line.

Parameters:
msg message object [IN]
sip public SIP message structure [IN/OUT]
b buffer containing unparsed data [IN]
bsiz buffer size [IN]
eos true if buffer contains whole message [IN]
Return values:
-1 error
0 cannot proceed
m 

sip_method_t sip_method_d ( char **  ss,
char const **  return_name 
)

Parse a SIP method name.

Parse a SIP method name and return a code corresponding to the method. The address of the first non-LWS character after method name is stored in *ss.

Parameters:
ss pointer to pointer to string to be parsed
return_name value-result parameter for method name
Note:
If there is no whitespace after method name, the value in *return_name may not be NUL-terminated. The calling function must NUL terminate the value by setting the **ss to NUL after first examining its value.
Returns:
The method code if method was identified, 0 (sip_method_unknown()) if method is not known, or -1 (sip_method_invalid()) if an error occurred.
If the value-result argument return_name is not NULL, a pointer to the method name is stored to it.

int sip_version_d ( char **  ss,
char const **  ver 
)

Parse SIP version.

Parse a SIP version string. Update the pointer at ss to first non-LWS character after the version string.

Parameters:
ss string to be parsed [IN/OUT]
ver value result for version [OUT]
Return values:
0 when successful,
-1 upon an error.


Sofia-SIP 1.12.6work - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.