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

Function new_msrp_session

modules/msrp_relay/auth.c:447–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

445}
446
447static struct msrp_session *new_msrp_session(struct msrp_url *top_from,
448 unsigned int expires)
449{
450 struct nonce_params _;
451 unsigned int hentry;
452 struct msrp_session *new;
453 void **val;
454
455 new = shm_malloc(sizeof *new + ncp->nonce_len + top_from->whole.len);
456 if (!new) {
457 LM_ERR("no more shm memory\n");
458 return NULL;
459 }
460 memset(new, 0, sizeof *new);
461
462 new->session_id.s = (char*)(new + 1);
463 new->session_id.len = ncp->nonce_len;
464 if (generate_nonce(&_, new->session_id.s) < 0) {
465 LM_ERR("Failed to generate session-id\n");
466 goto error;
467 }
468
469 new->top_from.s = (char*)(new + 1) + new->session_id.len;
470 new->top_from.len = top_from->whole.len;
471 memcpy(new->top_from.s, top_from->whole.s, top_from->whole.len);
472
473 new->expires = expires + get_ticks();
474
475 hentry = hash_entry(msrp_sessions, new->session_id);
476 hash_lock(msrp_sessions, hentry);
477
478 val = hash_get(msrp_sessions, hentry, new->session_id);
479 if (!val) {
480 hash_unlock(msrp_sessions, hentry);
481 LM_ERR("Failed to allocate new hash entry\n");
482 goto error;
483 }
484
485 if (*val != NULL) {
486 hash_unlock(msrp_sessions, hentry);
487 LM_ERR("Generated duplicate session-id\n");
488 goto error;
489 }
490 *val = new;
491
492 hash_unlock(msrp_sessions, hentry);
493
494 LM_DBG("New MSRP session: %.*s\n",
495 new->session_id.len, new->session_id.s);
496
497 return new;
498error:
499 shm_free(new);
500 return NULL;
501}
502
503#define RPL_200OK_HDRS_NO 3
504

Callers 1

handle_msrp_auth_reqFunction · 0.85

Calls 5

shm_mallocFunction · 0.85
generate_nonceFunction · 0.85
get_ticksFunction · 0.85
hash_entryClass · 0.85
shm_freeFunction · 0.85

Tested by

no test coverage detected