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