1 /**
2 * Copyright (C) 2016 Daniel-Constantin Mierla (asipto.com)
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 #include <stdio.h>
22 #include <unistd.h>
23 #include <stdlib.h>
24
25 #include <Python.h>
26 #include <frameobject.h>
27
28 #include "../../core/dprint.h"
29 #include "../../core/route.h"
30 #include "../../core/fmsg.h"
31 #include "../../core/kemi.h"
32 #include "../../core/pvar.h"
33 #include "../../core/timer.h"
34 #include "../../core/mem/pkg.h"
35 #include "../../core/mem/shm.h"
36 #include "../../core/rpc.h"
37 #include "../../core/rpc_lookup.h"
38
39 #include "msgobj_struct.h"
40 #include "python_exec.h"
41 #include "apy_kemi_export.h"
42 #include "apy_kemi.h"
43
44 int *_sr_python_reload_version = NULL;
45 int _sr_python_local_version = 0;
46 extern str _sr_python_load_file;
47 extern int _apy_process_rank;
48
49 /**
50 *
51 */
sr_kemi_config_engine_python(sip_msg_t * msg,int rtype,str * rname,str * rparam)52 int sr_kemi_config_engine_python(sip_msg_t *msg, int rtype, str *rname,
53 str *rparam)
54 {
55 int ret;
56
57 ret = -1;
58 if(rtype==REQUEST_ROUTE) {
59 if(rname!=NULL && rname->s!=NULL) {
60 ret = apy_exec(msg, rname->s,
61 (rparam && rparam->s)?rparam->s:NULL, 0);
62 } else {
63 ret = apy_exec(msg, "ksr_request_route", NULL, 1);
64 }
65 } else if(rtype==CORE_ONREPLY_ROUTE) {
66 if(kemi_reply_route_callback.len>0) {
67 ret = apy_exec(msg, kemi_reply_route_callback.s, NULL, 0);
68 }
69 } else if(rtype==BRANCH_ROUTE) {
70 if(rname!=NULL && rname->s!=NULL) {
71 ret = apy_exec(msg, rname->s, NULL, 0);
72 }
73 } else if(rtype==FAILURE_ROUTE) {
74 if(rname!=NULL && rname->s!=NULL) {
75 ret = apy_exec(msg, rname->s, NULL, 0);
76 }
77 } else if(rtype==BRANCH_FAILURE_ROUTE) {
78 if(rname!=NULL && rname->s!=NULL) {
79 ret = apy_exec(msg, rname->s, NULL, 0);
80 }
81 } else if(rtype==TM_ONREPLY_ROUTE) {
82 if(rname!=NULL && rname->s!=NULL) {
83 ret = apy_exec(msg, rname->s, NULL, 0);
84 }
85 } else if(rtype==ONSEND_ROUTE) {
86 if(kemi_onsend_route_callback.len>0) {
87 ret = apy_exec(msg, kemi_onsend_route_callback.s, NULL, 0);
88 }
89 return 1;
90 } else if(rtype==EVENT_ROUTE) {
91 if(rname!=NULL && rname->s!=NULL) {
92 ret = apy_exec(msg, rname->s,
93 (rparam && rparam->s)?rparam->s:NULL, 0);
94 }
95 } else {
96 if(rname!=NULL) {
97 LM_ERR("route type %d with name [%.*s] not implemented\n",
98 rtype, rname->len, rname->s);
99 } else {
100 LM_ERR("route type %d with no name not implemented\n",
101 rtype);
102 }
103 }
104
105 if(rname!=NULL) {
106 LM_DBG("execution of route type %d with name [%.*s] returned %d\n",
107 rtype, rname->len, rname->s, ret);
108 } else {
109 LM_DBG("execution of route type %d with no name returned %d\n",
110 rtype, ret);
111 }
112
113 return 1;
114 }
115
116 /**
117 *
118 */
sr_kemi_apy_return_true(void)119 PyObject *sr_kemi_apy_return_true(void)
120 {
121 Py_INCREF(Py_True);
122 return Py_True;
123 }
124
125 /**
126 *
127 */
sr_kemi_apy_return_false(void)128 PyObject *sr_kemi_apy_return_false(void)
129 {
130 Py_INCREF(Py_False);
131 return Py_False;
132 }
133
134 /**
135 *
136 */
sr_apy_kemi_return_none(void)137 PyObject *sr_apy_kemi_return_none(void)
138 {
139 Py_INCREF(Py_None);
140 return Py_None;
141 }
142
143 /**
144 *
145 */
sr_kemi_apy_return_int(sr_kemi_t * ket,int rval)146 PyObject *sr_kemi_apy_return_int(sr_kemi_t *ket, int rval)
147 {
148 if(ket!=NULL && ket->rtype==SR_KEMIP_BOOL) {
149 if(rval==SR_KEMI_TRUE) {
150 return sr_kemi_apy_return_true();
151 } else {
152 return sr_kemi_apy_return_false();
153 }
154 }
155 return PyInt_FromLong((long)rval);
156 }
157
158 /**
159 *
160 */
sr_apy_kemi_return_str(sr_kemi_t * ket,char * sval,int slen)161 PyObject *sr_apy_kemi_return_str(sr_kemi_t *ket, char *sval, int slen)
162 {
163 return PyString_FromStringAndSize(sval, slen);
164 }
165
166 /**
167 *
168 */
sr_kemi_apy_return_xval(sr_kemi_t * ket,sr_kemi_xval_t * rx)169 PyObject *sr_kemi_apy_return_xval(sr_kemi_t *ket, sr_kemi_xval_t *rx)
170 {
171 switch(rx->vtype) {
172 case SR_KEMIP_NONE:
173 return sr_apy_kemi_return_none();
174 case SR_KEMIP_INT:
175 return sr_kemi_apy_return_int(ket, rx->v.n);
176 case SR_KEMIP_STR:
177 return sr_apy_kemi_return_str(ket, rx->v.s.s, rx->v.s.len);
178 case SR_KEMIP_BOOL:
179 if(rx->v.n!=SR_KEMI_FALSE) {
180 return sr_kemi_apy_return_true();
181 } else {
182 return sr_kemi_apy_return_false();
183 }
184 case SR_KEMIP_ARRAY:
185 LM_ERR("unsupported return type: array\n");
186 sr_kemi_xval_free(rx);
187 return sr_apy_kemi_return_none();
188 case SR_KEMIP_DICT:
189 LM_ERR("unsupported return type: map\n");
190 sr_kemi_xval_free(rx);
191 return sr_apy_kemi_return_none();
192 case SR_KEMIP_XVAL:
193 /* unknown content - return false */
194 return sr_kemi_apy_return_false();
195 case SR_KEMIP_NULL:
196 return sr_apy_kemi_return_none();
197 default:
198 /* unknown type - return false */
199 return sr_kemi_apy_return_false();
200 }
201 }
202
203 /**
204 *
205 */
sr_apy_kemi_exec_func_ex(sr_kemi_t * ket,PyObject * self,PyObject * args,int idx)206 PyObject *sr_apy_kemi_exec_func_ex(sr_kemi_t *ket, PyObject *self,
207 PyObject *args, int idx)
208 {
209 str fname;
210 int i;
211 int ret;
212 sr_kemi_val_t vps[SR_KEMI_PARAMS_MAX];
213 sr_apy_env_t *env_P;
214 sip_msg_t *lmsg = NULL;
215 sr_kemi_xval_t *xret;
216
217 env_P = sr_apy_env_get();
218
219 if(env_P==NULL) {
220 LM_ERR("invalid Python environment attributes\n");
221 return sr_kemi_apy_return_false();
222 }
223 if(env_P->msg==NULL) {
224 lmsg = faked_msg_next();
225 } else {
226 lmsg = env_P->msg;
227 }
228
229 if(ket->mname.len>0) {
230 LM_DBG("execution of method: %.*s\n", ket->fname.len, ket->fname.s);
231 } else {
232 LM_DBG("execution of method: %.*s.%.*s\n",
233 ket->mname.len, ket->mname.s,
234 ket->fname.len, ket->fname.s);
235 }
236 fname = ket->fname;
237
238 if(ket->ptypes[0]==SR_KEMIP_NONE) {
239 if(ket->rtype==SR_KEMIP_XVAL) {
240 xret = ((sr_kemi_xfm_f)(ket->func))(lmsg);
241 return sr_kemi_apy_return_xval(ket, xret);
242 } else {
243 ret = ((sr_kemi_fm_f)(ket->func))(lmsg);
244 return sr_kemi_apy_return_int(ket, ret);
245 }
246 }
247
248 memset(vps, 0, SR_KEMI_PARAMS_MAX*sizeof(sr_kemi_val_t));
249 if(ket->ptypes[1]==SR_KEMIP_NONE) {
250 i = 1;
251 if(ket->ptypes[0]==SR_KEMIP_INT) {
252 if(!PyArg_ParseTuple(args, "i:kemi-param-n", &vps[0].n)) {
253 LM_ERR("unable to retrieve int param %d\n", 0);
254 return sr_kemi_apy_return_false();
255 }
256 LM_DBG("param[%d] for: %.*s is int: %d\n", i,
257 fname.len, fname.s, vps[0].n);
258 } else {
259 if(!PyArg_ParseTuple(args, "s:kemi-param-s", &vps[0].s.s)) {
260 LM_ERR("unable to retrieve str param %d\n", 0);
261 return sr_kemi_apy_return_false();
262 }
263 vps[0].s.len = strlen(vps[0].s.s);
264 LM_DBG("param[%d] for: %.*s is str: %.*s\n", i,
265 fname.len, fname.s, vps[0].s.len, vps[0].s.s);
266 }
267 } else if(ket->ptypes[2]==SR_KEMIP_NONE) {
268 i = 2;
269 if(ket->ptypes[0]==SR_KEMIP_INT && ket->ptypes[1]==SR_KEMIP_INT) {
270 if(!PyArg_ParseTuple(args, "ii:kemi-param-nn", &vps[0].n, &vps[1].n)) {
271 LM_ERR("unable to retrieve int-int params %d\n", i);
272 return sr_kemi_apy_return_false();
273 }
274 LM_DBG("params[%d] for: %.*s are int-int: [%d] [%d]\n", i,
275 fname.len, fname.s, vps[0].n, vps[1].n);
276 } else if(ket->ptypes[0]==SR_KEMIP_INT && ket->ptypes[1]==SR_KEMIP_STR) {
277 if(!PyArg_ParseTuple(args, "is:kemi-param-ns", &vps[0].n, &vps[1].s.s)) {
278 LM_ERR("unable to retrieve int-str params %d\n", i);
279 return sr_kemi_apy_return_false();
280 }
281 vps[1].s.len = strlen(vps[1].s.s);
282 LM_DBG("params[%d] for: %.*s are int-str: [%d] [%.*s]\n", i,
283 fname.len, fname.s, vps[0].n, vps[1].s.len, vps[1].s.s);
284 } else if(ket->ptypes[0]==SR_KEMIP_STR && ket->ptypes[1]==SR_KEMIP_INT) {
285 if(!PyArg_ParseTuple(args, "si:kemi-param-sn", &vps[0].s.s, &vps[1].n)) {
286 LM_ERR("unable to retrieve str-int params %d\n", i);
287 return sr_kemi_apy_return_false();
288 }
289 vps[0].s.len = strlen(vps[0].s.s);
290 LM_DBG("params[%d] for: %.*s are str-int: [%.*s] [%d]\n", i,
291 fname.len, fname.s, vps[0].s.len, vps[0].s.s, vps[1].n);
292 } else {
293 if(!PyArg_ParseTuple(args, "ss:kemi-param-ss", &vps[0].s.s, &vps[1].s.s)) {
294 LM_ERR("unable to retrieve str-str param %d\n", i);
295 return sr_kemi_apy_return_false();
296 }
297 vps[0].s.len = strlen(vps[0].s.s);
298 vps[1].s.len = strlen(vps[1].s.s);
299 LM_DBG("params[%d] for: %.*s are str: [%.*s] [%.*s]\n", i,
300 fname.len, fname.s, vps[0].s.len, vps[0].s.s,
301 vps[1].s.len, vps[1].s.s);
302 }
303
304 } else if(ket->ptypes[3]==SR_KEMIP_NONE) {
305 i = 3;
306 if(ket->ptypes[0]==SR_KEMIP_INT && ket->ptypes[1]==SR_KEMIP_INT
307 && ket->ptypes[2]==SR_KEMIP_INT) {
308 if(!PyArg_ParseTuple(args, "iii:kemi-param-nnn", &vps[0].n,
309 &vps[1].n, &vps[2].n)) {
310 LM_ERR("unable to retrieve int-int-int params %d\n", i);
311 return sr_kemi_apy_return_false();
312 }
313 LM_DBG("params[%d] for: %.*s are int-int-int: [%d] [%d] [%d]\n",
314 i, fname.len, fname.s, vps[0].n, vps[1].n, vps[2].n);
315 } else if(ket->ptypes[0]==SR_KEMIP_INT && ket->ptypes[1]==SR_KEMIP_INT
316 && ket->ptypes[2]==SR_KEMIP_STR) {
317 if(!PyArg_ParseTuple(args, "iis:kemi-param-nns", &vps[0].n,
318 &vps[1].n, &vps[2].s.s)) {
319 LM_ERR("unable to retrieve int-int-str params %d\n", i);
320 return sr_kemi_apy_return_false();
321 }
322 vps[2].s.len = strlen(vps[2].s.s);
323 LM_DBG("params[%d] for: %.*s are int-int-str: [%d] [%d] [%.*s]\n", i,
324 fname.len, fname.s, vps[0].n, vps[1].n, vps[2].s.len, vps[2].s.s);
325 } else if(ket->ptypes[0]==SR_KEMIP_INT && ket->ptypes[1]==SR_KEMIP_STR
326 && ket->ptypes[2]==SR_KEMIP_INT) {
327 if(!PyArg_ParseTuple(args, "isi:kemi-param-nsn", &vps[0].n,
328 &vps[1].s.s, &vps[2].n)) {
329 LM_ERR("unable to retrieve int-str-int params %d\n", i);
330 return sr_kemi_apy_return_false();
331 }
332 vps[1].s.len = strlen(vps[1].s.s);
333 LM_DBG("params[%d] for: %.*s are int-str-int: [%d] [%.*s] [%d]\n", i,
334 fname.len, fname.s, vps[0].n, vps[1].s.len, vps[1].s.s, vps[2].n);
335 } else if(ket->ptypes[0]==SR_KEMIP_INT && ket->ptypes[1]==SR_KEMIP_STR
336 && ket->ptypes[2]==SR_KEMIP_STR) {
337 if(!PyArg_ParseTuple(args, "iss:kemi-param-nss", &vps[0].n,
338 &vps[1].s.s, &vps[2].s.s)) {
339 LM_ERR("unable to retrieve int-str-str param %d\n", i);
340 return sr_kemi_apy_return_false();
341 }
342 vps[1].s.len = strlen(vps[1].s.s);
343 vps[2].s.len = strlen(vps[2].s.s);
344 LM_DBG("params[%d] for: %.*s are int-str-str: [%d] [%.*s]"
345 " [%.*s]\n", i, fname.len, fname.s,
346 vps[0].n, vps[1].s.len, vps[1].s.s, vps[2].s.len, vps[2].s.s);
347 } else if(ket->ptypes[0]==SR_KEMIP_STR && ket->ptypes[1]==SR_KEMIP_INT
348 && ket->ptypes[2]==SR_KEMIP_INT) {
349 if(!PyArg_ParseTuple(args, "sii:kemi-param-snn", &vps[0].s.s,
350 &vps[1].n, &vps[2].n)) {
351 LM_ERR("unable to retrieve str-int-int params %d\n", i);
352 return sr_kemi_apy_return_false();
353 }
354 vps[0].s.len = strlen(vps[0].s.s);
355 LM_DBG("params[%d] for: %.*s are str-int: [%.*s] [%d] [%d]\n", i,
356 fname.len, fname.s, vps[0].s.len, vps[0].s.s, vps[1].n,
357 vps[2].n);
358 } else if(ket->ptypes[0]==SR_KEMIP_STR && ket->ptypes[1]==SR_KEMIP_INT
359 && ket->ptypes[2]==SR_KEMIP_STR) {
360 if(!PyArg_ParseTuple(args, "sis:kemi-param-ssn", &vps[0].s.s,
361 &vps[1].n, &vps[2].s.s)) {
362 LM_ERR("unable to retrieve str-int-str param %d\n", i);
363 return sr_kemi_apy_return_false();
364 }
365 vps[0].s.len = strlen(vps[0].s.s);
366 vps[2].s.len = strlen(vps[2].s.s);
367 LM_DBG("params[%d] for: %.*s are str-str-int: [%.*s] [%d] [%.*s]\n",
368 i, fname.len, fname.s,
369 vps[0].s.len, vps[0].s.s,
370 vps[1].n, vps[2].s.len, vps[2].s.s);
371 } else if(ket->ptypes[0]==SR_KEMIP_STR && ket->ptypes[1]==SR_KEMIP_STR
372 && ket->ptypes[2]==SR_KEMIP_INT) {
373 if(!PyArg_ParseTuple(args, "ssi:kemi-param-ssn", &vps[0].s.s,
374 &vps[1].s.s, &vps[2].n)) {
375 LM_ERR("unable to retrieve str-str-int param %d\n", i);
376 return sr_kemi_apy_return_false();
377 }
378 vps[0].s.len = strlen(vps[0].s.s);
379 vps[1].s.len = strlen(vps[1].s.s);
380 LM_DBG("params[%d] for: %.*s are str-str-int: [%.*s] [%.*s]"
381 " [%d]\n", i, fname.len, fname.s,
382 vps[0].s.len, vps[0].s.s,
383 vps[1].s.len, vps[1].s.s, vps[2].n);
384 } else if(ket->ptypes[0]==SR_KEMIP_STR && ket->ptypes[1]==SR_KEMIP_STR
385 && ket->ptypes[2]==SR_KEMIP_STR) {
386 if(!PyArg_ParseTuple(args, "sss:kemi-param-sss", &vps[0].s.s,
387 &vps[1].s.s, &vps[2].s.s)) {
388 LM_ERR("unable to retrieve str-str-str param %d\n", i);
389 return sr_kemi_apy_return_false();
390 }
391 vps[0].s.len = strlen(vps[0].s.s);
392 vps[1].s.len = strlen(vps[1].s.s);
393 vps[2].s.len = strlen(vps[2].s.s);
394 LM_DBG("params[%d] for: %.*s are str-str-str: [%.*s] [%.*s]"
395 " [%.*s]\n", i, fname.len, fname.s,
396 vps[0].s.len, vps[0].s.s,
397 vps[1].s.len, vps[1].s.s, vps[2].s.len, vps[2].s.s);
398 } else {
399 LM_ERR("not implemented yet\n");
400 return sr_kemi_apy_return_false();
401 }
402 } else if(ket->ptypes[4]==SR_KEMIP_NONE) {
403 i = 4;
404 if(ket->ptypes[0]==SR_KEMIP_STR
405 && ket->ptypes[1]==SR_KEMIP_STR
406 && ket->ptypes[2]==SR_KEMIP_STR
407 && ket->ptypes[3]==SR_KEMIP_STR) {
408 if(!PyArg_ParseTuple(args, "ssss:kemi-param-ssss",
409 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s)) {
410 LM_ERR("unable to retrieve ssss params %d\n", i);
411 return sr_kemi_apy_return_false();
412 }
413 vps[0].s.len = strlen(vps[0].s.s);
414 vps[1].s.len = strlen(vps[1].s.s);
415 vps[2].s.len = strlen(vps[2].s.s);
416 vps[3].s.len = strlen(vps[3].s.s);
417
418 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%s] [%s]\n",
419 i, fname.len, fname.s,
420 vps[0].s.s, vps[1].s.s, vps[2].s.s, vps[3].s.s);
421 } else if(ket->ptypes[0]==SR_KEMIP_STR
422 && ket->ptypes[1]==SR_KEMIP_STR
423 && ket->ptypes[2]==SR_KEMIP_STR
424 && ket->ptypes[3]==SR_KEMIP_INT) {
425 if(!PyArg_ParseTuple(args, "sssn:kemi-param-sssn",
426 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].n)) {
427 LM_ERR("unable to retrieve sssn params %d\n", i);
428 return sr_kemi_apy_return_false();
429 }
430 vps[0].s.len = strlen(vps[0].s.s);
431 vps[1].s.len = strlen(vps[1].s.s);
432 vps[2].s.len = strlen(vps[2].s.s);
433
434 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%s] [%d]\n",
435 i, fname.len, fname.s,
436 vps[0].s.s, vps[1].s.s, vps[2].s.s, vps[3].n);
437 } else if(ket->ptypes[0]==SR_KEMIP_STR
438 && ket->ptypes[1]==SR_KEMIP_STR
439 && ket->ptypes[2]==SR_KEMIP_INT
440 && ket->ptypes[3]==SR_KEMIP_STR) {
441 if(!PyArg_ParseTuple(args, "ssns:kemi-param-ssns",
442 &vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].s.s)) {
443 LM_ERR("unable to retrieve ssns params %d\n", i);
444 return sr_kemi_apy_return_false();
445 }
446 vps[0].s.len = strlen(vps[0].s.s);
447 vps[1].s.len = strlen(vps[1].s.s);
448 vps[3].s.len = strlen(vps[3].s.s);
449
450 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%d] [%s]\n",
451 i, fname.len, fname.s,
452 vps[0].s.s, vps[1].s.s, vps[2].n, vps[3].s.s);
453 } else if(ket->ptypes[0]==SR_KEMIP_STR
454 && ket->ptypes[1]==SR_KEMIP_STR
455 && ket->ptypes[2]==SR_KEMIP_INT
456 && ket->ptypes[3]==SR_KEMIP_INT) {
457 if(!PyArg_ParseTuple(args, "ssnn:kemi-param-ssnn",
458 &vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].n)) {
459 LM_ERR("unable to retrieve ssnn params %d\n", i);
460 return sr_kemi_apy_return_false();
461 }
462 vps[0].s.len = strlen(vps[0].s.s);
463 vps[1].s.len = strlen(vps[1].s.s);
464
465 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%d] [%d]\n",
466 i, fname.len, fname.s,
467 vps[0].s.s, vps[1].s.s, vps[2].n, vps[3].n);
468 } else if(ket->ptypes[0]==SR_KEMIP_STR
469 && ket->ptypes[1]==SR_KEMIP_INT
470 && ket->ptypes[2]==SR_KEMIP_STR
471 && ket->ptypes[3]==SR_KEMIP_STR) {
472 if(!PyArg_ParseTuple(args, "snss:kemi-param-snss",
473 &vps[0].s.s, &vps[1].n, &vps[2].s.s, &vps[3].s.s)) {
474 LM_ERR("unable to retrieve snss params %d\n", i);
475 return sr_kemi_apy_return_false();
476 }
477 vps[0].s.len = strlen(vps[0].s.s);
478 vps[2].s.len = strlen(vps[2].s.s);
479 vps[3].s.len = strlen(vps[3].s.s);
480
481 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%s] [%s]\n",
482 i, fname.len, fname.s,
483 vps[0].s.s, vps[1].n, vps[2].s.s, vps[3].s.s);
484 } else if(ket->ptypes[0]==SR_KEMIP_STR
485 && ket->ptypes[1]==SR_KEMIP_INT
486 && ket->ptypes[2]==SR_KEMIP_STR
487 && ket->ptypes[3]==SR_KEMIP_INT) {
488 if(!PyArg_ParseTuple(args, "snsn:kemi-param-snsn",
489 &vps[0].s.s, &vps[1].n, &vps[2].s.s, &vps[3].n)) {
490 LM_ERR("unable to retrieve snsn params %d\n", i);
491 return sr_kemi_apy_return_false();
492 }
493 vps[0].s.len = strlen(vps[0].s.s);
494 vps[2].s.len = strlen(vps[2].s.s);
495
496 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%s] [%d]\n",
497 i, fname.len, fname.s,
498 vps[0].s.s, vps[1].n, vps[2].s.s, vps[3].n);
499 } else if(ket->ptypes[0]==SR_KEMIP_STR
500 && ket->ptypes[1]==SR_KEMIP_INT
501 && ket->ptypes[2]==SR_KEMIP_INT
502 && ket->ptypes[3]==SR_KEMIP_STR) {
503 if(!PyArg_ParseTuple(args, "snns:kemi-param-snns",
504 &vps[0].s.s, &vps[1].n, &vps[2].n, &vps[3].s.s)) {
505 LM_ERR("unable to retrieve snns params %d\n", i);
506 return sr_kemi_apy_return_false();
507 }
508 vps[0].s.len = strlen(vps[0].s.s);
509 vps[3].s.len = strlen(vps[3].s.s);
510
511 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%d] [%s]\n",
512 i, fname.len, fname.s,
513 vps[0].s.s, vps[1].n, vps[2].n, vps[3].s.s);
514 } else if(ket->ptypes[0]==SR_KEMIP_STR
515 && ket->ptypes[1]==SR_KEMIP_INT
516 && ket->ptypes[2]==SR_KEMIP_INT
517 && ket->ptypes[3]==SR_KEMIP_INT) {
518 if(!PyArg_ParseTuple(args, "snnn:kemi-param-snnn",
519 &vps[0].s.s, &vps[1].n, &vps[2].n, &vps[3].n)) {
520 LM_ERR("unable to retrieve snnn params %d\n", i);
521 return sr_kemi_apy_return_false();
522 }
523 vps[0].s.len = strlen(vps[0].s.s);
524
525 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%d] [%d]\n",
526 i, fname.len, fname.s,
527 vps[0].s.s, vps[1].n, vps[2].n, vps[3].n);
528 } else if(ket->ptypes[0]==SR_KEMIP_INT
529 && ket->ptypes[1]==SR_KEMIP_STR
530 && ket->ptypes[2]==SR_KEMIP_STR
531 && ket->ptypes[3]==SR_KEMIP_STR) {
532 if(!PyArg_ParseTuple(args, "nsss:kemi-param-nsss",
533 &vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s)) {
534 LM_ERR("unable to retrieve nsss params %d\n", i);
535 return sr_kemi_apy_return_false();
536 }
537 vps[1].s.len = strlen(vps[1].s.s);
538 vps[2].s.len = strlen(vps[2].s.s);
539 vps[3].s.len = strlen(vps[3].s.s);
540
541 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%s] [%s]\n",
542 i, fname.len, fname.s,
543 vps[0].n, vps[1].s.s, vps[2].s.s, vps[3].s.s);
544 } else if(ket->ptypes[0]==SR_KEMIP_INT
545 && ket->ptypes[1]==SR_KEMIP_STR
546 && ket->ptypes[2]==SR_KEMIP_STR
547 && ket->ptypes[3]==SR_KEMIP_INT) {
548 if(!PyArg_ParseTuple(args, "nssn:kemi-param-nssn",
549 &vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].n)) {
550 LM_ERR("unable to retrieve nssn params %d\n", i);
551 return sr_kemi_apy_return_false();
552 }
553 vps[1].s.len = strlen(vps[1].s.s);
554 vps[2].s.len = strlen(vps[2].s.s);
555
556 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%s] [%d]\n",
557 i, fname.len, fname.s,
558 vps[0].n, vps[1].s.s, vps[2].s.s, vps[3].n);
559 } else if(ket->ptypes[0]==SR_KEMIP_INT
560 && ket->ptypes[1]==SR_KEMIP_STR
561 && ket->ptypes[2]==SR_KEMIP_INT
562 && ket->ptypes[3]==SR_KEMIP_STR) {
563 if(!PyArg_ParseTuple(args, "nsns:kemi-param-nsns",
564 &vps[0].n, &vps[1].s.s, &vps[2].n, &vps[3].s.s)) {
565 LM_ERR("unable to retrieve nsns params %d\n", i);
566 return sr_kemi_apy_return_false();
567 }
568 vps[1].s.len = strlen(vps[1].s.s);
569 vps[3].s.len = strlen(vps[3].s.s);
570
571 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%d] [%s]\n",
572 i, fname.len, fname.s,
573 vps[0].n, vps[1].s.s, vps[2].n, vps[3].s.s);
574 } else if(ket->ptypes[0]==SR_KEMIP_INT
575 && ket->ptypes[1]==SR_KEMIP_STR
576 && ket->ptypes[2]==SR_KEMIP_INT
577 && ket->ptypes[3]==SR_KEMIP_INT) {
578 if(!PyArg_ParseTuple(args, "nsnn:kemi-param-nsnn",
579 &vps[0].n, &vps[1].s.s, &vps[2].n, &vps[3].n)) {
580 LM_ERR("unable to retrieve nsnn params %d\n", i);
581 return sr_kemi_apy_return_false();
582 }
583 vps[1].s.len = strlen(vps[1].s.s);
584
585 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%d] [%d]\n",
586 i, fname.len, fname.s,
587 vps[0].n, vps[1].s.s, vps[2].n, vps[3].n);
588 } else if(ket->ptypes[0]==SR_KEMIP_INT
589 && ket->ptypes[1]==SR_KEMIP_INT
590 && ket->ptypes[2]==SR_KEMIP_STR
591 && ket->ptypes[3]==SR_KEMIP_STR) {
592 if(!PyArg_ParseTuple(args, "nnss:kemi-param-nnss",
593 &vps[0].n, &vps[1].n, &vps[2].s.s, &vps[3].s.s)) {
594 LM_ERR("unable to retrieve nnss params %d\n", i);
595 return sr_kemi_apy_return_false();
596 }
597 vps[2].s.len = strlen(vps[2].s.s);
598 vps[3].s.len = strlen(vps[3].s.s);
599
600 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%s] [%s]\n",
601 i, fname.len, fname.s,
602 vps[0].n, vps[1].n, vps[2].s.s, vps[3].s.s);
603 } else if(ket->ptypes[0]==SR_KEMIP_INT
604 && ket->ptypes[1]==SR_KEMIP_INT
605 && ket->ptypes[2]==SR_KEMIP_STR
606 && ket->ptypes[3]==SR_KEMIP_INT) {
607 if(!PyArg_ParseTuple(args, "nnsn:kemi-param-nnsn",
608 &vps[0].n, &vps[1].n, &vps[2].s.s, &vps[3].n)) {
609 LM_ERR("unable to retrieve nnsn params %d\n", i);
610 return sr_kemi_apy_return_false();
611 }
612 vps[2].s.len = strlen(vps[2].s.s);
613
614 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%s] [%d]\n",
615 i, fname.len, fname.s,
616 vps[0].n, vps[1].n, vps[2].s.s, vps[3].n);
617 } else if(ket->ptypes[0]==SR_KEMIP_INT
618 && ket->ptypes[1]==SR_KEMIP_INT
619 && ket->ptypes[2]==SR_KEMIP_INT
620 && ket->ptypes[3]==SR_KEMIP_STR) {
621 if(!PyArg_ParseTuple(args, "nnns:kemi-param-nnns",
622 &vps[0].n, &vps[1].n, &vps[2].n, &vps[3].s.s)) {
623 LM_ERR("unable to retrieve nnns params %d\n", i);
624 return sr_kemi_apy_return_false();
625 }
626 vps[3].s.len = strlen(vps[3].s.s);
627
628 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%d] [%s]\n",
629 i, fname.len, fname.s,
630 vps[0].n, vps[1].n, vps[2].n, vps[3].s.s);
631 } else if(ket->ptypes[0]==SR_KEMIP_INT
632 && ket->ptypes[1]==SR_KEMIP_INT
633 && ket->ptypes[2]==SR_KEMIP_INT
634 && ket->ptypes[3]==SR_KEMIP_INT) {
635 if(!PyArg_ParseTuple(args, "nnnn:kemi-param-nnnn",
636 &vps[0].n, &vps[1].n, &vps[2].n, &vps[3].n)) {
637 LM_ERR("unable to retrieve nnnn params %d\n", i);
638 return sr_kemi_apy_return_false();
639 }
640
641 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%d] [%d]\n",
642 i, fname.len, fname.s,
643 vps[0].n, vps[1].n, vps[2].n, vps[3].n);
644 } else {
645 LM_ERR("invalid parameters for: %.*s\n", fname.len, fname.s);
646 return sr_kemi_apy_return_false();
647 }
648 } else if(ket->ptypes[5]==SR_KEMIP_NONE) {
649 i = 5;
650 if(ket->ptypes[0]==SR_KEMIP_STR
651 && ket->ptypes[1]==SR_KEMIP_STR
652 && ket->ptypes[2]==SR_KEMIP_STR
653 && ket->ptypes[3]==SR_KEMIP_STR
654 && ket->ptypes[4]==SR_KEMIP_STR) {
655 if(!PyArg_ParseTuple(args, "sssss:kemi-param-sssss",
656 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s, &vps[4].s.s)) {
657 LM_ERR("unable to retrieve sssss params %d\n", i);
658 return sr_kemi_apy_return_false();
659 }
660 vps[0].s.len = strlen(vps[0].s.s);
661 vps[1].s.len = strlen(vps[1].s.s);
662 vps[2].s.len = strlen(vps[2].s.s);
663 vps[3].s.len = strlen(vps[3].s.s);
664 vps[4].s.len = strlen(vps[4].s.s);
665
666 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%s] [%s] [%s]\n",
667 i, fname.len, fname.s,
668 vps[0].s.s, vps[1].s.s, vps[2].s.s, vps[3].s.s, vps[4].s.s);
669 } else if(ket->ptypes[0]==SR_KEMIP_STR
670 && ket->ptypes[1]==SR_KEMIP_STR
671 && ket->ptypes[2]==SR_KEMIP_STR
672 && ket->ptypes[3]==SR_KEMIP_STR
673 && ket->ptypes[4]==SR_KEMIP_INT) {
674 if(!PyArg_ParseTuple(args, "ssssn:kemi-param-ssssn",
675 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s, &vps[4].n)) {
676 LM_ERR("unable to retrieve ssssn params %d\n", i);
677 return sr_kemi_apy_return_false();
678 }
679 vps[0].s.len = strlen(vps[0].s.s);
680 vps[1].s.len = strlen(vps[1].s.s);
681 vps[2].s.len = strlen(vps[2].s.s);
682 vps[3].s.len = strlen(vps[3].s.s);
683
684 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%s] [%s] [%d]\n",
685 i, fname.len, fname.s,
686 vps[0].s.s, vps[1].s.s, vps[2].s.s, vps[3].s.s, vps[4].n);
687 } else if(ket->ptypes[0]==SR_KEMIP_STR
688 && ket->ptypes[1]==SR_KEMIP_STR
689 && ket->ptypes[2]==SR_KEMIP_STR
690 && ket->ptypes[3]==SR_KEMIP_INT
691 && ket->ptypes[4]==SR_KEMIP_STR) {
692 if(!PyArg_ParseTuple(args, "sssns:kemi-param-sssns",
693 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].n, &vps[4].s.s)) {
694 LM_ERR("unable to retrieve sssns params %d\n", i);
695 return sr_kemi_apy_return_false();
696 }
697 vps[0].s.len = strlen(vps[0].s.s);
698 vps[1].s.len = strlen(vps[1].s.s);
699 vps[2].s.len = strlen(vps[2].s.s);
700 vps[4].s.len = strlen(vps[4].s.s);
701
702 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%s] [%d] [%s]\n",
703 i, fname.len, fname.s,
704 vps[0].s.s, vps[1].s.s, vps[2].s.s, vps[3].n, vps[4].s.s);
705 } else if(ket->ptypes[0]==SR_KEMIP_STR
706 && ket->ptypes[1]==SR_KEMIP_STR
707 && ket->ptypes[2]==SR_KEMIP_STR
708 && ket->ptypes[3]==SR_KEMIP_INT
709 && ket->ptypes[4]==SR_KEMIP_INT) {
710 if(!PyArg_ParseTuple(args, "sssnn:kemi-param-sssnn",
711 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].n, &vps[4].n)) {
712 LM_ERR("unable to retrieve sssnn params %d\n", i);
713 return sr_kemi_apy_return_false();
714 }
715 vps[0].s.len = strlen(vps[0].s.s);
716 vps[1].s.len = strlen(vps[1].s.s);
717 vps[2].s.len = strlen(vps[2].s.s);
718
719 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%s] [%d] [%d]\n",
720 i, fname.len, fname.s,
721 vps[0].s.s, vps[1].s.s, vps[2].s.s, vps[3].n, vps[4].n);
722 } else if(ket->ptypes[0]==SR_KEMIP_STR
723 && ket->ptypes[1]==SR_KEMIP_STR
724 && ket->ptypes[2]==SR_KEMIP_INT
725 && ket->ptypes[3]==SR_KEMIP_STR
726 && ket->ptypes[4]==SR_KEMIP_STR) {
727 if(!PyArg_ParseTuple(args, "ssnss:kemi-param-ssnss",
728 &vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].s.s, &vps[4].s.s)) {
729 LM_ERR("unable to retrieve ssnss params %d\n", i);
730 return sr_kemi_apy_return_false();
731 }
732 vps[0].s.len = strlen(vps[0].s.s);
733 vps[1].s.len = strlen(vps[1].s.s);
734 vps[3].s.len = strlen(vps[3].s.s);
735 vps[4].s.len = strlen(vps[4].s.s);
736
737 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%d] [%s] [%s]\n",
738 i, fname.len, fname.s,
739 vps[0].s.s, vps[1].s.s, vps[2].n, vps[3].s.s, vps[4].s.s);
740 } else if(ket->ptypes[0]==SR_KEMIP_STR
741 && ket->ptypes[1]==SR_KEMIP_STR
742 && ket->ptypes[2]==SR_KEMIP_INT
743 && ket->ptypes[3]==SR_KEMIP_STR
744 && ket->ptypes[4]==SR_KEMIP_INT) {
745 if(!PyArg_ParseTuple(args, "ssnsn:kemi-param-ssnsn",
746 &vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].s.s, &vps[4].n)) {
747 LM_ERR("unable to retrieve ssnsn params %d\n", i);
748 return sr_kemi_apy_return_false();
749 }
750 vps[0].s.len = strlen(vps[0].s.s);
751 vps[1].s.len = strlen(vps[1].s.s);
752 vps[3].s.len = strlen(vps[3].s.s);
753
754 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%d] [%s] [%d]\n",
755 i, fname.len, fname.s,
756 vps[0].s.s, vps[1].s.s, vps[2].n, vps[3].s.s, vps[4].n);
757 } else if(ket->ptypes[0]==SR_KEMIP_STR
758 && ket->ptypes[1]==SR_KEMIP_STR
759 && ket->ptypes[2]==SR_KEMIP_INT
760 && ket->ptypes[3]==SR_KEMIP_INT
761 && ket->ptypes[4]==SR_KEMIP_STR) {
762 if(!PyArg_ParseTuple(args, "ssnns:kemi-param-ssnns",
763 &vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].n, &vps[4].s.s)) {
764 LM_ERR("unable to retrieve ssnns params %d\n", i);
765 return sr_kemi_apy_return_false();
766 }
767 vps[0].s.len = strlen(vps[0].s.s);
768 vps[1].s.len = strlen(vps[1].s.s);
769 vps[4].s.len = strlen(vps[4].s.s);
770
771 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%d] [%d] [%s]\n",
772 i, fname.len, fname.s,
773 vps[0].s.s, vps[1].s.s, vps[2].n, vps[3].n, vps[4].s.s);
774 } else if(ket->ptypes[0]==SR_KEMIP_STR
775 && ket->ptypes[1]==SR_KEMIP_STR
776 && ket->ptypes[2]==SR_KEMIP_INT
777 && ket->ptypes[3]==SR_KEMIP_INT
778 && ket->ptypes[4]==SR_KEMIP_INT) {
779 if(!PyArg_ParseTuple(args, "ssnnn:kemi-param-ssnnn",
780 &vps[0].s.s, &vps[1].s.s, &vps[2].n, &vps[3].n, &vps[4].n)) {
781 LM_ERR("unable to retrieve ssnnn params %d\n", i);
782 return sr_kemi_apy_return_false();
783 }
784 vps[0].s.len = strlen(vps[0].s.s);
785 vps[1].s.len = strlen(vps[1].s.s);
786
787 LM_DBG("params[%d] for: %.*s are: [%s] [%s] [%d] [%d] [%d]\n",
788 i, fname.len, fname.s,
789 vps[0].s.s, vps[1].s.s, vps[2].n, vps[3].n, vps[4].n);
790 } else if(ket->ptypes[0]==SR_KEMIP_STR
791 && ket->ptypes[1]==SR_KEMIP_INT
792 && ket->ptypes[2]==SR_KEMIP_STR
793 && ket->ptypes[3]==SR_KEMIP_STR
794 && ket->ptypes[4]==SR_KEMIP_STR) {
795 if(!PyArg_ParseTuple(args, "snsss:kemi-param-snsss",
796 &vps[0].s.s, &vps[1].n, &vps[2].s.s, &vps[3].s.s, &vps[4].s.s)) {
797 LM_ERR("unable to retrieve snsss params %d\n", i);
798 return sr_kemi_apy_return_false();
799 }
800 vps[0].s.len = strlen(vps[0].s.s);
801 vps[2].s.len = strlen(vps[2].s.s);
802 vps[3].s.len = strlen(vps[3].s.s);
803 vps[4].s.len = strlen(vps[4].s.s);
804
805 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%s] [%s] [%s]\n",
806 i, fname.len, fname.s,
807 vps[0].s.s, vps[1].n, vps[2].s.s, vps[3].s.s, vps[4].s.s);
808 } else if(ket->ptypes[0]==SR_KEMIP_STR
809 && ket->ptypes[1]==SR_KEMIP_INT
810 && ket->ptypes[2]==SR_KEMIP_STR
811 && ket->ptypes[3]==SR_KEMIP_STR
812 && ket->ptypes[4]==SR_KEMIP_INT) {
813 if(!PyArg_ParseTuple(args, "snssn:kemi-param-snssn",
814 &vps[0].s.s, &vps[1].n, &vps[2].s.s, &vps[3].s.s, &vps[4].n)) {
815 LM_ERR("unable to retrieve snssn params %d\n", i);
816 return sr_kemi_apy_return_false();
817 }
818 vps[0].s.len = strlen(vps[0].s.s);
819 vps[2].s.len = strlen(vps[2].s.s);
820 vps[3].s.len = strlen(vps[3].s.s);
821
822 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%s] [%s] [%d]\n",
823 i, fname.len, fname.s,
824 vps[0].s.s, vps[1].n, vps[2].s.s, vps[3].s.s, vps[4].n);
825 } else if(ket->ptypes[0]==SR_KEMIP_STR
826 && ket->ptypes[1]==SR_KEMIP_INT
827 && ket->ptypes[2]==SR_KEMIP_STR
828 && ket->ptypes[3]==SR_KEMIP_INT
829 && ket->ptypes[4]==SR_KEMIP_STR) {
830 if(!PyArg_ParseTuple(args, "snsns:kemi-param-snsns",
831 &vps[0].s.s, &vps[1].n, &vps[2].s.s, &vps[3].n, &vps[4].s.s)) {
832 LM_ERR("unable to retrieve snsns params %d\n", i);
833 return sr_kemi_apy_return_false();
834 }
835 vps[0].s.len = strlen(vps[0].s.s);
836 vps[2].s.len = strlen(vps[2].s.s);
837 vps[4].s.len = strlen(vps[4].s.s);
838
839 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%s] [%d] [%s]\n",
840 i, fname.len, fname.s,
841 vps[0].s.s, vps[1].n, vps[2].s.s, vps[3].n, vps[4].s.s);
842 } else if(ket->ptypes[0]==SR_KEMIP_STR
843 && ket->ptypes[1]==SR_KEMIP_INT
844 && ket->ptypes[2]==SR_KEMIP_STR
845 && ket->ptypes[3]==SR_KEMIP_INT
846 && ket->ptypes[4]==SR_KEMIP_INT) {
847 if(!PyArg_ParseTuple(args, "snsnn:kemi-param-snsnn",
848 &vps[0].s.s, &vps[1].n, &vps[2].s.s, &vps[3].n, &vps[4].n)) {
849 LM_ERR("unable to retrieve snsnn params %d\n", i);
850 return sr_kemi_apy_return_false();
851 }
852 vps[0].s.len = strlen(vps[0].s.s);
853 vps[2].s.len = strlen(vps[2].s.s);
854
855 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%s] [%d] [%d]\n",
856 i, fname.len, fname.s,
857 vps[0].s.s, vps[1].n, vps[2].s.s, vps[3].n, vps[4].n);
858 } else if(ket->ptypes[0]==SR_KEMIP_STR
859 && ket->ptypes[1]==SR_KEMIP_INT
860 && ket->ptypes[2]==SR_KEMIP_INT
861 && ket->ptypes[3]==SR_KEMIP_STR
862 && ket->ptypes[4]==SR_KEMIP_STR) {
863 if(!PyArg_ParseTuple(args, "snnss:kemi-param-snnss",
864 &vps[0].s.s, &vps[1].n, &vps[2].n, &vps[3].s.s, &vps[4].s.s)) {
865 LM_ERR("unable to retrieve snnss params %d\n", i);
866 return sr_kemi_apy_return_false();
867 }
868 vps[0].s.len = strlen(vps[0].s.s);
869 vps[3].s.len = strlen(vps[3].s.s);
870 vps[4].s.len = strlen(vps[4].s.s);
871
872 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%d] [%s] [%s]\n",
873 i, fname.len, fname.s,
874 vps[0].s.s, vps[1].n, vps[2].n, vps[3].s.s, vps[4].s.s);
875 } else if(ket->ptypes[0]==SR_KEMIP_STR
876 && ket->ptypes[1]==SR_KEMIP_INT
877 && ket->ptypes[2]==SR_KEMIP_INT
878 && ket->ptypes[3]==SR_KEMIP_STR
879 && ket->ptypes[4]==SR_KEMIP_INT) {
880 if(!PyArg_ParseTuple(args, "snnsn:kemi-param-snnsn",
881 &vps[0].s.s, &vps[1].n, &vps[2].n, &vps[3].s.s, &vps[4].n)) {
882 LM_ERR("unable to retrieve snnsn params %d\n", i);
883 return sr_kemi_apy_return_false();
884 }
885 vps[0].s.len = strlen(vps[0].s.s);
886 vps[3].s.len = strlen(vps[3].s.s);
887
888 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%d] [%s] [%d]\n",
889 i, fname.len, fname.s,
890 vps[0].s.s, vps[1].n, vps[2].n, vps[3].s.s, vps[4].n);
891 } else if(ket->ptypes[0]==SR_KEMIP_STR
892 && ket->ptypes[1]==SR_KEMIP_INT
893 && ket->ptypes[2]==SR_KEMIP_INT
894 && ket->ptypes[3]==SR_KEMIP_INT
895 && ket->ptypes[4]==SR_KEMIP_STR) {
896 if(!PyArg_ParseTuple(args, "snnns:kemi-param-snnns",
897 &vps[0].s.s, &vps[1].n, &vps[2].n, &vps[3].n, &vps[4].s.s)) {
898 LM_ERR("unable to retrieve snnns params %d\n", i);
899 return sr_kemi_apy_return_false();
900 }
901 vps[0].s.len = strlen(vps[0].s.s);
902 vps[4].s.len = strlen(vps[4].s.s);
903
904 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%d] [%d] [%s]\n",
905 i, fname.len, fname.s,
906 vps[0].s.s, vps[1].n, vps[2].n, vps[3].n, vps[4].s.s);
907 } else if(ket->ptypes[0]==SR_KEMIP_STR
908 && ket->ptypes[1]==SR_KEMIP_INT
909 && ket->ptypes[2]==SR_KEMIP_INT
910 && ket->ptypes[3]==SR_KEMIP_INT
911 && ket->ptypes[4]==SR_KEMIP_INT) {
912 if(!PyArg_ParseTuple(args, "snnnn:kemi-param-snnnn",
913 &vps[0].s.s, &vps[1].n, &vps[2].n, &vps[3].n, &vps[4].n)) {
914 LM_ERR("unable to retrieve snnnn params %d\n", i);
915 return sr_kemi_apy_return_false();
916 }
917 vps[0].s.len = strlen(vps[0].s.s);
918
919 LM_DBG("params[%d] for: %.*s are: [%s] [%d] [%d] [%d] [%d]\n",
920 i, fname.len, fname.s,
921 vps[0].s.s, vps[1].n, vps[2].n, vps[3].n, vps[4].n);
922 } else if(ket->ptypes[0]==SR_KEMIP_INT
923 && ket->ptypes[1]==SR_KEMIP_STR
924 && ket->ptypes[2]==SR_KEMIP_STR
925 && ket->ptypes[3]==SR_KEMIP_STR
926 && ket->ptypes[4]==SR_KEMIP_STR) {
927 if(!PyArg_ParseTuple(args, "nssss:kemi-param-nssss",
928 &vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s, &vps[4].s.s)) {
929 LM_ERR("unable to retrieve nssss params %d\n", i);
930 return sr_kemi_apy_return_false();
931 }
932 vps[1].s.len = strlen(vps[1].s.s);
933 vps[2].s.len = strlen(vps[2].s.s);
934 vps[3].s.len = strlen(vps[3].s.s);
935 vps[4].s.len = strlen(vps[4].s.s);
936
937 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%s] [%s] [%s]\n",
938 i, fname.len, fname.s,
939 vps[0].n, vps[1].s.s, vps[2].s.s, vps[3].s.s, vps[4].s.s);
940 } else if(ket->ptypes[0]==SR_KEMIP_INT
941 && ket->ptypes[1]==SR_KEMIP_STR
942 && ket->ptypes[2]==SR_KEMIP_STR
943 && ket->ptypes[3]==SR_KEMIP_STR
944 && ket->ptypes[4]==SR_KEMIP_INT) {
945 if(!PyArg_ParseTuple(args, "nsssn:kemi-param-nsssn",
946 &vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s, &vps[4].n)) {
947 LM_ERR("unable to retrieve nsssn params %d\n", i);
948 return sr_kemi_apy_return_false();
949 }
950 vps[1].s.len = strlen(vps[1].s.s);
951 vps[2].s.len = strlen(vps[2].s.s);
952 vps[3].s.len = strlen(vps[3].s.s);
953
954 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%s] [%s] [%d]\n",
955 i, fname.len, fname.s,
956 vps[0].n, vps[1].s.s, vps[2].s.s, vps[3].s.s, vps[4].n);
957 } else if(ket->ptypes[0]==SR_KEMIP_INT
958 && ket->ptypes[1]==SR_KEMIP_STR
959 && ket->ptypes[2]==SR_KEMIP_STR
960 && ket->ptypes[3]==SR_KEMIP_INT
961 && ket->ptypes[4]==SR_KEMIP_STR) {
962 if(!PyArg_ParseTuple(args, "nssns:kemi-param-nssns",
963 &vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].n, &vps[4].s.s)) {
964 LM_ERR("unable to retrieve nssns params %d\n", i);
965 return sr_kemi_apy_return_false();
966 }
967 vps[1].s.len = strlen(vps[1].s.s);
968 vps[2].s.len = strlen(vps[2].s.s);
969 vps[4].s.len = strlen(vps[4].s.s);
970
971 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%s] [%d] [%s]\n",
972 i, fname.len, fname.s,
973 vps[0].n, vps[1].s.s, vps[2].s.s, vps[3].n, vps[4].s.s);
974 } else if(ket->ptypes[0]==SR_KEMIP_INT
975 && ket->ptypes[1]==SR_KEMIP_STR
976 && ket->ptypes[2]==SR_KEMIP_STR
977 && ket->ptypes[3]==SR_KEMIP_INT
978 && ket->ptypes[4]==SR_KEMIP_INT) {
979 if(!PyArg_ParseTuple(args, "nssnn:kemi-param-nssnn",
980 &vps[0].n, &vps[1].s.s, &vps[2].s.s, &vps[3].n, &vps[4].n)) {
981 LM_ERR("unable to retrieve nssnn params %d\n", i);
982 return sr_kemi_apy_return_false();
983 }
984 vps[1].s.len = strlen(vps[1].s.s);
985 vps[2].s.len = strlen(vps[2].s.s);
986
987 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%s] [%d] [%d]\n",
988 i, fname.len, fname.s,
989 vps[0].n, vps[1].s.s, vps[2].s.s, vps[3].n, vps[4].n);
990 } else if(ket->ptypes[0]==SR_KEMIP_INT
991 && ket->ptypes[1]==SR_KEMIP_STR
992 && ket->ptypes[2]==SR_KEMIP_INT
993 && ket->ptypes[3]==SR_KEMIP_STR
994 && ket->ptypes[4]==SR_KEMIP_STR) {
995 if(!PyArg_ParseTuple(args, "nsnss:kemi-param-nsnss",
996 &vps[0].n, &vps[1].s.s, &vps[2].n, &vps[3].s.s, &vps[4].s.s)) {
997 LM_ERR("unable to retrieve nsnss params %d\n", i);
998 return sr_kemi_apy_return_false();
999 }
1000 vps[1].s.len = strlen(vps[1].s.s);
1001 vps[3].s.len = strlen(vps[3].s.s);
1002 vps[4].s.len = strlen(vps[4].s.s);
1003
1004 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%d] [%s] [%s]\n",
1005 i, fname.len, fname.s,
1006 vps[0].n, vps[1].s.s, vps[2].n, vps[3].s.s, vps[4].s.s);
1007 } else if(ket->ptypes[0]==SR_KEMIP_INT
1008 && ket->ptypes[1]==SR_KEMIP_STR
1009 && ket->ptypes[2]==SR_KEMIP_INT
1010 && ket->ptypes[3]==SR_KEMIP_STR
1011 && ket->ptypes[4]==SR_KEMIP_INT) {
1012 if(!PyArg_ParseTuple(args, "nsnsn:kemi-param-nsnsn",
1013 &vps[0].n, &vps[1].s.s, &vps[2].n, &vps[3].s.s, &vps[4].n)) {
1014 LM_ERR("unable to retrieve nsnsn params %d\n", i);
1015 return sr_kemi_apy_return_false();
1016 }
1017 vps[1].s.len = strlen(vps[1].s.s);
1018 vps[3].s.len = strlen(vps[3].s.s);
1019
1020 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%d] [%s] [%d]\n",
1021 i, fname.len, fname.s,
1022 vps[0].n, vps[1].s.s, vps[2].n, vps[3].s.s, vps[4].n);
1023 } else if(ket->ptypes[0]==SR_KEMIP_INT
1024 && ket->ptypes[1]==SR_KEMIP_STR
1025 && ket->ptypes[2]==SR_KEMIP_INT
1026 && ket->ptypes[3]==SR_KEMIP_INT
1027 && ket->ptypes[4]==SR_KEMIP_STR) {
1028 if(!PyArg_ParseTuple(args, "nsnns:kemi-param-nsnns",
1029 &vps[0].n, &vps[1].s.s, &vps[2].n, &vps[3].n, &vps[4].s.s)) {
1030 LM_ERR("unable to retrieve nsnns params %d\n", i);
1031 return sr_kemi_apy_return_false();
1032 }
1033 vps[1].s.len = strlen(vps[1].s.s);
1034 vps[4].s.len = strlen(vps[4].s.s);
1035
1036 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%d] [%d] [%s]\n",
1037 i, fname.len, fname.s,
1038 vps[0].n, vps[1].s.s, vps[2].n, vps[3].n, vps[4].s.s);
1039 } else if(ket->ptypes[0]==SR_KEMIP_INT
1040 && ket->ptypes[1]==SR_KEMIP_STR
1041 && ket->ptypes[2]==SR_KEMIP_INT
1042 && ket->ptypes[3]==SR_KEMIP_INT
1043 && ket->ptypes[4]==SR_KEMIP_INT) {
1044 if(!PyArg_ParseTuple(args, "nsnnn:kemi-param-nsnnn",
1045 &vps[0].n, &vps[1].s.s, &vps[2].n, &vps[3].n, &vps[4].n)) {
1046 LM_ERR("unable to retrieve nsnnn params %d\n", i);
1047 return sr_kemi_apy_return_false();
1048 }
1049 vps[1].s.len = strlen(vps[1].s.s);
1050
1051 LM_DBG("params[%d] for: %.*s are: [%d] [%s] [%d] [%d] [%d]\n",
1052 i, fname.len, fname.s,
1053 vps[0].n, vps[1].s.s, vps[2].n, vps[3].n, vps[4].n);
1054 } else if(ket->ptypes[0]==SR_KEMIP_INT
1055 && ket->ptypes[1]==SR_KEMIP_INT
1056 && ket->ptypes[2]==SR_KEMIP_STR
1057 && ket->ptypes[3]==SR_KEMIP_STR
1058 && ket->ptypes[4]==SR_KEMIP_STR) {
1059 if(!PyArg_ParseTuple(args, "nnsss:kemi-param-nnsss",
1060 &vps[0].n, &vps[1].n, &vps[2].s.s, &vps[3].s.s, &vps[4].s.s)) {
1061 LM_ERR("unable to retrieve nnsss params %d\n", i);
1062 return sr_kemi_apy_return_false();
1063 }
1064 vps[2].s.len = strlen(vps[2].s.s);
1065 vps[3].s.len = strlen(vps[3].s.s);
1066 vps[4].s.len = strlen(vps[4].s.s);
1067
1068 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%s] [%s] [%s]\n",
1069 i, fname.len, fname.s,
1070 vps[0].n, vps[1].n, vps[2].s.s, vps[3].s.s, vps[4].s.s);
1071 } else if(ket->ptypes[0]==SR_KEMIP_INT
1072 && ket->ptypes[1]==SR_KEMIP_INT
1073 && ket->ptypes[2]==SR_KEMIP_STR
1074 && ket->ptypes[3]==SR_KEMIP_STR
1075 && ket->ptypes[4]==SR_KEMIP_INT) {
1076 if(!PyArg_ParseTuple(args, "nnssn:kemi-param-nnssn",
1077 &vps[0].n, &vps[1].n, &vps[2].s.s, &vps[3].s.s, &vps[4].n)) {
1078 LM_ERR("unable to retrieve nnssn params %d\n", i);
1079 return sr_kemi_apy_return_false();
1080 }
1081 vps[2].s.len = strlen(vps[2].s.s);
1082 vps[3].s.len = strlen(vps[3].s.s);
1083
1084 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%s] [%s] [%d]\n",
1085 i, fname.len, fname.s,
1086 vps[0].n, vps[1].n, vps[2].s.s, vps[3].s.s, vps[4].n);
1087 } else if(ket->ptypes[0]==SR_KEMIP_INT
1088 && ket->ptypes[1]==SR_KEMIP_INT
1089 && ket->ptypes[2]==SR_KEMIP_STR
1090 && ket->ptypes[3]==SR_KEMIP_INT
1091 && ket->ptypes[4]==SR_KEMIP_STR) {
1092 if(!PyArg_ParseTuple(args, "nnsns:kemi-param-nnsns",
1093 &vps[0].n, &vps[1].n, &vps[2].s.s, &vps[3].n, &vps[4].s.s)) {
1094 LM_ERR("unable to retrieve nnsns params %d\n", i);
1095 return sr_kemi_apy_return_false();
1096 }
1097 vps[2].s.len = strlen(vps[2].s.s);
1098 vps[4].s.len = strlen(vps[4].s.s);
1099
1100 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%s] [%d] [%s]\n",
1101 i, fname.len, fname.s,
1102 vps[0].n, vps[1].n, vps[2].s.s, vps[3].n, vps[4].s.s);
1103 } else if(ket->ptypes[0]==SR_KEMIP_INT
1104 && ket->ptypes[1]==SR_KEMIP_INT
1105 && ket->ptypes[2]==SR_KEMIP_STR
1106 && ket->ptypes[3]==SR_KEMIP_INT
1107 && ket->ptypes[4]==SR_KEMIP_INT) {
1108 if(!PyArg_ParseTuple(args, "nnsnn:kemi-param-nnsnn",
1109 &vps[0].n, &vps[1].n, &vps[2].s.s, &vps[3].n, &vps[4].n)) {
1110 LM_ERR("unable to retrieve nnsnn params %d\n", i);
1111 return sr_kemi_apy_return_false();
1112 }
1113 vps[2].s.len = strlen(vps[2].s.s);
1114
1115 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%s] [%d] [%d]\n",
1116 i, fname.len, fname.s,
1117 vps[0].n, vps[1].n, vps[2].s.s, vps[3].n, vps[4].n);
1118 } else if(ket->ptypes[0]==SR_KEMIP_INT
1119 && ket->ptypes[1]==SR_KEMIP_INT
1120 && ket->ptypes[2]==SR_KEMIP_INT
1121 && ket->ptypes[3]==SR_KEMIP_STR
1122 && ket->ptypes[4]==SR_KEMIP_STR) {
1123 if(!PyArg_ParseTuple(args, "nnnss:kemi-param-nnnss",
1124 &vps[0].n, &vps[1].n, &vps[2].n, &vps[3].s.s, &vps[4].s.s)) {
1125 LM_ERR("unable to retrieve nnnss params %d\n", i);
1126 return sr_kemi_apy_return_false();
1127 }
1128 vps[3].s.len = strlen(vps[3].s.s);
1129 vps[4].s.len = strlen(vps[4].s.s);
1130
1131 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%d] [%s] [%s]\n",
1132 i, fname.len, fname.s,
1133 vps[0].n, vps[1].n, vps[2].n, vps[3].s.s, vps[4].s.s);
1134 } else if(ket->ptypes[0]==SR_KEMIP_INT
1135 && ket->ptypes[1]==SR_KEMIP_INT
1136 && ket->ptypes[2]==SR_KEMIP_INT
1137 && ket->ptypes[3]==SR_KEMIP_STR
1138 && ket->ptypes[4]==SR_KEMIP_INT) {
1139 if(!PyArg_ParseTuple(args, "nnnsn:kemi-param-nnnsn",
1140 &vps[0].n, &vps[1].n, &vps[2].n, &vps[3].s.s, &vps[4].n)) {
1141 LM_ERR("unable to retrieve nnnsn params %d\n", i);
1142 return sr_kemi_apy_return_false();
1143 }
1144 vps[3].s.len = strlen(vps[3].s.s);
1145
1146 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%d] [%s] [%d]\n",
1147 i, fname.len, fname.s,
1148 vps[0].n, vps[1].n, vps[2].n, vps[3].s.s, vps[4].n);
1149 } else if(ket->ptypes[0]==SR_KEMIP_INT
1150 && ket->ptypes[1]==SR_KEMIP_INT
1151 && ket->ptypes[2]==SR_KEMIP_INT
1152 && ket->ptypes[3]==SR_KEMIP_INT
1153 && ket->ptypes[4]==SR_KEMIP_STR) {
1154 if(!PyArg_ParseTuple(args, "nnnns:kemi-param-nnnns",
1155 &vps[0].n, &vps[1].n, &vps[2].n, &vps[3].n, &vps[4].s.s)) {
1156 LM_ERR("unable to retrieve nnnns params %d\n", i);
1157 return sr_kemi_apy_return_false();
1158 }
1159 vps[4].s.len = strlen(vps[4].s.s);
1160
1161 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%d] [%d] [%s]\n",
1162 i, fname.len, fname.s,
1163 vps[0].n, vps[1].n, vps[2].n, vps[3].n, vps[4].s.s);
1164 } else if(ket->ptypes[0]==SR_KEMIP_INT
1165 && ket->ptypes[1]==SR_KEMIP_INT
1166 && ket->ptypes[2]==SR_KEMIP_INT
1167 && ket->ptypes[3]==SR_KEMIP_INT
1168 && ket->ptypes[4]==SR_KEMIP_INT) {
1169 if(!PyArg_ParseTuple(args, "nnnnn:kemi-param-nnnnn",
1170 &vps[0].n, &vps[1].n, &vps[2].n, &vps[3].n, &vps[4].n)) {
1171 LM_ERR("unable to retrieve nnnnn params %d\n", i);
1172 return sr_kemi_apy_return_false();
1173 }
1174
1175 LM_DBG("params[%d] for: %.*s are: [%d] [%d] [%d] [%d] [%d]\n",
1176 i, fname.len, fname.s,
1177 vps[0].n, vps[1].n, vps[2].n, vps[3].n, vps[4].n);
1178 } else {
1179 LM_ERR("invalid parameters for: %.*s\n", fname.len, fname.s);
1180 return sr_kemi_apy_return_false();
1181 }
1182 } else {
1183 i = 6;
1184 if(ket->ptypes[0]==SR_KEMIP_STR
1185 && ket->ptypes[1]==SR_KEMIP_STR
1186 && ket->ptypes[2]==SR_KEMIP_STR
1187 && ket->ptypes[3]==SR_KEMIP_STR
1188 && ket->ptypes[4]==SR_KEMIP_STR
1189 && ket->ptypes[5]==SR_KEMIP_STR) {
1190 if(!PyArg_ParseTuple(args, "ssssss:kemi-param-ssssss",
1191 &vps[0].s.s, &vps[1].s.s, &vps[2].s.s, &vps[3].s.s,
1192 &vps[4].s.s, &vps[5].s.s)) {
1193 LM_ERR("unable to retrieve str-str-str-str params %d\n", i);
1194 return sr_kemi_apy_return_false();
1195 }
1196 vps[0].s.len = strlen(vps[0].s.s);
1197 vps[1].s.len = strlen(vps[1].s.s);
1198 vps[2].s.len = strlen(vps[2].s.s);
1199 vps[3].s.len = strlen(vps[3].s.s);
1200 vps[4].s.len = strlen(vps[4].s.s);
1201 vps[5].s.len = strlen(vps[5].s.s);
1202 LM_DBG("params[%d] for: %.*s are str: [%.*s] [%.*s]"
1203 " [%.*s] [%.*s] [%.*s] [%.*s]\n", i,
1204 fname.len, fname.s, vps[0].s.len, vps[0].s.s,
1205 vps[1].s.len, vps[1].s.s, vps[2].s.len, vps[2].s.s,
1206 vps[3].s.len, vps[3].s.s, vps[4].s.len, vps[4].s.s,
1207 vps[5].s.len, vps[5].s.s);
1208 } else {
1209 LM_ERR("not implemented yet\n");
1210 return sr_kemi_apy_return_false();
1211 }
1212 }
1213
1214 switch(i) {
1215 case 1:
1216 if(ket->ptypes[0]==SR_KEMIP_INT) {
1217 if(ket->rtype==SR_KEMIP_XVAL) {
1218 xret = ((sr_kemi_xfmn_f)(ket->func))(lmsg, vps[0].n);
1219 return sr_kemi_apy_return_xval(ket, xret);
1220 } else {
1221 ret = ((sr_kemi_fmn_f)(ket->func))(lmsg, vps[0].n);
1222 return sr_kemi_apy_return_int(ket, ret);
1223 }
1224 } else if(ket->ptypes[0]==SR_KEMIP_STR) {
1225 if(ket->rtype==SR_KEMIP_XVAL) {
1226 xret = ((sr_kemi_xfms_f)(ket->func))(lmsg, &vps[0].s);
1227 return sr_kemi_apy_return_xval(ket, xret);
1228 } else {
1229 ret = ((sr_kemi_fms_f)(ket->func))(lmsg, &vps[0].s);
1230 return sr_kemi_apy_return_int(ket, ret);
1231 }
1232 } else {
1233 LM_ERR("invalid parameters for: %.*s\n",
1234 fname.len, fname.s);
1235 return sr_kemi_apy_return_false();
1236 }
1237 break;
1238 case 2:
1239 if(ket->ptypes[0]==SR_KEMIP_INT) {
1240 if(ket->ptypes[1]==SR_KEMIP_INT) {
1241 if(ket->rtype==SR_KEMIP_XVAL) {
1242 xret = ((sr_kemi_xfmnn_f)(ket->func))(lmsg, vps[0].n, vps[1].n);
1243 return sr_kemi_apy_return_xval(ket, xret);
1244 } else {
1245 ret = ((sr_kemi_fmnn_f)(ket->func))(lmsg, vps[0].n, vps[1].n);
1246 return sr_kemi_apy_return_int(ket, ret);
1247 }
1248 } else if(ket->ptypes[1]==SR_KEMIP_STR) {
1249 if(ket->rtype==SR_KEMIP_XVAL) {
1250 xret = ((sr_kemi_xfmns_f)(ket->func))(lmsg, vps[0].n, &vps[1].s);
1251 return sr_kemi_apy_return_xval(ket, xret);
1252 } else {
1253 ret = ((sr_kemi_fmns_f)(ket->func))(lmsg, vps[0].n, &vps[1].s);
1254 return sr_kemi_apy_return_int(ket, ret);
1255 }
1256 } else {
1257 LM_ERR("invalid parameters for: %.*s\n",
1258 fname.len, fname.s);
1259 return sr_kemi_apy_return_false();
1260 }
1261 } else if(ket->ptypes[0]==SR_KEMIP_STR) {
1262 if(ket->ptypes[1]==SR_KEMIP_INT) {
1263 if(ket->rtype==SR_KEMIP_XVAL) {
1264 xret = ((sr_kemi_xfmsn_f)(ket->func))(lmsg, &vps[0].s, vps[1].n);
1265 return sr_kemi_apy_return_xval(ket, xret);
1266 } else {
1267 ret = ((sr_kemi_fmsn_f)(ket->func))(lmsg, &vps[0].s, vps[1].n);
1268 return sr_kemi_apy_return_int(ket, ret);
1269 }
1270 } else if(ket->ptypes[1]==SR_KEMIP_STR) {
1271 if(ket->rtype==SR_KEMIP_XVAL) {
1272 xret = ((sr_kemi_xfmss_f)(ket->func))(lmsg, &vps[0].s, &vps[1].s);
1273 return sr_kemi_apy_return_xval(ket, xret);
1274 } else {
1275 ret = ((sr_kemi_fmss_f)(ket->func))(lmsg, &vps[0].s, &vps[1].s);
1276 return sr_kemi_apy_return_int(ket, ret);
1277 }
1278 } else {
1279 LM_ERR("invalid parameters for: %.*s\n",
1280 fname.len, fname.s);
1281 return sr_kemi_apy_return_false();
1282 }
1283 } else {
1284 LM_ERR("invalid parameters for: %.*s\n",
1285 fname.len, fname.s);
1286 return sr_kemi_apy_return_false();
1287 }
1288 break;
1289 case 3:
1290 if(ket->ptypes[0]==SR_KEMIP_INT) {
1291 if(ket->ptypes[1]==SR_KEMIP_INT) {
1292 if(ket->ptypes[2]==SR_KEMIP_INT) {
1293 /* nnn */
1294 ret = ((sr_kemi_fmnnn_f)(ket->func))(lmsg,
1295 vps[0].n, vps[1].n, vps[2].n);
1296 return sr_kemi_apy_return_int(ket, ret);
1297 } else if(ket->ptypes[2]==SR_KEMIP_STR) {
1298 /* nns */
1299 ret = ((sr_kemi_fmnns_f)(ket->func))(lmsg,
1300 vps[0].n, vps[1].n, &vps[2].s);
1301 return sr_kemi_apy_return_int(ket, ret);
1302 } else {
1303 LM_ERR("invalid parameters for: %.*s\n",
1304 fname.len, fname.s);
1305 return sr_kemi_apy_return_false();
1306 }
1307 } else if(ket->ptypes[1]==SR_KEMIP_STR) {
1308 if(ket->ptypes[2]==SR_KEMIP_INT) {
1309 /* nsn */
1310 ret = ((sr_kemi_fmnsn_f)(ket->func))(lmsg,
1311 vps[0].n, &vps[1].s, vps[2].n);
1312 return sr_kemi_apy_return_int(ket, ret);
1313 } else if(ket->ptypes[2]==SR_KEMIP_STR) {
1314 /* nss */
1315 ret = ((sr_kemi_fmnss_f)(ket->func))(lmsg,
1316 vps[0].n, &vps[1].s, &vps[2].s);
1317 return sr_kemi_apy_return_int(ket, ret);
1318 } else {
1319 LM_ERR("invalid parameters for: %.*s\n",
1320 fname.len, fname.s);
1321 return sr_kemi_apy_return_false();
1322 }
1323 } else {
1324 LM_ERR("invalid parameters for: %.*s\n",
1325 fname.len, fname.s);
1326 return sr_kemi_apy_return_false();
1327 }
1328 } else if(ket->ptypes[0]==SR_KEMIP_STR) {
1329 if(ket->ptypes[1]==SR_KEMIP_INT) {
1330 if(ket->ptypes[2]==SR_KEMIP_INT) {
1331 /* snn */
1332 ret = ((sr_kemi_fmsnn_f)(ket->func))(lmsg,
1333 &vps[0].s, vps[1].n, vps[2].n);
1334 return sr_kemi_apy_return_int(ket, ret);
1335 } else if(ket->ptypes[2]==SR_KEMIP_STR) {
1336 /* sns */
1337 ret = ((sr_kemi_fmsns_f)(ket->func))(lmsg,
1338 &vps[0].s, vps[1].n, &vps[2].s);
1339 return sr_kemi_apy_return_int(ket, ret);
1340 } else {
1341 LM_ERR("invalid parameters for: %.*s\n",
1342 fname.len, fname.s);
1343 return sr_kemi_apy_return_false();
1344 }
1345 } else if(ket->ptypes[1]==SR_KEMIP_STR) {
1346 if(ket->ptypes[2]==SR_KEMIP_INT) {
1347 /* ssn */
1348 ret = ((sr_kemi_fmssn_f)(ket->func))(lmsg,
1349 &vps[0].s, &vps[1].s, vps[2].n);
1350 return sr_kemi_apy_return_int(ket, ret);
1351 } else if(ket->ptypes[2]==SR_KEMIP_STR) {
1352 /* sss */
1353 ret = ((sr_kemi_fmsss_f)(ket->func))(lmsg,
1354 &vps[0].s, &vps[1].s, &vps[2].s);
1355 return sr_kemi_apy_return_int(ket, ret);
1356 } else {
1357 LM_ERR("invalid parameters for: %.*s\n",
1358 fname.len, fname.s);
1359 return sr_kemi_apy_return_false();
1360 }
1361 } else {
1362 LM_ERR("invalid parameters for: %.*s\n",
1363 fname.len, fname.s);
1364 return sr_kemi_apy_return_false();
1365 }
1366 } else {
1367 LM_ERR("invalid parameters for: %.*s\n",
1368 fname.len, fname.s);
1369 return sr_kemi_apy_return_false();
1370 }
1371 break;
1372 case 4:
1373 if(ket->ptypes[0]==SR_KEMIP_STR
1374 && ket->ptypes[1]==SR_KEMIP_STR
1375 && ket->ptypes[2]==SR_KEMIP_STR
1376 && ket->ptypes[3]==SR_KEMIP_STR) {
1377 ret = ((sr_kemi_fmssss_f)(ket->func))(lmsg,
1378 &vps[0].s, &vps[1].s, &vps[2].s, &vps[3].s);
1379 return sr_kemi_apy_return_int(ket, ret);
1380 } else if(ket->ptypes[0]==SR_KEMIP_STR
1381 && ket->ptypes[1]==SR_KEMIP_STR
1382 && ket->ptypes[2]==SR_KEMIP_STR
1383 && ket->ptypes[3]==SR_KEMIP_INT) {
1384 ret = ((sr_kemi_fmsssn_f)(ket->func))(lmsg,
1385 &vps[0].s, &vps[1].s, &vps[2].s, vps[3].n);
1386 return sr_kemi_apy_return_int(ket, ret);
1387 } else if(ket->ptypes[0]==SR_KEMIP_STR
1388 && ket->ptypes[1]==SR_KEMIP_STR
1389 && ket->ptypes[2]==SR_KEMIP_INT
1390 && ket->ptypes[3]==SR_KEMIP_STR) {
1391 ret = ((sr_kemi_fmssns_f)(ket->func))(lmsg,
1392 &vps[0].s, &vps[1].s, vps[2].n, &vps[3].s);
1393 return sr_kemi_apy_return_int(ket, ret);
1394 } else if(ket->ptypes[0]==SR_KEMIP_STR
1395 && ket->ptypes[1]==SR_KEMIP_STR
1396 && ket->ptypes[2]==SR_KEMIP_INT
1397 && ket->ptypes[3]==SR_KEMIP_INT) {
1398 ret = ((sr_kemi_fmssnn_f)(ket->func))(lmsg,
1399 &vps[0].s, &vps[1].s, vps[2].n, vps[3].n);
1400 return sr_kemi_apy_return_int(ket, ret);
1401 } else if(ket->ptypes[0]==SR_KEMIP_STR
1402 && ket->ptypes[1]==SR_KEMIP_INT
1403 && ket->ptypes[2]==SR_KEMIP_STR
1404 && ket->ptypes[3]==SR_KEMIP_STR) {
1405 ret = ((sr_kemi_fmsnss_f)(ket->func))(lmsg,
1406 &vps[0].s, vps[1].n, &vps[2].s, &vps[3].s);
1407 return sr_kemi_apy_return_int(ket, ret);
1408 } else if(ket->ptypes[0]==SR_KEMIP_STR
1409 && ket->ptypes[1]==SR_KEMIP_INT
1410 && ket->ptypes[2]==SR_KEMIP_STR
1411 && ket->ptypes[3]==SR_KEMIP_INT) {
1412 ret = ((sr_kemi_fmsnsn_f)(ket->func))(lmsg,
1413 &vps[0].s, vps[1].n, &vps[2].s, vps[3].n);
1414 return sr_kemi_apy_return_int(ket, ret);
1415 } else if(ket->ptypes[0]==SR_KEMIP_STR
1416 && ket->ptypes[1]==SR_KEMIP_INT
1417 && ket->ptypes[2]==SR_KEMIP_INT
1418 && ket->ptypes[3]==SR_KEMIP_STR) {
1419 ret = ((sr_kemi_fmsnns_f)(ket->func))(lmsg,
1420 &vps[0].s, vps[1].n, vps[2].n, &vps[3].s);
1421 return sr_kemi_apy_return_int(ket, ret);
1422 } else if(ket->ptypes[0]==SR_KEMIP_STR
1423 && ket->ptypes[1]==SR_KEMIP_INT
1424 && ket->ptypes[2]==SR_KEMIP_INT
1425 && ket->ptypes[3]==SR_KEMIP_INT) {
1426 ret = ((sr_kemi_fmsnnn_f)(ket->func))(lmsg,
1427 &vps[0].s, vps[1].n, vps[2].n, vps[3].n);
1428 return sr_kemi_apy_return_int(ket, ret);
1429 } else if(ket->ptypes[0]==SR_KEMIP_INT
1430 && ket->ptypes[1]==SR_KEMIP_STR
1431 && ket->ptypes[2]==SR_KEMIP_STR
1432 && ket->ptypes[3]==SR_KEMIP_STR) {
1433 ret = ((sr_kemi_fmnsss_f)(ket->func))(lmsg,
1434 vps[0].n, &vps[1].s, &vps[2].s, &vps[3].s);
1435 return sr_kemi_apy_return_int(ket, ret);
1436 } else if(ket->ptypes[0]==SR_KEMIP_INT
1437 && ket->ptypes[1]==SR_KEMIP_STR
1438 && ket->ptypes[2]==SR_KEMIP_STR
1439 && ket->ptypes[3]==SR_KEMIP_INT) {
1440 ret = ((sr_kemi_fmnssn_f)(ket->func))(lmsg,
1441 vps[0].n, &vps[1].s, &vps[2].s, vps[3].n);
1442 return sr_kemi_apy_return_int(ket, ret);
1443 } else if(ket->ptypes[0]==SR_KEMIP_INT
1444 && ket->ptypes[1]==SR_KEMIP_STR
1445 && ket->ptypes[2]==SR_KEMIP_INT
1446 && ket->ptypes[3]==SR_KEMIP_STR) {
1447 ret = ((sr_kemi_fmnsns_f)(ket->func))(lmsg,
1448 vps[0].n, &vps[1].s, vps[2].n, &vps[3].s);
1449 return sr_kemi_apy_return_int(ket, ret);
1450 } else if(ket->ptypes[0]==SR_KEMIP_INT
1451 && ket->ptypes[1]==SR_KEMIP_STR
1452 && ket->ptypes[2]==SR_KEMIP_INT
1453 && ket->ptypes[3]==SR_KEMIP_INT) {
1454 ret = ((sr_kemi_fmnsnn_f)(ket->func))(lmsg,
1455 vps[0].n, &vps[1].s, vps[2].n, vps[3].n);
1456 return sr_kemi_apy_return_int(ket, ret);
1457 } else if(ket->ptypes[0]==SR_KEMIP_INT
1458 && ket->ptypes[1]==SR_KEMIP_INT
1459 && ket->ptypes[2]==SR_KEMIP_STR
1460 && ket->ptypes[3]==SR_KEMIP_STR) {
1461 ret = ((sr_kemi_fmnnss_f)(ket->func))(lmsg,
1462 vps[0].n, vps[1].n, &vps[2].s, &vps[3].s);
1463 return sr_kemi_apy_return_int(ket, ret);
1464 } else if(ket->ptypes[0]==SR_KEMIP_INT
1465 && ket->ptypes[1]==SR_KEMIP_INT
1466 && ket->ptypes[2]==SR_KEMIP_STR
1467 && ket->ptypes[3]==SR_KEMIP_INT) {
1468 ret = ((sr_kemi_fmnnsn_f)(ket->func))(lmsg,
1469 vps[0].n, vps[1].n, &vps[2].s, vps[3].n);
1470 return sr_kemi_apy_return_int(ket, ret);
1471 } else if(ket->ptypes[0]==SR_KEMIP_INT
1472 && ket->ptypes[1]==SR_KEMIP_INT
1473 && ket->ptypes[2]==SR_KEMIP_INT
1474 && ket->ptypes[3]==SR_KEMIP_STR) {
1475 ret = ((sr_kemi_fmnnns_f)(ket->func))(lmsg,
1476 vps[0].n, vps[1].n, vps[2].n, &vps[3].s);
1477 return sr_kemi_apy_return_int(ket, ret);
1478 } else if(ket->ptypes[0]==SR_KEMIP_INT
1479 && ket->ptypes[1]==SR_KEMIP_INT
1480 && ket->ptypes[2]==SR_KEMIP_INT
1481 && ket->ptypes[3]==SR_KEMIP_INT) {
1482 ret = ((sr_kemi_fmnnnn_f)(ket->func))(lmsg,
1483 vps[0].n, vps[1].n, vps[2].n, vps[3].n);
1484 return sr_kemi_apy_return_int(ket, ret);
1485 } else {
1486 LM_ERR("invalid parameters for: %.*s\n", fname.len, fname.s);
1487 return sr_kemi_apy_return_false();
1488 }
1489 break;
1490 case 5:
1491 if(ket->ptypes[0]==SR_KEMIP_STR
1492 && ket->ptypes[1]==SR_KEMIP_STR
1493 && ket->ptypes[2]==SR_KEMIP_STR
1494 && ket->ptypes[3]==SR_KEMIP_STR
1495 && ket->ptypes[4]==SR_KEMIP_STR) {
1496 ret = ((sr_kemi_fmsssss_f)(ket->func))(lmsg,
1497 &vps[0].s, &vps[1].s, &vps[2].s, &vps[3].s, &vps[4].s);
1498 return sr_kemi_apy_return_int(ket, ret);
1499 } else if(ket->ptypes[0]==SR_KEMIP_STR
1500 && ket->ptypes[1]==SR_KEMIP_STR
1501 && ket->ptypes[2]==SR_KEMIP_STR
1502 && ket->ptypes[3]==SR_KEMIP_STR
1503 && ket->ptypes[4]==SR_KEMIP_INT) {
1504 ret = ((sr_kemi_fmssssn_f)(ket->func))(lmsg,
1505 &vps[0].s, &vps[1].s, &vps[2].s, &vps[3].s, vps[4].n);
1506 return sr_kemi_apy_return_int(ket, ret);
1507 } else if(ket->ptypes[0]==SR_KEMIP_STR
1508 && ket->ptypes[1]==SR_KEMIP_STR
1509 && ket->ptypes[2]==SR_KEMIP_STR
1510 && ket->ptypes[3]==SR_KEMIP_INT
1511 && ket->ptypes[4]==SR_KEMIP_STR) {
1512 ret = ((sr_kemi_fmsssns_f)(ket->func))(lmsg,
1513 &vps[0].s, &vps[1].s, &vps[2].s, vps[3].n, &vps[4].s);
1514 return sr_kemi_apy_return_int(ket, ret);
1515 } else if(ket->ptypes[0]==SR_KEMIP_STR
1516 && ket->ptypes[1]==SR_KEMIP_STR
1517 && ket->ptypes[2]==SR_KEMIP_STR
1518 && ket->ptypes[3]==SR_KEMIP_INT
1519 && ket->ptypes[4]==SR_KEMIP_INT) {
1520 ret = ((sr_kemi_fmsssnn_f)(ket->func))(lmsg,
1521 &vps[0].s, &vps[1].s, &vps[2].s, vps[3].n, vps[4].n);
1522 return sr_kemi_apy_return_int(ket, ret);
1523 } else if(ket->ptypes[0]==SR_KEMIP_STR
1524 && ket->ptypes[1]==SR_KEMIP_STR
1525 && ket->ptypes[2]==SR_KEMIP_INT
1526 && ket->ptypes[3]==SR_KEMIP_STR
1527 && ket->ptypes[4]==SR_KEMIP_STR) {
1528 ret = ((sr_kemi_fmssnss_f)(ket->func))(lmsg,
1529 &vps[0].s, &vps[1].s, vps[2].n, &vps[3].s, &vps[4].s);
1530 return sr_kemi_apy_return_int(ket, ret);
1531 } else if(ket->ptypes[0]==SR_KEMIP_STR
1532 && ket->ptypes[1]==SR_KEMIP_STR
1533 && ket->ptypes[2]==SR_KEMIP_INT
1534 && ket->ptypes[3]==SR_KEMIP_STR
1535 && ket->ptypes[4]==SR_KEMIP_INT) {
1536 ret = ((sr_kemi_fmssnsn_f)(ket->func))(lmsg,
1537 &vps[0].s, &vps[1].s, vps[2].n, &vps[3].s, vps[4].n);
1538 return sr_kemi_apy_return_int(ket, ret);
1539 } else if(ket->ptypes[0]==SR_KEMIP_STR
1540 && ket->ptypes[1]==SR_KEMIP_STR
1541 && ket->ptypes[2]==SR_KEMIP_INT
1542 && ket->ptypes[3]==SR_KEMIP_INT
1543 && ket->ptypes[4]==SR_KEMIP_STR) {
1544 ret = ((sr_kemi_fmssnns_f)(ket->func))(lmsg,
1545 &vps[0].s, &vps[1].s, vps[2].n, vps[3].n, &vps[4].s);
1546 return sr_kemi_apy_return_int(ket, ret);
1547 } else if(ket->ptypes[0]==SR_KEMIP_STR
1548 && ket->ptypes[1]==SR_KEMIP_STR
1549 && ket->ptypes[2]==SR_KEMIP_INT
1550 && ket->ptypes[3]==SR_KEMIP_INT
1551 && ket->ptypes[4]==SR_KEMIP_INT) {
1552 ret = ((sr_kemi_fmssnnn_f)(ket->func))(lmsg,
1553 &vps[0].s, &vps[1].s, vps[2].n, vps[3].n, vps[4].n);
1554 return sr_kemi_apy_return_int(ket, ret);
1555 } else if(ket->ptypes[0]==SR_KEMIP_STR
1556 && ket->ptypes[1]==SR_KEMIP_INT
1557 && ket->ptypes[2]==SR_KEMIP_STR
1558 && ket->ptypes[3]==SR_KEMIP_STR
1559 && ket->ptypes[4]==SR_KEMIP_STR) {
1560 ret = ((sr_kemi_fmsnsss_f)(ket->func))(lmsg,
1561 &vps[0].s, vps[1].n, &vps[2].s, &vps[3].s, &vps[4].s);
1562 return sr_kemi_apy_return_int(ket, ret);
1563 } else if(ket->ptypes[0]==SR_KEMIP_STR
1564 && ket->ptypes[1]==SR_KEMIP_INT
1565 && ket->ptypes[2]==SR_KEMIP_STR
1566 && ket->ptypes[3]==SR_KEMIP_STR
1567 && ket->ptypes[4]==SR_KEMIP_INT) {
1568 ret = ((sr_kemi_fmsnssn_f)(ket->func))(lmsg,
1569 &vps[0].s, vps[1].n, &vps[2].s, &vps[3].s, vps[4].n);
1570 return sr_kemi_apy_return_int(ket, ret);
1571 } else if(ket->ptypes[0]==SR_KEMIP_STR
1572 && ket->ptypes[1]==SR_KEMIP_INT
1573 && ket->ptypes[2]==SR_KEMIP_STR
1574 && ket->ptypes[3]==SR_KEMIP_INT
1575 && ket->ptypes[4]==SR_KEMIP_STR) {
1576 ret = ((sr_kemi_fmsnsns_f)(ket->func))(lmsg,
1577 &vps[0].s, vps[1].n, &vps[2].s, vps[3].n, &vps[4].s);
1578 return sr_kemi_apy_return_int(ket, ret);
1579 } else if(ket->ptypes[0]==SR_KEMIP_STR
1580 && ket->ptypes[1]==SR_KEMIP_INT
1581 && ket->ptypes[2]==SR_KEMIP_STR
1582 && ket->ptypes[3]==SR_KEMIP_INT
1583 && ket->ptypes[4]==SR_KEMIP_INT) {
1584 ret = ((sr_kemi_fmsnsnn_f)(ket->func))(lmsg,
1585 &vps[0].s, vps[1].n, &vps[2].s, vps[3].n, vps[4].n);
1586 return sr_kemi_apy_return_int(ket, ret);
1587 } else if(ket->ptypes[0]==SR_KEMIP_STR
1588 && ket->ptypes[1]==SR_KEMIP_INT
1589 && ket->ptypes[2]==SR_KEMIP_INT
1590 && ket->ptypes[3]==SR_KEMIP_STR
1591 && ket->ptypes[4]==SR_KEMIP_STR) {
1592 ret = ((sr_kemi_fmsnnss_f)(ket->func))(lmsg,
1593 &vps[0].s, vps[1].n, vps[2].n, &vps[3].s, &vps[4].s);
1594 return sr_kemi_apy_return_int(ket, ret);
1595 } else if(ket->ptypes[0]==SR_KEMIP_STR
1596 && ket->ptypes[1]==SR_KEMIP_INT
1597 && ket->ptypes[2]==SR_KEMIP_INT
1598 && ket->ptypes[3]==SR_KEMIP_STR
1599 && ket->ptypes[4]==SR_KEMIP_INT) {
1600 ret = ((sr_kemi_fmsnnsn_f)(ket->func))(lmsg,
1601 &vps[0].s, vps[1].n, vps[2].n, &vps[3].s, vps[4].n);
1602 return sr_kemi_apy_return_int(ket, ret);
1603 } else if(ket->ptypes[0]==SR_KEMIP_STR
1604 && ket->ptypes[1]==SR_KEMIP_INT
1605 && ket->ptypes[2]==SR_KEMIP_INT
1606 && ket->ptypes[3]==SR_KEMIP_INT
1607 && ket->ptypes[4]==SR_KEMIP_STR) {
1608 ret = ((sr_kemi_fmsnnns_f)(ket->func))(lmsg,
1609 &vps[0].s, vps[1].n, vps[2].n, vps[3].n, &vps[4].s);
1610 return sr_kemi_apy_return_int(ket, ret);
1611 } else if(ket->ptypes[0]==SR_KEMIP_STR
1612 && ket->ptypes[1]==SR_KEMIP_INT
1613 && ket->ptypes[2]==SR_KEMIP_INT
1614 && ket->ptypes[3]==SR_KEMIP_INT
1615 && ket->ptypes[4]==SR_KEMIP_INT) {
1616 ret = ((sr_kemi_fmsnnnn_f)(ket->func))(lmsg,
1617 &vps[0].s, vps[1].n, vps[2].n, vps[3].n, vps[4].n);
1618 return sr_kemi_apy_return_int(ket, ret);
1619 } else if(ket->ptypes[0]==SR_KEMIP_INT
1620 && ket->ptypes[1]==SR_KEMIP_STR
1621 && ket->ptypes[2]==SR_KEMIP_STR
1622 && ket->ptypes[3]==SR_KEMIP_STR
1623 && ket->ptypes[4]==SR_KEMIP_STR) {
1624 ret = ((sr_kemi_fmnssss_f)(ket->func))(lmsg,
1625 vps[0].n, &vps[1].s, &vps[2].s, &vps[3].s, &vps[4].s);
1626 return sr_kemi_apy_return_int(ket, ret);
1627 } else if(ket->ptypes[0]==SR_KEMIP_INT
1628 && ket->ptypes[1]==SR_KEMIP_STR
1629 && ket->ptypes[2]==SR_KEMIP_STR
1630 && ket->ptypes[3]==SR_KEMIP_STR
1631 && ket->ptypes[4]==SR_KEMIP_INT) {
1632 ret = ((sr_kemi_fmnsssn_f)(ket->func))(lmsg,
1633 vps[0].n, &vps[1].s, &vps[2].s, &vps[3].s, vps[4].n);
1634 return sr_kemi_apy_return_int(ket, ret);
1635 } else if(ket->ptypes[0]==SR_KEMIP_INT
1636 && ket->ptypes[1]==SR_KEMIP_STR
1637 && ket->ptypes[2]==SR_KEMIP_STR
1638 && ket->ptypes[3]==SR_KEMIP_INT
1639 && ket->ptypes[4]==SR_KEMIP_STR) {
1640 ret = ((sr_kemi_fmnssns_f)(ket->func))(lmsg,
1641 vps[0].n, &vps[1].s, &vps[2].s, vps[3].n, &vps[4].s);
1642 return sr_kemi_apy_return_int(ket, ret);
1643 } else if(ket->ptypes[0]==SR_KEMIP_INT
1644 && ket->ptypes[1]==SR_KEMIP_STR
1645 && ket->ptypes[2]==SR_KEMIP_STR
1646 && ket->ptypes[3]==SR_KEMIP_INT
1647 && ket->ptypes[4]==SR_KEMIP_INT) {
1648 ret = ((sr_kemi_fmnssnn_f)(ket->func))(lmsg,
1649 vps[0].n, &vps[1].s, &vps[2].s, vps[3].n, vps[4].n);
1650 return sr_kemi_apy_return_int(ket, ret);
1651 } else if(ket->ptypes[0]==SR_KEMIP_INT
1652 && ket->ptypes[1]==SR_KEMIP_STR
1653 && ket->ptypes[2]==SR_KEMIP_INT
1654 && ket->ptypes[3]==SR_KEMIP_STR
1655 && ket->ptypes[4]==SR_KEMIP_STR) {
1656 ret = ((sr_kemi_fmnsnss_f)(ket->func))(lmsg,
1657 vps[0].n, &vps[1].s, vps[2].n, &vps[3].s, &vps[4].s);
1658 return sr_kemi_apy_return_int(ket, ret);
1659 } else if(ket->ptypes[0]==SR_KEMIP_INT
1660 && ket->ptypes[1]==SR_KEMIP_STR
1661 && ket->ptypes[2]==SR_KEMIP_INT
1662 && ket->ptypes[3]==SR_KEMIP_STR
1663 && ket->ptypes[4]==SR_KEMIP_INT) {
1664 ret = ((sr_kemi_fmnsnsn_f)(ket->func))(lmsg,
1665 vps[0].n, &vps[1].s, vps[2].n, &vps[3].s, vps[4].n);
1666 return sr_kemi_apy_return_int(ket, ret);
1667 } else if(ket->ptypes[0]==SR_KEMIP_INT
1668 && ket->ptypes[1]==SR_KEMIP_STR
1669 && ket->ptypes[2]==SR_KEMIP_INT
1670 && ket->ptypes[3]==SR_KEMIP_INT
1671 && ket->ptypes[4]==SR_KEMIP_STR) {
1672 ret = ((sr_kemi_fmnsnns_f)(ket->func))(lmsg,
1673 vps[0].n, &vps[1].s, vps[2].n, vps[3].n, &vps[4].s);
1674 return sr_kemi_apy_return_int(ket, ret);
1675 } else if(ket->ptypes[0]==SR_KEMIP_INT
1676 && ket->ptypes[1]==SR_KEMIP_STR
1677 && ket->ptypes[2]==SR_KEMIP_INT
1678 && ket->ptypes[3]==SR_KEMIP_INT
1679 && ket->ptypes[4]==SR_KEMIP_INT) {
1680 ret = ((sr_kemi_fmnsnnn_f)(ket->func))(lmsg,
1681 vps[0].n, &vps[1].s, vps[2].n, vps[3].n, vps[4].n);
1682 return sr_kemi_apy_return_int(ket, ret);
1683 } else if(ket->ptypes[0]==SR_KEMIP_INT
1684 && ket->ptypes[1]==SR_KEMIP_INT
1685 && ket->ptypes[2]==SR_KEMIP_STR
1686 && ket->ptypes[3]==SR_KEMIP_STR
1687 && ket->ptypes[4]==SR_KEMIP_STR) {
1688 ret = ((sr_kemi_fmnnsss_f)(ket->func))(lmsg,
1689 vps[0].n, vps[1].n, &vps[2].s, &vps[3].s, &vps[4].s);
1690 return sr_kemi_apy_return_int(ket, ret);
1691 } else if(ket->ptypes[0]==SR_KEMIP_INT
1692 && ket->ptypes[1]==SR_KEMIP_INT
1693 && ket->ptypes[2]==SR_KEMIP_STR
1694 && ket->ptypes[3]==SR_KEMIP_STR
1695 && ket->ptypes[4]==SR_KEMIP_INT) {
1696 ret = ((sr_kemi_fmnnssn_f)(ket->func))(lmsg,
1697 vps[0].n, vps[1].n, &vps[2].s, &vps[3].s, vps[4].n);
1698 return sr_kemi_apy_return_int(ket, ret);
1699 } else if(ket->ptypes[0]==SR_KEMIP_INT
1700 && ket->ptypes[1]==SR_KEMIP_INT
1701 && ket->ptypes[2]==SR_KEMIP_STR
1702 && ket->ptypes[3]==SR_KEMIP_INT
1703 && ket->ptypes[4]==SR_KEMIP_STR) {
1704 ret = ((sr_kemi_fmnnsns_f)(ket->func))(lmsg,
1705 vps[0].n, vps[1].n, &vps[2].s, vps[3].n, &vps[4].s);
1706 return sr_kemi_apy_return_int(ket, ret);
1707 } else if(ket->ptypes[0]==SR_KEMIP_INT
1708 && ket->ptypes[1]==SR_KEMIP_INT
1709 && ket->ptypes[2]==SR_KEMIP_STR
1710 && ket->ptypes[3]==SR_KEMIP_INT
1711 && ket->ptypes[4]==SR_KEMIP_INT) {
1712 ret = ((sr_kemi_fmnnsnn_f)(ket->func))(lmsg,
1713 vps[0].n, vps[1].n, &vps[2].s, vps[3].n, vps[4].n);
1714 return sr_kemi_apy_return_int(ket, ret);
1715 } else if(ket->ptypes[0]==SR_KEMIP_INT
1716 && ket->ptypes[1]==SR_KEMIP_INT
1717 && ket->ptypes[2]==SR_KEMIP_INT
1718 && ket->ptypes[3]==SR_KEMIP_STR
1719 && ket->ptypes[4]==SR_KEMIP_STR) {
1720 ret = ((sr_kemi_fmnnnss_f)(ket->func))(lmsg,
1721 vps[0].n, vps[1].n, vps[2].n, &vps[3].s, &vps[4].s);
1722 return sr_kemi_apy_return_int(ket, ret);
1723 } else if(ket->ptypes[0]==SR_KEMIP_INT
1724 && ket->ptypes[1]==SR_KEMIP_INT
1725 && ket->ptypes[2]==SR_KEMIP_INT
1726 && ket->ptypes[3]==SR_KEMIP_STR
1727 && ket->ptypes[4]==SR_KEMIP_INT) {
1728 ret = ((sr_kemi_fmnnnsn_f)(ket->func))(lmsg,
1729 vps[0].n, vps[1].n, vps[2].n, &vps[3].s, vps[4].n);
1730 return sr_kemi_apy_return_int(ket, ret);
1731 } else if(ket->ptypes[0]==SR_KEMIP_INT
1732 && ket->ptypes[1]==SR_KEMIP_INT
1733 && ket->ptypes[2]==SR_KEMIP_INT
1734 && ket->ptypes[3]==SR_KEMIP_INT
1735 && ket->ptypes[4]==SR_KEMIP_STR) {
1736 ret = ((sr_kemi_fmnnnns_f)(ket->func))(lmsg,
1737 vps[0].n, vps[1].n, vps[2].n, vps[3].n, &vps[4].s);
1738 return sr_kemi_apy_return_int(ket, ret);
1739 } else if(ket->ptypes[0]==SR_KEMIP_INT
1740 && ket->ptypes[1]==SR_KEMIP_INT
1741 && ket->ptypes[2]==SR_KEMIP_INT
1742 && ket->ptypes[3]==SR_KEMIP_INT
1743 && ket->ptypes[4]==SR_KEMIP_INT) {
1744 ret = ((sr_kemi_fmnnnnn_f)(ket->func))(lmsg,
1745 vps[0].n, vps[1].n, vps[2].n, vps[3].n, vps[4].n);
1746 return sr_kemi_apy_return_int(ket, ret);
1747 } else {
1748 LM_ERR("invalid parameters for: %.*s\n", fname.len, fname.s);
1749 return sr_kemi_apy_return_false();
1750 }
1751 break;
1752 case 6:
1753 if(ket->ptypes[0]==SR_KEMIP_STR
1754 && ket->ptypes[1]==SR_KEMIP_STR
1755 && ket->ptypes[2]==SR_KEMIP_STR
1756 && ket->ptypes[3]==SR_KEMIP_STR
1757 && ket->ptypes[4]==SR_KEMIP_STR
1758 && ket->ptypes[5]==SR_KEMIP_STR) {
1759 /* ssssss */
1760 ret = ((sr_kemi_fmssssss_f)(ket->func))(lmsg,
1761 &vps[0].s, &vps[1].s, &vps[2].s, &vps[3].s,
1762 &vps[4].s, &vps[5].s);
1763 return sr_kemi_apy_return_int(ket, ret);
1764 } else {
1765 LM_ERR("invalid parameters for: %.*s\n",
1766 fname.len, fname.s);
1767 return sr_kemi_apy_return_false();
1768 }
1769 break;
1770 default:
1771 LM_ERR("invalid parameters for: %.*s\n",
1772 fname.len, fname.s);
1773 return sr_kemi_apy_return_false();
1774 }
1775 }
1776
1777 /**
1778 *
1779 */
sr_apy_kemi_exec_func(PyObject * self,PyObject * args,int idx)1780 PyObject *sr_apy_kemi_exec_func(PyObject *self, PyObject *args, int idx)
1781 {
1782 sr_kemi_t *ket = NULL;
1783 PyObject *ret = NULL;
1784 PyThreadState *pstate = NULL;
1785 PyFrameObject *pframe = NULL;
1786 struct timeval tvb = {0}, tve = {0};
1787 struct timezone tz;
1788 unsigned int tdiff;
1789
1790 ket = sr_apy_kemi_export_get(idx);
1791 if(ket==NULL) {
1792 return sr_kemi_apy_return_false();
1793 }
1794 if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)
1795 && is_printable(cfg_get(core, core_cfg, latency_log))) {
1796 gettimeofday(&tvb, &tz);
1797 }
1798
1799 ret = sr_apy_kemi_exec_func_ex(ket, self, args, idx);
1800
1801 if(unlikely(cfg_get(core, core_cfg, latency_limit_action)>0)
1802 && is_printable(cfg_get(core, core_cfg, latency_log))) {
1803 gettimeofday(&tve, &tz);
1804 tdiff = (tve.tv_sec - tvb.tv_sec) * 1000000
1805 + (tve.tv_usec - tvb.tv_usec);
1806 if(tdiff >= cfg_get(core, core_cfg, latency_limit_action)) {
1807 pstate = PyThreadState_GET();
1808 if (pstate != NULL && pstate->frame != NULL) {
1809 pframe = pstate->frame;
1810 }
1811
1812 LOG(cfg_get(core, core_cfg, latency_log),
1813 "alert - action KSR.%s%s%s(...)"
1814 " took too long [%u us] (file:%s func:%s line:%d)\n",
1815 (ket->mname.len>0)?ket->mname.s:"",
1816 (ket->mname.len>0)?".":"", ket->fname.s, tdiff,
1817 (pframe && pframe->f_code)?PyString_AsString(pframe->f_code->co_filename):"",
1818 (pframe && pframe->f_code)?PyString_AsString(pframe->f_code->co_name):"",
1819 (pframe && pframe->f_code)?PyCode_Addr2Line(pframe->f_code, pframe->f_lasti):0);
1820 }
1821 }
1822
1823 return ret;
1824 }
1825
1826 /**
1827 *
1828 */
1829 PyObject *_sr_apy_ksr_module = NULL;
1830 PyObject *_sr_apy_ksr_module_dict = NULL;
1831 PyObject **_sr_apy_ksr_modules_list = NULL;
1832
1833 PyMethodDef *_sr_KSRMethods = NULL;
1834 #define SR_APY_KSR_MODULES_SIZE 256
1835 #define SR_APY_KSR_METHODS_SIZE (SR_APY_KEMI_EXPORT_SIZE + SR_APY_KSR_MODULES_SIZE)
1836
1837 /**
1838 *
1839 */
sr_apy_kemi_f_ktest(sip_msg_t * msg,str * txt)1840 static int sr_apy_kemi_f_ktest(sip_msg_t *msg, str *txt)
1841 {
1842 if(txt!=NULL && txt->s!=NULL)
1843 LM_DBG("%.*s", txt->len, txt->s);
1844 return 0;
1845 }
1846
1847 /**
1848 *
1849 */
1850 /* clang-format off */
1851 static sr_kemi_t _sr_apy_kemi_test[] = {
1852 { str_init(""), str_init("ktest"),
1853 SR_KEMIP_NONE, sr_apy_kemi_f_ktest,
1854 { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
1855 SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
1856 },
1857
1858 { {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
1859 };
1860 /* clang-format on */
1861
1862 /**
1863 *
1864 */
1865 static PyMethodDef _sr_apy_kemi_x_Methods[] = {
1866 {"modf", (PyCFunction)msg_call_function, METH_VARARGS,
1867 "Invoke function exported by the other module."},
1868 {NULL, NULL, 0, NULL} /* sentinel */
1869 };
1870
1871 /**
1872 *
1873 */
sr_apy_init_ksr(void)1874 int sr_apy_init_ksr(void)
1875 {
1876 PyMethodDef *_sr_crt_KSRMethods = NULL;
1877 sr_kemi_module_t *emods = NULL;
1878 int emods_size = 0;
1879 int i;
1880 int k;
1881 int m;
1882 int n;
1883 char mname[128];
1884
1885 /* init faked sip msg */
1886 if(faked_msg_init()<0)
1887 {
1888 LM_ERR("failed to init local faked sip msg\n");
1889 return -1;
1890 }
1891
1892 _sr_KSRMethods = malloc(SR_APY_KSR_METHODS_SIZE * sizeof(PyMethodDef));
1893 if(_sr_KSRMethods==NULL) {
1894 LM_ERR("no more pkg memory\n");
1895 return -1;
1896 }
1897 _sr_apy_ksr_modules_list = malloc(SR_APY_KSR_MODULES_SIZE * sizeof(PyObject*));
1898 if(_sr_apy_ksr_modules_list==NULL) {
1899 LM_ERR("no more pkg memory\n");
1900 return -1;
1901 }
1902 memset(_sr_KSRMethods, 0, SR_APY_KSR_METHODS_SIZE * sizeof(PyMethodDef));
1903 memset(_sr_apy_ksr_modules_list, 0, SR_APY_KSR_MODULES_SIZE * sizeof(PyObject*));
1904
1905 emods_size = sr_kemi_modules_size_get();
1906 emods = sr_kemi_modules_get();
1907
1908 n = 0;
1909 _sr_crt_KSRMethods = _sr_KSRMethods;
1910 if(emods_size==0 || emods[0].kexp==NULL) {
1911 LM_DBG("exporting KSR.%s(...)\n", _sr_apy_kemi_test[0].fname.s);
1912 _sr_crt_KSRMethods[0].ml_name = _sr_apy_kemi_test[0].fname.s;
1913 _sr_crt_KSRMethods[0].ml_meth = sr_apy_kemi_export_associate(&_sr_apy_kemi_test[0]);
1914 _sr_crt_KSRMethods[0].ml_flags = METH_VARARGS;
1915 _sr_crt_KSRMethods[0].ml_doc = NAME " exported function";
1916 } else {
1917 for(i=0; emods[0].kexp[i].func!=NULL; i++) {
1918 LM_DBG("exporting KSR.%s(...)\n", emods[0].kexp[i].fname.s);
1919 _sr_crt_KSRMethods[i].ml_name = emods[0].kexp[i].fname.s;
1920 _sr_crt_KSRMethods[i].ml_meth =
1921 sr_apy_kemi_export_associate(&emods[0].kexp[i]);
1922 if(_sr_crt_KSRMethods[i].ml_meth == NULL) {
1923 LM_ERR("failed to associate kemi function with python export\n");
1924 free(_sr_KSRMethods);
1925 _sr_KSRMethods = NULL;
1926 return -1;
1927 }
1928 _sr_crt_KSRMethods[i].ml_flags = METH_VARARGS;
1929 _sr_crt_KSRMethods[i].ml_doc = NAME " exported function";
1930 n++;
1931 }
1932 }
1933
1934 _sr_apy_ksr_module = Py_InitModule("KSR", _sr_crt_KSRMethods);
1935 _sr_apy_ksr_module_dict = PyModule_GetDict(_sr_apy_ksr_module);
1936
1937 Py_INCREF(_sr_apy_ksr_module);
1938
1939 m = 0;
1940
1941 /* special sub-modules - x.modf() can have variable number of params */
1942 _sr_apy_ksr_modules_list[m] = Py_InitModule("KSR.x",
1943 _sr_apy_kemi_x_Methods);
1944 PyDict_SetItemString(_sr_apy_ksr_module_dict,
1945 "x", _sr_apy_ksr_modules_list[m]);
1946 Py_INCREF(_sr_apy_ksr_modules_list[m]);
1947 m++;
1948
1949 if(emods_size>1) {
1950 for(k=1; k<emods_size; k++) {
1951 n++;
1952 _sr_crt_KSRMethods = _sr_KSRMethods + n;
1953 snprintf(mname, 128, "KSR.%s", emods[k].kexp[0].mname.s);
1954 for(i=0; emods[k].kexp[i].func!=NULL; i++) {
1955 LM_DBG("exporting %s.%s(...)\n", mname,
1956 emods[k].kexp[i].fname.s);
1957 _sr_crt_KSRMethods[i].ml_name = emods[k].kexp[i].fname.s;
1958 _sr_crt_KSRMethods[i].ml_meth =
1959 sr_apy_kemi_export_associate(&emods[k].kexp[i]);
1960 if(_sr_crt_KSRMethods[i].ml_meth == NULL) {
1961 LM_ERR("failed to associate kemi function with python export\n");
1962 free(_sr_KSRMethods);
1963 _sr_KSRMethods = NULL;
1964 return -1;
1965 }
1966 _sr_crt_KSRMethods[i].ml_flags = METH_VARARGS;
1967 _sr_crt_KSRMethods[i].ml_doc = NAME " exported function";
1968 n++;
1969 }
1970 LM_DBG("initializing kemi sub-module: %s (%s)\n", mname,
1971 emods[k].kexp[0].mname.s);
1972 _sr_apy_ksr_modules_list[m] = Py_InitModule(mname, _sr_crt_KSRMethods);
1973 PyDict_SetItemString(_sr_apy_ksr_module_dict,
1974 emods[k].kexp[0].mname.s, _sr_apy_ksr_modules_list[m]);
1975 Py_INCREF(_sr_apy_ksr_modules_list[m]);
1976 m++;
1977 }
1978 }
1979 LM_DBG("module 'KSR' has been initialized\n");
1980 return 0;
1981 }
1982
1983 /**
1984 *
1985 */
sr_apy_destroy_ksr(void)1986 void sr_apy_destroy_ksr(void)
1987 {
1988 if(_sr_apy_ksr_module!=NULL) {
1989 Py_XDECREF(_sr_apy_ksr_module);
1990 _sr_apy_ksr_module = NULL;
1991 }
1992 if(_sr_apy_ksr_module_dict!=NULL) {
1993 Py_XDECREF(_sr_apy_ksr_module_dict);
1994 _sr_apy_ksr_module_dict = NULL;
1995 }
1996 if(_sr_KSRMethods!=NULL) {
1997 free(_sr_KSRMethods);
1998 _sr_KSRMethods = NULL;
1999 }
2000
2001 LM_DBG("module 'KSR' has been destroyed\n");
2002 }
2003
2004 /**
2005 *
2006 */
apy_sr_init_mod(void)2007 int apy_sr_init_mod(void)
2008 {
2009 if(_sr_python_reload_version == NULL) {
2010 _sr_python_reload_version = (int*)shm_malloc(sizeof(int));
2011 if(_sr_python_reload_version == NULL) {
2012 SHM_MEM_ERROR;
2013 return -1;
2014 }
2015 *_sr_python_reload_version = 0;
2016 }
2017
2018 return 0;
2019 }
2020
2021 static const char* app_python_rpc_reload_doc[2] = {
2022 "Reload python file",
2023 0
2024 };
2025
2026
app_python_rpc_reload(rpc_t * rpc,void * ctx)2027 static void app_python_rpc_reload(rpc_t* rpc, void* ctx)
2028 {
2029 void *vh;
2030
2031 if(_sr_python_load_file.s == NULL && _sr_python_load_file.len<=0) {
2032 LM_WARN("script file path not provided\n");
2033 rpc->fault(ctx, 500, "No script file");
2034 return;
2035 }
2036 if(_sr_python_reload_version == NULL) {
2037 LM_WARN("reload not enabled\n");
2038 rpc->fault(ctx, 500, "Reload not enabled");
2039 return;
2040 }
2041
2042 *_sr_python_reload_version += 1;
2043 LM_INFO("marking for reload Python script file: %.*s (%d)\n",
2044 _sr_python_load_file.len, _sr_python_load_file.s,
2045 *_sr_python_reload_version);
2046
2047 if (rpc->add(ctx, "{", &vh) < 0) {
2048 rpc->fault(ctx, 500, "Server error");
2049 return;
2050 }
2051 rpc->struct_add(vh, "dd",
2052 "old", *_sr_python_reload_version-1,
2053 "new", *_sr_python_reload_version);
2054
2055 return;
2056 }
2057
2058 static const char* app_python_rpc_api_list_doc[2] = {
2059 "List kemi exports to javascript",
2060 0
2061 };
2062
app_python_rpc_api_list(rpc_t * rpc,void * ctx)2063 static void app_python_rpc_api_list(rpc_t* rpc, void* ctx)
2064 {
2065 int i;
2066 int n;
2067 sr_kemi_t *ket;
2068 void* th;
2069 void* sh;
2070 void* ih;
2071
2072 if (rpc->add(ctx, "{", &th) < 0) {
2073 rpc->fault(ctx, 500, "Internal error root reply");
2074 return;
2075 }
2076 n = 0;
2077 for(i=0; i<SR_APY_KSR_METHODS_SIZE ; i++) {
2078 ket = sr_apy_kemi_export_get(i);
2079 if(ket==NULL) continue;
2080 n++;
2081 }
2082
2083 if(rpc->struct_add(th, "d[",
2084 "msize", n,
2085 "methods", &ih)<0)
2086 {
2087 rpc->fault(ctx, 500, "Internal error array structure");
2088 return;
2089 }
2090 for(i=0; i<SR_APY_KSR_METHODS_SIZE; i++) {
2091 ket = sr_apy_kemi_export_get(i);
2092 if(ket==NULL) continue;
2093 if(rpc->struct_add(ih, "{", "func", &sh)<0) {
2094 rpc->fault(ctx, 500, "Internal error internal structure");
2095 return;
2096 }
2097 if(rpc->struct_add(sh, "SSSS",
2098 "ret", sr_kemi_param_map_get_name(ket->rtype),
2099 "module", &ket->mname,
2100 "name", &ket->fname,
2101 "params", sr_kemi_param_map_get_params(ket->ptypes))<0) {
2102 LM_ERR("failed to add the structure with attributes (%d)\n", i);
2103 rpc->fault(ctx, 500, "Internal error creating dest struct");
2104 return;
2105 }
2106 }
2107 }
2108
2109 rpc_export_t app_python_rpc_cmds[] = {
2110 {"app_python.reload", app_python_rpc_reload,
2111 app_python_rpc_reload_doc, 0},
2112 {"app_python.api_list", app_python_rpc_api_list,
2113 app_python_rpc_api_list_doc, 0},
2114 {0, 0, 0, 0}
2115 };
2116
2117 /**
2118 * register RPC commands
2119 */
app_python_init_rpc(void)2120 int app_python_init_rpc(void)
2121 {
2122 if (rpc_register_array(app_python_rpc_cmds)!=0)
2123 {
2124 LM_ERR("failed to register RPC commands\n");
2125 return -1;
2126 }
2127 return 0;
2128 }
2129