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

Function add_cc_agent

modules/call_center/cc_data.c:509–722  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

507#endif
508
509int add_cc_agent( struct cc_data *data, str *id, struct media_info *media,
510 str *skills, unsigned int logstate, unsigned int own_wrapup,
511 unsigned int wrapup_end_time)
512{
513 struct cc_agent *agent, *prev_agent= 0;
514 struct sip_uri uri;
515 str skill;
516 char *p;
517 unsigned int i, n,skill_id;
518#ifdef STATISTICS
519 char *name;
520 str s;
521#endif
522
523 /* is the agent a new one? - search by ID */
524 agent = get_agent_by_name( data, id, &prev_agent);
525 logstate = logstate ? 1 : 0;
526
527 if (agent==NULL) {
528 /* new agent -> create and populate one */
529 agent = (struct cc_agent*)shm_malloc(sizeof(struct cc_agent)+id->len);
530 if (agent==NULL) {
531 LM_ERR("not enough shmem for a new agent\n");
532 goto error;
533 }
534 memset( agent, 0, sizeof(struct cc_agent) );
535 /* id */
536 agent->id.s = (char*)(agent+1);
537 memcpy( agent->id.s, id->s, id->len);
538 agent->id.len = id->len;
539 /* locations */
540 if (media[CC_MEDIA_RTP].location.s==NULL &&
541 media[CC_MEDIA_MSRP].location.s==NULL){
542 LM_ERR("agent has neither RTP, nor MSRP locations\n");
543 goto error;
544 }
545 for (i=0 ; i<CC_MEDIA_NO ; i++ ) {
546 if (media[i].location.s==NULL)
547 continue;
548 agent->media[i].location.s =
549 (char*)shm_malloc(media[i].location.len);
550 if (agent->media[i].location.s==NULL) {
551 LM_ERR("not enough shmem for the %s location of the agent\n",
552 (i==CC_MEDIA_RTP)?"RTP":"MSRP");
553 goto error;
554 }
555 memcpy( agent->media[i].location.s, media[i].location.s,
556 media[i].location.len);
557 agent->media[i].location.len = media[i].location.len ;
558 if (parse_uri( agent->media[i].location.s,
559 agent->media[i].location.len, &uri)<0) {
560 LM_ERR("%s location [%.*s] of the agent is not a SIP URI\n",
561 (i==CC_MEDIA_RTP)?"RTP":"MSRP",
562 media[i].location.len, media[i].location.s);
563 goto error;
564 }
565 agent->media[i].did = uri.user;
566 agent->media[i].sessions = media[i].sessions;

Callers 1

cc_load_db_dataFunction · 0.85

Calls 13

get_agent_by_nameFunction · 0.85
shm_mallocFunction · 0.85
parse_uriFunction · 0.85
q_memchrFunction · 0.85
trimFunction · 0.85
get_skill_idFunction · 0.85
build_stat_nameFunction · 0.85
register_stat2Function · 0.85
add_cc_agent_topFunction · 0.85
shm_freeFunction · 0.85
agent_switch_loginFunction · 0.85
remove_cc_agentFunction · 0.85

Tested by

no test coverage detected