2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#ifndef _SIP_XACTION_H
2N/A#define _SIP_XACTION_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <pthread.h>
2N/A#include <sip.h>
2N/A#include <sys/types.h>
2N/A
2N/A#include "sip_msg.h"
2N/A#include "sip_miscdefs.h"
2N/A
2N/A/* Various transaction timers */
2N/Atypedef enum sip_timer_type_s {
2N/A SIP_XACTION_TIMER_A = 0,
2N/A SIP_XACTION_TIMER_B,
2N/A SIP_XACTION_TIMER_D,
2N/A SIP_XACTION_TIMER_E,
2N/A SIP_XACTION_TIMER_F,
2N/A SIP_XACTION_TIMER_G,
2N/A SIP_XACTION_TIMER_H,
2N/A SIP_XACTION_TIMER_I,
2N/A SIP_XACTION_TIMER_J,
2N/A SIP_XACTION_TIMER_K
2N/A} sip_xaction_timer_type_t;
2N/A
2N/A
2N/A/* Increment transaction reference count */
2N/A#define SIP_XACTION_REFCNT_INCR(trans) \
2N/A (trans)->sip_xaction_ref_cnt++;
2N/A
2N/A/* Decrement transaction reference count */
2N/A#define SIP_XACTION_REFCNT_DECR(trans) { \
2N/A (void) pthread_mutex_lock(&((trans)->sip_xaction_mutex)); \
2N/A assert((trans)->sip_xaction_ref_cnt > 0); \
2N/A (trans)->sip_xaction_ref_cnt--; \
2N/A if ((trans)->sip_xaction_ref_cnt == 0 && \
2N/A SIP_IS_XACTION_TERMINATED((trans)->sip_xaction_state)) { \
2N/A (void) pthread_mutex_unlock(&((trans)->sip_xaction_mutex));\
2N/A sip_xaction_delete(trans); \
2N/A } else { \
2N/A (void) pthread_mutex_unlock(&((trans)->sip_xaction_mutex));\
2N/A } \
2N/A}
2N/A
2N/A/* True if transaction is in the terminated state */
2N/A#define SIP_IS_XACTION_TERMINATED(trans_state) \
2N/A ((trans_state) == SIP_CLNT_INV_TERMINATED || \
2N/A (trans_state) == SIP_CLNT_NONINV_TERMINATED || \
2N/A (trans_state) == SIP_SRV_INV_TERMINATED || \
2N/A (trans_state) == SIP_SRV_NONINV_TERMINATED)
2N/A
2N/A/* Transaction structure */
2N/Atypedef struct sip_xaction {
2N/A char *sip_xaction_branch_id; /* Transaction id */
2N/A uint16_t sip_xaction_hash_digest[8];
2N/A _sip_msg_t *sip_xaction_orig_msg; /* orig request msg. */
2N/A _sip_msg_t *sip_xaction_last_msg; /* last msg sent */
2N/A sip_conn_object_t sip_xaction_conn_obj;
2N/A int sip_xaction_state; /* Transaction State */
2N/A sip_method_t sip_xaction_method;
2N/A uint32_t sip_xaction_ref_cnt;
2N/A pthread_mutex_t sip_xaction_mutex;
2N/A sip_timer_t sip_xaction_TA;
2N/A sip_timer_t sip_xaction_TB;
2N/A sip_timer_t sip_xaction_TD;
2N/A sip_timer_t sip_xaction_TE;
2N/A sip_timer_t sip_xaction_TF;
2N/A sip_timer_t sip_xaction_TG;
2N/A sip_timer_t sip_xaction_TH;
2N/A sip_timer_t sip_xaction_TI;
2N/A sip_timer_t sip_xaction_TJ;
2N/A sip_timer_t sip_xaction_TK;
2N/A void *sip_xaction_ctxt; /* currently unused */
2N/A int sip_xaction_msgcnt;
2N/A sip_log_t sip_xaction_log[SIP_SRV_NONINV_TERMINATED + 1];
2N/A} sip_xaction_t;
2N/A
2N/Aextern void sip_xaction_init(int (*ulp_trans_err)(sip_transaction_t,
2N/A int, void *), void (*ulp_state_cb)
2N/A (sip_transaction_t, sip_msg_t, int, int));
2N/Aextern int sip_xaction_output(sip_conn_object_t, sip_xaction_t *,
2N/A _sip_msg_t *);
2N/Aextern int sip_xaction_input(sip_conn_object_t, sip_xaction_t *,
2N/A _sip_msg_t **);
2N/Aextern sip_xaction_t *sip_xaction_get(sip_conn_object_t, sip_msg_t,
2N/A boolean_t, int, int *);
2N/Aextern void sip_xaction_delete(sip_xaction_t *);
2N/Aextern char *sip_get_xaction_state(int);
2N/Aextern int (*sip_xaction_ulp_trans_err)(sip_transaction_t, int,
2N/A void *);
2N/Aextern void (*sip_xaction_ulp_state_cb)(sip_transaction_t,
2N/A sip_msg_t, int, int);
2N/Aextern void sip_del_conn_obj_cache(sip_conn_object_t, void *);
2N/Aextern int sip_add_conn_obj_cache(sip_conn_object_t, void *);
2N/Aextern void sip_xaction_terminate(sip_xaction_t *, _sip_msg_t *,
2N/A int);
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _SIP_XACTION_H */