140cb5e5dSvi117747 /* 240cb5e5dSvi117747 * CDDL HEADER START 340cb5e5dSvi117747 * 440cb5e5dSvi117747 * The contents of this file are subject to the terms of the 540cb5e5dSvi117747 * Common Development and Distribution License (the "License"). 640cb5e5dSvi117747 * You may not use this file except in compliance with the License. 740cb5e5dSvi117747 * 840cb5e5dSvi117747 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 940cb5e5dSvi117747 * or http://www.opensolaris.org/os/licensing. 1040cb5e5dSvi117747 * See the License for the specific language governing permissions 1140cb5e5dSvi117747 * and limitations under the License. 1240cb5e5dSvi117747 * 1340cb5e5dSvi117747 * When distributing Covered Code, include this CDDL HEADER in each 1440cb5e5dSvi117747 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1540cb5e5dSvi117747 * If applicable, add the following below this CDDL HEADER, with the 1640cb5e5dSvi117747 * fields enclosed by brackets "[]" replaced with your own identifying 1740cb5e5dSvi117747 * information: Portions Copyright [yyyy] [name of copyright owner] 1840cb5e5dSvi117747 * 1940cb5e5dSvi117747 * CDDL HEADER END 2040cb5e5dSvi117747 */ 2140cb5e5dSvi117747 2240cb5e5dSvi117747 /* 23*943efbc3Sgm209912 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 2440cb5e5dSvi117747 * Use is subject to license terms. 2540cb5e5dSvi117747 */ 2640cb5e5dSvi117747 2740cb5e5dSvi117747 #ifndef _SIP_XACTION_H 2840cb5e5dSvi117747 #define _SIP_XACTION_H 2940cb5e5dSvi117747 3040cb5e5dSvi117747 #pragma ident "%Z%%M% %I% %E% SMI" 3140cb5e5dSvi117747 3240cb5e5dSvi117747 #ifdef __cplusplus 3340cb5e5dSvi117747 extern "C" { 3440cb5e5dSvi117747 #endif 3540cb5e5dSvi117747 362c2c4183Svi117747 #include <pthread.h> 372c2c4183Svi117747 #include <sip.h> 382c2c4183Svi117747 #include <sys/types.h> 392c2c4183Svi117747 402c2c4183Svi117747 #include "sip_msg.h" 412c2c4183Svi117747 #include "sip_miscdefs.h" 4240cb5e5dSvi117747 4340cb5e5dSvi117747 /* Various transaction timers */ 4440cb5e5dSvi117747 typedef enum sip_timer_type_s { 4540cb5e5dSvi117747 SIP_XACTION_TIMER_A = 0, 4640cb5e5dSvi117747 SIP_XACTION_TIMER_B, 4740cb5e5dSvi117747 SIP_XACTION_TIMER_D, 4840cb5e5dSvi117747 SIP_XACTION_TIMER_E, 4940cb5e5dSvi117747 SIP_XACTION_TIMER_F, 5040cb5e5dSvi117747 SIP_XACTION_TIMER_G, 5140cb5e5dSvi117747 SIP_XACTION_TIMER_H, 5240cb5e5dSvi117747 SIP_XACTION_TIMER_I, 5340cb5e5dSvi117747 SIP_XACTION_TIMER_J, 5440cb5e5dSvi117747 SIP_XACTION_TIMER_K 5540cb5e5dSvi117747 } sip_xaction_timer_type_t; 5640cb5e5dSvi117747 5740cb5e5dSvi117747 5840cb5e5dSvi117747 /* Increment transaction reference count */ 5940cb5e5dSvi117747 #define SIP_XACTION_REFCNT_INCR(trans) \ 6040cb5e5dSvi117747 (trans)->sip_xaction_ref_cnt++; 6140cb5e5dSvi117747 6240cb5e5dSvi117747 /* Decrement transaction reference count */ 6340cb5e5dSvi117747 #define SIP_XACTION_REFCNT_DECR(trans) { \ 6440cb5e5dSvi117747 (void) pthread_mutex_lock(&((trans)->sip_xaction_mutex)); \ 6540cb5e5dSvi117747 assert((trans)->sip_xaction_ref_cnt > 0); \ 6640cb5e5dSvi117747 (trans)->sip_xaction_ref_cnt--; \ 6740cb5e5dSvi117747 if ((trans)->sip_xaction_ref_cnt == 0 && \ 6840cb5e5dSvi117747 SIP_IS_XACTION_TERMINATED((trans)->sip_xaction_state)) { \ 6940cb5e5dSvi117747 (void) pthread_mutex_unlock(&((trans)->sip_xaction_mutex));\ 7040cb5e5dSvi117747 sip_xaction_delete(trans); \ 7140cb5e5dSvi117747 } else { \ 7240cb5e5dSvi117747 (void) pthread_mutex_unlock(&((trans)->sip_xaction_mutex));\ 7340cb5e5dSvi117747 } \ 7440cb5e5dSvi117747 } 7540cb5e5dSvi117747 7640cb5e5dSvi117747 /* True if transaction is in the terminated state */ 7740cb5e5dSvi117747 #define SIP_IS_XACTION_TERMINATED(trans_state) \ 7840cb5e5dSvi117747 ((trans_state) == SIP_CLNT_INV_TERMINATED || \ 7940cb5e5dSvi117747 (trans_state) == SIP_CLNT_NONINV_TERMINATED || \ 8040cb5e5dSvi117747 (trans_state) == SIP_SRV_INV_TERMINATED || \ 8140cb5e5dSvi117747 (trans_state) == SIP_SRV_NONINV_TERMINATED) 8240cb5e5dSvi117747 8340cb5e5dSvi117747 /* Transaction structure */ 8440cb5e5dSvi117747 typedef struct sip_xaction { 8540cb5e5dSvi117747 char *sip_xaction_branch_id; /* Transaction id */ 8640cb5e5dSvi117747 uint16_t sip_xaction_hash_digest[8]; 8740cb5e5dSvi117747 _sip_msg_t *sip_xaction_orig_msg; /* orig request msg. */ 8840cb5e5dSvi117747 _sip_msg_t *sip_xaction_last_msg; /* last msg sent */ 8940cb5e5dSvi117747 sip_conn_object_t sip_xaction_conn_obj; 9040cb5e5dSvi117747 int sip_xaction_state; /* Transaction State */ 9140cb5e5dSvi117747 sip_method_t sip_xaction_method; 9240cb5e5dSvi117747 uint32_t sip_xaction_ref_cnt; 9340cb5e5dSvi117747 pthread_mutex_t sip_xaction_mutex; 9440cb5e5dSvi117747 sip_timer_t sip_xaction_TA; 9540cb5e5dSvi117747 sip_timer_t sip_xaction_TB; 9640cb5e5dSvi117747 sip_timer_t sip_xaction_TD; 9740cb5e5dSvi117747 sip_timer_t sip_xaction_TE; 9840cb5e5dSvi117747 sip_timer_t sip_xaction_TF; 9940cb5e5dSvi117747 sip_timer_t sip_xaction_TG; 10040cb5e5dSvi117747 sip_timer_t sip_xaction_TH; 10140cb5e5dSvi117747 sip_timer_t sip_xaction_TI; 10240cb5e5dSvi117747 sip_timer_t sip_xaction_TJ; 10340cb5e5dSvi117747 sip_timer_t sip_xaction_TK; 10440cb5e5dSvi117747 void *sip_xaction_ctxt; /* currently unused */ 105*943efbc3Sgm209912 int sip_xaction_msgcnt; 106*943efbc3Sgm209912 sip_log_t sip_xaction_log[SIP_SRV_NONINV_TERMINATED + 1]; 10740cb5e5dSvi117747 } sip_xaction_t; 10840cb5e5dSvi117747 10940cb5e5dSvi117747 extern void sip_xaction_init(int (*ulp_trans_err)(sip_transaction_t, 11040cb5e5dSvi117747 int, void *), void (*ulp_state_cb) 11140cb5e5dSvi117747 (sip_transaction_t, sip_msg_t, int, int)); 11240cb5e5dSvi117747 extern int sip_xaction_output(sip_conn_object_t, sip_xaction_t *, 11340cb5e5dSvi117747 _sip_msg_t *); 11440cb5e5dSvi117747 extern int sip_xaction_input(sip_conn_object_t, sip_xaction_t *, 11540cb5e5dSvi117747 _sip_msg_t **); 11640cb5e5dSvi117747 extern sip_xaction_t *sip_xaction_get(sip_conn_object_t, sip_msg_t, 11740cb5e5dSvi117747 boolean_t, int, int *); 11840cb5e5dSvi117747 extern void sip_xaction_delete(sip_xaction_t *); 11940cb5e5dSvi117747 extern char *sip_get_xaction_state(int); 12040cb5e5dSvi117747 extern int (*sip_xaction_ulp_trans_err)(sip_transaction_t, int, 12140cb5e5dSvi117747 void *); 12240cb5e5dSvi117747 extern void (*sip_xaction_ulp_state_cb)(sip_transaction_t, 12340cb5e5dSvi117747 sip_msg_t, int, int); 12440cb5e5dSvi117747 extern void sip_del_conn_obj_cache(sip_conn_object_t, void *); 12540cb5e5dSvi117747 extern int sip_add_conn_obj_cache(sip_conn_object_t, void *); 12640cb5e5dSvi117747 extern void sip_xaction_terminate(sip_xaction_t *, _sip_msg_t *, 12740cb5e5dSvi117747 int); 12840cb5e5dSvi117747 #ifdef __cplusplus 12940cb5e5dSvi117747 } 13040cb5e5dSvi117747 #endif 13140cb5e5dSvi117747 13240cb5e5dSvi117747 #endif /* _SIP_XACTION_H */ 133