| 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) |
| 2172 | { |
| 2173 | aaa_message *dmsg = NULL; |
| 2174 | |
| 2175 | if (!req) { |
| 2176 | LM_ERR("no request provided\n"); |
| 2177 | return -1; |
| 2178 | } |
| 2179 | |
| 2180 | if (req->type != cJSON_Array) { |
| 2181 | LM_ERR("request must be an array\n"); |
| 2182 | return -2; |
| 2183 | } |
| 2184 | |
| 2185 | dmsg = _dm_create_message(NULL, AAA_CUSTOM_REQ, app_id, cmd_code, NULL); |
| 2186 | if (!dmsg) { |
| 2187 | LM_ERR("oom\n"); |
| 2188 | return -1; |
| 2189 | } |
| 2190 | |
| 2191 | if (dm_build_avps(&((struct dm_message *)(dmsg->avpair))->avps, |
| 2192 | req->child) != 0) { |
| 2193 | LM_ERR("failed to unpack JSON\n"); |
| 2194 | _dm_destroy_message(dmsg); |
| 2195 | return -1; |
| 2196 | } |
| 2197 | |
| 2198 | if (_dm_send_message_callback(NULL, dmsg, reply_cb, reply_param) != 0) { |
| 2199 | LM_ERR("could not send Diameter callback message\n"); |
| 2200 | return -1; |
| 2201 | } |
| 2202 | return 0; |
| 2203 | |
| 2204 | } |
| 2205 | |
| 2206 | cJSON *dm_api_get_reply(diameter_reply *rpl) |
| 2207 | { |
nothing calls this directly
no test coverage detected