4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SIP_MISCDEFS_H
28 #define _SIP_MISCDEFS_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
37 #include <sys/types.h>
43 #define SIP_HCOLON ':'
46 #define SIP_LAQUOT '<'
47 #define SIP_RAQUOT '>'
51 #define SIP_PERIOD '.'
55 #define SIP_BRANCHID_LEN 28 /* incl. the magic cookie */
56 #define SIP_TAG_LEN 20
57 #define SIP_URI_LEN 25
58 #define SIP_DISPLAY_LEN 25
59 #define SIP_DOMAIN_LEN 25
60 #define SIP_MAX_FWDLEN 5
61 #define SIP_TRANSPORT_LEN 5
62 #define SIP_SIZE_OF_STATUS_CODE 3
63 #define SIP_SPACE_LEN sizeof (char)
65 #define SIP_TRANSACTION_LOG 0x0001
66 #define SIP_DIALOG_LOG 0x0002
67 #define SIP_ASSERT_ERROR 0x0004
70 #define SIP_SECONDS (1000 * SIP_MS)
71 #define SIP_MINUTES (60 * SIP_SECONDS)
72 #define SIP_HOURS (60 * SIP_MINUTES)
74 /* timer granularity is in msecs */
75 #define SIP_TIMER_T1 (1 * SIP_SECONDS)
76 #define SIP_TIMER_T2 (4 * SIP_SECONDS)
77 #define SIP_TIMER_T4 (5 * SIP_SECONDS)
82 #define MICROSEC 1000000
83 #define NANOSEC 1000000000
85 typedef struct timespec timestruc_t
;
86 typedef long long hrtime_t
;
89 extern int sip_timer_T1
;
90 extern int sip_timer_T2
;
91 extern int sip_timer_T4
;
92 extern int sip_timer_TD
;
94 /* Structure for SIP timers */
95 typedef struct sip_timer_s
{
97 struct timeval sip_timeout_val
;
100 /* time is in msec */
101 #define SIP_SET_TIMEOUT(timer, time) { \
102 int mtime = (time); \
104 (timer).sip_timeout_val.tv_sec = mtime / MILLISEC; \
105 mtime -= (timer).sip_timeout_val.tv_sec * MILLISEC; \
106 (timer).sip_timeout_val.tv_usec = mtime * MILLISEC; \
109 /* time is in msec */
110 #define SIP_INIT_TIMER(timer, time) { \
111 SIP_SET_TIMEOUT(timer, time); \
112 (timer).sip_timerid = 0; \
115 #define SIP_SCHED_TIMER(timer, obj, func) { \
116 (timer).sip_timerid = sip_stack_timeout((void *)(obj), \
117 (func), &((timer).sip_timeout_val)); \
120 #define SIP_CANCEL_TIMER(timer) { \
121 if ((timer).sip_timerid != 0) { \
122 sip_stack_untimeout((timer).sip_timerid); \
123 (timer).sip_timerid = 0; \
127 /* returned time is in msec */
128 #define SIP_GET_TIMEOUT(timer) \
129 ((timer).sip_timeout_val.tv_sec * MILLISEC + \
130 (timer).sip_timeout_val.tv_usec / MILLISEC)
132 #define SIP_IS_TIMER_RUNNING(timer) ((timer).sip_timerid != 0)
134 #define SIP_UPDATE_COUNTERS(is_request, method, resp_code, outbound, size) { \
135 (void) pthread_mutex_lock(&sip_counters.sip_counter_mutex); \
136 if (sip_counters.enabled) { \
137 (void) sip_measure_traffic((is_request), (method), (resp_code),\
138 (outbound), (size)); \
140 (void) pthread_mutex_unlock(&sip_counters.sip_counter_mutex); \
143 /* This is the transaction list */
144 typedef struct sip_conn_cache_s
{
146 struct sip_conn_cache_s
*next
;
147 struct sip_conn_cache_s
*prev
;
150 /* TCP fragment entry */
151 typedef struct sip_reass_entry_s
{
153 int sip_reass_msglen
;
156 /* Library data in stored in connection object */
157 typedef struct sip_conn_obj_pvt_s
{
158 sip_reass_entry_t
*sip_conn_obj_reass
;
159 pthread_mutex_t sip_conn_obj_reass_lock
;
160 sip_conn_cache_t
*sip_conn_obj_cache
;
161 pthread_mutex_t sip_conn_obj_cache_lock
;
162 } sip_conn_obj_pvt_t
;
164 /* SIP traffic counters structure */
166 typedef struct sip_traffic_counters_s
{
170 uint64_t sip_total_bytes_rcvd
;
171 uint64_t sip_total_bytes_sent
;
172 uint64_t sip_total_req_rcvd
;
173 uint64_t sip_total_req_sent
;
174 uint64_t sip_total_resp_rcvd
;
175 uint64_t sip_total_resp_sent
;
176 uint64_t sip_ack_req_rcvd
;
177 uint64_t sip_ack_req_sent
;
178 uint64_t sip_bye_req_rcvd
;
179 uint64_t sip_bye_req_sent
;
180 uint64_t sip_cancel_req_rcvd
;
181 uint64_t sip_cancel_req_sent
;
182 uint64_t sip_info_req_rcvd
;
183 uint64_t sip_info_req_sent
;
184 uint64_t sip_invite_req_rcvd
;
185 uint64_t sip_invite_req_sent
;
186 uint64_t sip_notify_req_rcvd
;
187 uint64_t sip_notify_req_sent
;
188 uint64_t sip_options_req_rcvd
;
189 uint64_t sip_options_req_sent
;
190 uint64_t sip_prack_req_rcvd
;
191 uint64_t sip_prack_req_sent
;
192 uint64_t sip_refer_req_rcvd
;
193 uint64_t sip_refer_req_sent
;
194 uint64_t sip_register_req_rcvd
;
195 uint64_t sip_register_req_sent
;
196 uint64_t sip_subscribe_req_rcvd
;
197 uint64_t sip_subscribe_req_sent
;
198 uint64_t sip_update_req_rcvd
;
199 uint64_t sip_update_req_sent
;
200 uint64_t sip_1xx_resp_rcvd
;
201 uint64_t sip_1xx_resp_sent
;
202 uint64_t sip_2xx_resp_rcvd
;
203 uint64_t sip_2xx_resp_sent
;
204 uint64_t sip_3xx_resp_rcvd
;
205 uint64_t sip_3xx_resp_sent
;
206 uint64_t sip_4xx_resp_rcvd
;
207 uint64_t sip_4xx_resp_sent
;
208 uint64_t sip_5xx_resp_rcvd
;
209 uint64_t sip_5xx_resp_sent
;
210 uint64_t sip_6xx_resp_rcvd
;
211 uint64_t sip_6xx_resp_sent
;
212 pthread_mutex_t sip_counter_mutex
; /* Mutex should be always at end */
213 } sip_traffic_counters_t
;
215 /* SIP logfile structure */
216 typedef struct sip_logfile_s
{
217 boolean_t sip_logging_enabled
;
219 pthread_mutex_t sip_logfile_mutex
;
222 typedef struct sip_msg_chain_s
{
225 time_t msg_timestamp
;
226 struct sip_msg_chain_s
*next
;
229 typedef struct sip_log_s
{
230 sip_msg_chain_t
*sip_msgs
;
234 extern sip_traffic_counters_t sip_counters
;
236 extern sip_logfile_t trans_log
;
237 extern sip_logfile_t dialog_log
;
239 extern boolean_t sip_manage_dialog
;
241 /* To salt the hash function */
242 extern uint64_t sip_hash_salt
;
244 extern void sip_timeout_init();
245 extern uint_t
sip_timeout(void *, void (*)(void *), struct timeval
*);
246 extern boolean_t
sip_untimeout(uint_t
);
247 extern void sip_md5_hash(char *, int, char *, int, char *, int,
248 char *, int, char *, int, char *, int, uchar_t
*);
249 extern void sip_measure_traffic(boolean_t
, sip_method_t
, int,
251 extern void sip_add_log(sip_log_t
*, sip_msg_t
, int, int);
252 extern void sip_write_to_log(void *, int, char *, int);
258 #endif /* _SIP_MISCDEFS_H */