| 489 | } |
| 490 | |
| 491 | static int mi_script_func(struct sip_msg *msg, str *m, |
| 492 | pv_spec_p r, pv_spec_p p, pv_spec_p v) |
| 493 | { |
| 494 | struct mi_handler *hdl = NULL; |
| 495 | struct mi_cmd *cmd = NULL; |
| 496 | mi_response_t *resp = NULL; |
| 497 | mi_request_t *req = NULL; |
| 498 | pv_value_t val; |
| 499 | int traced = 0, shared = 0; |
| 500 | int ret = -2; |
| 501 | char *err = "unknown error"; |
| 502 | str error; |
| 503 | str method, params; |
| 504 | |
| 505 | mi_script_get_method(m, &method, ¶ms); |
| 506 | |
| 507 | cmd = lookup_mi_cmd(method.s, method.len); |
| 508 | if (!cmd) |
| 509 | return -1; |
| 510 | traced = is_mi_cmd_traced(mi_trace_mod_id, cmd); |
| 511 | if (cmd->flags & MI_ASYNC_RPL_FLAG) { |
| 512 | LM_DBG("command is async\n"); |
| 513 | /* We need to build an async handler */ |
| 514 | hdl = mi_script_new_async_handler(); |
| 515 | if (!hdl) { |
| 516 | err = "failed to build async handler"; |
| 517 | goto error; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | req = mi_script_parse_request(&method, ¶ms, p, v, 0); |
| 522 | if (!req) { |
| 523 | err = "could not parse script params!"; |
| 524 | goto error; |
| 525 | } |
| 526 | resp = handle_mi_request(req, cmd, hdl); |
| 527 | if (traced) |
| 528 | trace_script_request(msg, &method, req->params); |
| 529 | if (resp == MI_ASYNC_RPL) { |
| 530 | resp = mi_script_wait_async_handler(hdl); |
| 531 | shared = 1; |
| 532 | } |
| 533 | if (!resp) { |
| 534 | err = "failed to build MI response"; |
| 535 | if (traced) { |
| 536 | init_str(&error, err); |
| 537 | trace_script_reply(msg, &error); |
| 538 | } |
| 539 | ret = -3; |
| 540 | goto end; |
| 541 | } else { |
| 542 | ret = mi_script_handle_sync_response(msg, resp, r); |
| 543 | } |
| 544 | goto ret; |
| 545 | |
| 546 | error: |
| 547 | if (traced) |
| 548 | trace_script_err(msg, &method, err); |
nothing calls this directly
no test coverage detected