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_MISCDEFS_H 28*2882Svi117747 #define _SIP_MISCDEFS_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 <sys/types.h> 37*2882Svi117747 #include <sip.h> 38*2882Svi117747 39*2882Svi117747 #define SIP_CR '\r' 40*2882Svi117747 #define SIP_SP ' ' 41*2882Svi117747 #define SIP_HCOLON ':' 42*2882Svi117747 #define SIP_SEMI ';' 43*2882Svi117747 #define SIP_COMMA ',' 44*2882Svi117747 #define SIP_LAQUOT '<' 45*2882Svi117747 #define SIP_RAQUOT '>' 46*2882Svi117747 #define SIP_QUOTE '"' 47*2882Svi117747 #define SIP_EQUAL '=' 48*2882Svi117747 #define SIP_SLASH '/' 49*2882Svi117747 #define SIP_PERIOD '.' 50*2882Svi117747 #define SIP_LPAR '(' 51*2882Svi117747 #define SIP_RPAR ')' 52*2882Svi117747 53*2882Svi117747 #define SIP_BRANCHID_LEN 28 /* incl. the magic cookie */ 54*2882Svi117747 #define SIP_TAG_LEN 20 55*2882Svi117747 #define SIP_URI_LEN 25 56*2882Svi117747 #define SIP_DISPLAY_LEN 25 57*2882Svi117747 #define SIP_DOMAIN_LEN 25 58*2882Svi117747 #define SIP_MAX_FWDLEN 5 59*2882Svi117747 #define SIP_TRANSPORT_LEN 5 60*2882Svi117747 #define SIP_SIZE_OF_STATUS_CODE 3 61*2882Svi117747 #define SIP_SPACE_LEN sizeof (char) 62*2882Svi117747 63*2882Svi117747 #define SIP_MS 1L 64*2882Svi117747 #define SIP_SECONDS (1000 * SIP_MS) 65*2882Svi117747 #define SIP_MINUTES (60 * SIP_SECONDS) 66*2882Svi117747 #define SIP_HOURS (60 * SIP_MINUTES) 67*2882Svi117747 68*2882Svi117747 /* timer granularity is in msecs */ 69*2882Svi117747 #define SIP_TIMER_T1 (1 * SIP_SECONDS) 70*2882Svi117747 #define SIP_TIMER_T2 (4 * SIP_SECONDS) 71*2882Svi117747 #define SIP_TIMER_T4 (5 * SIP_SECONDS) 72*2882Svi117747 73*2882Svi117747 #ifdef __linux__ 74*2882Svi117747 #define SEC 1 75*2882Svi117747 #define MILLISEC 1000 76*2882Svi117747 #define MICROSEC 1000000 77*2882Svi117747 #define NANOSEC 1000000000 78*2882Svi117747 79*2882Svi117747 typedef struct timespec timestruc_t; 80*2882Svi117747 typedef long long hrtime_t; 81*2882Svi117747 #endif 82*2882Svi117747 83*2882Svi117747 extern int sip_timer_T1; 84*2882Svi117747 extern int sip_timer_T2; 85*2882Svi117747 extern int sip_timer_T4; 86*2882Svi117747 extern int sip_timer_TD; 87*2882Svi117747 88*2882Svi117747 /* Structure for SIP timers */ 89*2882Svi117747 typedef struct sip_timer_s { 90*2882Svi117747 uint_t sip_timerid; 91*2882Svi117747 struct timeval sip_timeout_val; 92*2882Svi117747 }sip_timer_t; 93*2882Svi117747 94*2882Svi117747 /* time is in msec */ 95*2882Svi117747 #define SIP_SET_TIMEOUT(timer, time) { \ 96*2882Svi117747 int mtime = (time); \ 97*2882Svi117747 \ 98*2882Svi117747 (timer).sip_timeout_val.tv_sec = mtime / MILLISEC; \ 99*2882Svi117747 mtime -= (timer).sip_timeout_val.tv_sec * MILLISEC; \ 100*2882Svi117747 (timer).sip_timeout_val.tv_usec = mtime * MILLISEC; \ 101*2882Svi117747 } 102*2882Svi117747 103*2882Svi117747 /* time is in msec */ 104*2882Svi117747 #define SIP_INIT_TIMER(timer, time) { \ 105*2882Svi117747 SIP_SET_TIMEOUT(timer, time); \ 106*2882Svi117747 (timer).sip_timerid = 0; \ 107*2882Svi117747 } 108*2882Svi117747 109*2882Svi117747 #define SIP_SCHED_TIMER(timer, obj, func) { \ 110*2882Svi117747 (timer).sip_timerid = sip_stack_timeout((void *)(obj), \ 111*2882Svi117747 (func), &((timer).sip_timeout_val)); \ 112*2882Svi117747 } 113*2882Svi117747 114*2882Svi117747 #define SIP_CANCEL_TIMER(timer) { \ 115*2882Svi117747 if ((timer).sip_timerid != 0) { \ 116*2882Svi117747 sip_stack_untimeout((timer).sip_timerid); \ 117*2882Svi117747 (timer).sip_timerid = 0; \ 118*2882Svi117747 } \ 119*2882Svi117747 } 120*2882Svi117747 121*2882Svi117747 /* returned time is in msec */ 122*2882Svi117747 #define SIP_GET_TIMEOUT(timer) \ 123*2882Svi117747 ((timer).sip_timeout_val.tv_sec * MILLISEC + \ 124*2882Svi117747 (timer).sip_timeout_val.tv_usec / MILLISEC) 125*2882Svi117747 126*2882Svi117747 #define SIP_IS_TIMER_RUNNING(timer) ((timer).sip_timerid != 0) 127*2882Svi117747 128*2882Svi117747 /* This is the transaction list */ 129*2882Svi117747 typedef struct sip_conn_cache_s { 130*2882Svi117747 void *obj; 131*2882Svi117747 struct sip_conn_cache_s *next; 132*2882Svi117747 struct sip_conn_cache_s *prev; 133*2882Svi117747 } sip_conn_cache_t; 134*2882Svi117747 135*2882Svi117747 /* TCP fragment entry */ 136*2882Svi117747 typedef struct sip_reass_entry_s { 137*2882Svi117747 char *sip_reass_msg; 138*2882Svi117747 int sip_reass_msglen; 139*2882Svi117747 }sip_reass_entry_t; 140*2882Svi117747 141*2882Svi117747 /* Library data in stored in connection object */ 142*2882Svi117747 typedef struct sip_conn_obj_pvt_s { 143*2882Svi117747 sip_reass_entry_t *sip_conn_obj_reass; 144*2882Svi117747 pthread_mutex_t sip_conn_obj_reass_lock; 145*2882Svi117747 sip_conn_cache_t *sip_conn_obj_cache; 146*2882Svi117747 pthread_mutex_t sip_conn_obj_cache_lock; 147*2882Svi117747 } sip_conn_obj_pvt_t; 148*2882Svi117747 149*2882Svi117747 extern boolean_t sip_manage_dialog; 150*2882Svi117747 151*2882Svi117747 /* To salt the hash function */ 152*2882Svi117747 extern uint64_t sip_hash_salt; 153*2882Svi117747 154*2882Svi117747 extern void sip_timeout_init(); 155*2882Svi117747 extern uint_t sip_timeout(void *, void (*)(void *), struct timeval *); 156*2882Svi117747 extern boolean_t sip_untimeout(uint_t); 157*2882Svi117747 extern void sip_md5_hash(char *, int, char *, int, char *, int, 158*2882Svi117747 char *, int, char *, int, char *, int, uchar_t *); 159*2882Svi117747 160*2882Svi117747 #ifdef __cplusplus 161*2882Svi117747 } 162*2882Svi117747 #endif 163*2882Svi117747 164*2882Svi117747 #endif /* _SIP_MISCDEFS_H */ 165