MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / get_cmd_fixups

Function get_cmd_fixups

mod_fix.c:334–489  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334int get_cmd_fixups(struct sip_msg* msg, const struct cmd_param *params,
335 action_elem_t *elems, void **cmdp, pv_value_t *tmp_vals)
336{
337 int i;
338 const struct cmd_param *param;
339 gparam_p gp;
340 regex_t *re = NULL;
341 int ret;
342
343 for (param=params, i=1; param->flags; param++, i++) {
344 gp = (gparam_p)elems[i].u.data;
345 if (!gp) {
346 cmdp[i-1] = NULL;
347 continue;
348 }
349
350 if (param->flags & CMD_PARAM_INT) {
351
352 switch (gp->type) {
353 case GPARAM_TYPE_VAL:
354 tmp_vals[i].ri = *(int*)gp->pval;
355 cmdp[i-1] = &tmp_vals[i].ri;
356 break;
357 case GPARAM_TYPE_FIXUP:
358 cmdp[i-1] = gp->pval;
359 break;
360 case GPARAM_TYPE_PVS:
361 if (pv_get_spec_value(msg, (pv_spec_t *)gp->pval,
362 &tmp_vals[i]) != 0) {
363 LM_ERR("Failed to get spec value in param [%d]\n", i);
364 return E_UNSPEC;
365 }
366 if (tmp_vals[i].flags & PV_VAL_NULL ||
367 !(tmp_vals[i].flags & PV_VAL_INT)) {
368 LM_ERR("Variable in param [%d] is not an integer\n", i);
369 return E_UNSPEC;
370 }
371
372 cmdp[i-1] = (void *)&tmp_vals[i].ri;
373
374 /* run fixup as we now have the value of the variable */
375 if (param->fixup && param->fixup(&cmdp[i-1]) < 0) {
376 LM_ERR("Fixup failed for param [%d]\n", i);
377 return E_UNSPEC;
378 }
379
380 break;
381 default:
382 LM_BUG("Bad type for generic parameter\n");
383 return E_BUG;
384 }
385
386 } else if (param->flags & CMD_PARAM_STR) {
387
388 switch (gp->type) {
389 case GPARAM_TYPE_VAL:
390 tmp_vals[i].rs = *(str*)gp->pval;
391 cmdp[i-1] = &tmp_vals[i].rs;

Callers 3

do_actionFunction · 0.85
py_do_actionFunction · 0.85
lua_do_actionFunction · 0.85

Calls 3

pv_get_spec_valueFunction · 0.85
pv_printf_sFunction · 0.85
fixup_regcompFunction · 0.85

Tested by

no test coverage detected