| 361 | |
| 362 | |
| 363 | static int dm_send_answer(struct sip_msg *msg, str *avp_json, int *is_error) |
| 364 | { |
| 365 | aaa_message *dmsg = NULL; |
| 366 | struct dm_message *dm; |
| 367 | cJSON *avps; |
| 368 | pv_param_t evp; |
| 369 | pv_value_t res; |
| 370 | str sessid; |
| 371 | int appid, cmdcode, rc; |
| 372 | uint64_t fd_req; |
| 373 | |
| 374 | if (route_type != EVENT_ROUTE) { |
| 375 | LM_ERR("can only run 'dm_send_answer()' inside an EVENT_ROUTE\n"); |
| 376 | return -1; |
| 377 | } |
| 378 | |
| 379 | if (ZSTRP(avp_json)) { |
| 380 | LM_ERR("unable to build reply (NULL 'avps_json' input)\n"); |
| 381 | return -1; |
| 382 | } |
| 383 | |
| 384 | avps = cJSON_Parse(avp_json->s); |
| 385 | if (!avps) { |
| 386 | LM_ERR_DM_JSON("failed to parse input JSON", avp_json); |
| 387 | return -1; |
| 388 | } |
| 389 | |
| 390 | if (avps->type != cJSON_Array) { |
| 391 | LM_ERR_DM_JSON("bad JSON type: must be Array", avp_json); |
| 392 | goto error; |
| 393 | } |
| 394 | |
| 395 | /* Here, we know 100% that we're inside an event_route, so we can pull the |
| 396 | * Diameter request info (Session-ID, App, Code) using the "params" API */ |
| 397 | memset(&evp, 0, sizeof evp); |
| 398 | evp.pvn.type = PV_NAME_INTSTR; |
| 399 | evp.pvn.u.isname.type = AVP_NAME_STR; |
| 400 | |
| 401 | evp.pvn.u.isname.name.s = dmev_req_pname_appid; |
| 402 | route_params_run(msg, &evp, &res); |
| 403 | if (!pvv_is_int(&res)) { |
| 404 | LM_ERR("failed to fetch Application ID\n"); |
| 405 | appid = 0; |
| 406 | } else { |
| 407 | appid = res.ri; |
| 408 | } |
| 409 | |
| 410 | evp.pvn.u.isname.name.s = dmev_req_pname_cmdcode; |
| 411 | route_params_run(msg, &evp, &res); |
| 412 | if (!pvv_is_int(&res)) { |
| 413 | LM_ERR("failed to fetch Command Code\n"); |
| 414 | cmdcode = 0; |
| 415 | } else { |
| 416 | cmdcode = res.ri; |
| 417 | } |
| 418 | |
| 419 | evp.pvn.u.isname.name.s = dmev_req_pname_fdmsg; |
| 420 | route_params_run(msg, &evp, &res); |
nothing calls this directly
no test coverage detected