- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,306 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
3 |
- * |
|
4 |
- * This file is part of Kamailio, a free SIP server. |
|
5 |
- * |
|
6 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
7 |
- * it under the terms of the GNU General Public License as published by |
|
8 |
- * the Free Software Foundation; either version 2 of the License, or |
|
9 |
- * (at your option) any later version |
|
10 |
- * |
|
11 |
- * Kamailio is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
- * GNU General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- */ |
|
20 |
- |
|
21 |
-/*! |
|
22 |
- * \file |
|
23 |
- * \brief Kamailio core :: Definitions for Pseudo-variable support |
|
24 |
- */ |
|
25 |
- |
|
26 |
- |
|
27 |
-#ifndef _PVAR_H_ |
|
28 |
-#define _PVAR_H_ |
|
29 |
- |
|
30 |
-#include "str.h" |
|
31 |
-#include "usr_avp.h" |
|
32 |
-#include "parser/msg_parser.h" |
|
33 |
- |
|
34 |
-#define PV_MARKER_STR "$" |
|
35 |
-#define PV_MARKER '$' |
|
36 |
- |
|
37 |
-#define PV_LNBRACKET_STR "(" |
|
38 |
-#define PV_LNBRACKET '(' |
|
39 |
-#define PV_RNBRACKET_STR ")" |
|
40 |
-#define PV_RNBRACKET ')' |
|
41 |
- |
|
42 |
-#define PV_LIBRACKET_STR "[" |
|
43 |
-#define PV_LIBRACKET '[' |
|
44 |
-#define PV_RIBRACKET_STR "]" |
|
45 |
-#define PV_RIBRACKET ']' |
|
46 |
- |
|
47 |
-#define PV_VAL_NONE 0 |
|
48 |
-#define PV_VAL_NULL 1 |
|
49 |
-#define PV_VAL_EMPTY 2 |
|
50 |
-#define PV_VAL_STR 4 |
|
51 |
-#define PV_VAL_INT 8 |
|
52 |
-#define PV_TYPE_INT 16 |
|
53 |
-#define PV_VAL_PKG 32 |
|
54 |
-#define PV_VAL_SHM 64 |
|
55 |
- |
|
56 |
-#define PV_NAME_INTSTR 0 |
|
57 |
-#define PV_NAME_PVAR 1 |
|
58 |
-#define PV_NAME_OTHER 2 |
|
59 |
- |
|
60 |
-#define PV_IDX_INT 0 |
|
61 |
-#define PV_IDX_PVAR 1 |
|
62 |
-#define PV_IDX_ALL 2 |
|
63 |
-#define PV_IDX_ITR 3 |
|
64 |
- |
|
65 |
-/*! if PV name is dynamic, integer, or str */ |
|
66 |
-#define pv_has_dname(pv) ((pv)->pvp.pvn.type==PV_NAME_PVAR) |
|
67 |
-#define pv_has_iname(pv) ((pv)->pvp.pvn.type==PV_NAME_INTSTR \ |
|
68 |
- && !((pv)->pvp.pvn.u.isname.type&AVP_NAME_STR)) |
|
69 |
-#define pv_has_sname(pv) ((pv)->pvp.pvn.type==PV_NAME_INTSTR \ |
|
70 |
- && (pv)->pvp.pvn.u.isname.type&AVP_NAME_STR) |
|
71 |
-#define pv_is_w(pv) ((pv)->setf!=NULL) |
|
72 |
- |
|
73 |
-enum _pv_type { |
|
74 |
- PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
|
75 |
- PVT_MARKER, PVT_AVP, PVT_HDR, |
|
76 |
- PVT_RURI, PVT_RURI_USERNAME, PVT_RURI_DOMAIN, |
|
77 |
- PVT_DSTURI, PVT_COLOR, PVT_BRANCH, |
|
78 |
- PVT_FROM, PVT_TO, PVT_OURI, |
|
79 |
- PVT_SCRIPTVAR, PVT_MSG_BODY, PVT_CONTEXT, |
|
80 |
- PVT_XAVP, PVT_OTHER, PVT_EXTRA /* keep it last */ |
|
81 |
-}; |
|
82 |
- |
|
83 |
-typedef enum _pv_type pv_type_t; |
|
84 |
-typedef int pv_flags_t; |
|
85 |
- |
|
86 |
-typedef void (*pv_name_free_f)(void*); |
|
87 |
- |
|
88 |
-typedef struct _pv_value |
|
89 |
-{ |
|
90 |
- str rs; /*!< string value */ |
|
91 |
- int ri; /*!< integer value */ |
|
92 |
- int flags; /*!< flags about the type of value */ |
|
93 |
-} pv_value_t, *pv_value_p; |
|
94 |
- |
|
95 |
-typedef struct _pv_name |
|
96 |
-{ |
|
97 |
- int type; /*!< type of name */ |
|
98 |
- pv_name_free_f nfree; /*!< function to free name structure */ |
|
99 |
- union { |
|
100 |
- struct { |
|
101 |
- int type; /*!< type of int_str name - compatibility with AVPs */ |
|
102 |
- int_str name; /*!< the value of the name */ |
|
103 |
- } isname; |
|
104 |
- void *dname; /*!< PV value - dynamic name */ |
|
105 |
- } u; |
|
106 |
-} pv_name_t, *pv_name_p; |
|
107 |
- |
|
108 |
-typedef struct _pv_index |
|
109 |
-{ |
|
110 |
- int type; /*!< type of PV index */ |
|
111 |
- union { |
|
112 |
- int ival; /*!< integer value */ |
|
113 |
- void *dval; /*!< PV value - dynamic index */ |
|
114 |
- } u; |
|
115 |
-} pv_index_t, *pv_index_p; |
|
116 |
- |
|
117 |
-typedef struct _pv_param |
|
118 |
-{ |
|
119 |
- pv_name_t pvn; /*!< PV name */ |
|
120 |
- pv_index_t pvi; /*!< PV index */ |
|
121 |
-} pv_param_t, *pv_param_p; |
|
122 |
- |
|
123 |
-typedef int (*pv_getf_t) (struct sip_msg*, pv_param_t*, pv_value_t*); |
|
124 |
-typedef int (*pv_setf_t) (struct sip_msg*, pv_param_t*, int, pv_value_t*); |
|
125 |
- |
|
126 |
-typedef struct _pv_spec { |
|
127 |
- pv_type_t type; /*!< type of PV */ |
|
128 |
- pv_getf_t getf; /*!< get PV value function */ |
|
129 |
- pv_setf_t setf; /*!< set PV value function */ |
|
130 |
- pv_param_t pvp; /*!< parameter to be given to get/set functions */ |
|
131 |
- void *trans; /*!< transformations */ |
|
132 |
-} pv_spec_t, *pv_spec_p; |
|
133 |
- |
|
134 |
-typedef int (*pv_parse_name_f)(pv_spec_p sp, str *in); |
|
135 |
-typedef int (*pv_parse_index_f)(pv_spec_p sp, str *in); |
|
136 |
-typedef int (*pv_init_param_f)(pv_spec_p sp, int param); |
|
137 |
- |
|
138 |
-#define pv_alter_context(pv) ((pv)->type==PVT_CONTEXT \ |
|
139 |
- || (pv)->type==PVT_BRANCH) |
|
140 |
- |
|
141 |
-/*! \brief |
|
142 |
- * PV spec format: |
|
143 |
- * - $class_name |
|
144 |
- * - $class_name(inner_name) |
|
145 |
- * - $(class_name[index]) |
|
146 |
- * - $(class_name(inner_name)[index]) |
|
147 |
- * - $(class_name{transformation}) |
|
148 |
- * - $(class_name(inner_name){transformation}) |
|
149 |
- * - $(class_name[index]{transformation}) |
|
150 |
- * - $(class_name(inner_name)[index]{transformation}) |
|
151 |
- */ |
|
152 |
-typedef struct _pv_export { |
|
153 |
- str name; /*!< class name of PV */ |
|
154 |
- pv_type_t type; /*!< type of PV */ |
|
155 |
- pv_getf_t getf; /*!< function to get the value */ |
|
156 |
- pv_setf_t setf; /*!< function to set the value */ |
|
157 |
- pv_parse_name_f parse_name; /*!< function to parse the inner name */ |
|
158 |
- pv_parse_index_f parse_index; /*!< function to parse the index of PV */ |
|
159 |
- pv_init_param_f init_param; /*!< function to init the PV spec */ |
|
160 |
- int iparam; /*!< parameter for the init function */ |
|
161 |
-} pv_export_t; |
|
162 |
- |
|
163 |
-typedef struct _pv_elem |
|
164 |
-{ |
|
165 |
- str text; |
|
166 |
- pv_spec_t *spec; |
|
167 |
- struct _pv_elem *next; |
|
168 |
-} pv_elem_t, *pv_elem_p; |
|
169 |
- |
|
170 |
-char* pv_parse_spec2(str *in, pv_spec_p sp, int silent); |
|
171 |
-#define pv_parse_spec(in, sp) pv_parse_spec2((in), (sp), 0) |
|
172 |
-int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value); |
|
173 |
-int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op, |
|
174 |
- pv_value_t *value); |
|
175 |
-int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); |
|
176 |
-int pv_elem_free_all(pv_elem_p log); |
|
177 |
-void pv_value_destroy(pv_value_t *val); |
|
178 |
-void pv_spec_destroy(pv_spec_t *spec); |
|
179 |
-void pv_spec_free(pv_spec_t *spec); |
|
180 |
-int pv_spec_dbg(pv_spec_p sp); |
|
181 |
-int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags); |
|
182 |
-int pv_get_avp_name(struct sip_msg* msg, pv_param_p ip, int_str *avp_name, |
|
183 |
- unsigned short *name_type); |
|
184 |
-int pv_parse_avp_name(pv_spec_p sp, str *in); |
|
185 |
-int pv_get_spec_name(struct sip_msg* msg, pv_param_p ip, pv_value_t *name); |
|
186 |
-int pv_parse_format(str *in, pv_elem_p *el); |
|
187 |
-int pv_parse_index(pv_spec_p sp, str *in); |
|
188 |
-int pv_init_iname(pv_spec_p sp, int param); |
|
189 |
-int pv_printf_s(struct sip_msg* msg, pv_elem_p list, str *s); |
|
190 |
-pv_spec_t* pv_spec_lookup(str *name, int *len); |
|
191 |
- |
|
192 |
-typedef struct _pvname_list { |
|
193 |
- pv_spec_t sname; |
|
194 |
- struct _pvname_list *next; |
|
195 |
-} pvname_list_t, *pvname_list_p; |
|
196 |
- |
|
197 |
-typedef struct pv_spec_list { |
|
198 |
- pv_spec_p spec; |
|
199 |
- struct pv_spec_list *next; |
|
200 |
-} pv_spec_list_t, *pv_spec_list_p; |
|
201 |
- |
|
202 |
-pvname_list_t* parse_pvname_list(str *in, unsigned int type); |
|
203 |
- |
|
204 |
-int register_pvars_mod(char *mod_name, pv_export_t *items); |
|
205 |
-int pv_free_extra_list(void); |
|
206 |
- |
|
207 |
-int pv_locate_name(str *in); |
|
208 |
-pv_spec_t* pv_cache_get(str *name); |
|
209 |
-str* pv_cache_get_name(pv_spec_t *spec); |
|
210 |
- |
|
211 |
-/*! \brief PV helper functions */ |
|
212 |
-int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
|
213 |
-int pv_get_strempty(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
|
214 |
- |
|
215 |
-int pv_get_uintval(struct sip_msg *msg, pv_param_t *param, |
|
216 |
- pv_value_t *res, unsigned int uival); |
|
217 |
-int pv_get_sintval(struct sip_msg *msg, pv_param_t *param, |
|
218 |
- pv_value_t *res, int sival); |
|
219 |
-int pv_get_strval(struct sip_msg *msg, pv_param_t *param, |
|
220 |
- pv_value_t *res, str *sval); |
|
221 |
-int pv_get_strzval(struct sip_msg *msg, pv_param_t *param, |
|
222 |
- pv_value_t *res, char *sval); |
|
223 |
-int pv_get_strlval(struct sip_msg *msg, pv_param_t *param, |
|
224 |
- pv_value_t *res, char *sval, int slen); |
|
225 |
-int pv_get_strintval(struct sip_msg *msg, pv_param_t *param, |
|
226 |
- pv_value_t *res, str *sval, int ival); |
|
227 |
-int pv_get_intstrval(struct sip_msg *msg, pv_param_t *param, |
|
228 |
- pv_value_t *res, int ival, str *sval); |
|
229 |
- |
|
230 |
-/** |
|
231 |
- * Core PV Cache |
|
232 |
- */ |
|
233 |
-typedef struct _pv_cache |
|
234 |
-{ |
|
235 |
- str pvname; |
|
236 |
- unsigned int pvid; |
|
237 |
- pv_spec_t spec; |
|
238 |
- struct _pv_cache *next; |
|
239 |
-} pv_cache_t; |
|
240 |
- |
|
241 |
-#define PV_CACHE_SIZE 32 /*!< pseudo-variables cache table size */ |
|
242 |
- |
|
243 |
-pv_cache_t **pv_cache_get_table(void); |
|
244 |
- |
|
245 |
- |
|
246 |
-/** |
|
247 |
- * Transformations |
|
248 |
- */ |
|
249 |
-#define TR_LBRACKET_STR "{" |
|
250 |
-#define TR_LBRACKET '{' |
|
251 |
-#define TR_RBRACKET_STR "}" |
|
252 |
-#define TR_RBRACKET '}' |
|
253 |
-#define TR_CLASS_MARKER '.' |
|
254 |
-#define TR_PARAM_MARKER ',' |
|
255 |
- |
|
256 |
-enum _tr_param_type { TR_PARAM_NONE=0, TR_PARAM_STRING, TR_PARAM_NUMBER, |
|
257 |
- TR_PARAM_SPEC, TR_PARAM_SUBST, TR_PARAM_OTHER }; |
|
258 |
- |
|
259 |
-typedef struct _tr_param { |
|
260 |
- int type; |
|
261 |
- union { |
|
262 |
- int n; |
|
263 |
- str s; |
|
264 |
- void *data; |
|
265 |
- } v; |
|
266 |
- struct _tr_param *next; |
|
267 |
-} tr_param_t, *tr_param_p; |
|
268 |
- |
|
269 |
-typedef int (*tr_func_t) (struct sip_msg *, tr_param_t*, int, pv_value_t*); |
|
270 |
- |
|
271 |
-typedef struct _trans { |
|
272 |
- str name; |
|
273 |
- int type; |
|
274 |
- int subtype; |
|
275 |
- tr_func_t trf; |
|
276 |
- tr_param_t *params; |
|
277 |
- struct _trans *next; |
|
278 |
-} trans_t, *trans_p; |
|
279 |
- |
|
280 |
-typedef char* (*tr_parsef_t)(str *, trans_t *); |
|
281 |
-typedef struct _tr_export { |
|
282 |
- str tclass; |
|
283 |
- tr_parsef_t tparse; |
|
284 |
-} tr_export_t, *tr_export_p; |
|
285 |
- |
|
286 |
-char* tr_lookup(str *in, trans_t **tr); |
|
287 |
-tr_export_t* tr_lookup_class(str *tclass); |
|
288 |
-int tr_exec(struct sip_msg *msg, trans_t *t, pv_value_t *v); |
|
289 |
-void tr_param_free(tr_param_t *tp); |
|
290 |
- |
|
291 |
-int register_trans_mod(char *mod_name, tr_export_t *items); |
|
292 |
- |
|
293 |
- |
|
294 |
-/** |
|
295 |
- * XAVP |
|
296 |
- */ |
|
297 |
-typedef struct _pv_xavp_name { |
|
298 |
- str name; |
|
299 |
- pv_spec_t index; |
|
300 |
- struct _pv_xavp_name *next; |
|
301 |
-} pv_xavp_name_t; |
|
302 |
- |
|
303 |
-int pv_eval_str(sip_msg_t *msg, str *dst, str *src); |
|
304 |
- |
|
305 |
-#endif |
|
306 |
- |
... | ... |
@@ -13,8 +13,8 @@ |
13 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | 14 |
* GNU General Public License for more details. |
15 | 15 |
* |
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
16 |
+ * You should have received a copy of the GNU General Public License |
|
17 |
+ * along with this program; if not, write to the Free Software |
|
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | 19 |
*/ |
20 | 20 |
|
... | ... |
@@ -70,8 +70,8 @@ |
70 | 70 |
&& (pv)->pvp.pvn.u.isname.type&AVP_NAME_STR) |
71 | 71 |
#define pv_is_w(pv) ((pv)->setf!=NULL) |
72 | 72 |
|
73 |
-enum _pv_type { |
|
74 |
- PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
|
73 |
+enum _pv_type { |
|
74 |
+ PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
|
75 | 75 |
PVT_MARKER, PVT_AVP, PVT_HDR, |
76 | 76 |
PVT_RURI, PVT_RURI_USERNAME, PVT_RURI_DOMAIN, |
77 | 77 |
PVT_DSTURI, PVT_COLOR, PVT_BRANCH, |
... | ... |
@@ -280,7 +280,7 @@ typedef struct _trans { |
280 | 280 |
typedef char* (*tr_parsef_t)(str *, trans_t *); |
281 | 281 |
typedef struct _tr_export { |
282 | 282 |
str tclass; |
283 |
- tr_parsef_t tparse; |
|
283 |
+ tr_parsef_t tparse; |
|
284 | 284 |
} tr_export_t, *tr_export_p; |
285 | 285 |
|
286 | 286 |
char* tr_lookup(str *in, trans_t **tr); |
... | ... |
@@ -210,6 +210,7 @@ str* pv_cache_get_name(pv_spec_t *spec); |
210 | 210 |
|
211 | 211 |
/*! \brief PV helper functions */ |
212 | 212 |
int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
213 |
+int pv_get_strempty(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
|
213 | 214 |
|
214 | 215 |
int pv_get_uintval(struct sip_msg *msg, pv_param_t *param, |
215 | 216 |
pv_value_t *res, unsigned int uival); |
... | ... |
@@ -219,6 +219,8 @@ int pv_get_strval(struct sip_msg *msg, pv_param_t *param, |
219 | 219 |
pv_value_t *res, str *sval); |
220 | 220 |
int pv_get_strzval(struct sip_msg *msg, pv_param_t *param, |
221 | 221 |
pv_value_t *res, char *sval); |
222 |
+int pv_get_strlval(struct sip_msg *msg, pv_param_t *param, |
|
223 |
+ pv_value_t *res, char *sval, int slen); |
|
222 | 224 |
int pv_get_strintval(struct sip_msg *msg, pv_param_t *param, |
223 | 225 |
pv_value_t *res, str *sval, int ival); |
224 | 226 |
int pv_get_intstrval(struct sip_msg *msg, pv_param_t *param, |
With this notation we want to check all values one by one not
the list of coma separated values
... | ... |
@@ -1,16 +1,14 @@ |
1 | 1 |
/* |
2 |
- * $Id: items.h 2111 2007-05-01 11:18:08Z juhe $ |
|
3 |
- * |
|
4 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 3 |
* |
6 |
- * This file is part of SIP-Router, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
7 | 5 |
* |
8 |
- * SIP-Router is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
9 | 7 |
* it under the terms of the GNU General Public License as published by |
10 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
11 | 9 |
* (at your option) any later version |
12 | 10 |
* |
13 |
- * SIP-Router is distributed in the hope that it will be useful, |
|
11 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
14 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 14 |
* GNU General Public License for more details. |
... | ... |
@@ -22,7 +20,7 @@ |
22 | 20 |
|
23 | 21 |
/*! |
24 | 22 |
* \file |
25 |
- * \brief Definitions for Pseudo-variable support |
|
23 |
+ * \brief Kamailio core :: Definitions for Pseudo-variable support |
|
26 | 24 |
*/ |
27 | 25 |
|
28 | 26 |
|
... | ... |
@@ -17,7 +17,7 @@ |
17 | 17 |
* |
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
21 | 21 |
*/ |
22 | 22 |
|
23 | 23 |
/*! |
... | ... |
@@ -288,5 +288,15 @@ void tr_param_free(tr_param_t *tp); |
288 | 288 |
|
289 | 289 |
int register_trans_mod(char *mod_name, tr_export_t *items); |
290 | 290 |
|
291 |
+ |
|
292 |
+/** |
|
293 |
+ * XAVP |
|
294 |
+ */ |
|
295 |
+typedef struct _pv_xavp_name { |
|
296 |
+ str name; |
|
297 |
+ pv_spec_t index; |
|
298 |
+ struct _pv_xavp_name *next; |
|
299 |
+} pv_xavp_name_t; |
|
300 |
+ |
|
291 | 301 |
#endif |
292 | 302 |
|
- they may need special handling for debug purposes
... | ... |
@@ -78,7 +78,7 @@ enum _pv_type { |
78 | 78 |
PVT_DSTURI, PVT_COLOR, PVT_BRANCH, |
79 | 79 |
PVT_FROM, PVT_TO, PVT_OURI, |
80 | 80 |
PVT_SCRIPTVAR, PVT_MSG_BODY, PVT_CONTEXT, |
81 |
- PVT_OTHER, PVT_EXTRA /* keep it last */ |
|
81 |
+ PVT_XAVP, PVT_OTHER, PVT_EXTRA /* keep it last */ |
|
82 | 82 |
}; |
83 | 83 |
|
84 | 84 |
typedef enum _pv_type pv_type_t; |
- pv cache struct moved to header file
... | ... |
@@ -225,6 +225,22 @@ int pv_get_strintval(struct sip_msg *msg, pv_param_t *param, |
225 | 225 |
int pv_get_intstrval(struct sip_msg *msg, pv_param_t *param, |
226 | 226 |
pv_value_t *res, int ival, str *sval); |
227 | 227 |
|
228 |
+/** |
|
229 |
+ * Core PV Cache |
|
230 |
+ */ |
|
231 |
+typedef struct _pv_cache |
|
232 |
+{ |
|
233 |
+ str pvname; |
|
234 |
+ unsigned int pvid; |
|
235 |
+ pv_spec_t spec; |
|
236 |
+ struct _pv_cache *next; |
|
237 |
+} pv_cache_t; |
|
238 |
+ |
|
239 |
+#define PV_CACHE_SIZE 32 /*!< pseudo-variables cache table size */ |
|
240 |
+ |
|
241 |
+pv_cache_t **pv_cache_get_table(void); |
|
242 |
+ |
|
243 |
+ |
|
228 | 244 |
/** |
229 | 245 |
* Transformations |
230 | 246 |
*/ |
... | ... |
@@ -207,6 +207,7 @@ int pv_free_extra_list(void); |
207 | 207 |
|
208 | 208 |
int pv_locate_name(str *in); |
209 | 209 |
pv_spec_t* pv_cache_get(str *name); |
210 |
+str* pv_cache_get_name(pv_spec_t *spec); |
|
210 | 211 |
|
211 | 212 |
/*! \brief PV helper functions */ |
212 | 213 |
int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
- reduces use of private memory for repetitive PVs
... | ... |
@@ -164,7 +164,7 @@ typedef struct _pv_export { |
164 | 164 |
typedef struct _pv_elem |
165 | 165 |
{ |
166 | 166 |
str text; |
167 |
- pv_spec_t spec; |
|
167 |
+ pv_spec_t *spec; |
|
168 | 168 |
struct _pv_elem *next; |
169 | 169 |
} pv_elem_t, *pv_elem_p; |
170 | 170 |
|
... | ... |
@@ -188,6 +188,7 @@ int pv_parse_format(str *in, pv_elem_p *el); |
188 | 188 |
int pv_parse_index(pv_spec_p sp, str *in); |
189 | 189 |
int pv_init_iname(pv_spec_p sp, int param); |
190 | 190 |
int pv_printf_s(struct sip_msg* msg, pv_elem_p list, str *s); |
191 |
+pv_spec_t* pv_spec_lookup(str *name, int *len); |
|
191 | 192 |
|
192 | 193 |
typedef struct _pvname_list { |
193 | 194 |
pv_spec_t sname; |
... | ... |
@@ -216,6 +216,8 @@ int pv_get_sintval(struct sip_msg *msg, pv_param_t *param, |
216 | 216 |
pv_value_t *res, int sival); |
217 | 217 |
int pv_get_strval(struct sip_msg *msg, pv_param_t *param, |
218 | 218 |
pv_value_t *res, str *sval); |
219 |
+int pv_get_strzval(struct sip_msg *msg, pv_param_t *param, |
|
220 |
+ pv_value_t *res, char *sval); |
|
219 | 221 |
int pv_get_strintval(struct sip_msg *msg, pv_param_t *param, |
220 | 222 |
pv_value_t *res, str *sval, int ival); |
221 | 223 |
int pv_get_intstrval(struct sip_msg *msg, pv_param_t *param, |
- can be used to reduce pkg memory usage by PVs
- solves memory leak of using PVs with dynamic names from embedded
languages
... | ... |
@@ -204,6 +204,9 @@ pvname_list_t* parse_pvname_list(str *in, unsigned int type); |
204 | 204 |
int register_pvars_mod(char *mod_name, pv_export_t *items); |
205 | 205 |
int pv_free_extra_list(void); |
206 | 206 |
|
207 |
+int pv_locate_name(str *in); |
|
208 |
+pv_spec_t* pv_cache_get(str *name); |
|
209 |
+ |
|
207 | 210 |
/*! \brief PV helper functions */ |
208 | 211 |
int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
209 | 212 |
|
- some PVs have dynamic name, therefore parsing them at runtime result in
memory leak
- the new attribute allow to free such kind of names
- not the case so far with stable versions but this can happen when using
such PVs with app_lua
... | ... |
@@ -84,6 +84,7 @@ enum _pv_type { |
84 | 84 |
typedef enum _pv_type pv_type_t; |
85 | 85 |
typedef int pv_flags_t; |
86 | 86 |
|
87 |
+typedef void (*pv_name_free_f)(void*); |
|
87 | 88 |
|
88 | 89 |
typedef struct _pv_value |
89 | 90 |
{ |
... | ... |
@@ -95,6 +96,7 @@ typedef struct _pv_value |
95 | 96 |
typedef struct _pv_name |
96 | 97 |
{ |
97 | 98 |
int type; /*!< type of name */ |
99 |
+ pv_name_free_f nfree; /*!< function to free name structure */ |
|
98 | 100 |
union { |
99 | 101 |
struct { |
100 | 102 |
int type; /*!< type of int_str name - compatibility with AVPs */ |
... | ... |
@@ -174,6 +176,7 @@ int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op, |
174 | 176 |
int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); |
175 | 177 |
int pv_elem_free_all(pv_elem_p log); |
176 | 178 |
void pv_value_destroy(pv_value_t *val); |
179 |
+void pv_spec_destroy(pv_spec_t *spec); |
|
177 | 180 |
void pv_spec_free(pv_spec_t *spec); |
178 | 181 |
int pv_spec_dbg(pv_spec_p sp); |
179 | 182 |
int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags); |
- core pv api can export pvs - $null and $$ are generic and can be used
without pv module
- pv_parse_avp_name() moved together with pv_get_avp_name()
... | ... |
@@ -179,6 +179,7 @@ int pv_spec_dbg(pv_spec_p sp); |
179 | 179 |
int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags); |
180 | 180 |
int pv_get_avp_name(struct sip_msg* msg, pv_param_p ip, int_str *avp_name, |
181 | 181 |
unsigned short *name_type); |
182 |
+int pv_parse_avp_name(pv_spec_p sp, str *in); |
|
182 | 183 |
int pv_get_spec_name(struct sip_msg* msg, pv_param_p ip, pv_value_t *name); |
183 | 184 |
int pv_parse_format(str *in, pv_elem_p *el); |
184 | 185 |
int pv_parse_index(pv_spec_p sp, str *in); |
- added init and destroy functions (declared in pvapi_init.h)
- fixed pv_table_free() and tr_table_free() bug
... | ... |
@@ -184,7 +184,6 @@ int pv_parse_format(str *in, pv_elem_p *el); |
184 | 184 |
int pv_parse_index(pv_spec_p sp, str *in); |
185 | 185 |
int pv_init_iname(pv_spec_p sp, int param); |
186 | 186 |
int pv_printf_s(struct sip_msg* msg, pv_elem_p list, str *s); |
187 |
-void pv_api_destroy(void); |
|
188 | 187 |
|
189 | 188 |
typedef struct _pvname_list { |
190 | 189 |
pv_spec_t sname; |
- wrapper for PV set function that takes in consideration cases of
altering the msg context
... | ... |
@@ -134,6 +134,9 @@ typedef int (*pv_parse_name_f)(pv_spec_p sp, str *in); |
134 | 134 |
typedef int (*pv_parse_index_f)(pv_spec_p sp, str *in); |
135 | 135 |
typedef int (*pv_init_param_f)(pv_spec_p sp, int param); |
136 | 136 |
|
137 |
+#define pv_alter_context(pv) ((pv)->type==PVT_CONTEXT \ |
|
138 |
+ || (pv)->type==PVT_BRANCH) |
|
139 |
+ |
|
137 | 140 |
/*! \brief |
138 | 141 |
* PV spec format: |
139 | 142 |
* - $class_name |
... | ... |
@@ -166,6 +169,8 @@ typedef struct _pv_elem |
166 | 169 |
char* pv_parse_spec2(str *in, pv_spec_p sp, int silent); |
167 | 170 |
#define pv_parse_spec(in, sp) pv_parse_spec2((in), (sp), 0) |
168 | 171 |
int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value); |
172 |
+int pv_set_spec_value(struct sip_msg* msg, pv_spec_p sp, int op, |
|
173 |
+ pv_value_t *value); |
|
169 | 174 |
int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); |
170 | 175 |
int pv_elem_free_all(pv_elem_p log); |
171 | 176 |
void pv_value_destroy(pv_value_t *val); |
* commit 'origin/daniel/pv':
fix add/lookup pv name
fix pv&t lookup due to signness
pv api updates
- list of PVs types syncronized with Kamailio
Conflicts:
pvapi.c
- added a silent version for pv_parse_spec (pv_parse_spec2()), so
that the script parsing fallback from pvars to avps for
ambiguous identifiers can happen without a ton of error messages
... | ... |
@@ -158,7 +158,8 @@ typedef struct _pv_elem |
158 | 158 |
struct _pv_elem *next; |
159 | 159 |
} pv_elem_t, *pv_elem_p; |
160 | 160 |
|
161 |
-char* pv_parse_spec(str *in, pv_spec_p sp); |
|
161 |
+char* pv_parse_spec2(str *in, pv_spec_p sp, int silent); |
|
162 |
+#define pv_parse_spec(in, sp) pv_parse_spec2((in), (sp), 0) |
|
162 | 163 |
int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value); |
163 | 164 |
int pv_print_spec(struct sip_msg* msg, pv_spec_p sp, char *buf, int *len); |
164 | 165 |
int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); |
- fix the transformations hash table size
- complete the functions in PV&T API
... | ... |
@@ -57,6 +57,7 @@ |
57 | 57 |
|
58 | 58 |
#define PV_NAME_INTSTR 0 |
59 | 59 |
#define PV_NAME_PVAR 1 |
60 |
+#define PV_NAME_OTHER 2 |
|
60 | 61 |
|
61 | 62 |
#define PV_IDX_INT 0 |
62 | 63 |
#define PV_IDX_PVAR 1 |
... | ... |
@@ -76,7 +77,7 @@ enum _pv_type { |
76 | 77 |
PVT_RURI, PVT_RURI_USERNAME, PVT_RURI_DOMAIN, |
77 | 78 |
PVT_DSTURI, PVT_COLOR, PVT_BRANCH, |
78 | 79 |
PVT_FROM, PVT_TO, PVT_OURI, |
79 |
- PVT_SCRIPTVAR, PVT_MSG_BODY, |
|
80 |
+ PVT_SCRIPTVAR, PVT_MSG_BODY, PVT_CONTEXT, |
|
80 | 81 |
PVT_OTHER, PVT_EXTRA /* keep it last */ |
81 | 82 |
}; |
82 | 83 |
|
... | ... |
@@ -164,7 +165,6 @@ typedef struct _pv_elem |
164 | 165 |
|
165 | 166 |
char* pv_parse_spec(str *in, pv_spec_p sp); |
166 | 167 |
int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value); |
167 |
-int pv_print_spec(struct sip_msg* msg, pv_spec_p sp, char *buf, int *len); |
|
168 | 168 |
int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); |
169 | 169 |
int pv_elem_free_all(pv_elem_p log); |
170 | 170 |
void pv_value_destroy(pv_value_t *val); |
... | ... |
@@ -175,8 +175,10 @@ int pv_get_avp_name(struct sip_msg* msg, pv_param_p ip, int_str *avp_name, |
175 | 175 |
unsigned short *name_type); |
176 | 176 |
int pv_get_spec_name(struct sip_msg* msg, pv_param_p ip, pv_value_t *name); |
177 | 177 |
int pv_parse_format(str *in, pv_elem_p *el); |
178 |
+int pv_parse_index(pv_spec_p sp, str *in); |
|
178 | 179 |
int pv_init_iname(pv_spec_p sp, int param); |
179 | 180 |
int pv_printf_s(struct sip_msg* msg, pv_elem_p list, str *s); |
181 |
+void pv_api_destroy(void); |
|
180 | 182 |
|
181 | 183 |
typedef struct _pvname_list { |
182 | 184 |
pv_spec_t sname; |
... | ... |
@@ -194,10 +196,7 @@ int register_pvars_mod(char *mod_name, pv_export_t *items); |
194 | 196 |
int pv_free_extra_list(void); |
195 | 197 |
|
196 | 198 |
/*! \brief PV helper functions */ |
197 |
-int pv_parse_index(pv_spec_p sp, str *in); |
|
198 |
- |
|
199 | 199 |
int pv_get_null(struct sip_msg *msg, pv_param_t *param, pv_value_t *res); |
200 |
-int pv_update_time(struct sip_msg *msg, time_t *t); |
|
201 | 200 |
|
202 | 201 |
int pv_get_uintval(struct sip_msg *msg, pv_param_t *param, |
203 | 202 |
pv_value_t *res, unsigned int uival); |
... | ... |
@@ -221,7 +220,7 @@ int pv_get_intstrval(struct sip_msg *msg, pv_param_t *param, |
221 | 220 |
#define TR_PARAM_MARKER ',' |
222 | 221 |
|
223 | 222 |
enum _tr_param_type { TR_PARAM_NONE=0, TR_PARAM_STRING, TR_PARAM_NUMBER, |
224 |
- TR_PARAM_SPEC }; |
|
223 |
+ TR_PARAM_SPEC, TR_PARAM_SUBST, TR_PARAM_OTHER }; |
|
225 | 224 |
|
226 | 225 |
typedef struct _tr_param { |
227 | 226 |
int type; |
... | ... |
@@ -253,6 +252,9 @@ typedef struct _tr_export { |
253 | 252 |
char* tr_lookup(str *in, trans_t **tr); |
254 | 253 |
tr_export_t* tr_lookup_class(str *tclass); |
255 | 254 |
int tr_exec(struct sip_msg *msg, trans_t *t, pv_value_t *v); |
255 |
+void tr_param_free(tr_param_t *tp); |
|
256 |
+ |
|
257 |
+int register_trans_mod(char *mod_name, tr_export_t *items); |
|
256 | 258 |
|
257 | 259 |
#endif |
258 | 260 |
|
... | ... |
@@ -72,7 +72,11 @@ |
72 | 72 |
|
73 | 73 |
enum _pv_type { |
74 | 74 |
PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
75 |
- PVT_MARKER, PVT_AVP, PVT_COLOR, |
|
75 |
+ PVT_MARKER, PVT_AVP, PVT_HDR, |
|
76 |
+ PVT_RURI, PVT_RURI_USERNAME, PVT_RURI_DOMAIN, |
|
77 |
+ PVT_DSTURI, PVT_COLOR, PVT_BRANCH, |
|
78 |
+ PVT_FROM, PVT_TO, PVT_OURI, |
|
79 |
+ PVT_SCRIPTVAR, PVT_MSG_BODY, |
|
76 | 80 |
PVT_OTHER, PVT_EXTRA /* keep it last */ |
77 | 81 |
}; |
78 | 82 |
|
- register PV exported by modules
- added functions to evaluate PVs
- xlog module from Kamailio/OpenSER should run now in sip-router compiled with DEFS+= -DKAMAILIO_MOD_INTERFACE
... | ... |
@@ -72,8 +72,8 @@ |
72 | 72 |
|
73 | 73 |
enum _pv_type { |
74 | 74 |
PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
75 |
- PVT_MARKER, PVT_AVP, PVT_OTHER, |
|
76 |
- PVT_EXTRA /* keep it last */ |
|
75 |
+ PVT_MARKER, PVT_AVP, PVT_COLOR, |
|
76 |
+ PVT_OTHER, PVT_EXTRA /* keep it last */ |
|
77 | 77 |
}; |
78 | 78 |
|
79 | 79 |
typedef enum _pv_type pv_type_t; |
... | ... |
@@ -248,6 +248,7 @@ typedef struct _tr_export { |
248 | 248 |
|
249 | 249 |
char* tr_lookup(str *in, trans_t **tr); |
250 | 250 |
tr_export_t* tr_lookup_class(str *tclass); |
251 |
+int tr_exec(struct sip_msg *msg, trans_t *t, pv_value_t *v); |
|
251 | 252 |
|
252 | 253 |
#endif |
253 | 254 |
|
- PV get null helper function required to stay in the API
- removed unused PV types - now AVP type is used to detect the type of
parameters, some related to R-URI are used by avpops, to be added if a
different solution is not found. Would be hard to manage the types in
core and do the implementation in module.
... | ... |
@@ -3,14 +3,14 @@ |
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2001-2003 FhG Fokus |
5 | 5 |
* |
6 |
- * This file is part of Kamailio, a free SIP server. |
|
6 |
+ * This file is part of SIP-Router, a free SIP server. |
|
7 | 7 |
* |
8 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
8 |
+ * SIP-Router is free software; you can redistribute it and/or modify |
|
9 | 9 |
* it under the terms of the GNU General Public License as published by |
10 | 10 |
* the Free Software Foundation; either version 2 of the License, or |
11 | 11 |
* (at your option) any later version |
12 | 12 |
* |
13 |
- * Kamailio is distributed in the hope that it will be useful, |
|
13 |
+ * SIP-Router is distributed in the hope that it will be useful, |
|
14 | 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | 16 |
* GNU General Public License for more details. |
... | ... |
@@ -72,34 +72,7 @@ |
72 | 72 |
|
73 | 73 |
enum _pv_type { |
74 | 74 |
PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
75 |
- PVT_MARKER, PVT_AVP, PVT_HDR, |
|
76 |
- PVT_PID, PVT_RETURN_CODE, PVT_TIMES, |
|
77 |
- PVT_TIMEF, PVT_MSGID, PVT_METHOD, |
|
78 |
- PVT_STATUS, PVT_REASON, PVT_RURI, |
|
79 |
- PVT_RURI_USERNAME, PVT_RURI_DOMAIN, PVT_RURI_PORT, |
|
80 |
- PVT_FROM, PVT_FROM_USERNAME, PVT_FROM_DOMAIN, |
|
81 |
- PVT_FROM_TAG, PVT_TO, PVT_TO_USERNAME, |
|
82 |
- PVT_TO_DOMAIN, PVT_TO_TAG, PVT_CSEQ, |
|
83 |
- PVT_CONTACT, PVT_CALLID, PVT_USERAGENT, |
|
84 |
- PVT_MSG_BUF, PVT_MSG_LEN, PVT_FLAGS, |
|
85 |
- PVT_HEXFLAGS, PVT_SRCIP, PVT_SRCPORT, |
|
86 |
- PVT_RCVIP, PVT_RCVPORT, PVT_REFER_TO, |
|
87 |
- PVT_DSET, PVT_DSTURI, PVT_COLOR, |
|
88 |
- PVT_BRANCH, PVT_BRANCHES, PVT_CONTENT_TYPE, |
|
89 |
- PVT_CONTENT_LENGTH, PVT_MSG_BODY, PVT_AUTH_USERNAME, |
|
90 |
- PVT_AUTH_REALM, PVT_RURI_PROTOCOL, PVT_DSTURI_DOMAIN, |
|
91 |
- PVT_DSTURI_PORT, PVT_DSTURI_PROTOCOL, PVT_FROM_DISPLAYNAME, |
|
92 |
- PVT_TO_DISPLAYNAME, PVT_OURI, PVT_OURI_USERNAME, |
|
93 |
- PVT_OURI_DOMAIN, PVT_OURI_PORT, PVT_OURI_PROTOCOL, |
|
94 |
- PVT_FORCE_SOCK, PVT_RPID_URI, PVT_DIVERSION_URI, |
|
95 |
- PVT_ACC_USERNAME, PVT_PPI, PVT_PPI_DISPLAYNAME, |
|
96 |
- PVT_PPI_DOMAIN, PVT_PPI_USERNAME, PVT_PAI_URI, |
|
97 |
- PVT_BFLAGS, PVT_HEXBFLAGS, PVT_SFLAGS, |
|
98 |
- PVT_HEXSFLAGS, PVT_ERR_CLASS, PVT_ERR_LEVEL, |
|
99 |
- PVT_ERR_INFO, PVT_ERR_RCODE, PVT_ERR_RREASON, |
|
100 |
- PVT_SCRIPTVAR, PVT_PROTO, PVT_AUTH_USERNAME_WHOLE, |
|
101 |
- PVT_AUTH_DURI, PVT_DIV_REASON, PVT_DIV_PRIVACY, |
|
102 |
- PVT_AUTH_DOMAIN, PVT_OTHER, |
|
75 |
+ PVT_MARKER, PVT_AVP, PVT_OTHER, |
|
103 | 76 |
PVT_EXTRA /* keep it last */ |
104 | 77 |
}; |
105 | 78 |
|
- to include only PV and transformation API, no implementation
- (still learning GIT to do it in one step :-) )
... | ... |
@@ -1,38 +1,74 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
2 |
+ * $Id: items.h 2111 2007-05-01 11:18:08Z juhe $ |
|
3 | 3 |
* |
4 |
- * Copyright (C) 2008 |
|
4 |
+ * Copyright (C) 2001-2003 FhG Fokus |
|
5 | 5 |
* |
6 |
- * Permission to use, copy, modify, and distribute this software for any |
|
7 |
- * purpose with or without fee is hereby granted, provided that the above |
|
8 |
- * copyright notice and this permission notice appear in all copies. |
|
6 |
+ * This file is part of Kamailio, a free SIP server. |
|
9 | 7 |
* |
10 |
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
11 |
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
12 |
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
13 |
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
14 |
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
15 |
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
16 |
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
17 |
- */ |
|
18 |
-/* |
|
19 |
- * pvar compatibility wrapper for kamailio |
|
20 |
- * for now it doesn't do anything (feel free to rm & replace the file) |
|
8 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
9 |
+ * it under the terms of the GNU General Public License as published by |
|
10 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
11 |
+ * (at your option) any later version |
|
12 |
+ * |
|
13 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
14 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
+ * GNU General Public License for more details. |
|
21 | 17 |
* |
22 |
- * History: |
|
23 |
- * -------- |
|
24 |
- * 2008-11-17 initial version compatible with kamailio pvar.h (andrei) |
|
18 |
+ * You should have received a copy of the GNU General Public License |
|
19 |
+ * along with this program; if not, write to the Free Software |
|
20 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+/*! |
|
24 |
+ * \file |
|
25 |
+ * \brief Definitions for Pseudo-variable support |
|
25 | 26 |
*/ |
26 | 27 |
|
27 |
-#ifndef _pvar_h_ |
|
28 |
-#define _pvar_h_ |
|
28 |
+ |
|
29 |
+#ifndef _PVAR_H_ |
|
30 |
+#define _PVAR_H_ |
|
29 | 31 |
|
30 | 32 |
#include "str.h" |
31 | 33 |
#include "usr_avp.h" |
32 | 34 |
#include "parser/msg_parser.h" |
33 | 35 |
|
36 |
+#define PV_MARKER_STR "$" |
|
37 |
+#define PV_MARKER '$' |
|
38 |
+ |
|
39 |
+#define PV_LNBRACKET_STR "(" |
|
40 |
+#define PV_LNBRACKET '(' |
|
41 |
+#define PV_RNBRACKET_STR ")" |
|
42 |
+#define PV_RNBRACKET ')' |
|
43 |
+ |
|
44 |
+#define PV_LIBRACKET_STR "[" |
|
45 |
+#define PV_LIBRACKET '[' |
|
46 |
+#define PV_RIBRACKET_STR "]" |
|
47 |
+#define PV_RIBRACKET ']' |
|
48 |
+ |
|
49 |
+#define PV_VAL_NONE 0 |
|
50 |
+#define PV_VAL_NULL 1 |
|
51 |
+#define PV_VAL_EMPTY 2 |
|
52 |
+#define PV_VAL_STR 4 |
|
53 |
+#define PV_VAL_INT 8 |
|
54 |
+#define PV_TYPE_INT 16 |
|
55 |
+#define PV_VAL_PKG 32 |
|
56 |
+#define PV_VAL_SHM 64 |
|
34 | 57 |
|
58 |
+#define PV_NAME_INTSTR 0 |
|
59 |
+#define PV_NAME_PVAR 1 |
|
35 | 60 |
|
61 |
+#define PV_IDX_INT 0 |
|
62 |
+#define PV_IDX_PVAR 1 |
|
63 |
+#define PV_IDX_ALL 2 |
|
64 |
+ |
|
65 |
+/*! if PV name is dynamic, integer, or str */ |
|
66 |
+#define pv_has_dname(pv) ((pv)->pvp.pvn.type==PV_NAME_PVAR) |
|
67 |
+#define pv_has_iname(pv) ((pv)->pvp.pvn.type==PV_NAME_INTSTR \ |
|
68 |
+ && !((pv)->pvp.pvn.u.isname.type&AVP_NAME_STR)) |
|
69 |
+#define pv_has_sname(pv) ((pv)->pvp.pvn.type==PV_NAME_INTSTR \ |
|
70 |
+ && (pv)->pvp.pvn.u.isname.type&AVP_NAME_STR) |
|
71 |
+#define pv_is_w(pv) ((pv)->setf!=NULL) |
|
36 | 72 |
|
37 | 73 |
enum _pv_type { |
38 | 74 |
PVT_NONE=0, PVT_EMPTY, PVT_NULL, |
... | ... |
@@ -63,12 +99,14 @@ enum _pv_type { |
63 | 99 |
PVT_ERR_INFO, PVT_ERR_RCODE, PVT_ERR_RREASON, |
64 | 100 |
PVT_SCRIPTVAR, PVT_PROTO, PVT_AUTH_USERNAME_WHOLE, |
65 | 101 |
PVT_AUTH_DURI, PVT_DIV_REASON, PVT_DIV_PRIVACY, |
66 |
- PVT_AUTH_DOMAIN, PVT_EXTRA /* keep it last */ |
|
102 |
+ PVT_AUTH_DOMAIN, PVT_OTHER, |
|
103 |
+ PVT_EXTRA /* keep it last */ |
|
67 | 104 |
}; |
68 | 105 |
|
69 | 106 |
typedef enum _pv_type pv_type_t; |
70 | 107 |
typedef int pv_flags_t; |
71 | 108 |
|
109 |
+ |
|
72 | 110 |
typedef struct _pv_value |
73 | 111 |
{ |
74 | 112 |
str rs; /*!< string value */ |
... | ... |
@@ -114,8 +152,6 @@ typedef struct _pv_spec { |
114 | 152 |
void *trans; /*!< transformations */ |
115 | 153 |
} pv_spec_t, *pv_spec_p; |
116 | 154 |
|
117 |
- |
|
118 |
- |
|
119 | 155 |
typedef int (*pv_parse_name_f)(pv_spec_p sp, str *in); |
120 | 156 |
typedef int (*pv_parse_index_f)(pv_spec_p sp, str *in); |
121 | 157 |
typedef int (*pv_init_param_f)(pv_spec_p sp, int param); |
... | ... |
@@ -142,4 +178,103 @@ typedef struct _pv_export { |
142 | 178 |
int iparam; /*!< parameter for the init function */ |
143 | 179 |
} pv_export_t; |
144 | 180 |
|
145 |
-#endif /* _pvar_h_ */ |
|
181 |
+typedef struct _pv_elem |
|
182 |
+{ |
|
183 |
+ str text; |
|
184 |
+ pv_spec_t spec; |
|
185 |
+ struct _pv_elem *next; |
|
186 |
+} pv_elem_t, *pv_elem_p; |
|
187 |
+ |
|
188 |
+char* pv_parse_spec(str *in, pv_spec_p sp); |
|
189 |
+int pv_get_spec_value(struct sip_msg* msg, pv_spec_p sp, pv_value_t *value); |
|
190 |
+int pv_print_spec(struct sip_msg* msg, pv_spec_p sp, char *buf, int *len); |
|
191 |
+int pv_printf(struct sip_msg* msg, pv_elem_p list, char *buf, int *len); |
|
192 |
+int pv_elem_free_all(pv_elem_p log); |
|
193 |
+void pv_value_destroy(pv_value_t *val); |
|
194 |
+void pv_spec_free(pv_spec_t *spec); |
|
195 |
+int pv_spec_dbg(pv_spec_p sp); |
|
196 |
+int pv_get_spec_index(struct sip_msg* msg, pv_param_p ip, int *idx, int *flags); |
|
197 |
+int pv_get_avp_name(struct sip_msg* msg, pv_param_p ip, int_str *avp_name, |
|
198 |
+ unsigned short *name_type); |
|
199 |
+int pv_get_spec_name(struct sip_msg* msg, pv_param_p ip, pv_value_t *name); |
|
200 |
+int pv_parse_format(str *in, pv_elem_p *el); |
|
201 |
+int pv_init_iname(pv_spec_p sp, int param); |
|
202 |
+int pv_printf_s(struct sip_msg* msg, pv_elem_p list, str *s); |
|
203 |
+ |
|
204 |
+typedef struct _pvname_list { |
|
205 |
+ pv_spec_t sname; |
|
206 |
+ struct _pvname_list *next; |
|
207 |
+} pvname_list_t, *pvname_list_p; |
|
208 |
+ |
|
209 |
+typedef struct pv_spec_list { |
|
210 |
+ pv_spec_p spec; |
|
211 |
+ struct pv_spec_list *next; |
|
212 |
+} pv_spec_list_t, *pv_spec_list_p; |
|
213 |
+ |
|
214 |
+pvname_list_t* parse_pvname_list(str *in, unsigned int type); |
|
215 |
+ |
|
216 |