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

Function dm_auth_reply

modules/aaa_diameter/dm_impl.c:308–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306
307
308static int dm_auth_reply(struct msg **_msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act)
309{
310 struct msg_hdr *hdr = NULL;
311 struct msg *msg = *_msg;
312 struct avp *a = NULL;
313 struct avp_hdr * h = NULL;
314 int rc;
315 str callid;
316 struct dm_cond **prpl_cond, *rpl_cond;
317 unsigned int hentry;
318
319 FD_CHECK(fd_msg_hdr(msg, &hdr));
320
321 if (hdr->msg_flags & CMD_FLAG_REQUEST) {
322 LM_INFO("received MAR request?! discarding...\n");
323 goto out;
324 }
325
326 FD_CHECK(fd_msg_search_avp(msg, dm_dict.Result_Code, &a));
327 FD_CHECK(fd_msg_avp_hdr(a, &h));
328 rc = h->avp_value->u32;
329
330 FD_CHECK(fd_msg_search_avp(msg, dm_dict.Acct_Session_Id, &a));
331 FD_CHECK(fd_msg_avp_hdr(a, &h));
332 callid.s = (char *)h->avp_value->os.data;
333 callid.len = (int)h->avp_value->os.len;
334
335 LM_DBG("MAA reply %d, Acct-Session-Id: %.*s\n", rc, callid.len, callid.s);
336
337 hentry = hash_entry(pending_replies, callid);
338 hash_lock(pending_replies, hentry);
339
340 prpl_cond = (struct dm_cond **)hash_find(pending_replies, hentry, callid);
341 if (!prpl_cond) {
342 hash_unlock(pending_replies, hentry);
343 LM_ERR("failed to match Call-ID %.*s to a pending request\n",
344 callid.len, callid.s);
345 goto out;
346 }
347 rpl_cond = *prpl_cond;
348 rpl_cond->rpl.rc = rc;
349
350 hash_remove_key(pending_replies, callid);
351 hash_unlock(pending_replies, hentry);
352
353 FD_CHECK(fd_msg_search_avp(msg, dm_dict.Error_Message, &a));
354 if (a) {
355 rpl_cond->rpl.is_error = 1;
356 FD_CHECK(fd_msg_avp_hdr(a, &h));
357 LM_DBG("auth failure, rc: %d (%.*s)\n",
358 rc, (int)h->avp_value->os.len, h->avp_value->os.data);
359 } else {
360 rpl_cond->rpl.is_error = 0;
361 }
362 dm_cond_signal(rpl_cond);
363 dm_cond_unref(rpl_cond);
364
365out:

Callers

nothing calls this directly

Calls 3

hash_entryClass · 0.85
dm_cond_signalFunction · 0.85
dm_cond_unrefFunction · 0.85

Tested by

no test coverage detected