sip_msg.h revision 2c2c41837e330b002c4220a39638150db504fe0e
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SIP_MSG_H
#define _SIP_MSG_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <pthread.h>
#include <sip.h>
#ifdef __solaris__
extern int mutex_held();
#endif
/* Compare Cseq numbers */
#define SIP_CSEQ_LT(a, b) ((int32_t)((a)-(b)) < 0)
#define SIP_CSEQ_GT(a, b) ((int32_t)((a)-(b)) > 0)
#define SIP_CSEQ_GEQ(a, b) ((int32_t)((a)-(b)) >= 0)
#define SIP_HEADER_ACTIVE 0x0
#define SIP_HEADER_DELETED 0x1
#define SIP_HEADER_DELETED_VAL 0x2
/* List of registered sent-by values */
typedef struct sent_by_list_s {
struct sent_by_list_s *sb_next;
struct sent_by_list_s *sb_prev;
char *sb_val;
extern sent_by_list_t *sip_sent_by;
extern int sip_sent_by_count;
extern pthread_mutex_t sip_sent_by_lock;
typedef struct sip_header {
int sip_header_state;
struct sip_header *sip_hdr_next;
struct sip_header *sip_hdr_prev;
struct sip_message *sip_hdr_sipmsg;
/* True if header was allocated */
/* Structure for the SIP message body */
typedef struct sip_content {
char *sip_content_start;
char *sip_content_end;
char *sip_content_current;
struct sip_content *sip_content_next;
/* General definitions */
/* Two string values */
typedef struct sip_2strs {
/* An integer and a string value */
typedef struct sip_intstr {
int i;
sip_str_t s;
} sip_intstr_t;
/* Warn value */
typedef struct sip_warn {
int code;
} sip_warn_t;
/* Date value */
typedef struct sip_date {
sip_str_t t;
int d;
sip_str_t m;
int y;
} sip_date_t;
/* Authorization and authentication value */
typedef struct sip_auth {
} sip_auth_t;
/* RACK value */
typedef struct sip_rack {
int rack_resp_num;
int rack_cseq_num;
/* Cseq value */
typedef struct sip_cseq {
int num;
/* Value for Contact, From and To header */
typedef struct cftr_value {
typedef struct sip_proto_version_s {
/* Via value */
typedef struct via_value {
int sent_by_port;
typedef struct sip_hdr_value {
union {
int i;
} hdr_value;
/*
* NOTE: ALL value structs MUST have sip_value_t as the first field.
*/
#define SIP_INT_VAL 0x01
#define SIP_STR_VAL 0x02
#define SIP_STRS_VAL 0x03
#define SIP_INTSTR_VAL 0x04
#define SIP_AUTH_VAL 0x05
/* hdr value contains two string */
typedef sip_hdr_value_t sip_acpt_value_t;
typedef sip_hdr_value_t sip_content_type_value_t;
/* hdr value contains one string only */
typedef sip_hdr_value_t sip_acpt_lang_value_t;
typedef sip_hdr_value_t sip_acpt_encode_value_t;
typedef sip_hdr_value_t sip_alert_value_t;
typedef sip_hdr_value_t sip_cl_info_value_t;
typedef sip_hdr_value_t sip_ct_disp_value_t;
typedef sip_hdr_value_t sip_ct_encode_value_t;
typedef sip_hdr_value_t sip_ct_lang_value_t;
typedef sip_hdr_value_t sip_irt_value_t;
typedef sip_hdr_value_t sip_mime_ver_value_t;
typedef sip_hdr_value_t sip_org_value_t;
typedef sip_hdr_value_t sip_prio_value_t;
typedef sip_hdr_value_t sip_reply_value_t;
typedef sip_hdr_value_t sip_privacy_value_t;
typedef sip_hdr_value_t sip_ppassertedid_value_t;
typedef sip_hdr_value_t sip_ppreferredid_value_t;
typedef sip_hdr_value_t sip_pxy_req_value_t;
typedef sip_hdr_value_t sip_req_value_t;
typedef sip_hdr_value_t sip_subject_value_t;
typedef sip_hdr_value_t sip_svr_value_t;
typedef sip_hdr_value_t sip_support_value_t;
typedef sip_hdr_value_t sip_unsupport_value_t;
typedef sip_hdr_value_t sip_usr_agt_value_t;
typedef sip_hdr_value_t sip_err_info_value_t;
typedef sip_hdr_value_t sip_date_value_t;
typedef sip_hdr_value_t sip_allert_value_t;
typedef sip_hdr_value_t sip_callid_value_t;
/* hdr value contain one int only */
typedef sip_hdr_value_t sip_expr_value_t;
typedef sip_hdr_value_t sip_min_expr_value_t;
typedef sip_hdr_value_t sip_retry_value_t;
typedef sip_hdr_value_t sip_timestamp_value_t;
typedef sip_hdr_value_t sip_rseq_value_t;
typedef sip_hdr_value_t sip_content_len_value_t;
typedef sip_hdr_value_t sip_max_forwards_value_t;
typedef sip_hdr_value_t sip_allow_value_t;
/* hdr value contain one int, two strings */
typedef sip_hdr_value_t sip_warn_value_t;
/* hdr field value is a list of param=param_val */
typedef sip_hdr_value_t sip_authen_value_t;
typedef sip_hdr_value_t sip_authen_info_value_t;
typedef sip_hdr_value_t sip_pxy_authen_value_t;
typedef sip_hdr_value_t sip_pxy_author_value_t;
typedef sip_hdr_value_t sip_3w_authen_value_t;
/* SIP request line structure */
typedef struct sip_request {
/* SIP response line structure */
typedef struct sip_response {
int sip_response_code;
/* SIP message type - request or response */
typedef struct sip_message_type {
union {
} U;
/* This is to save old value when we use a recvd message. */
struct sip_message_type *sip_next;
/* Increment reference count on SIP message */
#define SIP_MSG_REFCNT_INCR(sip_msg) { \
(sip_msg)->sip_msg_ref_cnt++; \
}
/* Decrement reference count on SIP message */
#define SIP_MSG_REFCNT_DECR(sip_msg) { \
if (--(sip_msg)->sip_msg_ref_cnt == 0) { \
} else { \
} \
}
/* SIP message structure */
typedef struct sip_message {
char *sip_msg_buf; /* Message */
char *sip_msg_old_buf;
int sip_msg_len;
/* All fields synchronizes on this */
/* doubly linked list of headers */
int sip_msg_ref_cnt;
char *, char *, boolean_t);
extern int _sip_find_and_copy_all_header(_sip_msg_t *,
_sip_msg_t *, char *header_name);
_sip_header_t *);
extern _sip_header_t *sip_new_header(int);
extern void sip_destroy_msg(_sip_msg_t *);
extern void sip_free_phdr(sip_parsed_header_t *);
extern void sip_free_cftr_header(sip_parsed_header_t *);
extern int sip_parse_allow_events_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_event_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_substate_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_acpt_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_acpt_encode_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_acpt_lang_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_alert_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_allow_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_useragt_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_usupport_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_timestamp_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_support_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_subject_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_server_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_retryaft_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_require_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_replyto_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_passertedid_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_ppreferredid_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_priority_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_org_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_mimeversion_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_minexpire_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_rseq_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_inreplyto_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_privacy_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_expire_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_errorinfo_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_contentlang_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_contentencode_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_contentdis_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_callinfo_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_date_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_warn_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_cftr_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_cseq_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_cid_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_via_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_clen_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_maxf_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_ctype_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_unknown_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_ainfo_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_preq_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_author_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_pauthor_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_pauthen_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_wauthen_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_passertedid(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_ppreferredid(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_parse_privacy_header(_sip_header_t *,
sip_parsed_header_t **);
extern int sip_copy_values(char *, _sip_header_t *);
extern int sip_add_content_length(_sip_msg_t *, int);
extern int sip_delete_start_line_locked(_sip_msg_t *);
/* Useful access macros */
#ifdef __cplusplus
}
#endif
#endif /* _SIP_MSG_H */