| 2130 | } |
| 2131 | |
| 2132 | int dm_api_send_req(diameter_conn *conn, int app_id, int cmd_code, cJSON *req, diameter_reply *rpl) |
| 2133 | { |
| 2134 | aaa_message *dmsg = NULL; |
| 2135 | struct dm_cond *rpl_cond = NULL; |
| 2136 | int rc = -1; |
| 2137 | |
| 2138 | if (!req) { |
| 2139 | LM_ERR("no request provided\n"); |
| 2140 | return -1; |
| 2141 | } |
| 2142 | |
| 2143 | if (req->type != cJSON_Array) { |
| 2144 | LM_ERR("request must be an array\n"); |
| 2145 | return -2; |
| 2146 | } |
| 2147 | |
| 2148 | dmsg = _dm_create_message(NULL, AAA_CUSTOM_REQ, app_id, cmd_code, NULL); |
| 2149 | if (!dmsg) { |
| 2150 | LM_ERR("oom\n"); |
| 2151 | return -1; |
| 2152 | } |
| 2153 | |
| 2154 | if (dm_build_avps(&((struct dm_message *)(dmsg->avpair))->avps, |
| 2155 | req->child) != 0) { |
| 2156 | LM_ERR("failed to unpack JSON\n"); |
| 2157 | _dm_destroy_message(dmsg); |
| 2158 | goto end; |
| 2159 | } |
| 2160 | |
| 2161 | if (_dm_send_message(NULL, dmsg, &rpl_cond) != 0) { |
| 2162 | LM_ERR("could not send Diameter message\n"); |
| 2163 | goto end; |
| 2164 | } |
| 2165 | rc = _dm_get_message_reply(rpl_cond, rpl); |
| 2166 | end: |
| 2167 | return rc; |
| 2168 | } |
| 2169 | |
| 2170 | int dm_api_send_req_async(diameter_conn *conn, int app_id, int cmd_code, cJSON *req, |
| 2171 | diameter_reply_cb *reply_cb, void *reply_param) |
nothing calls this directly
no test coverage detected