1*2882Svi117747 /* 2*2882Svi117747 * CDDL HEADER START 3*2882Svi117747 * 4*2882Svi117747 * The contents of this file are subject to the terms of the 5*2882Svi117747 * Common Development and Distribution License (the "License"). 6*2882Svi117747 * You may not use this file except in compliance with the License. 7*2882Svi117747 * 8*2882Svi117747 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*2882Svi117747 * or http://www.opensolaris.org/os/licensing. 10*2882Svi117747 * See the License for the specific language governing permissions 11*2882Svi117747 * and limitations under the License. 12*2882Svi117747 * 13*2882Svi117747 * When distributing Covered Code, include this CDDL HEADER in each 14*2882Svi117747 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*2882Svi117747 * If applicable, add the following below this CDDL HEADER, with the 16*2882Svi117747 * fields enclosed by brackets "[]" replaced with your own identifying 17*2882Svi117747 * information: Portions Copyright [yyyy] [name of copyright owner] 18*2882Svi117747 * 19*2882Svi117747 * CDDL HEADER END 20*2882Svi117747 */ 21*2882Svi117747 22*2882Svi117747 /* 23*2882Svi117747 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*2882Svi117747 * Use is subject to license terms. 25*2882Svi117747 */ 26*2882Svi117747 27*2882Svi117747 #ifndef _SIP_XACTION_H 28*2882Svi117747 #define _SIP_XACTION_H 29*2882Svi117747 30*2882Svi117747 #pragma ident "%Z%%M% %I% %E% SMI" 31*2882Svi117747 32*2882Svi117747 #ifdef __cplusplus 33*2882Svi117747 extern "C" { 34*2882Svi117747 #endif 35*2882Svi117747 36*2882Svi117747 #include <stdio.h> 37*2882Svi117747 #include <stdlib.h> 38*2882Svi117747 #include <string.h> 39*2882Svi117747 40*2882Svi117747 /* Various transaction timers */ 41*2882Svi117747 typedef enum sip_timer_type_s { 42*2882Svi117747 SIP_XACTION_TIMER_A = 0, 43*2882Svi117747 SIP_XACTION_TIMER_B, 44*2882Svi117747 SIP_XACTION_TIMER_D, 45*2882Svi117747 SIP_XACTION_TIMER_E, 46*2882Svi117747 SIP_XACTION_TIMER_F, 47*2882Svi117747 SIP_XACTION_TIMER_G, 48*2882Svi117747 SIP_XACTION_TIMER_H, 49*2882Svi117747 SIP_XACTION_TIMER_I, 50*2882Svi117747 SIP_XACTION_TIMER_J, 51*2882Svi117747 SIP_XACTION_TIMER_K 52*2882Svi117747 } sip_xaction_timer_type_t; 53*2882Svi117747 54*2882Svi117747 55*2882Svi117747 /* Increment transaction reference count */ 56*2882Svi117747 #define SIP_XACTION_REFCNT_INCR(trans) \ 57*2882Svi117747 (trans)->sip_xaction_ref_cnt++; 58*2882Svi117747 59*2882Svi117747 /* Decrement transaction reference count */ 60*2882Svi117747 #define SIP_XACTION_REFCNT_DECR(trans) { \ 61*2882Svi117747 (void) pthread_mutex_lock(&((trans)->sip_xaction_mutex)); \ 62*2882Svi117747 assert((trans)->sip_xaction_ref_cnt > 0); \ 63*2882Svi117747 (trans)->sip_xaction_ref_cnt--; \ 64*2882Svi117747 if ((trans)->sip_xaction_ref_cnt == 0 && \ 65*2882Svi117747 SIP_IS_XACTION_TERMINATED((trans)->sip_xaction_state)) { \ 66*2882Svi117747 (void) pthread_mutex_unlock(&((trans)->sip_xaction_mutex));\ 67*2882Svi117747 sip_xaction_delete(trans); \ 68*2882Svi117747 } else { \ 69*2882Svi117747 (void) pthread_mutex_unlock(&((trans)->sip_xaction_mutex));\ 70*2882Svi117747 } \ 71*2882Svi117747 } 72*2882Svi117747 73*2882Svi117747 /* True if transaction is in the terminated state */ 74*2882Svi117747 #define SIP_IS_XACTION_TERMINATED(trans_state) \ 75*2882Svi117747 ((trans_state) == SIP_CLNT_INV_TERMINATED || \ 76*2882Svi117747 (trans_state) == SIP_CLNT_NONINV_TERMINATED || \ 77*2882Svi117747 (trans_state) == SIP_SRV_INV_TERMINATED || \ 78*2882Svi117747 (trans_state) == SIP_SRV_NONINV_TERMINATED) 79*2882Svi117747 80*2882Svi117747 /* Transaction structure */ 81*2882Svi117747 typedef struct sip_xaction { 82*2882Svi117747 char *sip_xaction_branch_id; /* Transaction id */ 83*2882Svi117747 uint16_t sip_xaction_hash_digest[8]; 84*2882Svi117747 _sip_msg_t *sip_xaction_orig_msg; /* orig request msg. */ 85*2882Svi117747 _sip_msg_t *sip_xaction_last_msg; /* last msg sent */ 86*2882Svi117747 sip_conn_object_t sip_xaction_conn_obj; 87*2882Svi117747 int sip_xaction_state; /* Transaction State */ 88*2882Svi117747 sip_method_t sip_xaction_method; 89*2882Svi117747 uint32_t sip_xaction_ref_cnt; 90*2882Svi117747 pthread_mutex_t sip_xaction_mutex; 91*2882Svi117747 sip_timer_t sip_xaction_TA; 92*2882Svi117747 sip_timer_t sip_xaction_TB; 93*2882Svi117747 sip_timer_t sip_xaction_TD; 94*2882Svi117747 sip_timer_t sip_xaction_TE; 95*2882Svi117747 sip_timer_t sip_xaction_TF; 96*2882Svi117747 sip_timer_t sip_xaction_TG; 97*2882Svi117747 sip_timer_t sip_xaction_TH; 98*2882Svi117747 sip_timer_t sip_xaction_TI; 99*2882Svi117747 sip_timer_t sip_xaction_TJ; 100*2882Svi117747 sip_timer_t sip_xaction_TK; 101*2882Svi117747 void *sip_xaction_ctxt; /* currently unused */ 102*2882Svi117747 } sip_xaction_t; 103*2882Svi117747 104*2882Svi117747 extern void sip_xaction_init(int (*ulp_trans_err)(sip_transaction_t, 105*2882Svi117747 int, void *), void (*ulp_state_cb) 106*2882Svi117747 (sip_transaction_t, sip_msg_t, int, int)); 107*2882Svi117747 extern int sip_xaction_output(sip_conn_object_t, sip_xaction_t *, 108*2882Svi117747 _sip_msg_t *); 109*2882Svi117747 extern int sip_xaction_input(sip_conn_object_t, sip_xaction_t *, 110*2882Svi117747 _sip_msg_t **); 111*2882Svi117747 extern sip_xaction_t *sip_xaction_get(sip_conn_object_t, sip_msg_t, 112*2882Svi117747 boolean_t, int, int *); 113*2882Svi117747 extern void sip_xaction_delete(sip_xaction_t *); 114*2882Svi117747 extern char *sip_get_xaction_state(int); 115*2882Svi117747 extern int (*sip_xaction_ulp_trans_err)(sip_transaction_t, int, 116*2882Svi117747 void *); 117*2882Svi117747 extern void (*sip_xaction_ulp_state_cb)(sip_transaction_t, 118*2882Svi117747 sip_msg_t, int, int); 119*2882Svi117747 extern void sip_del_conn_obj_cache(sip_conn_object_t, void *); 120*2882Svi117747 extern int sip_add_conn_obj_cache(sip_conn_object_t, void *); 121*2882Svi117747 extern void sip_xaction_terminate(sip_xaction_t *, _sip_msg_t *, 122*2882Svi117747 int); 123*2882Svi117747 #ifdef __cplusplus 124*2882Svi117747 } 125*2882Svi117747 #endif 126*2882Svi117747 127*2882Svi117747 #endif /* _SIP_XACTION_H */ 128