1*40cb5e5dSvi /* 2*40cb5e5dSvi * CDDL HEADER START 3*40cb5e5dSvi * 4*40cb5e5dSvi * The contents of this file are subject to the terms of the 5*40cb5e5dSvi * Common Development and Distribution License (the "License"). 6*40cb5e5dSvi * You may not use this file except in compliance with the License. 7*40cb5e5dSvi * 8*40cb5e5dSvi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*40cb5e5dSvi * or http://www.opensolaris.org/os/licensing. 10*40cb5e5dSvi * See the License for the specific language governing permissions 11*40cb5e5dSvi * and limitations under the License. 12*40cb5e5dSvi * 13*40cb5e5dSvi * When distributing Covered Code, include this CDDL HEADER in each 14*40cb5e5dSvi * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*40cb5e5dSvi * If applicable, add the following below this CDDL HEADER, with the 16*40cb5e5dSvi * fields enclosed by brackets "[]" replaced with your own identifying 17*40cb5e5dSvi * information: Portions Copyright [yyyy] [name of copyright owner] 18*40cb5e5dSvi * 19*40cb5e5dSvi * CDDL HEADER END 20*40cb5e5dSvi */ 21*40cb5e5dSvi 22*40cb5e5dSvi /* 23*40cb5e5dSvi * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*40cb5e5dSvi * Use is subject to license terms. 25*40cb5e5dSvi */ 26*40cb5e5dSvi 27*40cb5e5dSvi #ifndef _SIP_MISCDEFS_H 28*40cb5e5dSvi #define _SIP_MISCDEFS_H 29*40cb5e5dSvi 30*40cb5e5dSvi #pragma ident "%Z%%M% %I% %E% SMI" 31*40cb5e5dSvi 32*40cb5e5dSvi #ifdef __cplusplus 33*40cb5e5dSvi extern "C" { 34*40cb5e5dSvi #endif 35*40cb5e5dSvi 36*40cb5e5dSvi #include <sys/types.h> 37*40cb5e5dSvi #include <sip.h> 38*40cb5e5dSvi 39*40cb5e5dSvi #define SIP_CR '\r' 40*40cb5e5dSvi #define SIP_SP ' ' 41*40cb5e5dSvi #define SIP_HCOLON ':' 42*40cb5e5dSvi #define SIP_SEMI ';' 43*40cb5e5dSvi #define SIP_COMMA ',' 44*40cb5e5dSvi #define SIP_LAQUOT '<' 45*40cb5e5dSvi #define SIP_RAQUOT '>' 46*40cb5e5dSvi #define SIP_QUOTE '"' 47*40cb5e5dSvi #define SIP_EQUAL '=' 48*40cb5e5dSvi #define SIP_SLASH '/' 49*40cb5e5dSvi #define SIP_PERIOD '.' 50*40cb5e5dSvi #define SIP_LPAR '(' 51*40cb5e5dSvi #define SIP_RPAR ')' 52*40cb5e5dSvi 53*40cb5e5dSvi #define SIP_BRANCHID_LEN 28 /* incl. the magic cookie */ 54*40cb5e5dSvi #define SIP_TAG_LEN 20 55*40cb5e5dSvi #define SIP_URI_LEN 25 56*40cb5e5dSvi #define SIP_DISPLAY_LEN 25 57*40cb5e5dSvi #define SIP_DOMAIN_LEN 25 58*40cb5e5dSvi #define SIP_MAX_FWDLEN 5 59*40cb5e5dSvi #define SIP_TRANSPORT_LEN 5 60*40cb5e5dSvi #define SIP_SIZE_OF_STATUS_CODE 3 61*40cb5e5dSvi #define SIP_SPACE_LEN sizeof (char) 62*40cb5e5dSvi 63*40cb5e5dSvi #define SIP_MS 1L 64*40cb5e5dSvi #define SIP_SECONDS (1000 * SIP_MS) 65*40cb5e5dSvi #define SIP_MINUTES (60 * SIP_SECONDS) 66*40cb5e5dSvi #define SIP_HOURS (60 * SIP_MINUTES) 67*40cb5e5dSvi 68*40cb5e5dSvi /* timer granularity is in msecs */ 69*40cb5e5dSvi #define SIP_TIMER_T1 (1 * SIP_SECONDS) 70*40cb5e5dSvi #define SIP_TIMER_T2 (4 * SIP_SECONDS) 71*40cb5e5dSvi #define SIP_TIMER_T4 (5 * SIP_SECONDS) 72*40cb5e5dSvi 73*40cb5e5dSvi #ifdef __linux__ 74*40cb5e5dSvi #define SEC 1 75*40cb5e5dSvi #define MILLISEC 1000 76*40cb5e5dSvi #define MICROSEC 1000000 77*40cb5e5dSvi #define NANOSEC 1000000000 78*40cb5e5dSvi 79*40cb5e5dSvi typedef struct timespec timestruc_t; 80*40cb5e5dSvi typedef long long hrtime_t; 81*40cb5e5dSvi #endif 82*40cb5e5dSvi 83*40cb5e5dSvi extern int sip_timer_T1; 84*40cb5e5dSvi extern int sip_timer_T2; 85*40cb5e5dSvi extern int sip_timer_T4; 86*40cb5e5dSvi extern int sip_timer_TD; 87*40cb5e5dSvi 88*40cb5e5dSvi /* Structure for SIP timers */ 89*40cb5e5dSvi typedef struct sip_timer_s { 90*40cb5e5dSvi uint_t sip_timerid; 91*40cb5e5dSvi struct timeval sip_timeout_val; 92*40cb5e5dSvi }sip_timer_t; 93*40cb5e5dSvi 94*40cb5e5dSvi /* time is in msec */ 95*40cb5e5dSvi #define SIP_SET_TIMEOUT(timer, time) { \ 96*40cb5e5dSvi int mtime = (time); \ 97*40cb5e5dSvi \ 98*40cb5e5dSvi (timer).sip_timeout_val.tv_sec = mtime / MILLISEC; \ 99*40cb5e5dSvi mtime -= (timer).sip_timeout_val.tv_sec * MILLISEC; \ 100*40cb5e5dSvi (timer).sip_timeout_val.tv_usec = mtime * MILLISEC; \ 101*40cb5e5dSvi } 102*40cb5e5dSvi 103*40cb5e5dSvi /* time is in msec */ 104*40cb5e5dSvi #define SIP_INIT_TIMER(timer, time) { \ 105*40cb5e5dSvi SIP_SET_TIMEOUT(timer, time); \ 106*40cb5e5dSvi (timer).sip_timerid = 0; \ 107*40cb5e5dSvi } 108*40cb5e5dSvi 109*40cb5e5dSvi #define SIP_SCHED_TIMER(timer, obj, func) { \ 110*40cb5e5dSvi (timer).sip_timerid = sip_stack_timeout((void *)(obj), \ 111*40cb5e5dSvi (func), &((timer).sip_timeout_val)); \ 112*40cb5e5dSvi } 113*40cb5e5dSvi 114*40cb5e5dSvi #define SIP_CANCEL_TIMER(timer) { \ 115*40cb5e5dSvi if ((timer).sip_timerid != 0) { \ 116*40cb5e5dSvi sip_stack_untimeout((timer).sip_timerid); \ 117*40cb5e5dSvi (timer).sip_timerid = 0; \ 118*40cb5e5dSvi } \ 119*40cb5e5dSvi } 120*40cb5e5dSvi 121*40cb5e5dSvi /* returned time is in msec */ 122*40cb5e5dSvi #define SIP_GET_TIMEOUT(timer) \ 123*40cb5e5dSvi ((timer).sip_timeout_val.tv_sec * MILLISEC + \ 124*40cb5e5dSvi (timer).sip_timeout_val.tv_usec / MILLISEC) 125*40cb5e5dSvi 126*40cb5e5dSvi #define SIP_IS_TIMER_RUNNING(timer) ((timer).sip_timerid != 0) 127*40cb5e5dSvi 128*40cb5e5dSvi /* This is the transaction list */ 129*40cb5e5dSvi typedef struct sip_conn_cache_s { 130*40cb5e5dSvi void *obj; 131*40cb5e5dSvi struct sip_conn_cache_s *next; 132*40cb5e5dSvi struct sip_conn_cache_s *prev; 133*40cb5e5dSvi } sip_conn_cache_t; 134*40cb5e5dSvi 135*40cb5e5dSvi /* TCP fragment entry */ 136*40cb5e5dSvi typedef struct sip_reass_entry_s { 137*40cb5e5dSvi char *sip_reass_msg; 138*40cb5e5dSvi int sip_reass_msglen; 139*40cb5e5dSvi }sip_reass_entry_t; 140*40cb5e5dSvi 141*40cb5e5dSvi /* Library data in stored in connection object */ 142*40cb5e5dSvi typedef struct sip_conn_obj_pvt_s { 143*40cb5e5dSvi sip_reass_entry_t *sip_conn_obj_reass; 144*40cb5e5dSvi pthread_mutex_t sip_conn_obj_reass_lock; 145*40cb5e5dSvi sip_conn_cache_t *sip_conn_obj_cache; 146*40cb5e5dSvi pthread_mutex_t sip_conn_obj_cache_lock; 147*40cb5e5dSvi } sip_conn_obj_pvt_t; 148*40cb5e5dSvi 149*40cb5e5dSvi extern boolean_t sip_manage_dialog; 150*40cb5e5dSvi 151*40cb5e5dSvi /* To salt the hash function */ 152*40cb5e5dSvi extern uint64_t sip_hash_salt; 153*40cb5e5dSvi 154*40cb5e5dSvi extern void sip_timeout_init(); 155*40cb5e5dSvi extern uint_t sip_timeout(void *, void (*)(void *), struct timeval *); 156*40cb5e5dSvi extern boolean_t sip_untimeout(uint_t); 157*40cb5e5dSvi extern void sip_md5_hash(char *, int, char *, int, char *, int, 158*40cb5e5dSvi char *, int, char *, int, char *, int, uchar_t *); 159*40cb5e5dSvi 160*40cb5e5dSvi #ifdef __cplusplus 161*40cb5e5dSvi } 162*40cb5e5dSvi #endif 163*40cb5e5dSvi 164*40cb5e5dSvi #endif /* _SIP_MISCDEFS_H */ 165