sip_headers.c revision 40cb5e5daa7b80bb70fcf8dadfb20f9281566331
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "sip_parse_uri.h"
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_parse_generic.h"
{"UNKNOWN", 7},
{"INVITE", 6},
{"ACK", 3},
{"OPTIONS", 7},
{"BYE", 3},
{"CANCEL", 6},
{"REGISTER", 8},
{"REFER", 5},
{"INFO", 4},
{"SUBSCRIBE", 9},
{"NOTIFY", 6},
{"PRACK", 5}
};
/*
* Built-In Header function table
*/
};
#define MAX_SIP_HEADERS \
sizeof (sip_header_function_table) / sizeof (sip_header_function_t)
/*
* External/application provided function table
*/
/*
* Free parameter list
*/
static void
{
param = param_list;
param = next_param;
}
}
/*
* Common header free routine
*/
void
{
return;
value = next_value;
}
}
/*
*/
void
{
return;
}
value = next_value;
}
}
/*
* Return new header
*/
{
if (new_header == NULL)
return (NULL);
/*
* We are using snprintf which adds a null character
* so allocate an extra byte which is not part of
* the message header
*/
return (NULL);
}
return (new_header);
}
/*
* Free the given header
*/
void
{
if (sip_header->sip_hdr_allocated) {
}
}
}
}
/*
* Return a copy of the header passed in.
*/
{
return (NULL);
} else {
}
return (to);
}
/*
* Copy header with extra_param, if any, to sip_msg
*/
int
{
int hdrlen;
int extra_len = 0;
int ncrlf = 0;
char *p;
#ifdef __solaris__
#endif
if (extra_param != NULL) {
}
/*
* Just take one if there are more, i.e. if this is the last header
* before the content.
*/
if (skip_crlf) {
header->sip_hdr_start) {
goto proceed;
}
ncrlf++;
break;
}
/*
* Take one CRLF.
*/
}
if (new_header == NULL)
return (ENOMEM);
int len;
} else {
hdrlen);
}
if (extra_param != NULL) {
/*
* Find CR
*/
if (sip_find_cr(new_header) != 0) {
return (EINVAL);
}
}
return (0);
}
/*
* Copy all "header_name" headers from _old_msg to _new_msg
*/
int
char *header_name)
{
int ret = 0;
return (EINVAL);
#ifdef __solaris__
#endif
if (ret != 0)
break;
}
return (ret);
}
/*
* Copy header_name from _old_msg to _new_msg with extra_parm.
*/
int
{
int ret;
return (EINVAL);
#ifdef __solaris__
#endif
return (EINVAL);
if (lock_newmsg)
if (lock_newmsg)
return (ret);
}
/*
* Copy all headers from old_msg to new_msg
*/
int
{
int ret = 0;
return (EINVAL);
if (ret != 0)
goto done;
}
done:
return (ret);
}
/*
* Copy start line from msg to sip_msg
*/
int
{
int len;
return (EINVAL);
return (EINVAL);
}
if (new_header == NULL) {
return (ENOMEM);
}
return (0);
}
/*
* Delete start line from sip_msg
*/
int
{
return (EINVAL);
}
/*
* Also delete the sip_msg_req_res info since we don't have a start
* line.
*/
}
}
}
return (0);
}
/*
* Delete start line from sip_msg
*/
int
{
int ret;
return (EINVAL);
return (ret);
}
/*
* Delete all headers from _sip_msg
*/
void
{
#ifdef __solaris__
#endif
}
}
/*
* Delete and free the named header. If header_name is null
* free all headers.
*/
void
{
#ifdef __solaris__
#endif
return;
} else {
}
} else {
}
if (header_name != NULL)
return;
else
}
}
/*
* Add a header to sip_msg. If header_name is provided then the new header
* is added before that header, if first is set, or after. If append is
* set, then the header is added to the end of the header list.
*/
void
{
return;
#ifdef __solaris__
#endif
if (header_name != NULL) {
header_tmp = header;
if (!first) {
header_tmp = header;
}
}
header = header_tmp;
}
if (append) {
} else {
}
} else {
} else {
}
}
} else {
if (append) {
} else {
}
} else {
} else {
}
}
}
}
/*
* Scan through the function table and return the entry for the given header
* type.
*/
{
int len;
int i = 0;
return (NULL);
/*
* If header_name is NULL we first have to locate the name
*/
if (header_name == NULL) {
if (sip_skip_white_space(sip_header) != 0) {
return (NULL);
}
(char)NULL) != 0) {
return (NULL);
}
} else {
}
if (len > 0) {
len ==
if (strncasecmp(header_name,
header_name, len) == 0) {
break;
}
} else if (sip_header_function_table[i].
if (strncasecmp(header_name,
header_short_name, len) == 0) {
break;
}
}
i++;
}
}
if (sip_header != NULL)
return (NULL);
return (&sip_header_function_table[i]);
}
/*
* Return the entry from the function table for the given header
*/
{
if (sip_header_function_table_external != NULL) {
if (header_f_table != NULL)
return (header_f_table);
}
return (func);
}
/*
* Search for the header name passed in.
*/
{
int len = 0;
int full_len = 0;
int compact_len = 0;
char *compact_name = NULL;
return (NULL);
#ifdef __solaris__
#endif
if (header_name != NULL) {
if (header_f_table != NULL) {
if (compact_name != NULL)
} else {
}
}
if (old_header != NULL)
else
continue;
}
if (compact_len == 0 && full_len == 0)
break;
if (sip_skip_white_space(header)) {
continue;
}
full_len) == 0) {
if (sip_skip_white_space(header)) {
continue;
}
break;
}
}
compact_len) == 0) {
if (sip_skip_white_space(header)) {
continue;
}
break;
}
}
}
if (header_f_table == NULL) {
if (header_f_table == NULL)
}
}
return (header);
}
/*
* Return the start line as a string. Caller frees string
*/
char *
{
char *slstr;
int len;
*error = 0;
return (NULL);
}
return (NULL);
}
return (slstr);
}
/*
* Return the given header as a string. Caller frees string
*/
char *
{
char *hdrstr;
char *tmpptr;
int len;
*error = 0;
if (sip_header == NULL) {
return (NULL);
}
(void) pthread_mutex_unlock(
}
return (NULL);
}
(void) pthread_mutex_lock(
}
(void) pthread_mutex_unlock(
}
return (NULL);
}
} else {
}
(void) pthread_mutex_unlock(
}
while (*tmpptr-- != '\n') {
return (NULL);
}
}
*tmpptr = '\0';
return (hdrstr);
}
/*
* Given a param list find the named parameter.
* Returns a pointer to the value or NULL.
*/
{
while (param_list != NULL) {
strlen(param_name)) == 0) {
return (param_list);
}
}
return (NULL);
}