/*
* 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
*/
/*
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <strings.h>
#include <pthread.h>
#include <sip.h>
#include "sip_msg.h"
#include "sip_miscdefs.h"
#include "sip_parse_uri.h"
#include "sip_xaction.h"
/*
* Find the header named header, consecutive calls with old_header
* passed in will return next header of the same type.
* If no name is passed the first header is returned. consectutive calls
* with no name but an old header will return the next header.
*/
const struct sip_header *
int *error)
{
*error = 0;
return (NULL);
}
return (sip_hdr);
}
/*
* Return the request line as a string. Caller releases the returned string.
*/
char *
{
char *reqstr;
*error = 0;
return (NULL);
}
return (reqstr);
}
/*
* Return the response line as a string. Caller releases the returned string.
*/
char *
{
char *respstr;
*error = 0;
return (NULL);
}
return (respstr);
}
/*
* return the first value of the header
*/
const struct sip_value *
{
int ret = 0;
*error = 0;
if (sip_header == NULL) {
return (NULL);
}
(void) pthread_mutex_lock(
}
(void) pthread_mutex_unlock(
}
return (NULL);
}
(void) pthread_mutex_unlock
}
if (ret != 0)
return (NULL);
}
return ((sip_header_value_t)value);
}
/*
* Return the next value of the header.
*/
const struct sip_value *
{
*error = 0;
return (NULL);
}
/*
* We never free the deleted values so no need to hold a lock.
*/
}
return ((sip_header_value_t)value);
}
/*
* Given a SIP message, delete the header "header_name".
*/
int
{
return (EINVAL);
if (_msg->sip_msg_cannot_be_modified) {
return (EPERM);
}
return (EINVAL);
}
return (0);
}
/*
* Mark the header as deleted.
*/
int
{
if (sip_header == NULL)
return (EINVAL);
(void) pthread_mutex_unlock
return (EPERM);
}
(void) pthread_mutex_unlock(
return (EINVAL);
}
(void) pthread_mutex_unlock
return (0);
}
/*
* Mark the value as deleted.
*/
int
{
int vlen;
char *c;
return (EINVAL);
(void) pthread_mutex_unlock(&_sip_header->
return (EPERM);
}
(void) pthread_mutex_unlock(
return (EINVAL);
}
(void) pthread_mutex_unlock(
return (EINVAL);
}
c = _sip_header_value->value_start;
while (*c-- != SIP_HCOLON)
vlen++;
} else {
c = _sip_header_value->value_start;
while (*c-- != SIP_COMMA)
vlen++;
}
char *s;
continue;
}
while (s != value->value_start) {
break;
}
s--;
}
}
if (!crlf_present) {
c = _sip_header_value->value_end;
while (*c-- != '\r')
vlen--;
}
}
(void) pthread_mutex_unlock
return (0);
}
/*
* Given a param list, check if a param name exists.
*/
int param_len)
{
param_len) == 0) {
return (B_TRUE);
}
}
return (B_FALSE);
}
/*
* Given a value header return the value of the named param.
*/
const sip_str_t *
int *error)
{
*error = 0;
return (NULL);
}
return (NULL);
}
return (NULL);
}
return (&sip_param->param_value);
return (NULL);
}
/*
* Return the list of params in the header
*/
const sip_param_t *
{
*error = 0;
if (header_value == NULL) {
return (NULL);
}
return (NULL);
}
return (sip_header_value->param_list);
}
/*
* Return true if this is a SIP request
*/
{
*error = 0;
return (B_FALSE);
}
return (B_FALSE);
}
return (ret);
}
/*
* Return true if this is a SIP response
*/
{
*error = 0;
return (B_FALSE);
}
return (B_FALSE);
}
return (is_resp);
}
/*
* Return the method in the request line
*/
{
*error = 0;
return (ret);
}
return (ret);
}
if (sip_msg_info->is_request)
return (ret);
}
/*
* Return the URI from the request line
*/
const sip_str_t *
{
*error = 0;
return (NULL);
}
return (NULL);
}
if (sip_msg_info->is_request)
/*
* If the error is required, check the validity of the URI via
* sip_uri_parse().
*/
if (parsed_uri != NULL)
}
return (ret);
}
/*
* Return the response code
*/
int
{
*error = 0;
return (ret);
}
return (ret);
}
if (!sip_msg_info->is_request)
return (ret);
}
/*
* Get the response phrase
*/
const sip_str_t *
{
*error = 0;
return (ret);
}
return (ret);
}
if (!sip_msg_info->is_request) {
if (sip_msg_info->sip_resp_phrase_len == 0)
else
}
return (ret);
}
/*
* Get the SIP version string
*/
const sip_str_t *
{
*error = 0;
return (ret);
}
return (ret);
}
return (ret);
}
/*
* Return the length of the SIP message
*/
int
{
*error = 0;
return (-1);
}
return (_sip_msg->sip_msg_len);
}
/*
* Get content as a string. Caller frees the string
*/
char *
{
char *content;
int len;
char *p;
*error = 0;
return (NULL);
}
return (NULL);
}
return (NULL);
}
p = content;
while (sip_content != NULL) {
p += len;
}
return (content);
}
/*
* copy sip_header with param, if any, to sip_msg
*/
int
{
int ret;
return (EINVAL);
if (_sip_msg->sip_msg_cannot_be_modified) {
return (EPERM);
}
return (EINVAL);
}
return (ret);
}
/*
* copy the header specified by header_name, with param, if any
*/
int
char *header_name, char *param)
{
int ret;
return (EINVAL);
}
if (_new_msg->sip_msg_cannot_be_modified) {
return (EPERM);
}
B_FALSE);
return (ret);
}
/*
* add the given header to sip_message
*/
int
{
int header_size;
return (EINVAL);
if (_sip_msg->sip_msg_cannot_be_modified) {
return (EPERM);
}
if (new_header == NULL) {
return (ENOMEM);
}
return (0);
}
/*
* add the given param to the sip_header. create a new header with the param
* and mark the old header as deleted.
*/
{
int hdrlen;
int param_len;
char *tmp_ptr;
*error = 0;
return (NULL);
}
(void) pthread_mutex_unlock(
return (NULL);
}
(void) pthread_mutex_unlock(
return (NULL);
}
if (new_header == NULL) {
(void) pthread_mutex_unlock(
return (NULL);
}
hdrlen);
/*
* Find CRLF
*/
while (*tmp_ptr-- != '\n') {
hdrlen++;
(void) pthread_mutex_unlock(
return (NULL);
}
}
(void) sip_delete_header(sip_header);
return ((sip_header_t)new_header);
}
/*
* Get Request URI
*/
const struct sip_uri *
{
*error = 0;
return (NULL);
}
} else {
}
}
}
}
/*
* returns a comma separated string of all the sent-by values registered by
* the UA.
*/
char *
{
int sb_len = 0;
int slen;
char *sb_str;
char *p;
int count = 0;
int cnt = 0;
*error = 0;
(void) pthread_mutex_lock(&sip_sent_by_lock);
if (sip_sent_by == NULL) {
(void) pthread_mutex_unlock(&sip_sent_by_lock);
return (NULL);
}
sb = sip_sent_by;
}
/*
* for the commas
*/
(void) pthread_mutex_unlock(&sip_sent_by_lock);
return (NULL);
}
sb = sip_sent_by;
p = sb_str;
if (cnt == 0) {
} else {
}
p += count;
}
(void) pthread_mutex_unlock(&sip_sent_by_lock);
return (sb_str);
}
/*
* A comma separated list of sent-by values.
*/
int
{
char *str;
int count = 0;
return (EINVAL);
int slen;
start++;
end--;
goto err_ret;
goto err_ret;
goto err_ret;
}
} else {
}
count++;
}
(void) pthread_mutex_lock(&sip_sent_by_lock);
if (sip_sent_by != NULL) {
}
sip_sent_by = sb;
(void) pthread_mutex_unlock(&sip_sent_by_lock);
return (0);
}
return (EINVAL);
}
/*
* Un-register sent-by values; 'val' contains a comma separated list
*/
void
{
char *str;
int count = 0;
(void) pthread_mutex_lock(&sip_sent_by_lock);
sb = sip_sent_by;
if (sb == sip_sent_by) {
else
sip_sent_by = NULL;
} else {
}
break;
}
}
}
(void) pthread_mutex_unlock(&sip_sent_by_lock);
}
/*
* Un-register all the sent-by values
*/
void
{
int count;
(void) pthread_mutex_lock(&sip_sent_by_lock);
sb = sip_sent_by;
sb = sip_sent_by;
}
sip_sent_by = NULL;
sip_sent_by_count = 0;
(void) pthread_mutex_unlock(&sip_sent_by_lock);
}
/*
* Given a response code, return the corresponding phrase
*/
char *
{
switch (resp_code) {
case SIP_TRYING:
return ("TRYING");
case SIP_RINGING:
return ("RINGING");
return ("CALL_IS_BEING_FORWARDED");
case SIP_QUEUED:
return ("QUEUED");
case SIP_SESSION_PROGRESS:
return ("SESSION_PROGRESS");
case SIP_OK:
return ("OK");
case SIP_ACCEPTED:
return ("ACCEPTED");
case SIP_MULTIPLE_CHOICES:
return ("MULTIPLE_CHOICES");
case SIP_MOVED_PERMANENTLY:
return ("MOVED_PERMANENTLY");
case SIP_MOVED_TEMPORARILY:
return ("MOVED_TEMPORARILY");
case SIP_USE_PROXY:
return ("USE_PROXY");
case SIP_ALTERNATIVE_SERVICE:
return ("ALTERNATIVE_SERVICE");
case SIP_BAD_REQUEST:
return ("BAD_REQUEST");
case SIP_UNAUTHORIZED:
return ("UNAUTHORIZED");
case SIP_PAYMENT_REQUIRED:
return ("PAYMENT_REQUIRED");
case SIP_FORBIDDEN:
return ("FORBIDDEN");
case SIP_NOT_FOUND:
return ("NOT_FOUND");
case SIP_METHOD_NOT_ALLOWED:
return ("METHOD_NOT_ALLOWED");
case SIP_NOT_ACCEPTABLE:
return ("NOT_ACCEPTABLE");
case SIP_PROXY_AUTH_REQUIRED:
return ("PROXY_AUTH_REQUIRED");
case SIP_REQUEST_TIMEOUT:
return ("REQUEST_TIMEOUT");
case SIP_GONE:
return ("GONE");
return ("REQUEST_ENTITY_2_LARGE");
case SIP_REQUEST_URI_2_LONG:
return ("REQUEST_URI_2_LONG");
return ("UNSUPPORTED_MEDIA_TYPE");
return ("UNSUPPORTED_URI_SCHEME");
case SIP_BAD_EXTENSION:
return ("BAD_EXTENSION");
case SIP_EXTENSION_REQUIRED:
return ("EXTENSION_REQUIRED");
case SIP_INTERVAL_2_BRIEF:
return ("INTERVAL_2_BRIEF");
case SIP_TEMPORARILY_UNAVAIL:
return ("TEMPORARILY_UNAVAIL");
case SIP_CALL_NON_EXISTANT:
return ("CALL_NON_EXISTANT");
case SIP_LOOP_DETECTED:
return ("LOOP_DETECTED");
case SIP_TOO_MANY_HOOPS:
return ("TOO_MANY_HOOPS");
case SIP_ADDRESS_INCOMPLETE:
return ("ADDRESS_INCOMPLETE");
case SIP_AMBIGUOUS:
return ("AMBIGUOUS");
case SIP_BUSY_HERE:
return ("BUSY_HERE");
case SIP_REQUEST_TERMINATED:
return ("REQUEST_TERMINATED");
case SIP_NOT_ACCEPTABLE_HERE:
return ("NOT_ACCEPTABLE_HERE");
case SIP_BAD_EVENT:
return ("BAD_EVENT");
case SIP_REQUEST_PENDING:
return ("REQUEST_PENDING");
case SIP_UNDECIPHERABLE:
return ("UNDECIPHERABLE");
return ("SERVER_INTERNAL_ERROR");
case SIP_NOT_IMPLEMENTED:
return ("NOT_IMPLEMENTED");
case SIP_BAD_GATEWAY:
return ("BAD_GATEWAY");
case SIP_SERVICE_UNAVAILABLE:
return ("SERVICE_UNAVAILABLE");
case SIP_SERVER_TIMEOUT:
return ("SERVER_TIMEOUT");
return ("VERSION_NOT_SUPPORTED");
case SIP_MESSAGE_2_LARGE:
return ("MESSAGE_2_LARGE");
case SIP_BUSY_EVERYWHERE:
return ("BUSY_EVERYWHERE");
case SIP_DECLINE:
return ("DECLINE");
return ("DOES_NOT_EXIST_ANYWHERE");
return ("NOT_ACCEPTABLE_ANYWHERE");
default:
return ("UNKNOWN");
}
}
/*
* The following three fns initialize and destroy the private library
* data in sip_conn_object_t. The assumption is that the 1st member
* of sip_conn_object_t is reserved for library use. The private data
* is used only for byte-stream protocols such as TCP to accumulate
* a complete SIP message, based on the CONTENT-LENGTH value, before
* processing it.
*/
int
{
void **obj_val;
return (EINVAL);
return (ENOMEM);
return (ENOMEM);
}
return (0);
}
/*
* Clear private date, if any
*/
void
{
void **obj_val;
return;
reass->sip_reass_msglen = 0;
}
}
/*
* Walk through all the transactions, remove if this obj has been cached
* by any.
*/
void
{
void **obj_val;
return;
}